Comparative study of loss functions for fine-tuning retrievers on food nutrition and food exchange domain
Abstract
Large Language Models (LLMs) increasingly rely on Retrieval-Augmented Generation (RAG) to enhance factual reliability by grounding responses in external evidence, and the effectiveness of such systems depends critically on the retriever, whose performance is strongly shaped by the loss function used during fine-tuning. Although numerous contrastive-based losses have been introduced, their comparative behavior in domain-specific contexts particularly in structured health-related domains—remains underexplored. This study examines how six loss functions—Contrastive Loss, Multiple Negatives Ranking Loss (MNRL), Triplet Loss, Hinge Loss, Circle Loss, and CROLoss—affect retrieval outcomes within a RAG framework for Thai nutrition and food-exchange information. A unified domain-specific corpus was constructed by integrating official nutrient-composition data with clinically validated food-exchange rules, and a Thai language model was fine-tuned under controlled experimental settings for each loss formulation. The results show clear distinctions in retrieval coverage and ranking quality, indicating that each objective shapes the embedding space differently and produces distinct retrieval behaviors. These findings highlight the importance of selecting an appropriate loss function for health-critical retrieval applications and offer practical insights for developing reliable RAG systems in domains requiring high factual precision.