thealper2/gemma-3-270m-foodextract
gemma-3-270m-foodextract
LoRA (merged) SFT of unsloth/gemma-3-270m-it for structured food/drink extraction from a text description, trained on mrdbourke/FoodExtract-135k.
Input / output
User turn (model chat template):
Extract the food and drink information from this description.
Description:
{description}Output (dataset column gpt-oss-120b-label-condensed, unchanged):
food_or_drink: 0|1
tags: <comma-separated codes>
foods: <comma-separated items>
drinks: <comma-separated items>Tag codes: np nutrition panel, il ingredient list, me menu, re recipe, fi food items, di drink items, fa food advertisement, fp food packaging.
Training data
Removed: empty descriptions, exact duplicate (description, target) pairs, examples longer than 1024 tokens (not truncated), train rows sharing a description with test. Test: official test split (held-out evaluation). Validation: 5% of cleaned official train, group-aware, seed=42.
Training procedure
Evaluation
Split: test (500 examples), greedy decoding, maxnewtokens=256.
Food/drink references only (344 examples): exact match 0.1977, foods F1 0.7282, drinks F1 0.6187, tags F1 0.9227.
Usage
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "thealper2/gemma-3-270m-foodextract"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, dtype=torch.bfloat16).to("cuda")
description = "A plate of grilled chicken with rice and a glass of orange juice."
messages = [{"role": "user", "content": "Extract the food and drink information from this description.\n\nDescription:\n" + description}]
prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
inputs = tokenizer(prompt, add_special_tokens=False, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=256, do_sample=False)
print(tokenizer.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True).strip())Limitations
- Targets were generated by
gpt-oss-120bfrom the text description; the model reproduces these LLM labels, including their errors. - Training data mixes real web captions (COYO-700M, PixMo-Cap, Open-Qwen2VL) with synthetic captions and random strings.
- Item lists are comma-separated; items containing commas cannot be represented unambiguously.
- English descriptions; inputs longer than 1024 tokens were not seen in training.
- Trained on a 20000-example subset of the cleaned training split.
- Use is subject to the Gemma Terms of Use of the base model.
