Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3
4# Load base model
5base_model = AutoModelForCausalLM.from_pretrained(
6 "TinyLlama/TinyLlama-1.1B-Chat-v1.0",
7 device_map="auto"
8)
9
10# Load fine-tuned adapter
11model = PeftModel.from_pretrained(
12 base_model,
13 "shettynavisha25/tinyllama-alpaca-finetuned"
14)
15
16tokenizer = AutoTokenizer.from_pretrained("TinyLlama/TinyLlama-1.1B-Chat-v1.0")
17
18# Format your prompt
19prompt = """### Instruction:
20Write a haiku about artificial intelligence
21
22### Response:
23"""
24
25inputs = tokenizer(prompt, return_tensors="pt")
26outputs = model.generate(**inputs, max_length=150, temperature=0.7)
27print(tokenizer.decode(outputs[0], skip_special_tokens=True))### Instruction:
Explain quantum computing in simple terms
### Response:### Instruction:
Write a Python function to calculate fibonacci numbers
### Response:text-davinci-003 model. The dataset covers diverse tasks including:| Hyperparameter | Value |
|---|---|
| Learning rate | 2e-4 |
| Batch size | 4 |
| Gradient accumulation steps | 4 |
| Effective batch size | 16 |
| Number of epochs | 3 |
| Max sequence length | 512 |
| Optimizer | paged_adamw_8bit |
| Learning rate schedule | Linear warmup (100 steps) |
| Weight decay | 0 |
| Warmup steps | 100 |
1@misc{tinyllama-alpaca-finetuned,
2 author = {Navisha Shetty},
3 title = {TinyLlama-1.1B Alpaca Fine-tuned},
4 year = {2025},
5 publisher = {HuggingFace},
6 howpublished = {\url{https://huggingface.co/shettynavisha25/tinyllama-alpaca-finetuned}}
7}1@article{zhang2024tinyllama,
2 title={TinyLlama: An Open-Source Small Language Model},
3 author={Zhang, Peiyuan and Guangtao, Zeng and Wang, Tianduo and Lu, Wei},
4 journal={arXiv preprint arXiv:2401.02385},
5 year={2024}
6}1@misc{alpaca,
2 author = {Rohan Taori and Ishaan Gulrajani and Tianyi Zhang and Yann Dubois and Xuechen Li and Carlos Guestrin and Percy Liang and Tatsunori B. Hashimoto},
3 title = {Stanford Alpaca: An Instruction-following LLaMA model},
4 year = {2023},
5 publisher = {GitHub},
6 journal = {GitHub repository},
7 howpublished = {\url{https://github.com/tatsu-lab/stanford_alpaca}},
8}