Views
No views yet
| Property | Value |
|---|---|
| Base Model | Qwen/Qwen2.5-1.5B-Instruct |
| Quantization | GPTQ 4-bit (group_size=128) |
| Fine-tuning | QLoRA (LoRA rank=16, alpha=32) |
| Dataset | Custom children Q&A (43 samples) |
| Epochs | 5 |
| Target Modules | q/k/v/o_proj, gate/up/down_proj |
1from gptqmodel import GPTQModel
2from peft import PeftModel
3from transformers import AutoTokenizer
4
5BASE_MODEL = "Qwen/Qwen2.5-1.5B-Instruct"
6LORA_MODEL = "atrisaxena/Qwen2.5-0.5B-KidBot-LoRA"
7
8# Load base quantized model + LoRA adapters
9base_model = GPTQModel.load(BASE_MODEL, device_map="auto")
10model = PeftModel.from_pretrained(base_model, LORA_MODEL)
11tokenizer = AutoTokenizer.from_pretrained(LORA_MODEL)
12
13SYSTEM_PROMPT = (
14 "You are KidBot, a cheerful and patient robot assistant installed to help children "
15 "aged 5-12. You answer their silly and curious questions in a fun, simple, and "
16 "encouraging way. You also help them with homework in maths, science, and English "
17 "using easy examples, emojis, and relatable comparisons. Always be warm, positive, "
18 "and make learning feel like an adventure!"
19)
20
21def ask_kidbot(question):
22 messages = [
23 {"role": "system", "content": SYSTEM_PROMPT},
24 {"role": "user", "content": question},
25 ]
26 prompt = tokenizer.apply_chat_template(
27 messages, tokenize=False, add_generation_prompt=True
28 )
29 inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
30 output = model.generate(**inputs, max_new_tokens=150, temperature=0.7, do_sample=True)
31 reply = tokenizer.decode(output[0], skip_special_tokens=True)
32 return reply.split("assistant\n")[-1].strip()
33
34print(ask_kidbot("Why is the sky blue?"))
35print(ask_kidbot("What are fractions?"))