openfoodfacts / openfoodfacts-ai

This is a tracking repo for all our AI projects. 🍕 🤖🍼
226 stars 53 forks source link

Use LLMs to parse ingredients lists #292

Open teolemon opened 1 year ago

teolemon commented 1 year ago

image image

Originally posted by @teolemon in https://github.com/openfoodfacts/openfoodfacts-ai/discussions/272#discussioncomment-5123846

Part of

raphael0202 commented 1 year ago

Successful test on structured parsing with romanian language:

Parse the ingredient lists in JSON format.
[INGREDIENTS] Potato, vegetable oils (corn, sunflower, rapeseed in varying proportions), seasoning with chicken with spices flavour [maltodextrin, salt, flavourings (contain onion powder, garlic powder, chicken meat powder 0,03%), sugar, spices (paprika powder 0,3%, cayenne pepper powder 0,06%, black pepper), potassium chloride, herbs (parsley 0,06%, thyme 0,06%, basil 0,03%), acid (citric acid), colour (paprika extract)]
[RESULT] [{"text":"Potato"},{"ingredients":[{"text":"corn"},{"text":"sunflower"},{"text":"rapeseed in varying proportions"}],"text":"vegetable oils"},{"ingredients":[{"text":"maltodextrin"},{"text":"salt"},{"ingredients":[{"text":"contain onion"},{"text":"garlic powder"},{"text":"chicken meat"}],"text":"flavourings"},{"text":"sugar"},{"ingredients":[{"percent":0.3,"text":"paprika powder"},{"percent":0.06,"processing":"en:powder","text":"cayenne pepper"},{"text":"black pepper"}],"text":"spices"},{"text":"potassium chloride"},{"ingredients":[{"percent":0.06,"text":"parsley"},{"percent":0.06,"text":"thyme"},{"percent":0.03,"text":"basil"}],"text":"herbs"},{"ingredients":[{"text":"citric acid"}],"text":"acid"},{"ingredients":[{"text":"paprika extract"}],"text":"colour"}],"text":"seasoning with chicken with spices flavour"}]

[INGREDIENTS] Cartofi, uleiuri vegetale (porumb, floarea soarelui, rapiță, în proporţii variabile), mix de ingrediente cu gust de pui cu mirodenii [maltodextrină, sare, arome (conțin ceapă pudră, usturoi pudră, carne de pui pudră 0,03%), zahăr, condimente (paprica pudră 0,3%), ardei cayenne pudră 0,06%, piper negru), clorură de potasiu, plante aromatice (pătrunjel 0,06%, cimbru 0,06%, busuioc 0,03%), acidifiant (citric acid), colorant (extract de ardei roşu)].
[RESULTS]

ChatGPT (3.5) result:

[
    {
        "text": "Cartofi"
    },
    {
        "ingredients": [
            {
                "text": "porumb"
            },
            {
                "text": "floarea soarelui"
            },
            {
                "text": "rapiță"
            },
            {
                "text": "în proporţii variabile"
            }
        ],
        "text": "uleiuri vegetale"
    },
    {
        "ingredients": [
            {
                "text": "maltodextrină"
            },
            {
                "text": "sare"
            },
            {
                "ingredients": [
                    {
                        "text": "conțin ceapă pudră"
                    },
                    {
                        "text": "usturoi pudră"
                    },
                    {
                        "percent": 0.03,
                        "text": "carne de pui pudră"
                    }
                ],
                "text": "arome"
            },
            {
                "text": "zahăr"
            },
            {
                "ingredients": [
                    {
                        "percent": 0.3,
                        "text": "paprica pudră"
                    },
                    {
                        "percent": 0.06,
                        "processing": "en:powder",
                        "text": "ardei cayenne"
                    },
                    {
                        "text": "piper negru"
                    }
                ],
                "text": "condimente"
            },
            {
                "text": "clorură de potasiu"
            },
            {
                "ingredients": [
                    {
                        "percent": 0.06,
                        "text": "pătrunjel"
                    },
                    {
                        "percent": 0.06,
                        "text": "cimbru"
                    },
                    {
                        "percent": 0.03,
                        "text": "busuioc"
                    }
                ],
                "text": "plante aromatice"
            },
            {
                "ingredients": [
                    {
                        "text": "citric acid"
                    }
                ],
                "text": "acidifiant"
            },
            {
                "ingredients": [
                    {
                        "text": "extract de ardei roşu"
                    }
                ],
                "text": "colorant"
            }
        ],
        "text": "mix de ingrediente cu gust de pui cu mirodenii"
    }
]