Views
No views yet
1from unsloth import FastLanguageModel
2from peft import PeftModel
3
4# Load base model
5model, tokenizer = FastLanguageModel.from_pretrained(
6 model_name="unsloth/Qwen3-8B-unsloth-bnb-4bit",
7 max_seq_length=2048,
8 dtype=None,
9 load_in_4bit=True,
10)
11
12# Load adapter
13model = PeftModel.from_pretrained(model, "kaushik2202/diet-advisor-qwen-qlora")
14
15# Enable inference mode
16FastLanguageModel.for_inference(model)
17
18# Use for diet advice
19prompt = """Human: I'm a 30-year-old female seeking dietary advice. I'm interested in Mediterranean cuisine.
20
21**My Health Profile:**
22• Weight: 65kg, Height: 165cm
23• Activity Level: Moderate exercise
24• Health Goals: Weight maintenance
25• Dietary Restrictions: None
26
27Can you suggest a Mediterranean meal plan?"""
28
29# Format for Qwen2.5
30formatted_prompt = f"<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n"
31
32inputs = tokenizer(formatted_prompt, return_tensors="pt")
33outputs = model.generate(**inputs, max_new_tokens=300, temperature=0.7)
34response = tokenizer.decode(outputs[0], skip_special_tokens=True)Assistant: I'll create a personalized Mediterranean meal plan based on your health profile.
## 🍽️ Mediterranean Recommendations for Your Health
**Breakfast:** Greek yogurt with berries and nuts
**Lunch:** Mediterranean salad with grilled chicken
**Dinner:** Baked fish with roasted vegetables
## 📋 Age-Specific Tips (30 years old)
• Focus on nutrient-dense foods for sustained energy
• Include calcium-rich foods for bone health
• Balance convenience with nutrition quality
**Remember:** These recommendations are tailored to your profile. Consult with a registered dietitian for detailed meal planning.1@model{diet-advisor-qwen-qlora,
2 author = {kaushik2202},
3 title = {Diet Advisor QLoRA - Personalized Nutrition Assistant},
4 year = {2025},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/kaushik2202/diet-advisor-qwen-qlora}
7}