Improve language tag
#1
by
lbourdois
- opened
README.md
CHANGED
@@ -1,111 +1,125 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
tags:
|
4 |
-
- unsloth
|
5 |
-
- query-expansion
|
6 |
-
datasets:
|
7 |
-
- s-emanuilov/query-expansion
|
8 |
-
base_model:
|
9 |
-
- Qwen/Qwen2.5-7B-Instruct
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
-
|
43 |
-
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
#
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
```
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
tags:
|
4 |
+
- unsloth
|
5 |
+
- query-expansion
|
6 |
+
datasets:
|
7 |
+
- s-emanuilov/query-expansion
|
8 |
+
base_model:
|
9 |
+
- Qwen/Qwen2.5-7B-Instruct
|
10 |
+
language:
|
11 |
+
- zho
|
12 |
+
- eng
|
13 |
+
- fra
|
14 |
+
- spa
|
15 |
+
- por
|
16 |
+
- deu
|
17 |
+
- ita
|
18 |
+
- rus
|
19 |
+
- jpn
|
20 |
+
- kor
|
21 |
+
- vie
|
22 |
+
- tha
|
23 |
+
- ara
|
24 |
+
---
|
25 |
+
# Query Expansion Dataset - based on Qwen2.5-7B
|
26 |
+
|
27 |
+
Fine-tuned Qwen2.5-7B model for generating search query expansions.
|
28 |
+
Part of a collection of query expansion models available in different architectures and sizes.
|
29 |
+
|
30 |
+
## Overview
|
31 |
+
|
32 |
+
**Task:** Search query expansion
|
33 |
+
**Base model:** [Qwen2.5-7B](https://huggingface.co/Qwen/Qwen2.5-7B)
|
34 |
+
**Training data:** [Query Expansion Dataset](https://huggingface.co/datasets/s-emanuilov/query-expansion)
|
35 |
+
|
36 |
+
<img src="static/query-expansion-model.jpg" alt="Query Expansion Model" width="600px" />
|
37 |
+
|
38 |
+
|
39 |
+
## Variants
|
40 |
+
### Fine-tuned models
|
41 |
+
|
42 |
+
- [Qwen2.5-3B](https://huggingface.co/s-emanuilov/query-expansion-Qwen2.5-3B)
|
43 |
+
- [Llama-3.2-3B](https://huggingface.co/s-emanuilov/query-expansion-Llama-3.2-3B)
|
44 |
+
|
45 |
+
### GGUF variants
|
46 |
+
- [Qwen2.5-3B-GGUF](https://huggingface.co/s-emanuilov/query-expansion-Qwen2.5-3B-GGUF)
|
47 |
+
- [Qwen2.5-7B-GGUF](https://huggingface.co/s-emanuilov/query-expansion-Qwen2.5-7B-GGUF)
|
48 |
+
- [Llama-3.2-3B-GGUF](https://huggingface.co/s-emanuilov/query-expansion-Llama-3.2-3B-GGUF)
|
49 |
+
|
50 |
+
Each GGUF model is available in several quantization formats: F16, Q8_0, Q5_K_M, Q4_K_M, Q3_K_M
|
51 |
+
|
52 |
+
## Details
|
53 |
+
This model is designed for enhancing search and retrieval systems by generating semantically relevant query expansions.
|
54 |
+
|
55 |
+
It could be useful for:
|
56 |
+
- Advanced RAG systems
|
57 |
+
- Search enhancement
|
58 |
+
- Query preprocessing
|
59 |
+
- Low-latency query expansion
|
60 |
+
|
61 |
+
## Usage
|
62 |
+
|
63 |
+
```python
|
64 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
65 |
+
from unsloth import FastLanguageModel
|
66 |
+
|
67 |
+
# Model configuration
|
68 |
+
MODEL_NAME = "s-emanuilov/query-expansion-Qwen2.5-7B"
|
69 |
+
MAX_SEQ_LENGTH = 2048
|
70 |
+
DTYPE = "float16"
|
71 |
+
LOAD_IN_4BIT = True
|
72 |
+
|
73 |
+
# Load model and tokenizer
|
74 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
75 |
+
model_name=MODEL_NAME,
|
76 |
+
max_seq_length=MAX_SEQ_LENGTH,
|
77 |
+
dtype=DTYPE,
|
78 |
+
load_in_4bit=LOAD_IN_4BIT,
|
79 |
+
)
|
80 |
+
|
81 |
+
# Enable faster inference
|
82 |
+
FastLanguageModel.for_inference(model)
|
83 |
+
|
84 |
+
# Define prompt template
|
85 |
+
PROMPT_TEMPLATE = """Below is a search query. Generate relevant expansions and related terms that would help broaden and enhance the search results.
|
86 |
+
|
87 |
+
### Query:
|
88 |
+
{query}
|
89 |
+
|
90 |
+
### Expansions:
|
91 |
+
{output}"""
|
92 |
+
|
93 |
+
# Prepare input
|
94 |
+
query = "apple stock"
|
95 |
+
inputs = tokenizer(
|
96 |
+
[PROMPT_TEMPLATE.format(query=query, output="")],
|
97 |
+
return_tensors="pt"
|
98 |
+
).to("cuda")
|
99 |
+
|
100 |
+
# Generate with streaming output
|
101 |
+
from transformers import TextStreamer
|
102 |
+
streamer = TextStreamer(tokenizer)
|
103 |
+
output = model.generate(
|
104 |
+
**inputs,
|
105 |
+
streamer=streamer,
|
106 |
+
max_new_tokens=128,
|
107 |
+
)
|
108 |
+
```
|
109 |
+
|
110 |
+
## Example
|
111 |
+
|
112 |
+
**Input:** "apple stock"
|
113 |
+
**Expansions:**
|
114 |
+
- "current apple share value"
|
115 |
+
- "latest updates on apple's market position"
|
116 |
+
- "how is apple performing in the current market?"
|
117 |
+
- "what is the latest information on apple's financial standing?"
|
118 |
+
|
119 |
+
## Citation
|
120 |
+
|
121 |
+
If you find my work helpful, feel free to give me a citation.
|
122 |
+
|
123 |
+
```
|
124 |
+
|
125 |
```
|