Upload 11 files
Browse files- MAP_EXP_24.py +285 -0
- MAP_EXP_24_oof.parquet +3 -0
- README.md +202 -0
- adapter_config.json +43 -0
- adapter_model.safetensors +3 -0
- chat_template.jinja +24 -0
- special_tokens_map.json +24 -0
- tokenizer.json +0 -0
- tokenizer.model +3 -0
- tokenizer_config.json +0 -0
- training_args.bin +3 -0
MAP_EXP_24.py
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# All imports at the top
|
| 2 |
+
import torch
|
| 3 |
+
import os
|
| 4 |
+
import shutil
|
| 5 |
+
import numpy as np
|
| 6 |
+
import pandas as pd
|
| 7 |
+
import mlflow
|
| 8 |
+
from collections import Counter
|
| 9 |
+
from sklearn.model_selection import train_test_split
|
| 10 |
+
from sklearn.preprocessing import LabelEncoder
|
| 11 |
+
from datasets import Dataset
|
| 12 |
+
|
| 13 |
+
import torch
|
| 14 |
+
import numpy as np
|
| 15 |
+
import mlflow
|
| 16 |
+
from collections import Counter
|
| 17 |
+
from transformers import Trainer
|
| 18 |
+
|
| 19 |
+
from transformers import (
|
| 20 |
+
AutoTokenizer,
|
| 21 |
+
TrainingArguments,
|
| 22 |
+
Trainer,
|
| 23 |
+
DataCollatorWithPadding,
|
| 24 |
+
BitsAndBytesConfig,
|
| 25 |
+
AutoModelForSequenceClassification
|
| 26 |
+
)
|
| 27 |
+
from peft import (
|
| 28 |
+
LoraConfig,
|
| 29 |
+
TaskType,
|
| 30 |
+
get_peft_model,
|
| 31 |
+
prepare_model_for_kbit_training,
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
os.environ["HF_TOKEN"] = "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"
|
| 35 |
+
|
| 36 |
+
# Configuration
|
| 37 |
+
exp_name = "MAP_EXP_24"
|
| 38 |
+
model_name = "mistralai/Mathstral-7B-v0.1"
|
| 39 |
+
MAX_LEN = 256
|
| 40 |
+
|
| 41 |
+
# MLflow setup
|
| 42 |
+
mlflow.set_tracking_uri("http://127.0.0.1:8081")
|
| 43 |
+
|
| 44 |
+
# Step 2: Loading the dataset
|
| 45 |
+
|
| 46 |
+
le = LabelEncoder()
|
| 47 |
+
train = pd.read_csv('category_misconception_folds.csv')
|
| 48 |
+
train.Misconception = train.Misconception.fillna('NA')
|
| 49 |
+
train['target'] = train.Category +":"+ train.Misconception
|
| 50 |
+
train['label'] = le.fit_transform(train['target'])
|
| 51 |
+
n_classes = len(le.classes_)
|
| 52 |
+
print(f"Train shape: {train.shape} with {n_classes} target classes")
|
| 53 |
+
print(train.head())
|
| 54 |
+
|
| 55 |
+
# Process correct answers
|
| 56 |
+
idx = train.apply(lambda row: row.Category.split('_')[0], axis=1) == 'True'
|
| 57 |
+
correct = train.loc[idx].copy()
|
| 58 |
+
correct['c'] = correct.groupby(['QuestionId', 'MC_Answer']).MC_Answer.transform('count')
|
| 59 |
+
correct = correct.sort_values('c', ascending=False)
|
| 60 |
+
correct = correct.drop_duplicates(['QuestionId'])
|
| 61 |
+
correct = correct[['QuestionId', 'MC_Answer']]
|
| 62 |
+
correct['is_correct'] = 1
|
| 63 |
+
|
| 64 |
+
train = train.merge(correct, on=['QuestionId', 'MC_Answer'], how='left')
|
| 65 |
+
train.is_correct = train.is_correct.fillna(0)
|
| 66 |
+
|
| 67 |
+
# Format input text
|
| 68 |
+
def format_input(row):
|
| 69 |
+
x = "This answer is correct."
|
| 70 |
+
if not row['is_correct']:
|
| 71 |
+
x = "This is answer is incorrect."
|
| 72 |
+
return (
|
| 73 |
+
f"Question: {row['QuestionText']}\n"
|
| 74 |
+
f"Answer: {row['MC_Answer']}\n"
|
| 75 |
+
f"{x}\n"
|
| 76 |
+
f"Student Explanation: {row['StudentExplanation']}"
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
train['text'] = train.apply(format_input, axis=1)
|
| 80 |
+
|
| 81 |
+
# Split data
|
| 82 |
+
train_df = train[train["fold"]==0].reset_index(drop=True)
|
| 83 |
+
val_df = train[train["fold"]==1].reset_index(drop=True)
|
| 84 |
+
|
| 85 |
+
COLS = ['text', 'label']
|
| 86 |
+
train_ds = Dataset.from_pandas(train_df[COLS])
|
| 87 |
+
val_ds = Dataset.from_pandas(val_df[COLS])
|
| 88 |
+
|
| 89 |
+
# Initialize tokenizer
|
| 90 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, token=os.environ["HF_TOKEN"])
|
| 91 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 92 |
+
|
| 93 |
+
# Tokenization function
|
| 94 |
+
def tokenize_func(example):
|
| 95 |
+
return tokenizer(
|
| 96 |
+
example["text"],
|
| 97 |
+
add_special_tokens=True,
|
| 98 |
+
truncation=True,
|
| 99 |
+
max_length=512,
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
+
# Tokenize datasets
|
| 103 |
+
train_ds = train_ds.map(tokenize_func, batched=True, desc="Tokenizing train data")
|
| 104 |
+
eval_ds = val_ds.map(tokenize_func, batched=True, desc="Tokenizing eval data")
|
| 105 |
+
|
| 106 |
+
# Step 3: Load model
|
| 107 |
+
# Model configuration
|
| 108 |
+
model_kwargs = dict(
|
| 109 |
+
trust_remote_code=True,
|
| 110 |
+
torch_dtype=torch.float16
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
+
model_kwargs["quantization_config"] = BitsAndBytesConfig(
|
| 114 |
+
load_in_4bit=True,
|
| 115 |
+
bnb_4bit_quant_type="nf4",
|
| 116 |
+
bnb_4bit_use_double_quant=True,
|
| 117 |
+
bnb_4bit_compute_dtype="float16",
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
# Load model
|
| 121 |
+
print(f"Loading model : {model_name}")
|
| 122 |
+
model = AutoModelForSequenceClassification.from_pretrained(
|
| 123 |
+
model_name, use_cache=False, num_labels=n_classes, token=os.environ["HF_TOKEN"], **model_kwargs
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
model.config.pad_token_id = tokenizer.pad_token_id
|
| 127 |
+
|
| 128 |
+
# LoRA configuration
|
| 129 |
+
lora_config = LoraConfig(
|
| 130 |
+
r=64,
|
| 131 |
+
lora_alpha=64,
|
| 132 |
+
target_modules="all-linear",
|
| 133 |
+
lora_dropout=0.05,
|
| 134 |
+
bias="none",
|
| 135 |
+
task_type=TaskType.SEQ_CLS,
|
| 136 |
+
modules_to_save=["score"],
|
| 137 |
+
)
|
| 138 |
+
|
| 139 |
+
# Prepare model for training
|
| 140 |
+
model = prepare_model_for_kbit_training(model)
|
| 141 |
+
model = get_peft_model(model, lora_config)
|
| 142 |
+
model.print_trainable_parameters()
|
| 143 |
+
|
| 144 |
+
# Training arguments
|
| 145 |
+
training_args = TrainingArguments(
|
| 146 |
+
output_dir=exp_name,
|
| 147 |
+
eval_strategy="steps",
|
| 148 |
+
save_strategy="no",
|
| 149 |
+
logging_strategy="steps",
|
| 150 |
+
eval_steps=500,
|
| 151 |
+
max_steps=2500,
|
| 152 |
+
logging_steps=100,
|
| 153 |
+
learning_rate=1e-4,
|
| 154 |
+
per_device_train_batch_size=16,
|
| 155 |
+
per_device_eval_batch_size=32,
|
| 156 |
+
#gradient_accumulation_steps=1,
|
| 157 |
+
lr_scheduler_type="cosine",
|
| 158 |
+
warmup_ratio=0.05,
|
| 159 |
+
report_to="mlflow",
|
| 160 |
+
gradient_checkpointing=True,
|
| 161 |
+
max_grad_norm=1.0,
|
| 162 |
+
weight_decay=0.01,
|
| 163 |
+
num_train_epochs=2
|
| 164 |
+
)
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
class MLflowMetricsLogger:
|
| 170 |
+
"""
|
| 171 |
+
A callable class to compute and log metrics to MLflow with step tracking.
|
| 172 |
+
"""
|
| 173 |
+
def __init__(self, trainer: Trainer, ks=[3, 5, 10]):
|
| 174 |
+
"""
|
| 175 |
+
Initializes the metrics logger.
|
| 176 |
+
|
| 177 |
+
Args:
|
| 178 |
+
trainer (Trainer): The Hugging Face Trainer instance.
|
| 179 |
+
ks (list): A list of k values for MAP@k calculation.
|
| 180 |
+
"""
|
| 181 |
+
self.trainer = trainer
|
| 182 |
+
self.ks = ks
|
| 183 |
+
|
| 184 |
+
def __call__(self, eval_pred):
|
| 185 |
+
"""
|
| 186 |
+
This method is called by the Trainer during evaluation.
|
| 187 |
+
"""
|
| 188 |
+
# Get the current training step from the trainer's state
|
| 189 |
+
step = self.trainer.state.global_step
|
| 190 |
+
|
| 191 |
+
# 1. Unpack logits and labels
|
| 192 |
+
logits, labels = eval_pred
|
| 193 |
+
labels = np.array(labels)
|
| 194 |
+
|
| 195 |
+
# 2. Convert logits to probabilities
|
| 196 |
+
probs = torch.nn.functional.softmax(torch.tensor(logits), dim=-1).numpy()
|
| 197 |
+
|
| 198 |
+
# 3. Get top-k predictions
|
| 199 |
+
max_k = max(self.ks)
|
| 200 |
+
top_k_preds = np.argsort(-probs, axis=1)[:, :max_k]
|
| 201 |
+
|
| 202 |
+
# 4. Create a boolean match array
|
| 203 |
+
match_array = (top_k_preds == labels[:, None])
|
| 204 |
+
|
| 205 |
+
# 5. Compute MAP@k for each specified k
|
| 206 |
+
metrics = {}
|
| 207 |
+
for k in self.ks:
|
| 208 |
+
match_at_k = match_array[:, :k]
|
| 209 |
+
ranks = np.argmax(match_at_k, axis=1) + 1
|
| 210 |
+
has_match_at_k = np.any(match_at_k, axis=1)
|
| 211 |
+
scores = has_match_at_k * (1.0 / ranks)
|
| 212 |
+
metrics[f"map@{k}"] = np.mean(scores)
|
| 213 |
+
|
| 214 |
+
# 6. Calculate detailed rank position breakdown
|
| 215 |
+
ranks_with_indices = [np.where(row)[0] for row in match_array]
|
| 216 |
+
correct_ranks = np.array([r[0] + 1 if len(r) > 0 else max_k + 1 for r in ranks_with_indices])
|
| 217 |
+
|
| 218 |
+
total = labels.shape[0]
|
| 219 |
+
rank_1_count = np.sum(correct_ranks == 1)
|
| 220 |
+
rank_2_to_3_count = np.sum((correct_ranks >= 2) & (correct_ranks <= 3))
|
| 221 |
+
rank_above_3_count = np.sum((correct_ranks > 3) & (correct_ranks <= max_k))
|
| 222 |
+
no_match_count = np.sum(correct_ranks > max_k)
|
| 223 |
+
|
| 224 |
+
# Log metrics to MLflow WITH the step argument
|
| 225 |
+
mlflow.log_metric("rank_1", rank_1_count, step=step)
|
| 226 |
+
mlflow.log_metric("rank_2_to_3", rank_2_to_3_count, step=step)
|
| 227 |
+
mlflow.log_metric("rank_above_3", rank_above_3_count, step=step)
|
| 228 |
+
mlflow.log_metric("no_match_in_top_k", no_match_count, step=step)
|
| 229 |
+
|
| 230 |
+
metrics["rank_1"] = rank_1_count
|
| 231 |
+
metrics["rank_2_to_3"] = rank_2_to_3_count
|
| 232 |
+
metrics["rank_above_3"] = rank_above_3_count
|
| 233 |
+
metrics["no_match_in_top_k"] = no_match_count
|
| 234 |
+
metrics["total"] = total
|
| 235 |
+
|
| 236 |
+
return metrics
|
| 237 |
+
|
| 238 |
+
|
| 239 |
+
# Initialize trainer
|
| 240 |
+
trainer = Trainer(
|
| 241 |
+
model,
|
| 242 |
+
args=training_args,
|
| 243 |
+
train_dataset=train_ds,
|
| 244 |
+
eval_dataset=eval_ds,
|
| 245 |
+
tokenizer=tokenizer,
|
| 246 |
+
data_collator=DataCollatorWithPadding(tokenizer),
|
| 247 |
+
)
|
| 248 |
+
|
| 249 |
+
metrics_computer = MLflowMetricsLogger(trainer)
|
| 250 |
+
trainer.compute_metrics = metrics_computer
|
| 251 |
+
|
| 252 |
+
# Main execution
|
| 253 |
+
if __name__ == "__main__":
|
| 254 |
+
|
| 255 |
+
# Start training
|
| 256 |
+
trainer.train()
|
| 257 |
+
|
| 258 |
+
# Save the model
|
| 259 |
+
trainer.save_model(exp_name)
|
| 260 |
+
|
| 261 |
+
print("Getting predictions on validation set...")
|
| 262 |
+
predictions = trainer.predict(eval_ds)
|
| 263 |
+
|
| 264 |
+
# Extract logits and predictions
|
| 265 |
+
logits = predictions.predictions
|
| 266 |
+
predicted_labels = np.argmax(logits, axis=1)
|
| 267 |
+
|
| 268 |
+
# Create results dataframe
|
| 269 |
+
val_results = val_df.copy()
|
| 270 |
+
val_results['predicted'] = predicted_labels
|
| 271 |
+
|
| 272 |
+
# Convert logits to list of lists for storage
|
| 273 |
+
val_results['logits'] = [logit.tolist() for logit in logits]
|
| 274 |
+
|
| 275 |
+
# Save validation results
|
| 276 |
+
val_results.to_parquet(f"{exp_name}/{exp_name}_oof.parquet", index=False)
|
| 277 |
+
print(f"Validation results saved to {exp_name}/{exp_name}.parquet")
|
| 278 |
+
|
| 279 |
+
source_file = f"{exp_name}.py"
|
| 280 |
+
destination_directory = exp_name
|
| 281 |
+
|
| 282 |
+
shutil.copy(source_file, destination_directory)
|
| 283 |
+
print(f"File '{source_file}' copied to '{destination_directory}'")
|
| 284 |
+
|
| 285 |
+
print("Training completed and model saved!")
|
MAP_EXP_24_oof.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dbaf83a651322985d601e81f84c479b9c8978f5ce606846fa7e32c539ccb67ad
|
| 3 |
+
size 3816746
|
README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: mistralai/Mathstral-7B-v0.1
|
| 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": "mistralai/Mathstral-7B-v0.1",
|
| 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 |
+
"gate_proj",
|
| 32 |
+
"v_proj",
|
| 33 |
+
"k_proj",
|
| 34 |
+
"down_proj",
|
| 35 |
+
"q_proj",
|
| 36 |
+
"o_proj",
|
| 37 |
+
"up_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:8b6aaf18afcffaeb4a3900c7d343b8564451f280ac400e8f758f6f7265b7969e
|
| 3 |
+
size 672214232
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- if messages[0]['role'] == 'system' %}
|
| 2 |
+
{%- set system_message = messages[0]['content'] %}
|
| 3 |
+
{%- set loop_messages = messages[1:] %}
|
| 4 |
+
{%- else %}
|
| 5 |
+
{%- set loop_messages = messages %}
|
| 6 |
+
{%- endif %}
|
| 7 |
+
|
| 8 |
+
{{- bos_token }}
|
| 9 |
+
{%- for message in loop_messages %}
|
| 10 |
+
{%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}
|
| 11 |
+
{{- raise_exception('After the optional system message, conversation roles must alternate user/assistant/user/assistant/...') }}
|
| 12 |
+
{%- endif %}
|
| 13 |
+
{%- if message['role'] == 'user' %}
|
| 14 |
+
{%- if loop.last and system_message is defined %}
|
| 15 |
+
{{- '[INST] ' + system_message + '\n\n' + message['content'] + '[/INST]' }}
|
| 16 |
+
{%- else %}
|
| 17 |
+
{{- '[INST] ' + message['content'] + '[/INST]' }}
|
| 18 |
+
{%- endif %}
|
| 19 |
+
{%- elif message['role'] == 'assistant' %}
|
| 20 |
+
{{- ' ' + message['content'] + eos_token}}
|
| 21 |
+
{%- else %}
|
| 22 |
+
{{- raise_exception('Only user and assistant roles are supported, with the exception of an initial optional system message!') }}
|
| 23 |
+
{%- endif %}
|
| 24 |
+
{%- endfor %}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<s>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"eos_token": {
|
| 10 |
+
"content": "</s>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"pad_token": "</s>",
|
| 17 |
+
"unk_token": {
|
| 18 |
+
"content": "<unk>",
|
| 19 |
+
"lstrip": false,
|
| 20 |
+
"normalized": false,
|
| 21 |
+
"rstrip": false,
|
| 22 |
+
"single_word": false
|
| 23 |
+
}
|
| 24 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:59f95e28944c062244741268596badc900df86c7f5ded05088d2da22a7379e06
|
| 3 |
+
size 587583
|
tokenizer_config.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8cba18f58eb5deabb738d167109f181e9741cd85a99a36981c296f18334414ac
|
| 3 |
+
size 5304
|