Skip to content
Go back

Seeking Collaborators: Cooking with Graphs (Fine Tuning an LLM + Graph Semantic Analysis)

Published:  at  07:00 AM

[!caution] I’m not interested in working on this anymore, but I’m leaving it up here in case you are!

I’m looking to get some experience building meaningful and useful applications with large language models, including:

The project I have in mind is a “What can I cook for dinner?” type service. It is an example of a structured decision-making and optimization application seeded with a relatively small amount of unstructured data.

Until recently, I think this type of thing was impossible to build, or at least impossible to build as just an individual or two.

Translating Recipes to Cooklang

We’ll start by translating a bunch (maybe 5-20k?) recipes into Cooklang using LLMs. I’ve already determined that GPT-4 can do this basically perfectly with few-shot prompting, but costs almost 10 cents per recipe translation (approaching more than $1k for running this on Wikibook’s Recipes + NYT’s recipe corpus).

I’ve also found that GPT-3.5 Turbo can’t really get this right. It can identify the ingredients, but I can’t get it to:

I think this task difficulty level (in between 3.5 and 4’s few-shot prompting capabilities) makes it ideal for a fine-tuning experiment (why would you want to fine-tune if you could just use the very cheap 3.5) and we can use GPT-4 to generate a few hundred examples.

I think it’s definitely likely that there may not be an open source base model sophisticated enough to be fine-tuned for this task (or one that can be fine-tuned with how much I’m willing to spend on GPU’s for this project). Even if that’s the case, I would consider that a successful outcome, since it would help me and others understand how much of a moat the big LLM players actually have. In that case, I’d probably just pay to do it with GPT-4, but have learned a bit more about the economics of GPT-4 vs fine-tuning.

Constructing the Meal

I’d like a user to be able to let this service know:

And for this service to pop out a meal of 3-4 dishes that:

For this, I want to test out a database I’ve read about called Cozo. It’s multi-model, with vector similarity search and a “relational-graph” model that you can query with Datalog.

Cozo has a blog post describing how you can construct layers of knowledge using their model. For this project, I think we have:

Once those exist, I believe we can meal plan by doing a Graph search over recipes, and can experiment with weighting the embedding vector distance (for vibe match), ingredient distance from current inventory, and other factors until it produces good meals. We can also experiment with different ways to approach “going well together”, such as balancing food groups, different cultural heuristics, or vector approaches.

Deduplicating Ingredients

In order to get all of this to work, we need to deduplicate ingredients so that the ingredient layer only includes things you purchase at the grocery store and gets the interchangeability of ingredients correct.

For example, in looking at how recipes describe ingredients and how LLMs translate that to Cooklang, there is a wide variety of ways that ingredients get described. I’ve seen standard, stock chicken eggs described as “standard eggs”, “chicken eggs”, “large brown organic chicken eggs”, or just plain “eggs”. Sometimes cheese is described as “shredded cheddar”, “a block of cheddar”, or just “cheddar”.

In order for our meal search queries to work, these duplicates need to be resolved. I believe GPT-3.5 can do this, or an open source LLM can. Vector embedding search alone may be able to, but I’m not sure it will correctly infer that “organic brown eggs” is actually the same as “chicken egg”, and not “organic quail egg” or “organic brown duck egg”. This seems to be the type of “common sense” that LLMs do well, and so we could potentially present some raw ingredients from an embedding similarity search for an LLM to choose from.

After It’s Done

Once it’s done I’d like to:

Please let me know if this interests you!



Previous Post
Previous Research Question
Next Post
Seeking Collaborators: An Ahead of Time Database