Instructions to use AdamCodd/t5-small-recipes-ingredients with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AdamCodd/t5-small-recipes-ingredients with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AdamCodd/t5-small-recipes-ingredients")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("AdamCodd/t5-small-recipes-ingredients") model = AutoModelForSeq2SeqLM.from_pretrained("AdamCodd/t5-small-recipes-ingredients") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use AdamCodd/t5-small-recipes-ingredients with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AdamCodd/t5-small-recipes-ingredients" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AdamCodd/t5-small-recipes-ingredients", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/AdamCodd/t5-small-recipes-ingredients
- SGLang
How to use AdamCodd/t5-small-recipes-ingredients 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 "AdamCodd/t5-small-recipes-ingredients" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AdamCodd/t5-small-recipes-ingredients", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "AdamCodd/t5-small-recipes-ingredients" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AdamCodd/t5-small-recipes-ingredients", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use AdamCodd/t5-small-recipes-ingredients with Docker Model Runner:
docker model run hf.co/AdamCodd/t5-small-recipes-ingredients
YAML Metadata Warning:The pipeline tag "text2text-generation" is not in the official list: text-classification, token-classification, table-question-answering, question-answering, zero-shot-classification, translation, summarization, feature-extraction, text-generation, fill-mask, sentence-similarity, text-to-speech, text-to-audio, automatic-speech-recognition, audio-to-audio, audio-classification, audio-text-to-text, voice-activity-detection, depth-estimation, image-classification, object-detection, image-segmentation, text-to-image, image-to-text, image-to-image, image-to-video, unconditional-image-generation, video-classification, reinforcement-learning, robotics, tabular-classification, tabular-regression, tabular-to-text, table-to-text, multiple-choice, text-ranking, text-retrieval, time-series-forecasting, text-to-video, image-text-to-text, image-text-to-image, image-text-to-video, visual-question-answering, document-question-answering, zero-shot-image-classification, graph-ml, mask-generation, zero-shot-object-detection, text-to-3d, image-to-3d, image-feature-extraction, video-text-to-text, keypoint-detection, visual-document-retrieval, any-to-any, video-to-video, other
t5-small-recipes-ingredients
This model t5-small has been finetuned on a curated recipe dataset.
It achieves the following results on the evaluation set:
- Loss: 0.0453
The idea behind this is to generate a few recipe names to consider, based on ingredient inputs. I think it's useful when we have some leftover ingredients and don't know what to cook with them. Ingredients should be input in english with commas between them as shown in the example below.
The license is cc-by-nc-4.0. For commercial use rights, please contact me (adamcoddml@gmail.com).
Usage
The length of the negative prompt can be adjusted using the max_length parameter (50-60 is fine for recipe names). You can enhance the creativity of the outputs with the temperature setting (note: coherence may significantly degrade if the temperature exceeds 1.2). The parameters no_repeat_ngram_size and repetition_penalty can also be used to slightly improve coherence.
Use num_return_sequences to generate multiple recipes in a single pass (recommended).
from transformers import pipeline
# Initialize the recipe generation pipeline
recipe_generator = pipeline("text2text-generation", model="AdamCodd/t5-small-recipes-ingredients")
# Generate recipes
generated_texts = recipe_generator(
"penne pasta, cherry tomatoes, basil, mozzarella cheese, olive oil",
max_length=50,
do_sample=True,
temperature=1.0,
no_repeat_ngram_size=2,
repetition_penalty=1.2,
num_return_sequences=5,
)
# Extract and print the generated recipes
for i, output in enumerate(generated_texts):
print(f"Recipe {i+1}: {output['generated_text']}")
# Recipe 1: Pasta With Tomatoes And Basil
# Recipe 2: Pasta With Shredded Tomatoes And Mozzarella
# Recipe 3: Penne With Tomato And Basil
# Recipe 4: Penne Fagioli
# Recipe 5: Lemon-Basil Penne
This model has been trained on a not perfectly clean dataset, so the suggestions don't always make sense but it's a minor issue when returning multiple sequences at once. Still, improving the dataset will be the main focus for a future version.
Training and evaluation data
More information needed
Training procedure
Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 3e-05
- train_batch_size: 32
- eval_batch_size: 64
- seed: 42
- optimizer: AdamW with betas=(0.9,0.999) and epsilon=1e-08
- Mixed precision
- num_epochs: 3
- weight_decay: 0.01
Framework versions
- Transformers 4.36.2
- Datasets 2.16.1
- Tokenizers 0.15.0
- Evaluate 0.4.1
If you want to support me, you can here.
- Downloads last month
- 38
Model tree for AdamCodd/t5-small-recipes-ingredients
Base model
google-t5/t5-smallEvaluation results
- lossself-reported0.045