Instructions to use caraman/Qwen2.5-7B-mtrag-query-rewriter-final with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use caraman/Qwen2.5-7B-mtrag-query-rewriter-final with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("caraman/Qwen2.5-7B-mtrag-query-rewriter-final") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use caraman/Qwen2.5-7B-mtrag-query-rewriter-final with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "caraman/Qwen2.5-7B-mtrag-query-rewriter-final"
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "caraman/Qwen2.5-7B-mtrag-query-rewriter-final" } ] } } }Run Pi
# Start Pi in your project directory: pi
- OpenClaw new
How to use caraman/Qwen2.5-7B-mtrag-query-rewriter-final with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "caraman/Qwen2.5-7B-mtrag-query-rewriter-final"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "caraman/Qwen2.5-7B-mtrag-query-rewriter-final" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
- MLX LM
How to use caraman/Qwen2.5-7B-mtrag-query-rewriter-final with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "caraman/Qwen2.5-7B-mtrag-query-rewriter-final"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "caraman/Qwen2.5-7B-mtrag-query-rewriter-final" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "caraman/Qwen2.5-7B-mtrag-query-rewriter-final", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use caraman/Qwen2.5-7B-mtrag-query-rewriter-final with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "caraman/Qwen2.5-7B-mtrag-query-rewriter-final"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default caraman/Qwen2.5-7B-mtrag-query-rewriter-final
Run Hermes
hermes
Qwen 2.5 7B Query Rewriter (Final) -- SemEval-2026 Task 8
Fine-tuned Qwen 2.5 7B Instruct model for query rewriting in multi-turn conversational retrieval. This is the final model used in our SemEval-2026 Task 8 (MTRAGEval) submission, achieving nDCG@5 of 0.531 (8th/38 systems).
This model has the LoRA adapter weights fused into the base model for direct inference without adapter loading.
Model Details
- Base Model: Qwen/Qwen2.5-7B-Instruct
- Training Method: LoRA (Low-Rank Adaptation), weights fused into base model
- Training Data: 777 query rewriting examples from MTRAGEval gold rewrites (all training + holdout combined)
- Training Iterations: 500
- Framework: MLX (Apple Silicon optimized)
- Task: Transform multi-turn conversational queries into standalone, search-friendly queries
Training Configuration
| Parameter | Value |
|---|---|
| LoRA Rank | 16 |
| LoRA Alpha | 32 |
| LoRA Dropout | 0.15 |
| Target Modules | q/k/v/o_proj, gate/up/down_proj |
| Layers Adapted | 28 (all) |
| Trainable Params | 40.4M (0.53%) |
| Optimizer | AdamW |
| Learning Rate | 1e-5 |
| Weight Decay | 0.01 |
| Batch Size | 2 (effective 16 with grad accumulation 8) |
| Max Sequence Length | 2048 |
| Gradient Checkpointing | Yes |
| Precision | bf16 |
| Seed | 42 |
Usage
With Transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("caraman/Qwen2.5-7B-mtrag-query-rewriter-final")
tokenizer = AutoTokenizer.from_pretrained("caraman/Qwen2.5-7B-mtrag-query-rewriter-final")
system_prompt = """You are a query rewriting assistant for information retrieval. Given a conversation history and a current question, rewrite the question to be completely standalone and self-contained.
Rules:
1. Resolve all pronouns (it, they, this, that) to their explicit referents
2. Include relevant context from the conversation that's needed to understand the query
3. Keep the rewritten query concise and search-friendly
4. Do not add information not present in the conversation
5. If the question is already standalone, return it unchanged"""
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": """CONVERSATION HISTORY:
USER: Tell me about the Eiffel Tower
ASSISTANT: The Eiffel Tower is a wrought-iron lattice tower in Paris, France.
CURRENT QUESTION: When was it built?
Rewrite this question to be standalone:"""}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=256, temperature=0.2)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
# Expected: "When was the Eiffel Tower built?"
With MLX (Apple Silicon)
from mlx_lm import load, generate
model, tokenizer = load("caraman/Qwen2.5-7B-mtrag-query-rewriter-final")
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
response = generate(model, tokenizer, prompt=prompt, max_tokens=256, temp=0.2)
Domain-Specific Temperature
For optimal performance, use domain-specific temperatures:
| Domain | Temperature | Description |
|---|---|---|
| Cloud (technical docs) | 0.0 | Deterministic -- preserves exact technical terms |
| ClapNQ (Wikipedia) | 0.2 | Minimal diversity for well-structured queries |
| FiQA (financial forums) | 0.3 | Slight exploration for ambiguous queries |
| Govt (government docs) | 0.3 | Slight exploration for policy terminology |
Performance
Part of a three-stage pipeline (query rewriting + hybrid BM25/dense retrieval + cross-encoder reranking):
| Metric | Development Holdout | Official Test |
|---|---|---|
| nDCG@5 | 0.422 (uniform t=0.2) | 0.531 |
| Rank | -- | 8th / 38 systems |
Query rewriting alone provides a 13.7% relative gain over no-rewriting baseline (nDCG@5: 0.371 -> 0.422).
License
Apache 2.0
- Downloads last month
- 23
Quantized