V erba N ex AI at S em E val-2025 Task 9: Advances and Challenges in the Automatic Detection of Food Hazards (2025)

Abstract: Ensuring food safety requires effective detection of potential hazards in food products. This paper presents the participation of VerbaNexAI in the SemEval-2025 Task 9 challenge, which focuses on the automatic identification and classification of food hazards from descriptive texts. Our approach employs a machine learning-based strategy, leveraging a Random Forest classifier combined with TF-IDF vectorization and character n-grams (n=2-5) to enhance linguistic pattern recognition. The system achieved competitive performance in hazard and product classification tasks, obtaining notable macro and micro F1 scores. However, we identified challenges such as handling underrepresented categories and improving generalization in multilingual contexts. Our findings highlight the need to refine preprocessing techniques and model architectures to enhance food hazard detection. We made the source code publicly available to encourage reproducibility and collaboration in future research.

## introduction detecting food hazards is an essential challenge to ensure the safety and quality of food products globally @xcite . following this line, the task proposed in semeval-2025 task 9: the food hazard detection challenge focuses on identifying and classifying different types of hazards associated with food products through the analysis of descriptive texts. this task is of great relevance due to the growing need to monitor and ensure food safety and the need for automated systems that can process large volumes of data, which facilitates the early detection of potential hazards in food products globally @xcite . the ability to accurately and efficiently detect these hazards contributes directly to preventing public health incidents and improving food safety standards (who, n.d.; usda, u.s. department of agriculture, 2024). our system employs a strategy based on machine learning and supervised classification using a random forest classifier combined with a tf-idf vectorization to represent textual features. we implemented an n-gram character analysis approach (@xmath0, hazard and product. this method facilitated the extraction of contextual information. it improved the model's ability to generalize from training data, thus optimizing prediction accuracy on new unlabeled datasets. by participating in this task, our system a notable performance compared to other teams, obtaining outstanding micro and macro f1 scores in hazard and product categories and hazard and product detection sub-tasks. however, we identified specific challenges, such as the difficulty in handling underrepresented categories and the need to improve the model's generalization in broader contexts. these findings underscore the importance of refining preprocessing techniques and model architecture to address the inherent complexity of food hazard detection effectively. participation in this task revealed promising results, positioning our system competitively against other participating teams. quantitatively, our model obtained outstanding macro and micro f1 scores in the hazard and product category classification sub-tasks, reflecting high accuracy and robustness. however, significant challenges were identified, such as difficulty in handling linguistic ambiguities, difficulty in handling underrepresented categories, and variability in textual descriptions, suggesting areas of improvement for future developments. these findings underscore the importance of refining preprocessing techniques and model architecture to address the complexity inherent in food hazard detection. we published the source code used for developing and training our model to encourage reproducibility and collaboration in future work related to food hazard detection. 1 it is available through the following link foot_0 . ## background semeval 2025 task 9: the food hazard detection challenge focuses on automatically identifying and classifying food hazards from textual descriptions of food products. the input type for this task consists of descriptive texts detailing food safetyrelated incidents, such as reports of contaminants in food products or warnings about unsafe food handling practices see table1. the datasets used in this task include mainly training and validation divisions, covering various textual genres related to food incidents. the genre of the data encompasses food safety incident reports from multiple sources, ensuring a varied representation of contexts and scenarios. in terms of size, the training set contains approximately 5,082 samples. in contrast, the test set includes about 5,984 examples, allowing for robust training and accurate model performance evaluation. the competition has two sub-tasks focused on detecting different levels of granularity in the hazard and product categories. we participated in sub-task st1, which focused on text classification for food hazard prediction, predicting the type of hazard and product, and sub-task st2, which focused on food hazard and product vector detection, predicting the exact hazard and product. these approaches contribute to strengthening safety in the food supply chain, reducing the incidence of hazards, and protecting consumer health. in addition, it is possible to design and implement more targeted and effective prevention strategies by having a precise classification and accurate identification of affected products. also, by clearly identifying the risks and products involved, companies and regulators can allocate resources more efficiently to address the most significant risk areas. in developing our system, we have employed supervised classification methods that have demonstrated efficacy in similar natural language processing tasks. this approach aligns with previous studies showing the effectiveness of random forest-based methods for text classification tasks @xcite @xcite providing a solid foundation for our methodology. furthermore, using tf-idf vectorization techniques combined with random forest classifiers is not novel. research such as @xcite highlighted the effectiveness of these methods in text classification. however, in our contribution, we have implemented a vectorization strategy based on n-grams of characters in the tf-idf vectorizer, which improves the capture of complex and contextual linguistic patterns present in food incident descriptions. furthermore, integrating preprocessing techniques and hyperparameter optimization for the random forest classifier represents innovations that enhance the accuracy and robustness of the model in different environments. ## system overview this section details how we integrated advanced natural language processing techniques and robust machine learning models to transform and analyze the information, allowing the accurate identification of incidents and addressing inherent challenges such as semantic ambiguity. it explains, step by step, the key components from vectorization and the application of the randomforestclassifier to the modular organization of the pipeline, providing a clear and complete overview of the process see figure1. ## results the official results of our submission for the st1 and st2 sub-tasks are shown in we conducted several ablation tests and comparisons of different design decisions to optimize system performance. the ablation tests included varying the vectorizer parameters and using different classifiers. we observed that using longer n-grams improved the capture of specific patterns in the incident titles, albeit at the cost of an increase in the dimensionality of the feature space. also, the random forest classifier proved robust regarding data variability, providing an appropriate balance between accuracy and recall. error analysis revealed that our system presented difficulties in classifying hazard categories and products with semantic similarities or specific technical terms not sufficiently represented in the training set. for example, incidents related to food allergies were frequently confused with bacterial contaminations due to the similarity in terminology used. in addition, we observed that product category predictions showed higher variability, possibly attributed to the diversity and specificity of food products mentioned in the data. to address these errors, we propose future incorporation of more advanced natural language processing techniques, such as contextualized embeddings, which could better capture the semantic subtleties of the terms used in the incidents. although our system did not achieve a top ranking in the competition, the results provide a solid foundation for future improvements. quantitative and error analysis has identified key areas where significant improvements can be implemented, such as optimizing text representation and exploring more sophisticated classifiers. these strategies and further enrichment of the training data could boost system performance in future iterations of the semeval 2025 task 9 challenge. ## limitations of the approach the proposed approach is subject to several limitations that could be addressed in future versions to enhance its performance. a primary challenge is the management of under-represented categories, which is prevalent in unbalanced classification problems. despite adjustments made to parameters such as @xmath1, under-represented classes still exert an influence on the model's accuracy. furthermore, the presence of semantic ambiguity in texts, where terms may possess multiple meanings depending on the context, poses an additional challenge. while the utilization of character n-grams assists in capturing contextual patterns, the disambiguation of terms in complex texts remains an area for enhancement. linguistic variability, arising from synonyms, typos and grammatical variations, also exerts a negative influence on model performance, despite pre-processing endeavors. ## conclusion our system implemented a strategy based on tf-idf vectorization and random forest classifier to address the food hazard detection and product classification tasks in semeval-2025 task 9. the performed tests and error analysis underline the importance of optimizing the text representation and exploring more advanced approaches, such as contextualized embeddings, to improve the classification accuracy of poorly represented categories. in future work, we plan to expand the training dataset, integrate architectures based on deep neural networks, and evaluate new natural language processing methods that effectively address the complexity of textual data. these efforts will lay the foundation for more robust and generalizable systems in the food safety domain.