--- language: - en tags: - text-generation - gpt2 - culinary - recipe-generation license: mit --- # chef_gpt2_recipe_generator ## Overview `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. ## Model Architecture This model is based on the `gpt2-medium` architecture (355M parameters). - **Base Model:** GPT-2 Medium. - **Training Objective:** Causal Language Modeling (CLP) / Next-token prediction. - **Data Format:** The model was trained on data structured as: `INGREDIENTS: [list of items] \n INSTRUCTIONS: [step-by-step guide] <|endoftext|>`. ## Intended Use - **Culinary Inspiration:** Generating creative ideas for leftover ingredients in a fridge. - **Creative Writing:** Assisting in generating content for food blogs or culinary fiction. - **Data Augmentation:** Creating synthetic recipe datasets for downstream culinary NLP tasks. ### How to use 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. ```python 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'])