rank1-llama3-8b-awq: Quantized Model for Test-Time Compute Reranking
rank1-llama3-8b-awq is a quantized version of the rank1-llama3-8b model. This AWQ-quantized 8B parameter model maintains the reasoning capabilities of the original model while requiring less memory and providing faster inference. The model is trained from the Llama 3.1 8B base model and leverages test-time compute to generate reasoning chains before deciding if a document is relevant to a query.
Model Description
rank1 introduces a novel approach to information retrieval by generating explicit reasoning chains before making relevance judgments. Unlike traditional rerankers that directly output scores, rank1:
- Receives a query and document pair
- Generates a reasoning chain within a
<think>...</think> section
- Makes a binary relevance judgment (
true or false)
- Returns a confidence score based on the logits of the true/false tokens
This approach helps the model break down complex relevance decisions into logical steps, improving performance across diverse retrieval tasks.
Quantization Details
This model uses Activation-aware Weight Quantization (AWQ) to reduce the model size while maintaining performance. Compared to the full-precision model, this quantized version:
- Requires less GPU memory
- Offers faster inference times
- Maintains comparable accuracy on retrieval tasks
Model Family
Quantized Variants
Associated Data and Resources
Usage
Note that official usage is found on the Github and accounts for edge cases. But for simple use cases the minimal example below works.
Click to expand: Minimal example with vLLM
1from vllm import LLM, SamplingParams
2import math
3
4# Initialize the model with vLLM
5model = LLM(
6 model="jhu-clsp/rank1-llama3-8b-awq",
7 tensor_parallel_size=1, # Number of GPUs
8 trust_remote_code=True,
9 max_model_len=16000, # Context length
10 gpu_memory_utilization=0.9,
11 dtype="auto", # Will use the appropriate quantized dtype
12)
13
14# Set up sampling parameters
15sampling_params = SamplingParams(
16 temperature=0,
17 max_tokens=8192,
18 logprobs=20,
19 stop=["</think> true", "</think> false"],
20 skip_special_tokens=False
21)
22
23# Prepare the prompt
24def create_prompt(query, document):
25 return (
26 "Determine if the following passage is relevant to the query. "
27 "Answer only with 'true' or 'false'.\n"
28 f"Query: {query}\n"
29 f"Passage: {document}\n"
30 "<think>"
31 )
32
33# Example usage
34query = "What are the effects of climate change?"
35document = "Climate change leads to rising sea levels, extreme weather events, and disruptions to ecosystems. These effects are caused by increasing greenhouse gas concentrations in the atmosphere due to human activities."
36
37# Generate prediction
38prompt = create_prompt(query, document)
39outputs = model.generate([prompt], sampling_params)
40
41# Extract score
42output = outputs[0].outputs[0]
43text = output.text
44final_logits = output.logprobs[-1]
45
46# Get token IDs for "true" and "false" tokens
47from transformers import AutoTokenizer
48tokenizer = AutoTokenizer.from_pretrained("jhu-clsp/rank1-llama3-8b-awq")
49true_token = tokenizer(" true", add_special_tokens=False).input_ids[0]
50false_token = tokenizer(" false", add_special_tokens=False).input_ids[0]
51
52# Calculate relevance score (probability of "true")
53true_logit = final_logits[true_token].logprob
54false_logit = final_logits[false_token].logprob
55true_score = math.exp(true_logit)
56false_score = math.exp(false_logit)
57relevance_score = true_score / (true_score + false_score)
58
59print(f"Reasoning chain: {text}")
60print(f"Relevance score: {relevance_score}")
Click to expand: Usage with AutoGPTQ/AWQ
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4# Load the tokenizer and quantized model
5tokenizer = AutoTokenizer.from_pretrained("jhu-clsp/rank1-llama3-8b-awq")
6model = AutoModelForCausalLM.from_pretrained(
7 "jhu-clsp/rank1-llama3-8b-awq",
8 device_map="auto",
9 trust_remote_code=True
10)
11
12# Prepare the prompt
13query = "What are the effects of climate change?"
14document = "Climate change leads to rising sea levels, extreme weather events, and disruptions to ecosystems. These effects are caused by increasing greenhouse gas concentrations in the atmosphere due to human activities."
15
16prompt = f"Determine if the following passage is relevant to the query. Answer only with 'true' or 'false'.\nQuery: {query}\nPassage: {document}\n<think>"
17
18# Generate the reasoning chain and relevance judgment
19inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
20with torch.no_grad():
21 outputs = model.generate(
22 **inputs,
23 max_new_tokens=512,
24 temperature=0.0,
25 return_dict_in_generate=True,
26 output_scores=True,
27 pad_token_id=tokenizer.eos_token_id
28 )
29
30# Process the output
31generated_text = tokenizer.decode(outputs.sequences[0], skip_special_tokens=False)
32reasoning_chain = generated_text.split("<think>")[1].split("</think>")[0].strip()
33relevance_judgment = "true" if "true" in generated_text.split("</think>")[1].strip().lower() else "false"
34
35print(f"Reasoning chain: {reasoning_chain}")
36print(f"Relevance judgment: {relevance_judgment}")
Performance
rank1-llama3-8b-awq demonstrates strong performance on retrieval benchmarks while offering faster inference and lower memory requirements than the full-precision model. The quantization process preserves the model's ability to "think through" relevance decisions, making it effective for nuanced topics.
For specific benchmark results and comparisons with other models, please refer to the paper and the official GitHub repository.
Installation
Please see the Github for detailed installation instructions.
MTEB Integration
rank1 is compatible with the
MTEB benchmarking framework:
1from mteb import MTEB
2from rank1 import rank1 # From the official repo
3
4# Initialize the model
5model = rank1(
6 model_name_or_path="jhu-clsp/rank1-llama3-8b-awq",
7 num_gpus=1,
8 device="cuda",
9 quantized=True # Indicate that you're using the quantized version
10)
11
12# Run evaluation on specific tasks
13evaluation = MTEB(tasks=["NevIR"])
14results = evaluation.run(model)
Citation
If you use rank1 in your research, please cite our work:
1@misc{weller2025rank1testtimecomputereranking,
2 title={Rank1: Test-Time Compute for Reranking in Information Retrieval},
3 author={Orion Weller and Kathryn Ricci and Eugene Yang and Andrew Yates and Dawn Lawrie and Benjamin Van Durme},
4 year={2025},
5 eprint={2502.18418},
6 archivePrefix={arXiv},
7 primaryClass={cs.IR},
8 url={https://arxiv.org/abs/2502.18418},
9}
License