Parsing text content to generate links to database of items using large language models
Item linked recipe generation using machine learning is described. Raw data is received that describes a recipe that uses ingredients. Ingredient descriptors are extracted from the raw data for the ingredients. Parsed ingredient data is determined using the ingredient descriptors and a large language model, such that the parsed ingredient data for each ingredient includes a name, a quantity, and a unit of measure. The name of each ingredient is mapped to a corresponding ingredient identifier that is part of an ingredient database. And each ingredient identifier in the ingredient database is associated with a corresponding item that is available for sale at one or more sources. A linked recipe is generated that includes for each ingredient: an ingredient identifier, a quantity of the ingredient, and a unit of measure of the quantity. A recommendation for the linked recipe is provided to a user client device.
1 . A method, performed at a computer system comprising a processor and a computer-readable medium, comprising:
receiving first raw recipe data that describes a recipe that uses a set of ingredients;
extracting, from the first raw recipe data, ingredient descriptors for the set of ingredients, wherein an ingredient descriptor of the ingredient descriptors comprises a range of quantities associated with an ingredient of the set of ingredients;
generating, by a recipe management module of an online system, parsed ingredient data by prompting a large language model of an artificial intelligence system using the ingredient descriptors, such that the parsed ingredient data for each ingredient of the set of ingredients includes an ingredient name, an ingredient quantity, and a unit of measure of the ingredient quantity, wherein generating the parsed ingredient data by prompting the large language model comprises:
generating, by a first neural network model of the artificial intelligence system, a prompt to provide to the large language model, wherein the prompt instructs the large language model to select a value from the range of quantities,
wherein the parsed ingredient data for the ingredient descriptor specifies a single quantity of the ingredient, and the single quantity corresponds to the value of the range of quantities;
mapping, for each ingredient of the parsed ingredient data, the ingredient name to a corresponding ingredient identifier that is part of an ingredient database, and each ingredient identifier in the ingredient database is associated with a corresponding item that is available for sale at one or more sources;
generating a first linked recipe associated with the first raw recipe data;
generating a second linked recipe associated with second raw recipe data;
in response to accessing, by a user client device, a graphical user interface (GUI) associated with the online system:
providing, by a second neural network model of the artificial intelligence system, a search query prompt to the large language model, wherein the search query prompt requests an order for presenting the first linked recipe and the second linked recipe in different positions of a scrollable recipe carousel to be displayed on the GUI;
computing, by the large language model, (i) a first embedding score associated with a first item embedding and a third item embedding and (ii) a second embedding score associated with a second item embedding and the third item embedding;
selecting, by the large language model, the order of the first linked recipe and the second linked recipe for presentation based on the first embedding score and the second embedding score; and
causing the user client device to display the GUI by rendering the first linked recipe and second linked recipe in respective positions of the scrollable recipe carousel, the respective positions corresponding to the selected order.
2 . The method of claim 1 , further comprising:
tuning the large language model using one or more examples, each example including raw recipe data and a corresponding set of parsed ingredient data.
3 . The method of claim 1 , further comprising:
generating additional training examples using portions of the linked recipe and complaint data; and
tuning the large language model based in part on the additional training examples.
4 . The method of claim 1 , further comprising:
identifying, using the ingredient identifier of the linked recipe, a corresponding item that is available for sale from a source of the one or more sources that is associated with the user client device; and
providing a description for the corresponding item to the user client device.
5 . The method of claim 1 , wherein a first ingredient descriptor of the recipe does not specify a quantity, and generating parsed ingredient data by prompting a large language model using the ingredient descriptors comprises:
generating, by the first neural network model, a prompt to provide to the large language model, the prompt instructing the large language model to select, for an ingredient descriptor that does not specify a quantity, a quantity of one,
wherein the parsed ingredient data for the first ingredient descriptor specifies a quantity of one for the first ingredient descriptor.
6 . The method of claim 1 , wherein mapping, for each ingredient of the parsed ingredient data, the name of the ingredient to a corresponding ingredient identifier that is part of the ingredient database, further comprises:
for a name of a first ingredient of the set of ingredients,
mapping the name of the first ingredient to a corresponding set of one or more versions of the name of the first ingredient that are mapped to a first ingredient identifier in the ingredient database, and
mapping the name of the first ingredient to the first ingredient identifier.
7 . The method of claim 6 , wherein the corresponding set of one or more versions of the name of the first ingredient are synonyms for the name of the first ingredient.
8 . The method of claim 1 , wherein a first ingredient of the recipe is a compound ingredient that is composed of a separate first ingredient and a second separate ingredient, and extracting, from the raw recipe data, ingredient descriptors for the set of ingredients, further comprises:
generating a prompt to provide to the large language model, the prompt instructing the large language model to:
identify whether any ingredient of the set of ingredients is a compound ingredient that is composed of multiple ingredients,
separate any identified compound ingredient into separate ingredients such that the set of ingredients includes the multiple ingredients, and
extract, from the raw recipe data, ingredient descriptors for the set of ingredients,
wherein the ingredient descriptors include an ingredient descriptor for the first separate ingredient and an ingredient descriptor for the second separate ingredient.
9 . The method of claim 1 , wherein the recipe includes a sub-recipe that is composed of a first ingredient and a second ingredient, and extracting, from the raw recipe data, ingredient descriptors for the set of ingredients, further comprises:
generating, by the first neural network model, a prompt to provide to the large language model, the prompt instructing the large language model to:
identify whether the recipe includes a sub-recipe,
identify any ingredients that are associated with the sub-recipe, such that the set of ingredients includes ingredients for the recipe and ingredients for the sub-recipe, and
extract, from the raw recipe data, ingredient descriptors for the set of ingredients,
wherein the ingredient descriptors includes an ingredient descriptor for the first ingredient and an ingredient descriptor for the second ingredient.
10 . A computer program product comprising a non-transitory computer readable storage medium having instructions encoded thereon that, when executed by a processor of a computer system, cause the computer system to perform steps comprising:
receiving first raw recipe data that describes a recipe that uses a set of ingredients;
extracting, from the first raw recipe data, ingredient descriptors for the set of ingredients, wherein an ingredient descriptor of the ingredient descriptors comprises a range of quantities associated with an ingredient of the set of ingredients;
generating, by a recipe management module of an online system, parsed ingredient data by prompting a large language model of an artificial intelligence system using the ingredient descriptors, such that the parsed ingredient data for each ingredient of the set of ingredients includes an ingredient name, an ingredient quantity, and a unit of measure of the ingredient quantity, wherein generating the parsed ingredient data by prompting the large language model comprises:
generating, by a first neural network model of the artificial intelligence system, a prompt to provide to the large language model, wherein the prompt instructs the large language model to select a value from the range of quantities,
wherein the parsed ingredient data for the ingredient descriptor specifies a single quantity of the ingredient, and the single quantity corresponds to the value of the range of quantities;
mapping, for each ingredient of the parsed ingredient data, the ingredient name to a corresponding ingredient identifier that is part of an ingredient database, and each ingredient identifier in the ingredient database is associated with a corresponding item that is available for sale at one or more sources;
generating a first linked recipe associated with the first raw recipe data;
generating a second linked recipe associated with second raw recipe data;
in response to accessing, by a user client device, a graphical user interface (GUI) associated with the online system:
providing, by a second neural network model of the artificial intelligence system, a search query prompt to the large language model, wherein the search query prompt requests an order for presenting the first linked recipe and the second linked recipe in different positions of a scrollable recipe carousel to be displayed on the GUI;
computing, by the large language model, (i) a first embedding score associated with a first item embedding and a third item embedding and (ii) a second embedding score associated with a second item embedding and the third item embedding;
selecting, by the large language model, the order of the first linked recipe and the second linked recipe for presentation based on the first embedding score and the second embedding score; and
causing the user client device to display the GUI by rendering the first linked recipe and second linked recipe in respective positions of the scrollable recipe carousel, the respective positions corresponding to the selected order.
11 . The computer program product of claim 10 , further comprising encoded instructions that when executed cause the computer system to perform steps comprising:
tuning the large language model using one or more examples, each example including raw recipe data and a corresponding set of parsed ingredient data.
12 . The computer program product of claim 10 , further comprising encoded instructions that when executed cause the computer system to perform steps comprising:
generating additional training examples using portions of the linked recipe and complaint data; and
tuning the large language model based in part on the additional training examples.
13 . The computer program product of claim 10 , wherein a first ingredient descriptor of the recipe does not specify a quantity, and generating parsed ingredient data by prompting a large language model using the ingredient descriptors comprises:
generating, by the first neural network model, a prompt to provide to the large language model, the prompt instructing the large language model to select, for an ingredient descriptor that does not specify a quantity, a quantity of one,
wherein the parsed ingredient data for the first ingredient descriptor specifies a quantity of one for the first ingredient descriptor.
14 . The computer program product of claim 10 , wherein the encoded instructions to map, for each ingredient of the parsed ingredient data, the name of the ingredient to a corresponding ingredient identifier that is part of the ingredient database, further comprises instructions that when executed cause the computer system to perform steps comprising:
for a name of a first ingredient of the set of ingredients,
mapping the name of the first ingredient to a corresponding set of one or more versions of the name of the first ingredient that are mapped to a first ingredient identifier in the ingredient database, and
mapping the name of the first ingredient to the first ingredient identifier.
15 . The computer program product of claim 14 , wherein the corresponding set of one or more versions of the name of the first ingredient are synonyms for the name of the first ingredient.
16 . The computer program product of claim 10 , wherein a first ingredient of the recipe is a compound ingredient that is composed of a first separate ingredient and a second separate ingredient, and the encoded instructions to extract, from the raw recipe data, ingredient descriptors for the set of ingredients, further comprises instructions that when executed cause the computer system to perform steps comprising:
generating a prompt to provide to the large language model, the prompt instructing the large language model to:
identify whether any ingredient of the set of ingredients is a compound ingredient that is composed of multiple ingredients,
separate any identified compound ingredient into separate ingredients such that the set of ingredients includes the multiple ingredients, and
extract, from the raw recipe data, ingredient descriptors for the set of ingredients,
wherein the ingredient descriptors include an ingredient descriptor for the first separate ingredient and an ingredient descriptor for the second separate ingredient.
17 . The computer program product of claim 10 , wherein the recipe includes a sub-recipe that is composed of a first ingredient and a second ingredient, and the encoded instructions to extract, from the raw recipe data, ingredient descriptors for the set of ingredients, further comprises instructions that when executed cause the computer system to perform steps comprising:
generating a prompt to provide to the large language model, the prompt instructing the large language model to:
identify whether the recipe includes a sub-recipe,
identify any ingredients that are associated with the sub-recipe, such that the set of ingredients includes ingredients for the recipe and ingredients for the sub-recipe, and
extract, from the raw recipe data, ingredient descriptors for the set of ingredients,
wherein the ingredient descriptors include an ingredient descriptor for the first ingredient and an ingredient descriptor for the second ingredient.
18 . A computer system comprising:
a processor; and
a non-transitory computer readable storage medium having instructions encoded thereon that, when executed by the processor, cause the computer system to perform steps comprising:
receiving first raw recipe data that describes a recipe that uses a set of ingredients;
extracting, from the first raw recipe data, ingredient descriptors for the set of ingredients, wherein an ingredient descriptor of the ingredient descriptors comprises a range of quantities associated with an ingredient of the set of ingredients;
generating, by a recipe management module of an online system, parsed ingredient data by prompting a large language model of an artificial intelligence system using the ingredient descriptors, such that the parsed ingredient data for each ingredient of the set of ingredients includes an ingredient name, an ingredient quantity, and a unit of measure of the ingredient quantity, wherein generating the parsed ingredient data by prompting the large language model comprises:
generating, by a first neural network model of the artificial intelligence system, a prompt to provide to the large language model, wherein the prompt instructs the large language model to select a value from the range of quantities,
wherein the parsed ingredient data for the ingredient descriptor specifies a single quantity of the ingredient, and the single quantity corresponds to the value of the range of quantities;
mapping, for each ingredient of the parsed ingredient data, the ingredient name to a corresponding ingredient identifier that is part of an ingredient database, and each ingredient identifier in the ingredient database is associated with a corresponding item that is available for sale at one or more sources;
generating a first linked recipe associated with the first raw recipe data;
generating a second linked recipe associated with second raw recipe data;
in response to accessing, by a user client device, a graphical user interface (GUI) associated with the online system:
providing, by a second neural network model of the artificial intelligence system, a search query prompt to the large language model, wherein the search query prompt requests an order for presenting the first linked recipe and the second linked recipe in different positions of a scrollable recipe carousel to be displayed on the GUI;
computing, by the large language model, (i) a first embedding score associated with a first item embedding and a third item embedding and (ii) a second embedding score associated with a second item embedding and the third item embedding;
selecting, by the large language model, the order of the first linked recipe and the second linked recipe for presentation based on the first embedding score and the second embedding score; and
causing the user client device to display the GUI by rendering the first linked recipe and second linked recipe in respective positions of the scrollable recipe carousel, the respective positions corresponding to the selected order.