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