Practical Prompt Engineering: Extracting Structured Recipe Data from Plain Text

Initial Attempt

The rationale behind this prompt is to specify the specific fields we want to extract from the recipe. We assume that the field names are self-explanatory and only specify the fields and datatypes that might be ambiguous.

extract the following information:

- dishName
- publishDate
- author
- ingredients (name, unit, amount)
- steps (array of strings)
- servings
- If you don't find any suitable values use null or an empty array

RECIPE

[REPLACE_WITH_RECIPE_TEXT]

OUTPUT AS VALID JSON

Sample

The sample was obtained from this page.

To grab a sample programmatically in a real-world project, I recommend doing the following:

  1. Retrieve the HTML response of the page.
  2. Exclude unnecessary elements such as nav, footer, and head, as they are typically irrelevant.
  3. "Strip out" all HTML tags from the remaining HTML (leaving the text, aka PHP's strip_tags() function
  4. Replace tabs, spaces, and newlines with a single space.
  5. Eliminate any duplicate spaces.
  6. Trim the leading and trailing whitespace from the string.
Skip to content
All Recipes

Appetizers
Bread & Muffins
Breakfast
Desserts
Drinks
Main Dish
Salad
Side Dish
Soup
Chicken Recipes
Ground Beef
Easy Dinners
Breakfast
About
Contact
Search for
Search the site…

Home | Easy Dinners | The Best Classic Chili

The Best Classic Chili
by Amanda Finks
on May 19, 2018

Rate Now
Jump to Recipe
Jump to Video
Print Recipe
The Best Classic Chili – This traditional chili recipe is just like mom used to make with ground beef, beans, and a simple homemade blend of chili seasonings.

The Best Classic Chili recipe in a red bowl topped with cheese and sour cream
This classic chili is perfect for a weeknight meal because it can be made in minutes.  The only thing to chop is an onion.

How do you make good homemade chili?
Heat olive in a large soup pot.
Add chopped onion and cook for 5 minutes.
Add ground beef and break it apart with a wooden spoon.
Cook for 6-7 minutes.
onions and ground beef sautéing in a soup pot
Add chili powder, cumin, sugar, tomato paste, garlic powder, salt, pepper, and optional cayenne.
Stir until well combined.
chili powder, cumin, garlic powder, sugar, salt, and pepper over browned beef and onions in a pot
Add diced tomatoes, kidney beans, beef broth, and tomato sauce.
Stir well.
diced tomatoes over chili seasoned ground beef and onions in a soup pot
Simmer for 20-25 minutes.
Let the chili rest for 5-10 minutes before serving.
beans, beef broth, and tomato sauce added to chili seasoned beef, onions, and tomatoes in a pot
What do you top chili with?
In addition to the chili ingredients listed in this recipe for chili, you may also want to have these things as toppings.

shredded cheddar cheese
sour cream
sliced green onions
saltine crackers or oyster crackers
diced avocado
What goes well with chili for dinner?
Bacon Cheddar Jalapeno Cornbread
Quick & Easy Cornbread
 Two Ingredient Nutella Brownies
I’ve been playing around with this chili recipe for the past few months, making it many times.  My family didn’t mind the repetition at all because I really do believe that I ended up with the best chili ever!

Watch the step by step recipe video for this chili recipe below.
Find more of my recipes on TikTok

Follow me on TikTok
The best classic chili recipe in a red bowl topped with cheddar cheese and sour cream
The Best Classic Chili Recipe
4.96 from 2930 votes
The Best Classic Chili - This traditional chili recipe is just like mom used to make with ground beef, beans, and a simple homemade blend of chili seasonings.
Prep Time
5 minutes
Cook Time
25 minutes
Total Time
30 minutes
Video
Servings
6 servings
Calories
334 kcal
Rate the Recipe
Print Recipe
Ingredients

1x
2x
3x
1 tablespoon olive oil
1 medium yellow onion -diced
1 pound 90% lean ground beef
2 1/2 tablespoons chili powder
2 tablespoons ground cumin
2 tablespoons granulated sugar
2 tablespoons tomato paste
1 tablespoon garlic powder
1 1/2 teaspoons salt
1/2 teaspoon ground black pepper
1/4 teaspoon ground cayenne pepper* -optional
1 1/2 cups beef broth
1 (15 oz.) can petite diced tomatoes
1 (16 oz.) can red kidney beans, drained and rinsed
1 (8 oz.) can tomato sauce
Instructions
Add the olive oil to a large soup pot and place it over medium-high heat for two minutes. Add the onion. Cook for 5 minutes, stirring occasionally.
Add the ground beef to the pot. Break it apart with a wooden spoon. Cook for 6-7 minutes, until the beef is browned, stirring occasionally.
Add the chili powder, cumin, sugar, tomato paste, garlic powder, salt, pepper, and optional cayenne. Stir until well combined.
Add the broth, diced tomatoes (with their juice), drained beans, and tomato sauce. Stir well.
Bring the liquid to a low boil. Then, reduce the heat (low to medium-low) to gently simmer the chili, uncovered, for 20-25 minutes, stirring occasionally.
Remove the pot from the heat. Let the chili rest for 5-10 minutes before serving.
Notes
I typically skip the cayenne pepper because I have a young kiddo.  Then, I put out some hot sauce for those adults that want to add some spiciness to their chili.
Nutrition
Serving: 1/6th of the recipe | Calories: 334kcal | Carbohydrates: 34g | Protein: 25g | Fat: 11g | Saturated Fat: 3g | Cholesterol: 49mg | Sodium: 1249mg | Potassium: 1110mg | Fiber: 9g | Sugar: 10g | Vitamin A: 1445IU | Vitamin C: 12.8mg | Calcium: 99mg | Iron: 7.5mg
Course
Dinner, Entree, Main Course
Keyword
best chili, chili recipe, classic chili, homemade chili
Cuisine
American
Author
Amanda Finks
Tried this recipe?
Let us know how it was by leaving a review or sharing on Instagram with the tag #thewholesomedish!
Check out all of my great ground beef recipes.

SHARE
PREVIOUS POST:
Crock Pot Italian Chicken Tortellini Soup
NEXT POST:
The Best Classic Lasagna
Want more recipes?
Sign up here to have new recipes sent directly to your inbox.
First Name *
First Name...
Email *
Email address...
Let's Go
newsletter signup
Leave a Comment
Your email address will not be published. Required fields are marked *

RECIPE RATING
Recipe Rating
COMMENT *

NAME *

EMAIL *

Comments
Amaya
April 11, 2023 at 12:27 PM
3 starsin my opinion, it’s far too spice heavy. The texture and everything else is good, just don’t prefer this spice blend

Reply
Chuck g
April 10, 2023 at 2:04 PM
5 starsLoved it

Reply
Kenneth C
April 10, 2023 at 1:43 PM
5 starsFirst time I’ve ever made chili. I was asked to be one of five to make chili for our church mens fellowship meeting. I made the large batch 18 servings size. Since having never made chili before I made sure to follow the recipe as written and I must say it is a very delicious chili. It didn’t last 30 minutes before it was all gone. Everyone stated this was the best chili there. I’m now asked to make chili for our upcoming church senior lunch gathering. Thanks so much great chili simple to make. A Win Win!

Reply
Kate
April 8, 2023 at 12:54 PM
5 starsThis is a great recipe. I did however change it a little bit. I put in Raos marinara sauce with some tomato paste instead of the tomato sauce and tomatoes. There’s something so natural about this marinara sauce and it is fantastic in every dish I make. I also put in a little bit of the chili pepper flakes instead of cayenne pepper. Of course I really upped the chili powder as well.

Reply
Peter
April 7, 2023 at 7:48 PM
Too salty, absolutely no heat.
Read the reviews and figured with such a high rating, it would come out ok. Nope! It did not. I see people complaining about it being spicy but I think they’re confusing salty with heat. Should of used a 1/2tsp of salt not 1.5 tsp!!!?!?! Absolutely no heat whatsoever as well. Very bland.
I will not do this recipe again. Posting this knowing very well my review will be deleted.

Reply
Judy
April 7, 2023 at 2:51 PM
5 starsMy very favourite chili recipe. Thanks!!

Reply
Diane Morrison
April 7, 2023 at 9:02 AM
Made for a Pot luck. Everyone enjoyed it, Little a left over. I rated it Great. Even some people wanted the reccipe. I used my own Canned beans & Tomato. Nice to have the basic on hand. I soaked the beans 12 hrs. rinsed canned set aside for times like this. Cost was light when you have canned your own stuff

Reply
Junko
April 6, 2023 at 4:11 PM
5 starsThis has been my go-to recipe for the last two years and, my family loves it. In fact I have a double batch simmering on my stove right now! We will have a bowl tonight and I’ll freeze the rest.

Reply
Mona
April 6, 2023 at 12:11 PM
5 starsExcellent recipe! It is now my go to on cold evenings.

Reply
Jackie Bouchard
April 5, 2023 at 5:23 PM
5 starsEvery time I make this my family says it’s the best chili they ever tasted. They keep telling me I need to enter a chili . Fantastic recipe.

Reply
Jenny
April 4, 2023 at 7:51 PM
5 starsWonderful and quick chili – in our all-time, record breaking snow year in Utah. Wanted a stay at home day with warm food. Easy stuff to find in pantry! My kiddo loved it, too (she can do spice, although, I didn’t find it too overwhelming in heat, anyhow). I halved the sugar upon reading reviews. Thank you for this gluten free chili recipe. I will make it again. 🙂

Reply
LOAD MORE COMMENTS


About Amanda Finks
I’m a Registered Dietitian Nutritionist living in Zionsville, IN. I’m an avid cook, travel nerd, & lover of good food! I’m trained in Food Science & recipe development. It’s my mission to bring you the BEST recipes your whole family will love!

Read more
Hi, I’m Amanda Finks


I’m a Registered Dietitian Nutritionist living in Zionsville, IN.  I’m an avid cook, travel nerd, & lover of good food!  I’m trained in Food Science & recipe development. It’s my mission to bring you the BEST recipes your whole family will love! See More

Recent Posts
Slice of strawberry jello pie topped with whipped cream on a white plate.
Strawberry Pie
Casserole dish full of tater tot casserole
Easy Tater Tot Casserole
Piece of butterscotch pumpkin poke cake on a white plate.
Butterscotch Pumpkin Poke Cake
Bowl full of crock pot ranch white chicken chili topped with tortilla chips, cheese, and lime.
Crock Pot Ranch White Chicken Chili
White bowl full of beef and noodles with green beans in the background.
Crock Pot Beef and Noodles
White bowl full of chili mac.
Easy Chili Mac
Recipes
About
Contact
© The Wholesome Dish 2023. All rights reserved.
Disclaimer  Privacy Policy

Let's try out our prompt on this sample:

Result

Note: I shortened the JSON by putting the ingredients on 1 line, instead of keeping the format verbatim, there is no practical difference for the purpose of this demonstration.

{
  "dishName": "The Best Classic Chili",
  "publishDate": "May 19, 2018",
  "author": "Amanda Finks",
  "ingredients": [
    { "name": "olive oil", "unit": null, "amount": 1 },
    { "name": "yellow onion", "unit": "diced", "amount": 1 },
    { "name": "ground beef", "unit": "90% lean", "amount": 1 },
    { "name": "chili powder", "unit": null, "amount": 2.5 },
    { "name": "ground cumin", "unit": null, "amount": 2 },
    { "name": "granulated sugar", "unit": null, "amount": 2 },
    { "name": "tomato paste", "unit": null, "amount": 2 },
    { "name": "garlic powder", "unit": null, "amount": 1 },
    { "name": "salt", "unit": null, "amount": 1.5 },
    { "name": "ground black pepper", "unit": null, "amount": 0.5 },
    { "name": "ground cayenne pepper", "unit": null, "amount": 0.25 },
    { "name": "beef broth", "unit": null, "amount": 1.5 },
    { "name": "petite diced tomatoes", "unit": "15 oz. can", "amount": 1 },
    {
      "name": "red kidney beans",
      "unit": "16 oz. can, drained and rinsed",
      "amount": 1
    },
    { "name": "tomato sauce", "unit": "8 oz. can", "amount": 1 }
  ],
  "steps": [
    "Add the olive oil to a large soup pot and place it over medium-high heat for two minutes. Add the onion. Cook for 5 minutes, stirring occasionally.",
    "Add the ground beef to the pot. Break it apart with a wooden spoon. Cook for 6-7 minutes, until the beef is browned, stirring occasionally.",
    "Add the chili powder, cumin, sugar, tomato paste, garlic powder, salt, pepper, and optional cayenne. Stir until well combined.",
    "Add the broth, diced tomatoes (with their juice), drained beans, and tomato sauce. Stir well.",
    "Bring the liquid to a low boil. Then, reduce the heat (low to medium-low) to gently simmer the chili, uncovered, for 20-25 minutes, stirring occasionally.",
    "Remove the pot from the heat. Let the chili rest for 5-10 minutes before serving."
  ],
  "servings": 6,
  "toppings": [
    "shredded cheddar cheese",
    "sour cream",
    "sliced green onions",
    "saltine crackers or oyster crackers",
    "diced avocado"
  ],
  "sideDishes": [
    "Bacon Cheddar Jalapeno Cornbread",
    "Quick & Easy Cornbread",
    "Two Ingredient Nutella Brownies"
  ]
}

Review

The following is problematic with the previous result:

Good:

  • All the fields we asked for were included.
  • The JSON is valid and can be parsed without error.
  • The datatypes seem correct (numbers are represented as numbers instead of strings).

Bad:

  • The prompt engineering succeeded in extracting the requested fields, but it also included additional fields like "toppings" and "sideDishes" that we did not specify. This could be a result of the model inferring additional information or patterns from the recipe text.
  • We cannot rely on this "working by accident" to consistently extract the desired fields.
  • The "publishDate" format is still in the original format from the article. It would be more helpful to have it in the standardized YYYY-MM-DD format.

Improved Prompt:

Extract only the following information from the recipe

- dishName
- publishDate (in YYYY-MM-DD format)
- author
- ingredients (name, unit, amount)
- steps (array of strings)
- servings

RECIPE

[REPLACE_WITH_RECIPE_TEXT]

OUTPUT AS VALID JSON

By refining the prompt to focus solely on the requested fields and specifying the desired format for "publishDate," we can significantly enhance the accuracy and consistency of the data extraction.

The following JSON represents the result of our changes:

{
  "dishName": "The Best Classic Chili",
  "publishDate": "2018-05-19",
  "author": "Amanda Finks",
  "ingredients": [
    { "name": "olive oil", "unit": "tablespoon", "amount": 1 },
    { "name": "yellow onion", "unit": "medium", "amount": 1 },
    { "name": "ground beef", "unit": "pound", "amount": 1 },
    { "name": "chili powder", "unit": "tablespoon", "amount": 2.5 },
    { "name": "ground cumin", "unit": "tablespoon", "amount": 2 },
    { "name": "granulated sugar", "unit": "tablespoon", "amount": 2 },
    { "name": "tomato paste", "unit": "tablespoon", "amount": 2 },
    { "name": "garlic powder", "unit": "tablespoon", "amount": 1 },
    { "name": "salt", "unit": "teaspoon", "amount": 1.5 },
    { "name": "black pepper", "unit": "teaspoon", "amount": 0.5 },
    { "name": "cayenne pepper", "unit": "teaspoon", "amount": 0.25 },
    { "name": "beef broth", "unit": "cup", "amount": 1.5 },
    { "name": "petite diced tomatoes", "unit": "can", "amount": 1 },
    { "name": "red kidney beans", "unit": "can", "amount": 1 },
    { "name": "tomato sauce", "unit": "can", "amount": 1 }
  ],
  "steps": [
    "Add the olive oil to a large soup pot and place it over medium-high heat for two minutes. Add the onion. Cook for 5 minutes, stirring occasionally.",
    "Add the ground beef to the pot. Break it apart with a wooden spoon. Cook for 6-7 minutes, until the beef is browned, stirring occasionally.",
    "Add the chili powder, cumin, sugar, tomato paste, garlic powder, salt, pepper, and optional cayenne. Stir until well combined.",
    "Add the broth, diced tomatoes (with their juice), drained beans, and tomato sauce. Stir well.",
    "Bring the liquid to a low boil. Then, reduce the heat (low to medium-low) to gently simmer the chili, uncovered, for 20-25 minutes, stirring occasionally.",
    "Remove the pot from the heat. Let the chili rest for 5-10 minutes before serving."
  ],
  "servings": 6
}

Much better! We can now observe that our publishDate is in the correct format.

It's worth noting that this time around, we have also obtained units for the ingredients.

This improvement may be attributed to the removal of the line - If you don't find any suitable values, use null or an empty array.

This particular instruction could have been ambiguous and possibly prompted the model to default to null, resulting in the exclusion of units like "teaspoon" for not being deemed "suitable."

While it's uncertain if this was the case, it underscores the importance of being specific when crafting prompts.

Hope you learned something.