Text Generation
PEFT
Safetensors
English
French
TRL
lora
SFT
nutrition
dietetics
smartplate
conversational
Instructions to use KlibiYoussef/smart-plate-nutrition-adapter with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use KlibiYoussef/smart-plate-nutrition-adapter with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-4B-Base") model = PeftModel.from_pretrained(base_model, "KlibiYoussef/smart-plate-nutrition-adapter") - Notebooks
- Google Colab
- Kaggle
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:
- Accurate Nutritional Analysis: Instantly breaks down calories and macronutrients (proteins, carbohydrates, fats) per 100g for thousands of diverse foods and ingredients.
- 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): Features custom behavioral safety constraints. 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"
"Analyze my plate, I ate 100g of chicken breast.\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)
- Downloads last month
- 94
Model tree for KlibiYoussef/smart-plate-nutrition-adapter
Base model
Qwen/Qwen3-4B-Base