Views
No views yet
1### Question:
2Is Apples healthy or unhealthy?
3
4### Answer:
5Healthy1### Question:
2Is French Fries healthy or unhealthy?
3
4### Answer:
5Unhealthypip install transformers peft torch1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3
4base_model_name = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
5
6# Load base TinyLlama model
7base_model = AutoModelForCausalLM.from_pretrained(base_model_name)
8
9# Load LoRA adapter
10model = PeftModel.from_pretrained(
11 base_model,
12 "YOUR_USERNAME/health-food-demo-lora"
13)
14
15tokenizer = AutoTokenizer.from_pretrained(
16 "YOUR_USERNAME/health-food-demo-lora"
17)
18
19prompt = """
20### Question:
21Is Pizza healthy or unhealthy?
22
23### Answer:
24"""
25
26inputs = tokenizer(prompt, return_tensors="pt")
27
28output = model.generate(
29 **inputs,
30 max_new_tokens=10
31)
32
33print(tokenizer.decode(output[0], skip_special_tokens=True))1### Question:
2Is Pizza healthy or unhealthy?
3
4### Answer:
5Unhealthy1### Question:
2Is Salmon healthy or unhealthy?
3
4### Answer:
5Healthy1LoraConfig(
2 task_type=TaskType.CAUSAL_LM,
3 r=16,
4 lora_alpha=32,
5 lora_dropout=0.05,
6 bias="none"
7)1llama-cli \
2 -m TinyLlama-1.1B-Chat-v1.0-Q4_K_M.gguf \
3 --lora health_food_demo_lora.gguf \
4 -p "### Question: Is Pizza healthy or unhealthy?\n\n### Answer:"| File | Description |
|---|---|
adapter_model.safetensors | LoRA adapter weights |
adapter_config.json | LoRA configuration |
tokenizer.json | Tokenizer |
README.md | Documentation |
| File | Description |
|---|---|
health_food_demo_lora.gguf | GGUF LoRA adapter for llama.cpp |