KlibiYoussef/smart-plate-nutrition-adapter
134
Smart Plate Nutrition AI - Adapter Model
This model is a fine-tuned LoRA adapter built on top of the Qwen/Qwen3-4B-Base architecture. It is specifically trained to power the core intelligent assistant of the Smart Plate Nutrition platform.
Specialization & Features
The model has been optimized using a custom, strictly filtered bilingual dataset to handle three main responsibilities:
- Scientific Dietary Guidance: Provides evidence-based advice regarding muscle gain, weight loss, managing cravings, meal timing, and proper hydration.
- Strict Out-of-Scope Filtering (Guardrails): If a user asks questions unrelated to diet, fitness, or health (e.g., programming tasks, history, geography, or coding scripts), it will politely decline to answer and guide the user back to nutritional or health topics.
Response Style & Brand Voice
- Politeness & Professionalism: Always maintains an empathetic, supportive, and respectful tone (enforcing formal "vouvoiement" address when communicating in French).
- Fixed Structural Output: Every response structurally initiates with a warm, welcoming greeting and systematically concludes with an encouraging closing remark aligned with the user's wellness goals.
Quick Start (Usage Example)
The adapter follows the ChatML prompt structure. Below is an optimized script demonstrating how to programmatically initialize the base model along with this adapter using the platform's official system prompt setup:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
# Repository Configurations
BASE_MODEL_ID = "Qwen/Qwen3-4B-Base"
ADAPTER_PATH = "KlibiYoussef/smart-plate-nutrition-adapter"
# 1. Load Tokenizer and Base Model with the LoRA Adapter
tokenizer = AutoTokenizer.from_pretrained(ADAPTER_PATH)
base_model = AutoModelForCausalLM.from_pretrained(
BASE_MODEL_ID,
torch_dtype=torch.float16,
device_map="auto"
)
model = PeftModel.from_pretrained(base_model, ADAPTER_PATH)
model.eval()
# 2. Construct the Prompt in ChatML format using the official platform prompt
prompt = (
"<|im_start|>system\n"
"You are the 'Smart Plate Nutrition' AI assistant. Your role is to provide ultra-precise, "
"scientific, and personalized nutritional information. You must always be polite, helpful, "
"start with a warm greeting, and end with an encouraging health-focused closing statement."
"<|im_end|>\n"
"<|im_start|>user\n"
"How can I lose fat without losing muscle?\n"
"<|im_end|>\n"
"<|im_start|>assistant\n"
)
# 3. Generate Response
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=256,
temperature=0.3,
do_sample=True,
repetition_penalty=1.1
)
# Decode the Output
generated_tokens = outputs[0][inputs.input_ids.shape[1]:]
response = tokenizer.decode(generated_tokens, skip_special_tokens=True)
print(response)