Views
No views yet


{
"messages": [
{
"role": "user",
"content": "Instruction:
text_here
Solution:
text_here
},
{
"role": "assistant",
"content": "text_here"
}
]
}
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4# Load the tokenizer and model
5model_name = "secemp9/TraceBack-12b"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(model_name)
8
9# Move the model to the desired device
10device = 'cuda' if torch.cuda.is_available() else 'cpu'
11model.to(device)
12
13# Define the messages
14messages = [
15 {"role": "user", "content": """Instruction:
16how many r in strawberry
17
18
19Solution:
20There are **three** "r"s in "strawberry."
21"""}
22]
23
24# Step 1: Apply chat template to get formatted text as a string
25formatted_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
26
27# Step 2: Tokenize the formatted text into a dictionary of tensors
28inputs = tokenizer(formatted_text, return_tensors="pt").to(device)
29
30# Generate the response
31outputs = model.generate(**inputs, max_new_tokens=32000)
32
33# Decode and print the output
34generated_text = tokenizer.decode(outputs[0])
35print(generated_text)1from unsloth import FastLanguageModel
2
3# Load the model and tokenizer
4model, tokenizer = FastLanguageModel.from_pretrained("secemp9/TraceBack-12b")
5
6# Define the messages (replace "stuff_here" with your actual input)
7messages = [
8 {"role": "user", "content": """Instruction:
9how many r in strawberry
10
11
12Solution:
13There are **three** "r"s in "strawberry."
14"""}
15]
16
17# Step 1: Apply chat template to get formatted text as a string
18formatted_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
19
20# Step 2: Tokenize the formatted text into a dictionary of tensors
21inputs = tokenizer(formatted_text, return_tensors="pt").to(model.device)
22
23# Generate the response
24outputs = model.generate(**inputs, max_new_tokens=32000)
25
26# Decode and print the output
27generated_text = tokenizer.decode(outputs[0])
28print(generated_text)# Base model configuration
base_model: unsloth/Mistral-Nemo-Instruct-2407-bnb-4bit
load_in_4bit: true
# Dataset configuration
datasets:
- path: instruction_solution_to_thought_dataset.jsonl
type: chat_template
# Chat template
chat_template: chatml
# LoRA adapter configuration
adapter: lora
lora_r: 16
lora_alpha: 16
lora_dropout: 0
lora_target_modules:
- q_proj
- k_proj
- v_proj
- o_proj
- gate_proj
- up_proj
- down_proj
# Training hyperparameters
max_seq_length: 128000
micro_batch_size: 2
gradient_accumulation_steps: 8
learning_rate: 3e-5
num_epochs: 3
warmup_steps: 100
optimizer: adamw_8bit
weight_decay: 0.01
lr_scheduler_type: cosine
max_grad_norm: 1.0
output_dir: ./outputs_solution_to_thought
seed: 3407
merge_lora: true
hf_upload: true
hf_repo: secemp9/TraceBack-12b
xformers_attention:
flash_attention: True
bf16: true # Enable BF16 mixed precision
# Multi-GPU training with DeepSpeed
deepspeed: deepspeed_configs/zero2.json
# Optional: Enable gradient checkpointing
gradient_checkpointing: true{
"zero_optimization": {
"stage": 2,
"allgather_partitions": true,
"allgather_bucket_size": 2e8,
"overlap_comm": true,
"reduce_scatter": true,
"reduce_bucket_size": 2e8,
"contiguous_gradients": true
},
"bf16": {
"enabled": true
},
"optimizer": {
"type": "AdamW",
"params": {
"lr": "auto",
"weight_decay": "auto",
"betas": [0.9, 0.999],
"eps": 1e-8
}
},
"scheduler": {
"type": "WarmupLR",
"params": {
"warmup_min_lr": 0,
"warmup_max_lr": "auto",
"warmup_num_steps": "auto"
}
},
"train_micro_batch_size_per_gpu": "auto",
"gradient_accumulation_steps": "auto",
"steps_per_print": 10,
"wandb": {
"enabled": true
}
}