Enhancing LLMs’ Mathematical Reasoning through Retrieval-Augmente Generation in the Casting Domain: Improving LLM’s mathematical reasoning capabilities using RAG technique integration with formula-based KG in Neo4j, vector-based embeddings in FAISS, or both external resources within the casting domain
2025 (English) Independent thesis Advanced level (degree of Master (Two Years)), 20 credits / 30 HE credits
Student thesis
Abstract [en]
Large Language Models (LLMs) have demonstrated impressive capabilities in natural language understanding and basic mathematical problem-solving. However, they often struggle with math- ematical problems that demand multi-step, logic-intensive reasoning capabilities. This challenge is further amplified by their lack of domain knowledge in specific fields such as casting, where the correct utilization of formulas to solve mathematical problems depends heavily on the inte- gration of formula-related knowledge. The Retrieval-Augmented Generation (RAG) technique shows promising potential in enriching LLMs with domain-specific knowledge by integrating ex- ternal domain resources to enhance their performance in downstream mathematical reasoning tasks within the casting domain. Therefore, the objective of this study is to investigate how RAG systems leverage structured knowledge in the form of a formula-based knowledge graph (KG) stored in Neo4j, semi-structured knowledge in the form of vector-based embeddings stored in FAISS, or a hybrid of both, to enhance the mathematical reasoning capabilities of LLMs within the casting domain. To achieve this, a pipeline is proposed that integrates a formula-based KG, vector-based embeddings, or both external resources with the RAG technique to enhance LLM performance in mathematical reasoning tasks. The formula-based KG is constructed using a chaining prompt embedded with a mathematical formula ontology for information extraction task, while the vector-based embeddings are generated by a distilled transformer model and in- dexed in FAISS. The pipeline is thoroughly evaluated using metrics such as F1-score, Precision, and Recall to assess the coverage of formula knowledge in the KG and the quality of entity extraction by the LLM. For retrieval efficacy, MRR, Recall@K, and nDCG@K are applied to measure vector-based retrieval; Recall is employed to measure KG-based retrieval, while answer accuracy is used for evaluating the end-to-end mathematical reasoning performance. Results show that the vector-based RAG system achieved the highest overall accuracy (70%), followed by the hybrid system (50%) and the KG-based RAG system (30%). The results indicate that all three systems are promising in improving LLMs’ mathematical reasoning capacities compared to the baseline model. The vector-based retrieval outperforms both hybrid and KG-based retrieval in improving mathematical reasoning capabilities within the casting domain. These findings highlight the effectiveness of vector-based retrieval in enhancing LLMs’ mathematical reasoning, suggesting that vector-based retrieval could be a key factor in addressing domain-specific math- ematical reasoning challenges. This work contributes to the field by proposing a pipeline for improving LLM mathematical reasoning performance using RAG techniques within the casting domain. The pipeline can be adapted to other domains involving formula-based problem solv- ing. This study also constructs a novel ontology schema for mathematical formulas and builds a formula-based KG for the casting domain.
Place, publisher, year, edition, pages 2025. , p. 47
Keywords [en]
Large Language Models, Retrieval-augmented Generation, Knowledge Graph, Cast- ing Domain, Embeddings, Mathematical Reasoning
National Category
Engineering and Technology
Identifiers URN: urn:nbn:se:hj:diva-67880 OAI: oai:DiVA.org:hj-67880 DiVA, id: diva2:1961516
Subject / course JTH, Computer Engineering
Supervisors
Examiners
2025-06-132025-05-272025-10-13 Bibliographically approved