Views
No views yet
SFTTrainer and PEFT (LoRA) on Windows. The following hyperparameters were used:gate_proj, down_proj, k_proj, q_proj, v_proj, up_proj, o_projadamw_8bit)content) and mapped it to the Python solution (python) under the Alpaca instruction format:1### Instruction:
2[LeetCode Problem Description]
3
4### Response:
5[Python Code Solution and Explanation]1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4# Load the merged model
5model_id = "sriram279/Leet-Reason-Qwen0.5"
6tokenizer = AutoTokenizer.from_pretrained(model_id)
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 torch_dtype=torch.float16,
10 device_map="auto"
11)
12
13# Format your prompt
14prompt = "solve Two sum problem in Python"
15inputs = tokenizer.apply_chat_template(
16 [{"role": "user", "content": prompt}],
17 tokenize=True,
18 add_generation_prompt=True,
19 return_tensors="pt"
20).to(model.device)
21
22# Generate
23outputs = model.generate(
24 inputs,
25 max_new_tokens=512,
26 temperature=0.7,
27 do_sample=True
28)
29
30print(tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True))