AI Detecting Dangerous Foods: How a New Approach is Making Food Safer

Every year, food recalls and contamination incidents affect millions of people. What if artificial intelligence (AI) could help us catch these hazards before they reach our plates?

That’s exactly what we (a team of researchers from Politecnico di Torino and JAKALA) set out to improve. In our latest work, presented at the SemEval 2025 Food Hazard Detection challenge, we presented a novel approach on how to automatically detect potential risks in food-related incident reports using AI and Natural Language Processing (NLP).

The Challenge: Food Safety in a Sea of Text

Government agencies and safety bodies around the world publish thousands of food recall reports each year. These reports vary widely in style and format, often containing complex language and unstructured text. Extracting useful insights from this information manually is time-consuming and error-prone.

The challenge was to automatically analyze these reports and correctly label:

  • The type of food (e.g., “milk,” “frozen pizza,” “shellfish”)

  • The type of hazard (e.g., “Listeria,” “foreign objects,” “undeclared allergens”)

This isn’t as easy as it sounds. Some foods have many subtypes, and hazards can relate differently to each one. For example, detecting bacteria in raw chicken is more urgent than detecting it in canned food. Existing AI systems often mix these up or miss key connections.

The Challenge: Food Safety in a Sea of Text

To solve this, the team introduced a three-part solution. This approach involves training one classification model for each sub-task (ST1 and ST2), with two classification heads: one for classifying the product labels, and one for classifying the food hazard. Then, we constrain the probabilities of the ST2 detailed labels on the probabilities of the ST1 more generic categories.

Here’s a breakdown of the methodology:

Overview of the adopted methodology.
Multi-Head Classification

Instead of training one AI model to predict both food types and hazards in a single go, they used a model with two heads. One head specialized in identifying food types, the other focused on hazards. This separation helped the model become more accurate and specialized.

Sequential Classification

Think of this like narrowing down your search. First, the system predicts broad categories (e.g., “dairy” or “meat”). Then, based on those, it refines its prediction to more specific types (e.g., “soft cheese” or “minced beef”). This helps the model avoid guessing unrelated labels.

Text Normalization Using AI

 Food reports vary a lot in how they’re written. The team used a large language model (LLM) to extract structured summaries from the raw reports. This cleaned-up version of the text made it much easier for the model to work with the information.

What Did We Find?

Their approach significantly improved performance:

  • It boosted classification accuracy by 30–40% compared to a basic model.

  • The proposed model ranked among the top 15 in the international SemEval-2025 competition for food hazard detection.

  • Separating the tasks into multiple heads and using structured summaries helped avoid confusion and improved prediction consistency.

Why This Matters

Food safety isn’t just a technical issue—it’s a public health priority. With AI-powered tools that can read and understand food recall reports better than ever, regulators and companies can act faster to prevent dangerous products from reaching consumers.

While this system is still being refined, it’s a big step toward real-world applications like:

  • Automatic alert systems for food recalls

  • Early detection of emerging foodborne disease trends

  • Faster response in multinational food supply chains

Moving Forward

The team is now focused on enhancing the model by incorporating more external knowledge like scientific studies or expert taxonomies. Integrating this external information aims to make the model more robust and adaptable to various food safety situations. Additionally, they plan to investigate alternative methods for structuring the classification process, with the goal of finding the best balance between clarity and effectiveness. This project demonstrates how combining AI with organized approaches and real-world data can significantly improve food safety.

Article originally posted on Medium.

Send us a message

Get our latest news

Subscribe
to our newsletter.