Instructions to use Qwen/Qwen3-Reranker-0.6B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Qwen/Qwen3-Reranker-0.6B with Transformers:
# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-Reranker-0.6B") model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-Reranker-0.6B") - sentence-transformers
How to use Qwen/Qwen3-Reranker-0.6B with sentence-transformers:
from sentence_transformers import CrossEncoder model = CrossEncoder("Qwen/Qwen3-Reranker-0.6B") query = "Which planet is known as the Red Planet?" passages = [ "Venus is often called Earth's twin because of its similar size and proximity.", "Mars, known for its reddish appearance, is often referred to as the Red Planet.", "Jupiter, the largest planet in our solar system, has a prominent red spot.", "Saturn, famous for its rings, is sometimes mistaken for the Red Planet." ] scores = model.predict([(query, passage) for passage in passages]) print(scores) - Notebooks
- Google Colab
- Kaggle
TypeError: argument of type 'NoneType' is not iterable
TypeError Traceback (most recent call last)
Cell In[3], line 5
2 from transformers import AutoTokenizer, AutoModelForCausalLM
4 tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-Reranker-0.6B", cache_dir="/workspace/raw_model/")
----> 5 model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-Reranker-0.6B", cache_dir="/workspace/raw_model/")
File /usr/local/lib/python3.10/dist-packages/transformers/models/auto/auto_factory.py:571, in _BaseAutoModelClass.from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
569 if model_class.config_class == config.sub_configs.get("text_config", None):
570 config = config.get_text_config()
--> 571 return model_class.from_pretrained(
572 pretrained_model_name_or_path, *model_args, config=config, **hub_kwargs, **kwargs
573 )
574 raise ValueError(
575 f"Unrecognized configuration class {config.class} for this kind of AutoModel: {cls.name}.\n"
576 f"Model type should be one of {', '.join(c.name for c in cls._model_mapping.keys())}."
577 )
File /usr/local/lib/python3.10/dist-packages/transformers/modeling_utils.py:309, in restore_default_torch_dtype.._wrapper(*args, **kwargs)
307 old_dtype = torch.get_default_dtype()
308 try:
--> 309 return func(*args, **kwargs)
310 finally:
311 torch.set_default_dtype(old_dtype)
File /usr/local/lib/python3.10/dist-packages/transformers/modeling_utils.py:4508, in PreTrainedModel.from_pretrained(cls, pretrained_model_name_or_path, config, cache_dir, ignore_mismatched_sizes, force_download, local_files_only, token, revision, use_safetensors, weights_only, *model_args, **kwargs)
4499 config = cls._autoset_attn_implementation(
4500 config,
4501 use_flash_attention_2=use_flash_attention_2,
4502 torch_dtype=torch_dtype,
4503 device_map=device_map,
4504 )
4506 with ContextManagers(model_init_context):
4507 # Let's make sure we don't run the init function of buffer modules
-> 4508 model = cls(config, *model_args, **model_kwargs)
4510 # Make sure to tie the weights correctly
4511 model.tie_weights()
File /usr/local/lib/python3.10/dist-packages/transformers/models/qwen3/modeling_qwen3.py:660, in Qwen3ForCausalLM.init(self, config)
658 def init(self, config):
659 super().init(config)
--> 660 self.model = Qwen3Model(config)
661 self.vocab_size = config.vocab_size
662 self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
File /usr/local/lib/python3.10/dist-packages/transformers/models/qwen3/modeling_qwen3.py:389, in Qwen3Model.init(self, config)
386 self.gradient_checkpointing = False
388 # Initialize weights and apply final processing
--> 389 self.post_init()
File /usr/local/lib/python3.10/dist-packages/transformers/modeling_utils.py:1969, in PreTrainedModel.post_init(self)
1967 if self._tp_plan is not None and is_torch_greater_or_equal("2.3"):
1968 for _, v in self._tp_plan.items():
-> 1969 if v not in ALL_PARALLEL_STYLES:
1970 raise ValueError(
1971 f"Unsupported tensor parallel style {v}. Supported styles are {ALL_PARALLEL_STYLES}"
1972 )
TypeError: argument of type 'NoneType' is not iterable
It's an official problem. qwen3 emb/rerank is not compatible with the latest version of transformers' tp. I encountered the same error. You only need to roll back to transformers==4.51.0 to load the weights normally.