Model details
Table | |
|---|
| Developed by | luisandrademe |
| Model type | LoRA adapter for a vision-language model (image + text → text) |
| Base model | Qwen/Qwen3-VL-4B-Instruct (4.4 B parameters) |
| Trainable parameters | 33.0 M (language model only) |
| Output language | Spanish ingredient names, English JSON keys |
| License | Apache 2.0 |
The model answers with one JSON object. quantity is free text and confidence is
alta, media or baja:
{"ingredients": [ {"name": "tomate", "quantity": "4 unidades", "confidence": "alta"}, {"name": "leche", "quantity": "1 botella", "confidence": "media"}]}
In the app the call uses Ollama's JSON-schema format, temperature 0.1 and
repeat_penalty 1.1, and names are normalized afterwards (accents, plurals, aliases,
duplicates).
Why fine-tune
On real photos the base model is precise but conservative: it names few items it
isn't sure about and misses roughly a third of the human-verified ingredients. The
goal is higher recall without losing precision, while keeping the model's ability to
name foods outside any fixed label set, because users photograph whatever is in
their fridge.
Training data
luisandrademe/nevera-ingredients: CC BY photos from
Open Images V7 with
human-verified image-level labels for 34 food classes mapped to Spanish names.
Training photos come from the Open Images test split and the benchmark from the
validation split, so no photo is shared.
Targets are built by self-distillation with label correction:
- The base model labels each photo with the exact production prompt, image size
(768 px) and post-processing.
- Its answer is corrected only where Open Images has verified labels: items verified
absent are removed (hallucinations), verified items it missed are added, verified
items it found are kept with confidence
alta.
- Everything that can't be checked (foods outside the 34 classes) is kept as the base
model said it.
Training only on the 34-class labels would teach the model to stop naming everything
else. Correcting its own answers keeps its vocabulary and style and fixes only the
mistakes that can be verified.
Corrections applied to the teacher answers (Qwen/Qwen3-VL-4B-Instruct, greedy, repetition_penalty 1.1):
Table with columns: Train, Validation | Train | Validation |
|---|
| Photos used | 578 | 96 |
| Invalid JSON, skipped | 22 | 4 |
| Verified items kept | 421 | 74 |
| Unverifiable items kept | 737 | 133 |
| Hallucinations removed | 17 | 1 |
| Missed items added | 190 | 27 |
Training procedure
LoRA on the attention and MLP projections of the language model; the vision encoder
and projector stay frozen. The loss is computed on the answer tokens only. The adapter
with the lowest validation loss is kept.
Table with columns: Hyperparameter, Value| Hyperparameter | Value |
|---|
| LoRA rank / alpha / dropout | 16 / 32 / 0.05 |
| Target modules | q, k, v, o, gate, up, down projections of the language model |
| Trainable parameters | 33.0 M |
| Train / validation photos | 578 / 96 |
| Epochs / optimizer steps | 2 / 146 |
| Batch | 1 photo × 8 gradient accumulation |
| Optimizer | AdamW, lr 0.0001, 5% warmup, cosine decay, gradient clipping 1.0 |
| Image size | up to 589,824 pixels (768 × 768) |
| Precision | fp16 with fp32 LoRA weights |
| Hardware | 1 × Tesla T4 (Kaggle, free tier) |
| Training time | 62 min |
Loss

Table with columns: Step, Train loss, Validation loss| Step | Train loss | Validation loss |
|---|
| 0 | — | 0.7435 |
| 25 | 0.1381 | 0.1499 |
| 50 | 0.1951 | 0.1379 |
| 75 | 0.1191 | 0.1134 |
| 100 | 0.0939 | 0.1058 |
| 125 | 0.124 | 0.1054 |
| 146 | 0.0517 | 0.1041 (best) |
The targets are mostly the model's own answers, so the loss starts low and falls
quickly; what matters is the benchmark below, scored on photos it never saw.
Raw logs: training/log.jsonl (every optimizer step) and
training/summary.json.
Export
The adapter is merged into the base model in bf16 and converted with llama.cpp the
same way as the official Ollama model: Q4_K_M text weights plus an f16 vision
projector (mmproj), and a Modelfile with the qwen3-vl-instruct renderer and parser.
Ollama cannot load a Qwen3-VL fine-tune from safetensors on macOS, which is why the
GGUF route is used.
Evaluation
The served GGUF is scored with the same pipeline as the base model: 85 Open Images
validation photos, production prompt and post-processing. Following the Open Images
challenge protocol, only verified classes count as positives, unverified classes are
not scored either way, and names outside the vocabulary are reported separately as
"out-of-vocabulary per photo" rather than counted as errors.
Served with Ollama (Q4_K_M) on a 16 GB M4 Mac. openimages: 85 real photos; synthetic: 6 generated fridge photos.
Table with columns: Model, Dataset, Precision, Recall, F1, Failed, Out-of-vocabulary / photo, p50| Model | Dataset | Precision | Recall | F1 | Failed | Out-of-vocabulary / photo | p50 |
|---|
| base | openimages | 0.958 | 0.653 | 0.777 | 0 | 1.09 | 8.7 s |
| fine-tuned | openimages | 0.969 | 0.723 | 0.828 | 0 | 0.82 | 6.7 s |
| base | synthetic | 0.852 | 0.793 | 0.821 | 0 | — | 9.8 s |
| fine-tuned | synthetic | 0.815 | 0.759 | 0.786 | 0 | — | 8.3 s |
Usage
Ollama (how the app serves it)
hf download luisandrademe/nevera-vision-4b-GGUF --local-dir nevera-vision-4bollama create nevera-vision:4b -f nevera-vision-4b/Modelfileollama run nevera-vision:4b "Lista los ingredientes" ./fridge.jpg
from peft import PeftModelfrom transformers import AutoProcessor, Qwen3VLForConditionalGeneration base = Qwen3VLForConditionalGeneration.from_pretrained( "Qwen/Qwen3-VL-4B-Instruct", dtype="auto", device_map="auto")model = PeftModel.from_pretrained(base, "luisandrademe/nevera-vision-4b-lora")processor = AutoProcessor.from_pretrained("Qwen/Qwen3-VL-4B-Instruct")
Use the system and user prompts from
backend/app/services/prompts.py;
the model was trained with them.
Intended use and limitations
- Built for kitchen photos: fridges, pantries, groceries, plates. Not a general
object detector and not for dietary, allergy or food-safety decisions.
- Ingredient names are Spanish.
- Recall is measured on 34 Open Images classes; foods outside them are kept from the
base model but not scored.
- Quantities are rough estimates.
- A 4 B model still confuses similar foods (orange vs. grapefruit) and misses items
at the back of a crowded shelf.
License and attribution
Apache 2.0, as the base model. Training images are CC BY 2.0 by their Flickr authors
and Open Images annotations CC BY 4.0 (Google LLC); attribution for every photo is in
the dataset.