Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,99 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
base_model: Qwen/Qwen2.5-7B-Instruct
|
| 6 |
+
tags:
|
| 7 |
+
- retrieval
|
| 8 |
+
- query-rewriting
|
| 9 |
+
- reinforcement-learning
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
<h1 align="center">INF-Query-Aligner</h1>
|
| 13 |
+
|
| 14 |
+
<p align="center">
|
| 15 |
+
<a href="https://brightbenchmark.github.io/"><img src="https://img.shields.io/badge/BRIGHT_Benchmark-Rank_1st-8A2BE2" alt="Rank"></a>
|
| 16 |
+
<a href="https://huggingface.co/infly/inf-query-aligner"><img src="https://img.shields.io/badge/🤗%20Hugging%20Face-INF--Query--Aligner-blue" alt="Hugging Face"></a>
|
| 17 |
+
<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache--2.0-green.svg" alt="License"></a>
|
| 18 |
+
</p>
|
| 19 |
+
|
| 20 |
+
## 📖 Overview
|
| 21 |
+
|
| 22 |
+
**INF-Query-Aligner** is a specialized component of the **INF-X-Retriever** framework, designed to distill the core retrieval intent from complex, verbose, or reasoning-intensive queries. Built upon the **Qwen2.5-7B-instruct** foundation and fine-tuned via Reinforcement Learning, it transforms raw user queries into concise, search-optimized queries for dense retrieval systems.
|
| 23 |
+
|
| 24 |
+
This model is a key enabler for **INF-X-Retriever**'s state-of-the-art performance, currently holding the **No. 1 position** on the [BRIGHT Benchmark](https://brightbenchmark.github.io/) (as of Dec 17, 2025).
|
| 25 |
+
|
| 26 |
+
For more details on the full framework, please visit the [INF-X-Retriever Repository](https://github.com/infly/INF-X-Retriever).
|
| 27 |
+
|
| 28 |
+
---
|
| 29 |
+
|
| 30 |
+
## 🚀 Quick Start
|
| 31 |
+
|
| 32 |
+
Below is a simple example of how to use **INF-Query-Aligner** for query rewriting using the `transformers` library.
|
| 33 |
+
|
| 34 |
+
### Installation
|
| 35 |
+
|
| 36 |
+
```bash
|
| 37 |
+
pip install transformers==4.51.0
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
### Usage
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 44 |
+
|
| 45 |
+
model_name = "infly/inf-query-aligner"
|
| 46 |
+
|
| 47 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 48 |
+
model_name,
|
| 49 |
+
torch_dtype="auto",
|
| 50 |
+
device_map="auto"
|
| 51 |
+
)
|
| 52 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 53 |
+
|
| 54 |
+
prompt = "Give me a short introduction to large language model."
|
| 55 |
+
messages = [
|
| 56 |
+
{"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
|
| 57 |
+
{"role": "user", "content": prompt}
|
| 58 |
+
]
|
| 59 |
+
|
| 60 |
+
text = tokenizer.apply_chat_template(
|
| 61 |
+
messages,
|
| 62 |
+
tokenize=False,
|
| 63 |
+
add_generation_prompt=True
|
| 64 |
+
)
|
| 65 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
| 66 |
+
|
| 67 |
+
generated_ids = model.generate(
|
| 68 |
+
**model_inputs,
|
| 69 |
+
max_new_tokens=512
|
| 70 |
+
)
|
| 71 |
+
generated_ids = [
|
| 72 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
| 73 |
+
]
|
| 74 |
+
|
| 75 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
---
|
| 79 |
+
|
| 80 |
+
## 🖊️ Citation
|
| 81 |
+
|
| 82 |
+
If you find this model useful, please consider citing our work:
|
| 83 |
+
|
| 84 |
+
```bibtex
|
| 85 |
+
@misc{inf-x-retriever-2025,
|
| 86 |
+
title = {INF-X-Retriever},
|
| 87 |
+
author = {Yichen Yao, Jiahe Wan, Yuxin Hong, Mengna Zhang, Junhan Yang, Zhouyu Jiang, Qing Xu, Yinghui Xu, Wei Chu, Yuan Qi},
|
| 88 |
+
year = {2025},
|
| 89 |
+
url = {https://yaoyichen.github.io/INF-X-Retriever},
|
| 90 |
+
publisher = {GitHub repository}
|
| 91 |
+
}
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
---
|
| 95 |
+
|
| 96 |
+
## 📬 Contact
|
| 97 |
+
|
| 98 |
+
**Project Lead:** Yichen Yao ([eason.yyc@inftech.ai](mailto:eason.yyc@inftech.ai))
|
| 99 |
+
|