jaytonde05 commited on
Commit
befbf96
·
verified ·
1 Parent(s): 53bae70

Upload 12 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
MAP_EXP_12_FULL.py ADDED
@@ -0,0 +1,360 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # All imports at the top
2
+ import torch
3
+ import shutil
4
+ import numpy as np
5
+ import pandas as pd
6
+ import mlflow
7
+ from collections import Counter
8
+ from sklearn.model_selection import train_test_split
9
+ from sklearn.preprocessing import LabelEncoder
10
+ from datasets import Dataset
11
+ from transformers import (
12
+ AutoTokenizer,
13
+ TrainingArguments,
14
+ Trainer,
15
+ DataCollatorWithPadding,
16
+ BitsAndBytesConfig,
17
+ AutoModelForSequenceClassification
18
+ )
19
+ from peft import (
20
+ LoraConfig,
21
+ TaskType,
22
+ get_peft_model,
23
+ prepare_model_for_kbit_training,
24
+ )
25
+
26
+ # Configuration
27
+ model_name = "Qwen/Qwen2.5-Math-7B"
28
+ MAX_LEN = 256
29
+
30
+ # MLflow setup
31
+ mlflow.set_tracking_uri("http://127.0.0.1:8081")
32
+
33
+ # Step 2: Loading the dataset
34
+
35
+ le = LabelEncoder()
36
+ train = pd.read_csv('train.csv')
37
+ train.Misconception = train.Misconception.fillna('NA')
38
+ train['target'] = train.Category +":"+ train.Misconception
39
+ train['label'] = le.fit_transform(train['target'])
40
+ n_classes = len(le.classes_)
41
+ print(f"Train shape: {train.shape} with {n_classes} target classes")
42
+ print(train.head())
43
+
44
+ # Process correct answers
45
+ idx = train.apply(lambda row: row.Category.split('_')[0], axis=1) == 'True'
46
+ correct = train.loc[idx].copy()
47
+ correct['c'] = correct.groupby(['QuestionId', 'MC_Answer']).MC_Answer.transform('count')
48
+ correct = correct.sort_values('c', ascending=False)
49
+ correct = correct.drop_duplicates(['QuestionId'])
50
+ correct = correct[['QuestionId', 'MC_Answer']]
51
+ correct['is_correct'] = 1
52
+
53
+ train = train.merge(correct, on=['QuestionId', 'MC_Answer'], how='left')
54
+ train.is_correct = train.is_correct.fillna(0)
55
+
56
+ # Format input text
57
+ def format_input(row):
58
+ x = "This answer is correct."
59
+ if not row['is_correct']:
60
+ x = "This is answer is incorrect."
61
+ return (
62
+ f"Question: {row['QuestionText']}\n"
63
+ f"Answer: {row['MC_Answer']}\n"
64
+ f"{x}\n"
65
+ f"Student Explanation: {row['StudentExplanation']}"
66
+ )
67
+
68
+ train['text'] = train.apply(format_input, axis=1)
69
+
70
+ # Split data
71
+ train_df = train
72
+ #train_df, val_df = train_test_split(train, test_size=0.2, random_state=42)
73
+
74
+ COLS = ['text', 'label']
75
+ train_ds = Dataset.from_pandas(train_df[COLS])
76
+ #val_ds = Dataset.from_pandas(val_df[COLS])
77
+
78
+ # Initialize tokenizer
79
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
80
+
81
+ # Tokenization function
82
+ def tokenize_func(example):
83
+ return tokenizer(
84
+ example["text"],
85
+ add_special_tokens=True,
86
+ truncation=True,
87
+ max_length=512,
88
+ )
89
+
90
+ # Tokenize datasets
91
+ train_ds = train_ds.map(tokenize_func, batched=True, desc="Tokenizing train data")
92
+ #eval_ds = val_ds.map(tokenize_func, batched=True, desc="Tokenizing eval data")
93
+
94
+ # Step 3: Load model
95
+ # Model configuration
96
+ model_kwargs = dict(
97
+ trust_remote_code=True,
98
+ torch_dtype=torch.float16
99
+ )
100
+
101
+ model_kwargs["quantization_config"] = BitsAndBytesConfig(
102
+ load_in_4bit=True,
103
+ bnb_4bit_quant_type="nf4",
104
+ bnb_4bit_use_double_quant=True,
105
+ bnb_4bit_compute_dtype="float16",
106
+ )
107
+
108
+ # Load model
109
+ print(f"Loading model : {model_name}")
110
+ model = AutoModelForSequenceClassification.from_pretrained(
111
+ model_name, use_cache=False, num_labels=n_classes, **model_kwargs
112
+ )
113
+ model.config.pad_token_id = tokenizer.pad_token_id
114
+
115
+ # LoRA configuration
116
+ lora_config = LoraConfig(
117
+ r=64,
118
+ lora_alpha=64,
119
+ target_modules="all-linear",
120
+ lora_dropout=0.05,
121
+ bias="none",
122
+ task_type=TaskType.SEQ_CLS,
123
+ modules_to_save=["score"],
124
+ )
125
+
126
+ # Prepare model for training
127
+ model = prepare_model_for_kbit_training(model)
128
+ model = get_peft_model(model, lora_config)
129
+ model.print_trainable_parameters()
130
+
131
+ # Custom evaluation metric
132
+ def compute_multi_map(eval_pred, ks=[3, 5, 10]):
133
+ """
134
+ Computes MAP@k and a detailed rank distribution.
135
+
136
+ This includes:
137
+ - Rank counts for rank 1, 2-3, and above 3.
138
+ - For rank groups 2-3 and above 3, it finds the top 3 most frequent
139
+ classes and calculates their average probability score.
140
+ """
141
+ # 1. Unpack logits and labels
142
+ logits, labels = eval_pred
143
+ labels = np.array(labels)
144
+
145
+ # 2. Convert logits to probabilities
146
+ # The `probs` array has shape: (num_samples, num_classes)
147
+ probs = torch.nn.functional.softmax(torch.tensor(logits), dim=-1).numpy()
148
+
149
+ # 3. Get top-k predictions
150
+ max_k = max(ks)
151
+ top_k_preds = np.argsort(-probs, axis=1)[:, :max_k]
152
+
153
+ # 4. Create a boolean match array
154
+ match_array = (top_k_preds == labels[:, None])
155
+
156
+ # 5. Compute MAP@k for each specified k
157
+ metrics = {}
158
+ for k in ks:
159
+ match_at_k = match_array[:, :k]
160
+ ranks = np.argmax(match_at_k, axis=1) + 1
161
+ has_match_at_k = np.any(match_at_k, axis=1)
162
+ scores = has_match_at_k * (1.0 / ranks)
163
+ metrics[f"map@{k}"] = np.mean(scores)
164
+
165
+ # 6. Calculate detailed rank position breakdown
166
+ ranks_with_indices = [np.where(row)[0] for row in match_array]
167
+ correct_ranks = np.array([r[0] + 1 if len(r) > 0 else max_k + 1 for r in ranks_with_indices])
168
+
169
+ total = labels.shape[0]
170
+ metrics["rank_1"] = np.sum(correct_ranks == 1)
171
+ metrics["rank_2_to_3"] = np.sum((correct_ranks >= 2) & (correct_ranks <= 3))
172
+ metrics["rank_above_3"] = np.sum((correct_ranks > 3) & (correct_ranks <= max_k))
173
+ metrics["no_match_in_top_k"] = np.sum(correct_ranks > max_k)
174
+ metrics["total"] = total
175
+
176
+ # 7. Find top 3 classes for rank groups and their average probability
177
+
178
+ # --- For ranks 2 to 3 ---
179
+ # Create a boolean mask for samples in this rank group
180
+ rank_2_to_3_mask = (correct_ranks >= 2) & (correct_ranks <= 3)
181
+ # Get the true labels for these samples
182
+ rank_2_to_3_labels = labels[rank_2_to_3_mask]
183
+
184
+ if len(rank_2_to_3_labels) > 0:
185
+ top_classes = Counter(rank_2_to_3_labels).most_common(3)
186
+ augmented_top_classes = []
187
+ for cls, count in top_classes:
188
+ # Find samples that both belong to this class AND are in this rank group
189
+ class_in_group_mask = (labels == cls) & rank_2_to_3_mask
190
+ # Get the probabilities assigned to the correct class for these specific samples
191
+ class_probs = probs[class_in_group_mask, cls]
192
+ # Calculate the average probability and add to list
193
+ avg_prob = np.mean(class_probs)
194
+ augmented_top_classes.append((cls, count, round(float(avg_prob), 4)))
195
+ metrics["rank_2_to_3_details"] = augmented_top_classes
196
+ else:
197
+ metrics["rank_2_to_3_details"] = []
198
+
199
+ # --- For ranks above 3 (up to max_k) ---
200
+ rank_above_3_mask = (correct_ranks > 3) & (correct_ranks <= max_k)
201
+ rank_above_3_labels = labels[rank_above_3_mask]
202
+
203
+ if len(rank_above_3_labels) > 0:
204
+ top_classes = Counter(rank_above_3_labels).most_common(3)
205
+ augmented_top_classes = []
206
+ for cls, count in top_classes:
207
+ class_in_group_mask = (labels == cls) & rank_above_3_mask
208
+ class_probs = probs[class_in_group_mask, cls]
209
+ avg_prob = np.mean(class_probs)
210
+ augmented_top_classes.append((cls, count, round(float(avg_prob), 4)))
211
+ metrics["rank_above_3_details"] = augmented_top_classes
212
+ else:
213
+ metrics["rank_above_3_details"] = []
214
+
215
+ mlflow.log_metric("rank_1", metrics["rank_1"])
216
+ mlflow.log_metric("rank_2_to_3", metrics["rank_2_to_3"])
217
+ mlflow.log_metric("rank_above_3", metrics["rank_above_3"])
218
+ mlflow.log_metric("no_match_in_top_k", metrics["no_match_in_top_k"])
219
+ # mlflow.log_metric("rank_2_to_3_details", metrics["rank_2_to_3_details"])
220
+ # mlflow.log_metric("rank_above_3_details", metrics["rank_above_3_details"])
221
+
222
+ return metrics
223
+
224
+ # Training arguments
225
+ training_args = TrainingArguments(
226
+ output_dir="MAP_EXP_12_FULL",
227
+ eval_strategy="no",
228
+ save_strategy="no",
229
+ logging_strategy="steps",
230
+ #eval_steps=500,
231
+ logging_steps=100,
232
+ learning_rate=1e-4,
233
+ per_device_train_batch_size=16,
234
+ per_device_eval_batch_size=32,
235
+ gradient_accumulation_steps=1,
236
+ lr_scheduler_type="cosine",
237
+ warmup_ratio=0.05,
238
+ report_to="mlflow",
239
+ gradient_checkpointing=True,
240
+ group_by_length=True,
241
+ max_grad_norm=1.0,
242
+ weight_decay=0.01,
243
+ num_train_epochs=2
244
+ )
245
+
246
+
247
+ import torch
248
+ import numpy as np
249
+ import mlflow
250
+ from collections import Counter
251
+ from transformers import Trainer
252
+
253
+ class MLflowMetricsLogger:
254
+ """
255
+ A callable class to compute and log metrics to MLflow with step tracking.
256
+ """
257
+ def __init__(self, trainer: Trainer, ks=[3, 5, 10]):
258
+ """
259
+ Initializes the metrics logger.
260
+
261
+ Args:
262
+ trainer (Trainer): The Hugging Face Trainer instance.
263
+ ks (list): A list of k values for MAP@k calculation.
264
+ """
265
+ self.trainer = trainer
266
+ self.ks = ks
267
+
268
+ def __call__(self, eval_pred):
269
+ """
270
+ This method is called by the Trainer during evaluation.
271
+ """
272
+ # Get the current training step from the trainer's state
273
+ step = self.trainer.state.global_step
274
+
275
+ # 1. Unpack logits and labels
276
+ logits, labels = eval_pred
277
+ labels = np.array(labels)
278
+
279
+ # 2. Convert logits to probabilities
280
+ probs = torch.nn.functional.softmax(torch.tensor(logits), dim=-1).numpy()
281
+
282
+ # 3. Get top-k predictions
283
+ max_k = max(self.ks)
284
+ top_k_preds = np.argsort(-probs, axis=1)[:, :max_k]
285
+
286
+ # 4. Create a boolean match array
287
+ match_array = (top_k_preds == labels[:, None])
288
+
289
+ # 5. Compute MAP@k for each specified k
290
+ metrics = {}
291
+ for k in self.ks:
292
+ match_at_k = match_array[:, :k]
293
+ ranks = np.argmax(match_at_k, axis=1) + 1
294
+ has_match_at_k = np.any(match_at_k, axis=1)
295
+ scores = has_match_at_k * (1.0 / ranks)
296
+ metrics[f"map@{k}"] = np.mean(scores)
297
+
298
+ # 6. Calculate detailed rank position breakdown
299
+ ranks_with_indices = [np.where(row)[0] for row in match_array]
300
+ correct_ranks = np.array([r[0] + 1 if len(r) > 0 else max_k + 1 for r in ranks_with_indices])
301
+
302
+ total = labels.shape[0]
303
+ rank_1_count = np.sum(correct_ranks == 1)
304
+ rank_2_to_3_count = np.sum((correct_ranks >= 2) & (correct_ranks <= 3))
305
+ rank_above_3_count = np.sum((correct_ranks > 3) & (correct_ranks <= max_k))
306
+ no_match_count = np.sum(correct_ranks > max_k)
307
+
308
+ # Log metrics to MLflow WITH the step argument
309
+ mlflow.log_metric("rank_1", rank_1_count, step=step)
310
+ mlflow.log_metric("rank_2_to_3", rank_2_to_3_count, step=step)
311
+ mlflow.log_metric("rank_above_3", rank_above_3_count, step=step)
312
+ mlflow.log_metric("no_match_in_top_k", no_match_count, step=step)
313
+
314
+ # Note: The detailed lists cannot be logged as a time-series metric.
315
+ # These are better logged as artifacts (e.g., a JSON file) or a dictionary
316
+ # at the end of the run if needed.
317
+ # For example: mlflow.log_dict(details_dict, "rank_details.json")
318
+
319
+ # The Trainer still requires a dictionary of metrics to be returned.
320
+ metrics["rank_1"] = rank_1_count
321
+ metrics["rank_2_to_3"] = rank_2_to_3_count
322
+ metrics["rank_above_3"] = rank_above_3_count
323
+ metrics["no_match_in_top_k"] = no_match_count
324
+ metrics["total"] = total
325
+
326
+ return metrics
327
+
328
+
329
+ # Initialize trainer
330
+ trainer = Trainer(
331
+ model,
332
+ args=training_args,
333
+ train_dataset=train_ds,
334
+ #eval_dataset=eval_ds,
335
+ tokenizer=tokenizer,
336
+ compute_metrics=compute_multi_map,
337
+ data_collator=DataCollatorWithPadding(tokenizer),
338
+ )
339
+
340
+ metrics_computer = MLflowMetricsLogger(trainer)
341
+
342
+ # 3. Assign the instance to the trainer's compute_metrics attribute
343
+ trainer.compute_metrics = metrics_computer
344
+
345
+ # Main execution
346
+ if __name__ == "__main__":
347
+
348
+ # Start training
349
+ trainer.train()
350
+
351
+ # Save the model
352
+ trainer.save_model("MAP_EXP_12_FULL")
353
+
354
+ source_file = "MAP_EXP_12_FULL.py"
355
+ destination_directory = "MAP_EXP_12_FULL"
356
+
357
+ shutil.copy(source_file, destination_directory)
358
+ print(f"File '{source_file}' copied to '{destination_directory}'")
359
+
360
+ print("Training completed and model saved!")
README.md ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: Qwen/Qwen2.5-Math-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.15.2
adapter_config.json ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "Qwen/Qwen2.5-Math-7B",
5
+ "bias": "none",
6
+ "corda_config": null,
7
+ "eva_config": null,
8
+ "exclude_modules": null,
9
+ "fan_in_fan_out": false,
10
+ "inference_mode": true,
11
+ "init_lora_weights": true,
12
+ "layer_replication": null,
13
+ "layers_pattern": null,
14
+ "layers_to_transform": null,
15
+ "loftq_config": {},
16
+ "lora_alpha": 64,
17
+ "lora_bias": false,
18
+ "lora_dropout": 0.05,
19
+ "megatron_config": null,
20
+ "megatron_core": "megatron.core",
21
+ "modules_to_save": [
22
+ "score",
23
+ "classifier",
24
+ "score"
25
+ ],
26
+ "peft_type": "LORA",
27
+ "r": 64,
28
+ "rank_pattern": {},
29
+ "revision": null,
30
+ "target_modules": [
31
+ "v_proj",
32
+ "up_proj",
33
+ "o_proj",
34
+ "k_proj",
35
+ "down_proj",
36
+ "q_proj",
37
+ "gate_proj"
38
+ ],
39
+ "task_type": "SEQ_CLS",
40
+ "trainable_token_indices": null,
41
+ "use_dora": false,
42
+ "use_rslora": false
43
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ef0c3e10c4fa881e49c743e552df80019c7abc0946fd4e950e721b3c9bd87185
3
+ size 646907648
added_tokens.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</tool_call>": 151658,
3
+ "<tool_call>": 151657,
4
+ "<|box_end|>": 151649,
5
+ "<|box_start|>": 151648,
6
+ "<|endoftext|>": 151643,
7
+ "<|file_sep|>": 151664,
8
+ "<|fim_middle|>": 151660,
9
+ "<|fim_pad|>": 151662,
10
+ "<|fim_prefix|>": 151659,
11
+ "<|fim_suffix|>": 151661,
12
+ "<|im_end|>": 151645,
13
+ "<|im_start|>": 151644,
14
+ "<|image_pad|>": 151655,
15
+ "<|object_ref_end|>": 151647,
16
+ "<|object_ref_start|>": 151646,
17
+ "<|quad_end|>": 151651,
18
+ "<|quad_start|>": 151650,
19
+ "<|repo_name|>": 151663,
20
+ "<|video_pad|>": 151656,
21
+ "<|vision_end|>": 151653,
22
+ "<|vision_pad|>": 151654,
23
+ "<|vision_start|>": 151652
24
+ }
chat_template.jinja ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['role'] == 'system' %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {{- 'Please reason step by step, and put your final answer within \\boxed{}.' }}
7
+ {%- endif %}
8
+ {{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
9
+ {%- for tool in tools %}
10
+ {{- "\n" }}
11
+ {{- tool | tojson }}
12
+ {%- endfor %}
13
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
14
+ {%- else %}
15
+ {%- if messages[0]['role'] == 'system' %}
16
+ {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
17
+ {%- else %}
18
+ {{- '<|im_start|>system\nPlease reason step by step, and put your final answer within \\boxed{}.<|im_end|>\n' }}
19
+ {%- endif %}
20
+ {%- endif %}
21
+ {%- for message in messages %}
22
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
23
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
24
+ {%- elif message.role == "assistant" %}
25
+ {{- '<|im_start|>' + message.role }}
26
+ {%- if message.content %}
27
+ {{- '\n' + message.content }}
28
+ {%- endif %}
29
+ {%- for tool_call in message.tool_calls %}
30
+ {%- if tool_call.function is defined %}
31
+ {%- set tool_call = tool_call.function %}
32
+ {%- endif %}
33
+ {{- '\n<tool_call>\n{"name": "' }}
34
+ {{- tool_call.name }}
35
+ {{- '", "arguments": ' }}
36
+ {{- tool_call.arguments | tojson }}
37
+ {{- '}\n</tool_call>' }}
38
+ {%- endfor %}
39
+ {{- '<|im_end|>\n' }}
40
+ {%- elif message.role == "tool" %}
41
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
42
+ {{- '<|im_start|>user' }}
43
+ {%- endif %}
44
+ {{- '\n<tool_response>\n' }}
45
+ {{- message.content }}
46
+ {{- '\n</tool_response>' }}
47
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
48
+ {{- '<|im_end|>\n' }}
49
+ {%- endif %}
50
+ {%- endif %}
51
+ {%- endfor %}
52
+ {%- if add_generation_prompt %}
53
+ {{- '<|im_start|>assistant\n' }}
54
+ {%- endif %}
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
special_tokens_map.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>"
16
+ ],
17
+ "eos_token": {
18
+ "content": "<|endoftext|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "pad_token": {
25
+ "content": "<|endoftext|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ }
31
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:962b8d8c521fefa934665afddae177326e974ddd6a26e69ff31ad6bccbb5593b
3
+ size 11421994
tokenizer_config.json ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "151643": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "151644": {
14
+ "content": "<|im_start|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "151645": {
22
+ "content": "<|im_end|>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "151646": {
30
+ "content": "<|object_ref_start|>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "151647": {
38
+ "content": "<|object_ref_end|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "151648": {
46
+ "content": "<|box_start|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "151649": {
54
+ "content": "<|box_end|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "151650": {
62
+ "content": "<|quad_start|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "151651": {
70
+ "content": "<|quad_end|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "151652": {
78
+ "content": "<|vision_start|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "151653": {
86
+ "content": "<|vision_end|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "151654": {
94
+ "content": "<|vision_pad|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "151655": {
102
+ "content": "<|image_pad|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "151656": {
110
+ "content": "<|video_pad|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": true
116
+ },
117
+ "151657": {
118
+ "content": "<tool_call>",
119
+ "lstrip": false,
120
+ "normalized": false,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": false
124
+ },
125
+ "151658": {
126
+ "content": "</tool_call>",
127
+ "lstrip": false,
128
+ "normalized": false,
129
+ "rstrip": false,
130
+ "single_word": false,
131
+ "special": false
132
+ },
133
+ "151659": {
134
+ "content": "<|fim_prefix|>",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false,
139
+ "special": false
140
+ },
141
+ "151660": {
142
+ "content": "<|fim_middle|>",
143
+ "lstrip": false,
144
+ "normalized": false,
145
+ "rstrip": false,
146
+ "single_word": false,
147
+ "special": false
148
+ },
149
+ "151661": {
150
+ "content": "<|fim_suffix|>",
151
+ "lstrip": false,
152
+ "normalized": false,
153
+ "rstrip": false,
154
+ "single_word": false,
155
+ "special": false
156
+ },
157
+ "151662": {
158
+ "content": "<|fim_pad|>",
159
+ "lstrip": false,
160
+ "normalized": false,
161
+ "rstrip": false,
162
+ "single_word": false,
163
+ "special": false
164
+ },
165
+ "151663": {
166
+ "content": "<|repo_name|>",
167
+ "lstrip": false,
168
+ "normalized": false,
169
+ "rstrip": false,
170
+ "single_word": false,
171
+ "special": false
172
+ },
173
+ "151664": {
174
+ "content": "<|file_sep|>",
175
+ "lstrip": false,
176
+ "normalized": false,
177
+ "rstrip": false,
178
+ "single_word": false,
179
+ "special": false
180
+ }
181
+ },
182
+ "additional_special_tokens": [
183
+ "<|im_start|>",
184
+ "<|im_end|>",
185
+ "<|object_ref_start|>",
186
+ "<|object_ref_end|>",
187
+ "<|box_start|>",
188
+ "<|box_end|>",
189
+ "<|quad_start|>",
190
+ "<|quad_end|>",
191
+ "<|vision_start|>",
192
+ "<|vision_end|>",
193
+ "<|vision_pad|>",
194
+ "<|image_pad|>",
195
+ "<|video_pad|>"
196
+ ],
197
+ "bos_token": null,
198
+ "clean_up_tokenization_spaces": false,
199
+ "eos_token": "<|endoftext|>",
200
+ "errors": "replace",
201
+ "extra_special_tokens": {},
202
+ "model_max_length": 131072,
203
+ "pad_token": "<|endoftext|>",
204
+ "split_special_tokens": false,
205
+ "tokenizer_class": "Qwen2Tokenizer",
206
+ "unk_token": null
207
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34ce2971b006c04a4aaa9d6cca5b69ec2690f637c52bc4f8589cd95f7217d92f
3
+ size 5304
vocab.json ADDED
The diff for this file is too large to render. See raw diff