Abstract:
In response to the high complexity of unstructured text data management and low efficiency of traditional retrieval methods in the railway industry, this paper designed and implemented a question-and-answer system for the railway industry knowledge base based on Retrieval-Augmented Generation (RAG). The paper integrated LangChain and Flask framework technologies to build the system’s overall architecture. It cleaned the text data according to predefined rules, and constructed a railway industry-specific vector knowledge base using a dynamic contextual text segmentation algorithm. Compared with traditional text segmentation algorithms, this proposed algorithm preserves more contextual semantic information. The paper integrated the Milvus vector database and the BGE M3 Embedding model to achieve hybrid vector-keyword retrieval capability, and then implemented an efficient and accurate text retrieval function through metadata filtering. The system implements efficient knowledge retrieval and intelligent interaction by deploying a domestically developed open-source Large Language Model (LLM) locally and introducing prompt engineering, thus facilitating the digital and intelligent transformation of the railway industry.