PEFT
Safetensors
English
micheleriva commited on
Commit
52b665f
·
verified ·
1 Parent(s): a2bc4a7

Update fine-tuned adapter weights

Browse files
Files changed (3) hide show
  1. README.md +187 -183
  2. adapter_config.json +8 -5
  3. adapter_model.safetensors +2 -2
README.md CHANGED
@@ -1,198 +1,202 @@
1
  ---
2
  base_model: Qwen/Qwen2.5-7B
3
  library_name: peft
4
- language:
5
- - en
6
- license: agpl-3.0
7
- datasets:
8
- - OramaSearch/nlp-to-query-small
9
  ---
10
 
11
- # Query Translator Mini
 
 
12
 
13
- This repository contains a fine-tuned version of Qwen 2.5 7B model specialized in translating natural language queries into structured Orama search queries.
14
 
15
- The model uses PEFT with LoRA to maintain efficiency while achieving high performance.
16
 
17
  ## Model Details
18
 
19
  ### Model Description
20
 
21
- The Query Translator Mini model is designed to convert natural language queries into structured JSON queries compatible with the Orama search engine.
22
-
23
- It understands various data types and query operators, making it versatile for different search scenarios.
24
-
25
- ### Key Features
26
-
27
- - Translates natural language to structured Orama queries
28
- - Supports multiple field types: string, number, boolean, enum, and arrays
29
- - Handles complex query operators: `gt`, `gte`, `lt`, `lte`, `eq`, `between`, `containsAll`
30
- - Supports nested properties with dot notation
31
- - Works with both full-text search and filtered queries
32
-
33
- ## Usage
34
-
35
- ```python
36
- from transformers import AutoModelForCausalLM, AutoTokenizer
37
- from peft import PeftModel
38
-
39
- # Load the model and tokenizer
40
- model_name = "your-username/query-translator-mini"
41
- tokenizer = AutoTokenizer.from_pretrained(model_name)
42
- model = AutoModelForCausalLM.from_pretrained(model_name)
43
-
44
- # System Prompt used during training
45
- SYSTEM_PROMPT = """
46
- You are a tool used to generate synthetic data of Orama queries. Orama is a full-text, vector, and hybrid search engine.
47
-
48
- Let me show you what you need to do with some examples.
49
-
50
- Example:
51
- - Query: `"What are the red wines that cost less than 20 dollars?"`
52
- - Schema: `{ "name": "string", "content": "string", "price": "number", "tags": "enum[]" }`
53
- - Generated query: `{ "term": "", "where": { "tags": { "containsAll": ["red", "wine"] }, "price": { "lt": 20 } } }`
54
-
55
- Another example:
56
- - Query: `"Show me 5 prosecco wines good for aperitif"`
57
- - Schema: `{ "name": "string", "content": "string", "price": "number", "tags": "enum[]" }`
58
- - Generated query: `{ "term": "prosecco aperitif", "limit": 5 }`
59
-
60
- One last example:
61
- - Query: `"Show me some wine reviews with a score greater than 4.5 and less than 5.0."`
62
- - Schema: `{ "title": "string", "content": "string", "reviews": { "score": "number", "text": "string" } }]`
63
- - Generated query: `{ "term": "", "where": { "reviews.score": { "between": [4.5, 5.0] } } }`
64
-
65
- The rules to generate the query are:
66
-
67
- - Never use an "embedding" field in the schema.
68
- - Every query has a "term" field that is a string. It represents the full-text search terms. Can be empty (will match all documents).
69
- - You can use a "where" field that is an object. It represents the filters to apply to the documents. Its keys and values depend on the schema of the database:
70
- - If the field is a "string", you should not use operators. Example: `{ "where": { "title": "champagne" } }`.
71
- - If the field is a "number", you can use the following operators: "gt", "gte", "lt", "lte", "eq", "between". Example: `{ "where": { "price": { "between": [20, 100] } } }`. Another example: `{ "where": { "price": { "lt": 20 } } }`.
72
- - If the field is an "enum", you can use the following operators: "eq", "in", "nin". Example: `{ "where": { "tags": { "containsAll": ["red", "wine"] } } }`.
73
- - If the field is an "string[]", it's gonna be just like the "string" field, but you can use an array of values. Example: `{ "where": { "title": ["champagne", "montagne"] } }`.
74
- - If the field is a "boolean", you can use the following operators: "eq". Example: `{ "where": { "isAvailable": true } }`. Another example: `{ "where": { "isAvailable": false } }`.
75
- - If the field is a "enum[]", you can use the following operators: "containsAll". Example: `{ "where": { "tags": { "containsAll": ["red", "wine"] } } }`.
76
- - Nested properties are supported. Just translate them into dot notation. Example: `{ "where": { "author.name": "John" } }`.
77
- - Array of numbers are not supported.
78
- - Array of booleans are not supported.
79
- """
80
-
81
- # Example query
82
- query = "What are the red wines that cost less than 20 dollars?"
83
-
84
- # Orama schema
85
- schema = {
86
- "name": "string",
87
- "content": "string",
88
- "price": "number",
89
- "tags": "enum[]"
90
- }
91
-
92
- # Generate structured query
93
- messages = [
94
- {"role": "system", "content": SYSTEM_PROMPT},
95
- {"role": "user", "content": f"Query: {query}\nSchema: {json.dumps(schema)}"},
96
- ]
97
-
98
- prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
99
- inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
100
- outputs = model.generate(
101
- **inputs,
102
- max_length=512,
103
- temperature=0.1,
104
- top_p=0.9,
105
- num_return_sequences=1,
106
- )
107
-
108
- response = tokenizer.decode(outputs[0], skip_special_tokens=True)
109
- ```
110
 
111
  ## Training Details
112
 
113
- The model was trained using the following configuration:
114
-
115
- - Base Model: Qwen 2.5 7B
116
- - Training Method: LoRA
117
- - Quantization: 4-bit quantization using bitsandbytes
118
- - LoRA Configuration:
119
- - Rank: 16
120
- - Alpha: 32
121
- - Dropout: 0.1
122
- - Target Modules: Attention layers and MLP
123
-
124
- - Training Arguments:
125
- - Epochs: 3
126
- - Batch Size: 2
127
- - Learning Rate: 5e-5
128
- - Gradient Accumulation Steps: 8
129
- - FP16 Training: Enabled
130
- - Gradient Checkpointing: Enabled
131
-
132
- ## Supported Query Types
133
-
134
- The model can handle various types of queries including:
135
-
136
- 1. Simple text search:
137
-
138
- ```json
139
- {
140
- "term": "prosecco aperitif",
141
- "limit": 5
142
- }
143
- ```
144
-
145
- 2. Numeric range queries:
146
-
147
- ```json
148
- {
149
- "term": "",
150
- "where": {
151
- "price": {
152
- "between": [20, 100]
153
- }
154
- }
155
- }
156
- ```
157
-
158
- 3. Tag-based filtering:
159
-
160
- ```json
161
- {
162
- "term": "",
163
- "where": {
164
- "tags": {
165
- "containsAll": ["red", "wine"]
166
- }
167
- }
168
- }
169
- ```
170
-
171
- ## Limitations
172
-
173
- - Does not support array of numbers or booleans
174
- - Maximum input length is 1024 tokens
175
- - Embedding fields are not supported in the schema
176
-
177
- ## Citation
178
-
179
- If you use this model in your research, please cite:
180
-
181
- ```
182
- @misc{query-translator-mini,
183
- author = {OramaSearch Inc.},
184
- title = {Query Translator Mini: Natural Language to Orama Query Translation},
185
- year = {2024},
186
- publisher = {HuggingFace},
187
- journal = {HuggingFace Repository},
188
- howpublished = {\url{https://huggingface.co/OramaSearch/query-translator-mini}}
189
- }
190
- ```
191
-
192
- ## License
193
-
194
- AGPLv3
195
-
196
- ## Acknowledgments
197
-
198
- This model builds upon the Qwen 2.5 7B model and uses techniques from the PEFT library. Special thanks to the teams behind these projects.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  base_model: Qwen/Qwen2.5-7B
3
  library_name: peft
 
 
 
 
 
4
  ---
5
 
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
 
 
10
 
 
11
 
12
  ## Model Details
13
 
14
  ### Model Description
15
 
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+
19
+
20
+ - **Developed by:** [More Information Needed]
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** [More Information Needed]
24
+ - **Language(s) (NLP):** [More Information Needed]
25
+ - **License:** [More Information Needed]
26
+ - **Finetuned from model [optional]:** [More Information Needed]
27
+
28
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ [More Information Needed]
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ [More Information Needed]
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ### Recommendations
65
+
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
+
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
+
70
+ ## How to Get Started with the Model
71
+
72
+ Use the code below to get started with the model.
73
+
74
+ [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  ## Training Details
77
 
78
+ ### Training Data
79
+
80
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
+
82
+ [More Information Needed]
83
+
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
102
+
103
+ ## Evaluation
104
+
105
+ <!-- This section describes the evaluation protocols and provides the results. -->
106
+
107
+ ### Testing Data, Factors & Metrics
108
+
109
+ #### Testing Data
110
+
111
+ <!-- This should link to a Dataset Card if possible. -->
112
+
113
+ [More Information Needed]
114
+
115
+ #### Factors
116
+
117
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Metrics
122
+
123
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
+
125
+ [More Information Needed]
126
+
127
+ ### Results
128
+
129
+ [More Information Needed]
130
+
131
+ #### Summary
132
+
133
+
134
+
135
+ ## Model Examination [optional]
136
+
137
+ <!-- Relevant interpretability work for the model goes here -->
138
+
139
+ [More Information Needed]
140
+
141
+ ## Environmental Impact
142
+
143
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
+
145
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
+
147
+ - **Hardware Type:** [More Information Needed]
148
+ - **Hours used:** [More Information Needed]
149
+ - **Cloud Provider:** [More Information Needed]
150
+ - **Compute Region:** [More Information Needed]
151
+ - **Carbon Emitted:** [More Information Needed]
152
+
153
+ ## Technical Specifications [optional]
154
+
155
+ ### Model Architecture and Objective
156
+
157
+ [More Information Needed]
158
+
159
+ ### Compute Infrastructure
160
+
161
+ [More Information Needed]
162
+
163
+ #### Hardware
164
+
165
+ [More Information Needed]
166
+
167
+ #### Software
168
+
169
+ [More Information Needed]
170
+
171
+ ## Citation [optional]
172
+
173
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
+
175
+ **BibTeX:**
176
+
177
+ [More Information Needed]
178
+
179
+ **APA:**
180
+
181
+ [More Information Needed]
182
+
183
+ ## Glossary [optional]
184
+
185
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
+
187
+ [More Information Needed]
188
+
189
+ ## More Information [optional]
190
+
191
+ [More Information Needed]
192
+
193
+ ## Model Card Authors [optional]
194
+
195
+ [More Information Needed]
196
+
197
+ ## Model Card Contact
198
+
199
+ [More Information Needed]
200
+ ### Framework versions
201
+
202
+ - PEFT 0.14.0
adapter_config.json CHANGED
@@ -17,19 +17,22 @@
17
  "lora_dropout": 0.1,
18
  "megatron_config": null,
19
  "megatron_core": "megatron.core",
20
- "modules_to_save": null,
 
 
 
21
  "peft_type": "LORA",
22
  "r": 16,
23
  "rank_pattern": {},
24
  "revision": null,
25
  "target_modules": [
26
- "self_attn.o_proj",
27
  "self_attn.v_proj",
28
- "mlp.gate_proj",
 
29
  "mlp.up_proj",
 
30
  "mlp.down_proj",
31
- "self_attn.k_proj",
32
- "self_attn.q_proj"
33
  ],
34
  "task_type": "CAUSAL_LM",
35
  "use_dora": false,
 
17
  "lora_dropout": 0.1,
18
  "megatron_config": null,
19
  "megatron_core": "megatron.core",
20
+ "modules_to_save": [
21
+ "embed_tokens",
22
+ "lm_head"
23
+ ],
24
  "peft_type": "LORA",
25
  "r": 16,
26
  "rank_pattern": {},
27
  "revision": null,
28
  "target_modules": [
 
29
  "self_attn.v_proj",
30
+ "self_attn.q_proj",
31
+ "self_attn.k_proj",
32
  "mlp.up_proj",
33
+ "self_attn.o_proj",
34
  "mlp.down_proj",
35
+ "mlp.gate_proj"
 
36
  ],
37
  "task_type": "CAUSAL_LM",
38
  "use_dora": false,
adapter_model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:03d12df6255da192aabbcb330241f396d88a6ccff51cd47049dba8ff9e0462bb
3
- size 161533192
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0fe5daa38880f7e6469caf0c77c4798fabcb7e9755229d1642c339a795c18942
3
+ size 2260783880