A LoRA adapter for Qwen/Qwen2.5-0.5B-Instruct that turns a short user profile (age, gender, height, weight, activity level, dietary preference, daily calorie target) into a one-day meal plan with breakfast, lunch, snack and dinner.
It is a small, fast, single-purpose model: about 2.2M trainable parameters on top of a 0.5B base, usable on CPU.
Not medical advice. This is an experimental model trained on a small dataset. Its output has not been reviewed by a dietitian and must not be used to manage a health condition. See Limitations.
| Developed by | syubraj |
| Model type | LoRA adapter (PEFT) for a causal language model |
| Base model | Qwen/Qwen2.5-0.5B-Instruct |
| Language | English |
| License | Apache-2.0 |
| Training data | syubraj/DietRecommendation-dataset-Qwen-2.5-0.5b |
| Related model | syubraj/DietRecommender_4bit_Qwen2.5-0.5B (trained on the same dataset) |
The adapter was trained on one fixed prompt layout. Use the same system prompt and the same field names and order, otherwise quality drops. Two details matter:
Ages: in the training data, so keep it that way.import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
BASE = "Qwen/Qwen2.5-0.5B-Instruct"
ADAPTER = "syubraj/DietRecommendation-Qwen2.5-0.5B"
tokenizer = AutoTokenizer.from_pretrained(ADAPTER)
model = AutoModelForCausalLM.from_pretrained(BASE, torch_dtype="auto", device_map="auto")
model = PeftModel.from_pretrained(model, ADAPTER)
model.eval()
# Exact system prompt used in training (including the line break).
SYSTEM_PROMPT = (
"Act as a nutrition expert. Based on the user’s age, gender, height, weight, "
"activity level, diet preference, and calorie target, \n"
"suggest a balanced meal plan with breakfast, lunch, snacks, and dinner."
)
def build_profile(age, gender, height_cm, weight_kg, activity, diet, kcal):
return (
f"Ages: {age}\n"
f"Gender: {gender}\n"
f"Height: {height_cm} cm\n"
f"Weight: {weight_kg} kg\n"
f"Activity Level: {activity}\n"
f"Dietary Preference: {diet}\n"
f"Daily Calorie Target: {kcal} kcal"
)
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": build_profile(32, "Female", 165, 65, "Lightly Active", "Vegetarian", 1600)},
]
inputs = tokenizer.apply_chat_template(
messages, add_generation_prompt=True, return_tensors="pt", return_dict=True
).to(model.device)
with torch.no_grad():
output = model.generate(**inputs, max_new_tokens=96, do_sample=False)
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
device_map="auto" needs accelerate; drop that argument to load on CPU.
| Field | Values |
|---|---|
| Gender | Male, Female |
| Activity Level | Sedentary, Lightly Active, Moderately Active, Very Active |
| Dietary Preference | Omnivore, Vegetarian, Vegan |
| Height / Weight | centimetres / kilograms |
| Daily Calorie Target | kcal |
Four lines, one per meal. This example is a row from the training set and shows the format the model was taught to produce:
Breakfast: Tofu scramble with veggies
Lunch: Lentil soup with whole wheat bread
Snack: Apple with almond butter
Dinner: Vegetable stir-fry with brown rice
To ship a standalone model with no PEFT dependency:
merged = model.merge_and_unload()
merged.save_pretrained("DietRecommendation-Qwen2.5-0.5B-merged")
tokenizer.save_pretrained("DietRecommendation-Qwen2.5-0.5B-merged")
syubraj/DietRecommendation-dataset-Qwen-2.5-0.5b: 1,698 examples (1,358 train / 340 validation), derived from the Kaggle dataset Nutrition Daily Meals in Diseases Cases.
Each example is a single text string already rendered in ChatML (system prompt, user profile, assistant meal plan), 525 to 678 characters long.
| Setting | Value |
|---|---|
Rank (r) |
4 |
lora_alpha |
16 |
lora_dropout |
0.1 |
| Bias | none |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Task type | CAUSAL_LM |
| Trainable parameters | about 2.2M (roughly 0.44% of the base model) |
| Setting | Value |
|---|---|
| Learning rate | 2e-4 |
| Train / eval batch size | 4 / 4 |
| Gradient accumulation steps | 4 (effective batch size 16) |
| Optimizer | AdamW (adamw_torch), betas (0.9, 0.999), epsilon 1e-8 |
| LR scheduler | cosine, 100 warmup steps |
| Epochs | 15 |
| Mixed precision | native AMP |
| Seed | 42 |
| Training loss | Epoch | Step | Validation loss |
|---|---|---|---|
| 3.0693 | 1.18 | 100 | 0.2517 |
| 0.9641 | 2.35 | 200 | 0.2243 |
| 0.8782 | 3.53 | 300 | 0.2218 |
| 0.8378 | 4.71 | 400 | 0.2253 |
| 0.8114 | 5.88 | 500 | 0.2179 |
| 0.7791 | 7.06 | 600 | 0.2193 |
| 0.7539 | 8.24 | 700 | 0.2178 |
| 0.7247 | 9.41 | 800 | 0.2185 |
| 0.6962 | 10.59 | 900 | 0.2234 |
| 0.6731 | 11.76 | 1000 | 0.2265 |
| 0.6363 | 12.94 | 1100 | 0.2317 |
| 0.6184 | 14.12 | 1200 | 0.2343 |
Final reported validation loss: 0.2343 (step 1200).
How to read these numbers:
Only validation loss was measured. There is no task-level evaluation yet: no check of nutritional adequacy, calorie accuracy, adherence to the dietary preference, or expert review. Treat the model as unvalidated for all of these.
Show a clear "not medical advice" notice wherever outputs reach end users, keep a person in the loop, and check dietary-preference compliance separately rather than trusting the model.
@misc{syubraj2025dietrecommendation,
title = {DietRecommendation-Qwen2.5-0.5B: a LoRA adapter for meal-plan recommendation},
author = {syubraj},
year = {2025},
url = {https://huggingface.co/syubraj/DietRecommendation-Qwen2.5-0.5B}
}
Base model:
@misc{qwen2.5,
title = {Qwen2.5: A Party of Foundation Models},
url = {https://qwenlm.github.io/blog/qwen2.5/},
author = {Qwen Team},
month = {September},
year = {2024}
}
adapter_model.safetensors 8 MiBtraining_args.bin 5.2 KiBQwen/Qwen2.5-0.5B-Instruct