Instructions to use xorslider/FoodExtract-gemma-3-4b-finetuned with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use xorslider/FoodExtract-gemma-3-4b-finetuned with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("xorslider/FoodExtract-gemma-3-4b-finetuned", device_map="auto") - Notebooks
- Google Colab
- Kaggle
FoodExtract: Fine-Tuned Gemma 3 4B
A fine-tuned version of google/gemma-3-4b-it trained to extract food and drink items from raw text.
What It Does
Given any text input, this model outputs a structured extraction:
food_or_drink: 1
tags: fi, di
foods: eggs, bacon, toast
drinks: orange juice
If the input contains no food or drink items:
food_or_drink: 0
tags:
foods:
drinks:
Tag Reference
| Tag | Meaning |
|---|---|
| np | nutrition_panel |
| il | ingredient_list |
| me | menu |
| re | recipe |
| fi | food_items |
| di | drink_items |
| fa | food_advertisement |
| fp | food_packaging |
How to Use
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
model_id = "xorslider/FoodExtract-gemma-3-4b-finetuned"
model = AutoModelForCausalLM.from_pretrained(model_id, dtype="auto", device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_id)
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
input_text = "A bowl of ramen with soft-boiled eggs, nori, and a side of green tea."
formatted = pipe.tokenizer.apply_chat_template(
[{"role": "user", "content": input_text}],
tokenize=False,
add_generation_prompt=True
)
output = pipe(formatted, max_new_tokens=128)
print(output[0]["generated_text"][len(formatted):])
Training
Base model: google/gemma-3–4b-it
Dataset: mrdbourke/FoodExtract-1k (1,136 training samples)
Method: Full supervised fine-tuning (SFT) via Hugging Face TRL
Epochs: 3
Batch size: 4
Learning rate: 2e-4
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support