Instructions to use xorslider/FoodExtract-gemma-3-270m-finetuned with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use xorslider/FoodExtract-gemma-3-270m-finetuned with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="xorslider/FoodExtract-gemma-3-270m-finetuned") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("xorslider/FoodExtract-gemma-3-270m-finetuned") model = AutoModelForCausalLM.from_pretrained("xorslider/FoodExtract-gemma-3-270m-finetuned", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use xorslider/FoodExtract-gemma-3-270m-finetuned with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "xorslider/FoodExtract-gemma-3-270m-finetuned" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xorslider/FoodExtract-gemma-3-270m-finetuned", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/xorslider/FoodExtract-gemma-3-270m-finetuned
- SGLang
How to use xorslider/FoodExtract-gemma-3-270m-finetuned with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "xorslider/FoodExtract-gemma-3-270m-finetuned" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xorslider/FoodExtract-gemma-3-270m-finetuned", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "xorslider/FoodExtract-gemma-3-270m-finetuned" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xorslider/FoodExtract-gemma-3-270m-finetuned", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use xorslider/FoodExtract-gemma-3-270m-finetuned with Docker Model Runner:
docker model run hf.co/xorslider/FoodExtract-gemma-3-270m-finetuned
FoodExtract: Fine-Tuned Gemma 3 270M
A fine-tuned version of google/gemma-3-270m-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-270m-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–270m-it
Dataset: mrdbourke/FoodExtract-1k (1,136 training samples)
Method: Full supervised fine-tuning (SFT) via Hugging Face TRL
Epochs: 3
Batch size: 16
Learning rate: 5e-5
- Downloads last month
- 369