metadata
library_name: transformers
tags:
- unsloth
- trl
- sft
Model Card for Model ID
Model Details
A 1.5B model for reasoning ability:
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
MAX_REASONING_TOKENS = 4096
MAX_RESPONSE_TOKENS = 256 # Recommend 512, 1024 Recommen
model = AutoModelForCausalLM.from_pretrained(
'beyoru/ThinkAgainSm_1',
torch_dtype=torch.float16,
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained('beyoru/ThinkAgainSm_1')
while True:
prompt = input("USER: ")
messages = [
{"role": "user", "content": prompt}
]
# Generate reasoning
reasoning_template = tokenizer.apply_chat_template(messages, tokenize=False, add_reasoning_prompt=True)
reasoning_inputs = tokenizer(reasoning_template, return_tensors="pt").to(model.device)
reasoning_ids = model.generate(**reasoning_inputs, max_new_tokens=MAX_REASONING_TOKENS)
reasoning_output = tokenizer.decode(reasoning_ids[0, reasoning_inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(reasoning_output)
# Generate answer
messages.append({"role": "reasoning", "content": reasoning_output})
response_template = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
response_inputs = tokenizer(response_template, return_tensors="pt").to(model.device)
response_ids = model.generate(**response_inputs, max_new_tokens=MAX_RESPONSE_TOKENS)
response_output = tokenizer.decode(response_ids[0, response_inputs.input_ids.shape[1]:], skip_special_tokens=True)
messages.append({"role": "assistant", "content": response_output})
print(response_output)
Training on 2 hour with LoRA only attns layers
rank = 32, aplpha = 64 lr = 2e-4,
For the instruction task recommend to add in the user prompt, not the system prompt. Example:
Create SQL query for sepectific table you will provide:<your question> \n <your table> \n <your desc if your table is complex>
Weakness:
- Model still priority for English