1from transformers import AutoTokenizer, AutoModelForCausalLM
2
3# One-liner to load
4tokenizer = AutoTokenizer.from_pretrained("arif-butt/tinyllama-peft-merged")
5model = AutoModelForCausalLM.from_pretrained(
6 "arif-butt/tinyllama-peft-merged",
7 torch_dtype=torch.float16,
8 device_map="auto"
9)
10
11# Generate
12prompt = "Q: What courses does Arif teach?\nA:"
13inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
14outputs = model.generate(**inputs, max_new_tokens=100)
15print(tokenizer.decode(outputs[0], skip_special_tokens=True))
16
17📦 What's Inside
18tinyllama-peft-merged/
19├── model.safetensors # 2.2 GB — merged weights
20├── config.json # Model architecture
21├── generation_config.json # Default generation settings
22├── tokenizer.json # Vocabulary (1.76 MB)
23├── tokenizer_config.json # Tokenizer settings
24└── special_tokens_map.json # Special tokens
25
26No adapter files. No PEFT needed. Just load and go.
27
28
29🔧 Generation Settings
30outputs = model.generate(
31 **inputs,
32 max_new_tokens=150,
33 temperature=0.7,
34 top_p=0.95,
35 do_sample=True,
36 repetition_penalty=1.1,
37 pad_token_id=tokenizer.eos_token_id,
38)
39
40
41💬 Prompt Format
42Q: Your question here?
43A:
44Example:
45
46 Q: What is deep learning?
47A: Deep learning is a subset of machine learning...
48
49
50Q: What is Python?
51A: Python is a high-level, interpreted programming language known for its simple, readable syntax. It supports multiple programming paradigms including object-oriented, imperative, and functional programming.
52
53Q: Explain gradient descent
54A: Gradient descent is an optimization algorithm used to minimize the loss function in machine learning models. It works by iteratively moving parameters in the direction of the negative gradient.
55
56Q: Name Arif's courses
57A: Dr. Muhammad Arif Butt teaches Python Programming, Data Structures & Algorithms, Machine Learning, and Deep Learning courses.
58
59Epoch 1: ████████████████░░░░ 0.8
60Epoch 2: ████████████████████ 0.4
61Epoch 3: ████████████████████ 0.05