GPT-4 is a passable personal nutritionist
TL;DR: You can use GPT-4 as your own personal nutritionist. It does a pretty good job!
It started with my public food journal
I started a renewed focus on my health a few weeks ago, and one of my commitments to myself was to keep a public food journal, logging everything I eat. You can find it on Beeminder. It’s not exciting reading, and I don’t really expect that many will take more than a brief look, but making it public helps me create accountability for myself.
Each meal is usually just quite a short description, but I do try to include all ingredients to the best of my knowledge, and have amounts as specific as I can. A typical entry might be something like yesterday’s dinner, which was:
Dinner: About 230g pan-fried salmon, 1tsp allioli, half small tomato, small green salad, 2 strawberries, 3tsp roasted mixed seeds, 2tsp feta cheese cubes in oil, about two small potatoes worth of cold potato salad with olive oil, arugula and red onion.
How GPT-4 helped me estimate macros
A few days into this, I started wondering if I could get a rough calorie estimate from ChatGPT, and it turns out that GPT-4 is actually a passable nutritionist, and one that I have at my personal disposal, no less.
GPT-3.5 had more trouble understanding my short descriptions, and was less accurate in my tests, so I wouldn’t recommend using it for this task, although it can provide helpful insights.
Let’s take the dinner I mentioned above as an example. I prefixed the description of dinner with a simple prompt to GPT-4:
Can you help me estimate the kcal and macros in a meal? I’ll show you the foods and maybe you can create a table for the meal with a breakdown of the food items, amount of each item, and amount of kcal, protein, fat and carbs in each item?
Dinner: …
and GPT-4 comes back with something like:
Here’s the nutritional information for your dinner:
Food Item Amount kcal Protein (g) Fat (g) Carbs (g) Pan-fried salmon 230g 529 57.5 33 0 Allioli 1 tsp 40 0 4.5 0 Half small tomato 1/2 11 0.5 0 2.5 … … … … … … Total 1018 68.7 63.5 50.5 This table shows the breakdown of the kcal, protein, fat, and carbs for your dinner. Please note that these values are approximate and may vary depending on specific brands and preparation methods.
Is it accurate enough?
It was surprising to me how well this worked. Maybe it shouldn’t have been, since GPT-4’s training set includes, for example, Reddit, which has multiple subreddits devoted to estimating food macros.
If you try the same prompt and meal in several different chat sessions, you will find that there is some variation in the results. You will also find that sometimes, it over- or underestimates significantly, although the more egregious cases of that have happened when I tried to do the same with GPT-3.5. GPT-4 is usually as close to accurate as I could expect a human non-expert or semi-expert to be, based on the level of specificity that I give about my meals in my food journal. It might sometimes be 20-30% off in either direction, but I feel like this evens out with time and is good enough to be a really useful tool to get estimated macros with almost no additional effort on top of journaling what I eat.
Even more useful: Long-running chats
As I progressed in using GPT-4 this way, instead of starting a new chat per meal, I progressed to keeping one long-running chat.
This has several benefits. I can ask GPT-4:
Can you help me estimate total kcal and macros for the day? Today’s meals started with the last lunch I told you about. Please show a summary table with the totals for each meal, the totals for the day, and then a breakdown of total macros for the day and percent of calories from each macro.
And of course, it goes ahead and does just that. It’s clearly an area that GPT-4 has been given some guardrails around, as it tends to append the warning you saw above to almost all responses, “these values are approximate and may vary yada yada”.
Another benefit is, if I notice that it’s not using the right macros for a given food, I can say something like:
That low-carb slice of bread I had, it’s actually about 130 kcal, 13g of protein.
It will update the table it gave me for the meal, and it will also remember what I’ve told it, so the next time I say I had a slice of low-carb bread, it will assume that it’s the same brand and use the macros information that I gave it.
Let’s say I’ve logged “low carb slice of toast, with 1tsp butter” a couple of times, and then I log simply “low carb toast with butter”. It will realize to use my typical 1tsp butter estimate.
The last thing I’ve started doing is to tell it today’s date when I ask it about the first meal of the day. Then later, in a long-running chat, I could prompt it with something like:
Can you estimate the calorie deficit I may be creating for the last few days? My base metabolic rate is about 2680 kcal considering normal daily activity without exercise, and I actively exercised for 480 kcal today, 350 kcal yesterday, but had a break the day before.
Given that kind of prompt, as long as youv’e been clear on when a new day is starting, and what day it is today, it will happily calculate your estimated calorie deficit for you.
In summary: Same work, more benefit
I started logging my food intake to a reasonable level of specificity, but short enough that it’s less than a one-minute task at the end of each meal. The benefit I initially intended to get was simply to provide accountability and motivation for myself by doing so publicly.
With GPT-4, for almost no additional work, I now have a reasonably accurate personal nutritionist telling me the macros I’ve consumed, able to estimate whether I should expect to be losing weight or not, and even able to advise me on whether my macros profile for the last few days fits with my overall intended diet (which for me these days is, liberally low-carb and creating a 500-1000 kcal deficit daily).
I think this is part of the magic of a really capable LLM like GPT-4. Given the same amount of human work, I’m getting multiple times more value.