Downloads · 30 days
13
22% of all-time downloads
Shoriful025/chef_gpt2_recipe_generator
chef_gpt2_recipe_generator is a text generation model from Shoriful025. Use it when you need the model to write or continue text. The card lists the license as mit.
chefgpt2recipegenerator is a Causal Language Model designed to generate cooking recipes based on a provided list of ingredients. It is fine-tuned on a large corpus of structured recipes, learning the relationship betw…
Downloads · 30 days
13
22% of all-time downloads
All-time downloads
59
Public
Repo size
—
Likes
0
Public
Click a slice to open those files.
.md1.9 KB · 45%
From the Hugging Face model README
chef_gpt2_recipe_generator is a Causal Language Model designed to generate cooking recipes based on a provided list of ingredients. It is fine-tuned on a large corpus of structured recipes, learning the relationship between ingredients, quantities, and instructions.
This model is based on the gpt2-medium architecture (355M parameters).
INGREDIENTS: [list of items] \n INSTRUCTIONS: [step-by-step guide] <|endoftext|>.The model works best when prompted with the specific format it was trained on. You should provide a list of ingredients following the INGREDIENTS: tag.
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
model_name = "your_username/chef_gpt2_recipe_generator"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
chef = pipeline('text-generation', model=model, tokenizer=tokenizer, device=-1)
# Define ingredients
prompt = "INGREDIENTS: Chicken breast, garlic, soy sauce, honey, broccoli. \n INSTRUCTIONS:"
output = chef(
prompt,
max_length=400,
num_return_sequences=1,
do_sample=True,
top_k=50,
top_p=0.92,
temperature=0.8,
pad_token_id=tokenizer.eos_token_id
)
print(output[0]['generated_text'])