File tree Expand file tree Collapse file tree 1 file changed +22
-10
lines changed 
examples/offline_inference Expand file tree Collapse file tree 1 file changed +22
-10
lines changed Original file line number Diff line number Diff line change 2222# If you want to load the official original version, the init parameters are 
2323# as follows. 
2424
25- model  =  LLM (
26-     model = model_name ,
27-     task = "score" ,
28-     hf_overrides = {
29-         "architectures" : ["Qwen3ForSequenceClassification" ],
30-         "classifier_from_token" : ["no" , "yes" ],
31-         "is_original_qwen3_reranker" : True ,
32-     },
33- )
25+ 
26+ def  get_model () ->  LLM :
27+     """Initializes and returns the LLM model for Qwen3-Reranker.""" 
28+     return  LLM (
29+         model = model_name ,
30+         task = "score" ,
31+         hf_overrides = {
32+             "architectures" : ["Qwen3ForSequenceClassification" ],
33+             "classifier_from_token" : ["no" , "yes" ],
34+             "is_original_qwen3_reranker" : True ,
35+         },
36+     )
37+ 
3438
3539# Why do we need hf_overrides for the official original version: 
3640# vllm converts it to Qwen3ForSequenceClassification when loaded for 
5155query_template  =  "{prefix}<Instruct>: {instruction}\n <Query>: {query}\n " 
5256document_template  =  "<Document>: {doc}{suffix}" 
5357
54- if  __name__  ==  "__main__" :
58+ 
59+ def  main () ->  None :
5560    instruction  =  (
5661        "Given a web search query, retrieve relevant passages that answer the query" 
5762    )
7277    ]
7378    documents  =  [document_template .format (doc = doc , suffix = suffix ) for  doc  in  documents ]
7479
80+     model  =  get_model ()
7581    outputs  =  model .score (queries , documents )
7682
83+     print ("-"  *  30 )
7784    print ([output .outputs .score  for  output  in  outputs ])
85+     print ("-"  *  30 )
86+ 
87+ 
88+ if  __name__  ==  "__main__" :
89+     main ()
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments