A traditional Chinese medicine ancient book knowledge question and answer system and method based on a multi-agent framework
Patent Information
- Application Number
- CN202611015382.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-08
- Publication Date
- 2026-10-30
AI Technical Summary
[0005]为解决上述问题,本发明的主要目的在于提供一种基于多智能体框架的中医古籍知识问答系统及方法,该系统通过自适应分层版面解析、大模型OCR拆解式识别、辨证推理链抽取、三路径混合检索增强生成,旨在解决中医古籍处理中文本识别精度低、知识提取自动化程度低、智能问答语义理解差以及处理流程不灵活等问题,实现中医古籍从图像输入到可溯源智能问答的端到端全流程自动化处理
(1)文本识别精度高:通过文本区域检测与识别校正智能体的协同,专门针对中医古籍的竖排、繁体、异体字、复杂版面等特征进行优化,采用大模型 OCR 拆解架构与分层版面解析,显著提升了数字化文本准确性,为后续处理奠定了可靠基础。
Smart Images

Figure CN123012101A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of medical ancient book processing technology, and specifically relates to a question-and-answer system and method for traditional Chinese medicine ancient books based on a multi-agent framework. Background Technology
[0002] Ancient Chinese medical texts are an important part of the treasure trove of Chinese medicine, containing rich clinical experience, prescription theories, and pharmacological knowledge. However, due to their antiquity, these texts are mostly in traditional Chinese characters, handwritten or printed, and face challenges such as illegible characters, numerous variant characters, and complex layouts (e.g., interference from annotations, comments, and seals). Their digitization and intelligent processing are significantly more difficult than that of ordinary texts. Currently, the digitization and intelligent processing of ancient Chinese medical texts faces many challenges: Current OCR (Optical Character Recognition) technology is difficult to effectively handle the unique vertical layout, rare variant characters, and taboo characters of ancient books, and it cannot distinguish between the main text and interfering elements such as annotations and seals. Existing large-scale OCR models are mostly end-to-end overall recognition, which performs well in global layout analysis, but is inferior to traditional methods in recognizing dense and overlapping text in local areas. It cannot achieve the advantages of "global layout + local fine segmentation", resulting in a high error rate in the recognized text and requiring a lot of manual proofreading.
[0003] At the same time, TCM terminology is highly polysemous and the relationships between entities are complex. Existing technologies mostly extract simple triplets and fail to form a diagnostic reasoning chain that conforms to the clinical logic of TCM, making it difficult to support in-depth question answering and reasoning.
[0004] Furthermore, traditional digital systems for ancient Chinese medicine texts, relying on keyword-based retrieval, struggle to understand the deep semantics of users' natural language queries, resulting in low precision. Directly using a general large language model (LLM) for question answering presents the risk of generating "illusions" (i.e., fabricated or incorrect content) and providing answers that are untraceable. General search augmentation generation (RAG) methods often employ single-path retrieval, lacking the ability to uncover implicit dialectical relationships and failing to meet the rigor required for academic research and clinical reference in the field of traditional Chinese medicine. Simultaneously, existing digital systems for ancient Chinese medicine texts are mostly linear "scan-recognition-storage" pipelines, unable to flexibly adjust processing logic based on different user input needs, resulting in poor system flexibility and low resource utilization. Summary of the Invention
[0005] To address the aforementioned issues, the main objective of this invention is to provide a knowledge-based question-and-answer system and method for ancient Chinese medicine texts based on a multi-agent framework. This system utilizes adaptive hierarchical layout parsing, large-model OCR decompositional recognition, dialectical reasoning chain extraction, and three-path hybrid retrieval enhancement generation to solve problems such as low text recognition accuracy, low automation of knowledge extraction, poor semantic understanding of intelligent question-and-answer, and inflexible processing flow in the processing of ancient Chinese medicine texts. It aims to achieve end-to-end fully automated processing of ancient Chinese medicine texts from image input to traceable intelligent question-and-answer.
[0006] To achieve the above objectives, a first aspect of the present invention provides a question-and-answer system for ancient Chinese medical texts based on a multi-agent framework, comprising: The interface module is used to acquire data to be processed and present the processing results. The data to be processed includes at least one of the following: images of ancient Chinese medicine books and user query questions. The knowledge base module is used to store standardized text data of ancient Chinese medicine books, knowledge graphs in the field of Chinese medicine, and rule data of Chinese medicine experts. The core intelligent agent cluster includes a text region detection intelligent agent unit, an identification and correction intelligent agent unit, a knowledge graph construction intelligent agent unit, and a retrieval enhancement and question-answer generation intelligent agent unit; The text region detection intelligent agent unit is used to perform adaptive layered layout parsing on images of ancient Chinese medicine books and output layout structured data. The recognition and correction intelligent agent unit is used to perform text recognition on the image of the ancient Chinese medicine book based on the layout structured data, correct the recognition results, and output the corrected standardized text data to the knowledge base module. The knowledge graph construction intelligent agent unit is used to extract TCM entities, attributes and relationships between entities from the standardized text data of the knowledge base module according to the TCM syndrome differentiation logic, and to construct and update the TCM domain knowledge graph in the knowledge base module. The retrieval-enhanced question-answering intelligent agent unit is used to perform hybrid retrieval and generative question answering based on standardized text data in the knowledge base module and knowledge graphs in the field of traditional Chinese medicine. The scheduling and coordination module is connected to the interface module, the core intelligent agent cluster, and the knowledge base module, respectively. It includes identifying the type of the data to be processed and dynamically planning the execution path of the core intelligent agent cluster based on the identified type, so as to complete the end-to-end processing from ancient book image parsing and knowledge graph construction to intelligent question answer generation.
[0007] Furthermore, the text region detection intelligent agent unit includes: The layout parsing subunit is used to segment the input image of ancient Chinese medicine books, identify and locate the corresponding text regions according to the adaptive hierarchical layout of the main text, title, annotation, seal, and image, and output the layout structured data containing the coordinates and type labels of each region. The visualization annotation subunit is used to perform regional annotation on the original image of ancient Chinese medicine books based on the layout structured data and output the annotation results.
[0008] Furthermore, the recognition and correction intelligent agent unit adopts a large-model OCR decomposition recognition architecture, specifically including: The layout analysis subunit is used to locate global text regions in the image of ancient Chinese medicine books with reading order based on the layout structured data and using a large model (such as PP-DocLayoutV3). The text segmentation subunit is used to perform secondary fine-grained cell segmentation of text regions with different locations based on the global text region location and using a large model (such as PP-StructureV3). The visual encoding recognition subunit is used to recognize single characters and lines of text after finely segmented cell text. The text correction subunit is used to filter special characters, correct rare characters and variant characters in traditional Chinese medicine, and convert between simplified and traditional characters in the recognition results, and output the corrected standardized text data.
[0009] Furthermore, the knowledge graph construction agent unit includes: The dialectical reasoning chain extraction subunit is used to identify and extract dialectical reasoning chains that conform to the progressive logic of symptoms-syndromes-treatment principles-prescriptions from standardized text data using customized prompt word templates. The dialectical reasoning chain includes symptom entities, syndrome entities, treatment principle entities, and prescription entities, and each entity is connected by the dialectical logical relationship of "diagnostic reasoning", "treatment", and "prescription". The knowledge fusion alignment subunit is used to resolve common references and align knowledge from multiple dialectical reasoning chains extracted from standardized text data from different sources, thereby eliminating knowledge redundancy and conflict and fusion to form a network knowledge structure that spans diseases and prescriptions. The knowledge graph update subunit is used to construct and update the knowledge graph in the field of traditional Chinese medicine by integrating the fused network knowledge structure.
[0010] Furthermore, the retrieval-enhanced question-answering intelligent agent unit includes: The query intent parsing subunit is used to perform semantic parsing on the user's natural language query, extract the target entity, attribute intent and logical constraints, and generate a query intent vector and a set of constraints, which are used as a query perception representation. The hybrid retrieval subunit is used to perform a hybrid retrieval of the standardized text data and the TCM knowledge graph concurrently or in association within the knowledge base module, based on the query-aware representation, to obtain retrieval results from different data sources. The hybrid retrieval includes the following three execution paths: The first path performs dense vector retrieval in standardized text data to obtain semantically similar unstructured text fragments (that is, TCM literature or knowledge description texts that are semantically similar and topic-related to the input obtained by the first path performing dense vector retrieval in standardized text data; for example, inputting "liver qi stagnation" can retrieve the symptom description, treatment, drug contraindications, etc. corresponding to this syndrome). The second path performs entity matching and direct relation query in the TCM knowledge graph to obtain structured knowledge triples (the entity association information obtained by performing exact entity matching and direct relation query in the TCM knowledge graph, such as "fever and chills → belongs to → wind-cold exterior syndrome", "Ephedra Decoction → composition → ephedra", "Ephedra Decoction → composition → cinnamon twig"). The third path performs indirect relationship queries in the TCM knowledge graph with the target entity as the central node, expands outward to related entities, completes indirect dialectical relationships, and extracts and forms a complete implicit dialectical reasoning relationship chain (that is, the dialectical reasoning associations extracted by the third path in the TCM knowledge graph with the target entity as the central node, used to complete the indirect dialectical relationships between entities; the target entity is a basic concept unit in the TCM field, covering disease name, syndrome type, symptoms, Chinese medicine, prescription, processing, treatment method, constitution, etc. For example, inputting "fever and chills, no sweating, cough, thin white tongue coating" can match the corresponding symptoms, syndrome and disease name).
[0011] The knowledge fusion and reordering subunit is used to dynamically weight and fusion multi-source features of the retrieval results from different data sources obtained by the hybrid retrieval subunit based on the intent weights of the user's query perception representation, removing redundancy and forming a unified knowledge context. The dynamic weighted ranking allocates the proportion of results executed by each retrieval path of the hybrid retrieval subunit according to the proportion of intent weights expressed by the user's query perception representation. (For example, if the input is "What are the uses of ephedra?", which is a broad question, the first path will receive more results; if the input is "What are the components of ephedra decoction?", which requires a specific relationship, the second path will receive more results; if the input is "What diseases can ephedra treat?", which requires an indirect relationship, the third path will receive more results.) The multi-source features include the vector similarity score of the first path, the node centrality of the second path, and the path length of the third path.
[0012] The question-answering generation subunit is used to inject the knowledge context as constraint information into the large language model, guiding the generation of answers in the field of Traditional Chinese Medicine (TCM) that match the query. The various types of relevant TCM information are integrated into a context and input into the large language model along with the query question to generate a question answer. The answer is then labeled with its source in the knowledge base module, generating a question-answering result with source information.
[0013] Furthermore, the scheduling and coordination module performs state routing and task scheduling between image parsing, text correction, knowledge extraction, and question-and-answer generation stages according to the type of data to be processed, in order to adapt to the entire processing flow of ancient Chinese medicine books.
[0014] Furthermore, the scheduling and coordination module is specifically used for: When the data to be processed contains only images of ancient Chinese medicine books, a first execution path is planned, and the scheduling and coordination module sequentially calls the text region detection intelligent agent unit, the recognition and correction intelligent agent unit and the knowledge graph construction intelligent agent unit. When the data to be processed contains only user query questions, a second execution path is planned, and the scheduling and coordination module directly calls the retrieval enhancement question-answering intelligent agent unit. When the data to be processed contains images of ancient Chinese medicine books and user query questions, a third execution path is planned, and the scheduling and coordination module sequentially calls the text region detection intelligent agent unit, the recognition and correction intelligent agent unit, the knowledge graph construction intelligent agent, and the retrieval enhancement and question-answer generation intelligent agent unit.
[0015] A second aspect of the present invention also provides a question-and-answer method for knowledge of ancient Chinese medical texts based on a multi-agent framework, applied to the aforementioned system, comprising the following steps: S1: Receive data to be processed, the data to be processed including at least one of images of ancient Chinese medical books and user query questions; S2: Identify the type of the data to be processed, and dynamically plan the execution path of the core intelligent agent cluster based on the identified type; S3: According to the triggered execution path, schedule the core intelligent agent cluster to process the data to be processed. The processing flow includes at least one or more of the following: The image layout parsing and text standardization process is used to adaptively parse the layout of the images of the ancient Chinese medicine books and output the layout structured data; based on the layout structured data, the text recognition of the images of the ancient Chinese medicine books is performed, and the recognition results are filtered for special characters, corrected for rare and variant characters in Chinese medicine, and converted between traditional and simplified characters. The corrected standardized text data is then output and stored in the knowledge base module. The knowledge automation construction process is used to extract the dialectical reasoning chain of symptom-syndrome-treatment principle-prescription progression logic based on the standardized text data and using customized prompt word templates. After coreference resolution and knowledge alignment, it is integrated into a network knowledge structure and updated to the knowledge graph of the traditional Chinese medicine field. The hybrid retrieval-enhanced generative question-answering process is used to perform retrieval-enhanced generative question-answering on the user query question by using hybrid retrieval and knowledge fusion rearrangement based on the constructed knowledge graph of the traditional Chinese medicine field and the standardized text data, and outputs traceable traditional Chinese medicine question-answering results.
[0016] A third aspect of the present invention also provides a computer-readable storage medium storing a computer program, which is executed by a processor for the aforementioned question-and-answer method for knowledge of ancient Chinese medical texts based on a multi-agent framework.
[0017] Compared with the prior art, the present invention has the following beneficial effects: (1) High text recognition accuracy: Through the collaboration of text region detection and recognition correction intelligent agents, it is specifically optimized for the vertical layout, traditional characters, variant characters, complex layout and other features of ancient Chinese medicine books. The large model OCR decomposition architecture and layered layout analysis are adopted, which significantly improves the accuracy of digital text and lays a reliable foundation for subsequent processing.
[0018] (2) More intelligent knowledge extraction and more in line with the logic of traditional Chinese medicine: The knowledge graph construction agent automatically extracts the dialectical reasoning chain and completes knowledge fusion by using a large language model and customized prompt word templates, which greatly reduces the dependence on domain experts and improves the efficiency and standardization of knowledge graph construction.
[0019] (3) More accurate, reliable, and traceable question-answering results: The retrieval-enhanced question-answering agent adopts a three-path hybrid retrieval enhancement generation technology that combines vector retrieval, entity exact matching, and implicit relation query. It integrates text semantic retrieval and knowledge graph association retrieval, providing rich evidential context for generative large language models and effectively suppressing the "illusion" phenomenon. At the same time, the system provides detailed source annotations for the answers, ensuring the verifiability and rigor of the answers.
[0020] (4) The system architecture is more flexible and adaptable: Traditional Chinese medicine ancient books digitization mostly rely on a single technology or a simple pipeline. This invention realizes dynamic routing and intelligent scheduling according to input type through the scheduling and coordination module, which breaks through the limitations of the traditional linear fixed processing flow. This enables the system to flexibly cope with various scenarios such as only images, only questions, and a combination of images and questions, thereby improving the system's practicality and resource utilization.
[0021] Other features and effects of the invention will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the invention. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 This is a schematic diagram of the structure of the Traditional Chinese Medicine Ancient Books Knowledge Question Answering System based on a multi-agent framework according to an embodiment of the present invention; Figure 2 This is a visualization and annotation effect diagram of the text region detection intelligent agent unit in an embodiment of the present invention; Figure 3 This is a flowchart illustrating the OCR disassembly process of the identification and correction intelligent agent unit in this invention. Figure 4 A visual example diagram illustrating the dialectical reasoning chain knowledge graph of the intelligent agent unit for the knowledge graph construction of this invention. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0025] This invention provides a knowledge-based question-and-answer system for ancient Chinese medicine texts based on a multi-agent framework. The core is built upon a layered, modular architecture, with four specialized agents collaboratively performing various tasks. Coupled with dynamic routing based on a scheduling and coordination module, it achieves end-to-end automated processing from image input of ancient Chinese medicine texts to knowledge graph construction and intelligent question-and-answer output. This solves problems in traditional digitization of ancient Chinese medicine texts such as low text recognition accuracy, difficulty in knowledge extraction, poor retrieval efficiency, high manual costs, and insufficient reliability of question-and-answer results. The following sections will provide a detailed explanation of the overall system architecture, execution steps of each core module, key technology implementation methods, and the complete data flow process.
[0026] This invention adopts a multi-layered modular architecture, and its system flow is as follows: Figure 1As shown, it is divided into four parts: interface module, scheduling and coordination module, core intelligent agent cluster, and knowledge base module. The interface module can be developed into a web-based visual interactive interface, supporting users to upload image files of ancient Chinese medicine books in JPG / PNG format, as well as inputting query questions related to Chinese medicine. It can also receive input content consisting of both images and questions. Finally, the scheduling and coordination module presents the final processing results executed by the core intelligent agent cluster to the user in a visual form.
[0027] The scheduling and coordination module undertakes the core scheduling functions of the system. For example, it can rely on the LangGraph framework to realize agent workflow orchestration, global state management, and routing decisions, and achieve dynamic adaptation to different input scenarios through conditional edge design. The core agent cluster of this invention includes four types of specialized agent units: text region detection agent unit (DetectAgent), recognition and correction agent unit (RecognizeAgent), knowledge graph construction agent unit (KGAgent), and retrieval enhancement and question-answering generation agent unit (RAGAgent). Each type of agent completes its corresponding sub-task independently. All scheduling instructions are obtained from the LangGraph-based scheduling and coordination module, and the processed data is also transmitted and flowed through this module. The specific implementation method of the core agent cluster architecture in this embodiment is as follows: (1) Text region detection intelligent agent (DetectAgent): The core function of DetectAgent is to analyze the layout structure of images of ancient Chinese medicine books, accurately locate different types of text regions, and output structured layout data to define the precise region range for subsequent OCR recognition.
[0028] The DetectAgent comprises a layout parsing subunit and a visualization annotation subunit, primarily responsible for intelligent layout parsing and visualization annotation of images of ancient Chinese medicine books. Its workflow is as follows: First, the layout parsing subunit receives user-uploaded JPG or PNG images of ancient Chinese medicine books. Preprocessing of the images includes grayscale conversion, noise reduction, contrast enhancement, and tilt correction. The images are then converted to base64 encoding to conform to the input specifications of the layout parsing API. Second, an adaptive hierarchical layout parsing algorithm is used to segment the vertically formatted ancient books into rows and columns. Text, title, annotation, seal, and image regions are identified and located, and structured data such as coordinate positions and type labels for each region are obtained. Third, to verify the visualization effect of the detection results, the visualization annotation module completes region annotation on the original ancient Chinese medicine book image. For example, in this embodiment, the text is marked with a green rectangle, the title with red, the annotation with blue, and the seal with yellow, distinguishing different regions through different colors. The annotated image is then converted to base64 encoding and output along with the layout structured data to the scheduling and coordination module. The effect is as follows: Figure 2 As shown (footer is the page footer, vertical_text is the text, paragraph_title is the paragraph title, and head is the main title), the layout analysis results are visualized, facilitating manual verification and result traceability.
[0029] (2) RecognizeAgent: RecognizeAgent, relying on the structured data output by DetectAgent, completes the recognition of Chinese classical texts, filters out meaningless characters in Chinese classical texts, performs standardized correction from traditional Chinese to simplified Chinese, and addresses the low recognition accuracy issues of vertically arranged traditional Chinese characters, variant characters, taboo characters, and densely overlapping text in Chinese classical texts, outputting standardized text data that can be used for knowledge extraction.
[0030] The RecognizeAgent employs a large-model OCR decomposition architecture, including layout analysis subunits, text segmentation subunits, visual encoding recognition subunits, and text post-processing subunits. Its specific processing steps are as follows: Figure 3 As shown: Based on the structured layout data, the layout analysis subunit uses a large model (such as PP-DocLayoutV3) to locate and classify the global text regions of ancient book images with reading order, filtering out non-textual interference areas such as seals, stains, and borders; by using reading order, it avoids the differences in reading habits between ancient books and modern texts.
[0031] The text segmentation subunit utilizes a large model (such as PP-StructureV3) to perform secondary fine segmentation on annotations, marginal notes, double-line small text, dense text, overlapping text, and small-print annotation regions. The visual encoding recognition subunit uses a convolutional neural network and a Transformer encoding structure to perform single-character recognition and line / sentence recognition on finely segmented text regions, splitting long text lines into single characters and short sentences into single lines, thereby improving the recognition success rate of small-sized and blurry text. The text correction subunit fine-tunes the model (e.g., ERNIE-4.5-0.3) for traditional Chinese characters, variant characters, and rare characters in traditional Chinese medicine, ultimately converting the image features extracted by the visual encoder into structured results such as text, formulas, or tables. Simultaneously, it performs multi-layered standardization processing on the structured text: the first layer filters special characters, establishing rules for filtering meaningless characters from ancient Chinese medical texts, removing CJK radicals, ideographic characters, seal symbols, decorative symbols, garbled text, and extra spaces; the second layer performs simplified / traditional Chinese character conversion and normalization of Chinese medicine terminology; the third layer corrects rare characters, taboo characters, and phonetic loan characters based on a pre-set expert rule base, finally outputting high-purity standardized text data and storing it in the knowledge base module.
[0032] (3) Knowledge Graph Construction Agent Unit (KGAgent): KGAgent relies on the corrected and standardized text data output by RecognizeAgent to extract TCM knowledge and construct a knowledge graph through customized prompt words and a large language model, thereby realizing the structured and systematic storage of ancient book knowledge.
[0033] The KGAgent includes a dialectical reasoning chain extraction subunit, a knowledge fusion alignment subunit, and a knowledge graph update subunit.
[0034] The dialectical reasoning chain extracts sub-units and loads customized TCM domain prompt word templates. Standardized text is input into a large language model, and entities and relations are extracted according to the progressive logic of symptoms-syndromes-treatment principles-prescriptions. Entity types include symptoms, syndrome types, disease names, treatment methods, prescriptions, Chinese medicines, and contraindications. Relationship types include syndrome differentiation, treatment with, prescription use, composition, contraindications, and belonging to, forming a complete dialectical reasoning chain. Knowledge fusion aligns the sub-units to resolve the coreference of dialectical reasoning chains from multiple sources (i.e., grouping different references to the same entity into the same equivalent set, such as "ephedra" and "pure ephedra" referring to the same thing). Through this coreference resolution, the newly generated relation chains are aligned with the original knowledge graph, entity alignment and relation fusion are achieved, synonymous entities are merged, conflicting relations are verified, and knowledge redundancy and conflict caused by differences in ownership, heterogeneous sources, and naming variations are eliminated, forming a network knowledge structure that spans diseases, chapters, and prescriptions. The knowledge graph update subunit adopts a graph database storage structure, assigns a unique identifier to each entity, constructs an entity attribute table and a relation edge table, and batches the fused network knowledge structure to write and update the knowledge graph in the field of traditional Chinese medicine, and synchronously stores it in the knowledge base module.
[0035] (4) Retrieve enhanced question-answering agent unit (RAGAgent) and knowledge base: RAGAgent leverages the corrected and standardized text data from its knowledge base module and a knowledge graph in the field of Traditional Chinese Medicine to achieve enhanced generative intelligent question answering. This addresses the semantic gap problem inherent in traditional keyword retrieval, improving the accuracy, credibility, and traceability of the question answering results.
[0036] The knowledge base module first receives standardized text data output by the recognition and correction agent unit. It then segments and stores this data in a structured manner according to page numbers, chapters, paragraphs, and sources from ancient texts. Each segment is tagged with metadata such as the source text name, dynasty, author, page number, paragraph number, and text type. An inverted index and vector index are also established to support fast and accurate retrieval. Simultaneously, the knowledge base module associates and binds the standardized text with a TCM knowledge graph output by the knowledge graph construction agent unit. This establishes a bidirectional mapping between text fragments and entities such as symptoms, syndromes, treatment principles, prescriptions, and Chinese medicines, as well as dialectical relationships such as "differentiation of syndromes," "treatment based on," and "prescription application." Ultimately, this forms a dual knowledge base system—a collaborative support system of unstructured text and structured knowledge graph—that is searchable, associative, and reasonable, providing underlying data support for hybrid retrieval and traceable question answering.
[0037] The RAGAgent includes a query intent parsing subunit, a hybrid retrieval subunit, a knowledge fusion and rearrangement subunit, and a question-answer generation subunit. The specific processing flow of each subunit is as follows: The query intent parsing subunit performs word segmentation, semantic encoding, and intent classification on the natural language queries input by the user. It identifies question types such as symptom queries, syndrome queries, prescription queries, treatment method queries, and contraindication queries. It extracts the target entity (the core object of the query), attribute intent (the message features of the query), and constraints (conditions added by the user to limit the search scope and question-answer boundaries). These three elements are used together as features to generate a query intent vector. Simultaneously, logical constraints are separately structured and stored as a constraint set, which is then provided to the downstream retrieval enhancement generation module. For example: What are some medical case studies on spleen and stomach diseases by physicians from the Xin'an School in the Qing Dynasty? The target entities are spleen and stomach diseases and medical case studies; the attribute intent is a list of medical case studies; and the logical constraints are Xin'an physicians and the Qing Dynasty. An example of its effect graph is shown below. Figure 4 As shown, the extracted keywords are displayed in the form of a relationship graph. Finally, the generated knowledge graph of ancient Chinese medicine texts and standardized text data are synchronously transmitted to the LangGraph scheduling and coordination module and stored in the knowledge base module.
[0038] Based on query-aware representation, the hybrid retrieval subunit concurrently or in association performs the following three retrieval paths on standardized text data and knowledge graphs in the field of Traditional Chinese Medicine within the knowledge base module: The first path performs dense vector retrieval in a standardized text library, encodes the text and query question into multi-dimensional vectors, obtains highly semantically relevant text fragments through cosine similarity calculation, and combines keyword matching to supplement the calculation of relevance scores, outputting relevant text information including text content, page number, source and confidence level; The second approach performs precise entity matching and direct relationship querying in the knowledge graph of traditional Chinese medicine, quickly returning entity attributes, direct relationships, and structured knowledge triples; The third path performs multi-hop indirect relationship queries centered on the target entity, expands outward to related entities, and completes the implicit dialectical reasoning chain and diagnostic logic relationship.
[0039] The knowledge fusion and rearrangement subunit dynamically weights and sorts the heterogeneous search results returned by the three paths, performs redundancy removal and multi-source feature fusion based on the intent weight carried by the query perception representation, filters low-confidence fragment information, and integrates them to form a coherent, consistent, and high-quality knowledge context. For example, taking "What are the uses of ephedra" as an example, this question is of broad knowledge. The dynamic weighting process is as follows: the weight of the first path is set to W1, the weight of the second path is set to W2, and the weight of the third path is set to W3, assuming W1=0.8, W2=0.1, and W3=0.1; assuming the feature vector similarity score of the first path is s1, the feature node centrality of the second path is s2, and the feature path length of the third path is s3; after performing Min-Max normalization to make the feature weights 0-1, we can obtain s1', s2', and s3'; by calculation, we can obtain the fusion score: the fusion score of the first path is W1×s1'; the fusion score of the second path is W2×s2'; and the fusion score of the third path is W3×s3'; then the core text fragments are sorted according to the fusion score and spliced together to form the final context.
[0040] The question-answering generation subunit uses the knowledge context as a strong constraint context and inputs it into the large language model along with the user's query question. It adopts a few-sample prompt and fact verification mechanism to constrain the model to generate answers only based on the retrieved knowledge, which significantly reduces the probability of model illusion. At the same time, it automatically labels the answers with source literature, text fragments, knowledge graph entities and relationship information, and generates a complete result containing question-answering content, relevant evidence, confidence level and source information. The result is then visualized and displayed to the user through the interface module via the scheduling and coordination module.
[0041] The scheduling and coordination module, as the core scheduling unit of the system, undertakes the functions of agent orchestration, state management and routing control. It includes a state definition unit, a node definition unit and a routing decision unit to realize flexible scheduling and condition execution of multiple agents.
[0042] The state definition unit is used to define and maintain the system's state variables throughout the entire process, enabling task state tracking and synchronization. The node definition unit is used to encapsulate each intelligent agent unit in the core intelligent agent cluster into an independent executable node, namely the detect node, the recognize node, the extract_knowledge node, and the answer_question node. The routing decision unit is used to identify the data type to be processed and dynamically plan the execution path based on the input type, completing adaptive scheduling for three business scenarios.
[0043] Based on this, the scheduling and coordination module performs state routing and task scheduling according to the data type of the task to be processed, specifically configured as follows: When the data to be processed contains only images of ancient Chinese medicine books, the first execution path is planned, and the text region detection intelligent agent unit, the recognition and correction intelligent agent unit, and the knowledge graph construction intelligent agent unit are scheduled to execute in sequence to complete the digitization of ancient book images and the construction of knowledge graphs. When the data to be processed only contains user query questions, a second execution path is planned to directly schedule the retrieval enhancement question-answering agent unit to execute, quickly completing the retrieval and question-answering output; When the data to be processed contains both images of ancient Chinese medicine books and user query questions, a third execution path is planned, sequentially scheduling the text region detection intelligent agent unit, the recognition and correction intelligent agent unit, the knowledge graph construction intelligent agent unit, and the retrieval enhancement and question answer generation intelligent agent unit to complete the full-link automated processing from image parsing to intelligent question answering.
[0044] A second aspect of the present invention also provides a question-and-answer method for knowledge of ancient Chinese medical texts based on a multi-agent framework, applied to the aforementioned question-and-answer system for knowledge of ancient Chinese medical texts based on a multi-agent framework, comprising the following steps: S1: Receive data to be processed, the data to be processed including at least one of images of ancient Chinese medical books and query questions; S2: Based on the type of data to be processed, dynamically plan and trigger the execution path of the corresponding core intelligent agent cluster; S3: According to the triggered execution path, schedule the core intelligent agent cluster to process the data to be processed. The processing flow includes at least one or more of the following: The image layout parsing and text standardization process is used to perform adaptive layered layout parsing, character recognition, character filtering, simplified / traditional conversion, and expert rule correction of rare and variant characters in traditional Chinese medicine texts according to the main text, title, annotation, seal, and pictures. The corrected standardized text data is then output and stored in the knowledge base module. The knowledge automation construction process is used to extract the dialectical reasoning chain of symptom-syndrome-treatment principle-prescription progression logic based on the standardized text data and using customized prompt word templates. After coreference resolution and knowledge alignment, it is integrated into a network knowledge structure and updated to the knowledge graph of the traditional Chinese medicine field. The hybrid retrieval-enhanced generative question-answering process is used to perform three-path parallel retrieval, knowledge fusion and rearrangement, and constraint-based generative question answering on the user query based on the constructed knowledge graph of the traditional Chinese medicine field and the standardized text data, and output traceable traditional Chinese medicine question-answering results.
[0045] The image layout parsing and text standardization process, knowledge automation construction process, and hybrid retrieval enhanced generative question-answering process described in this invention are consistent with the processing flow of the corresponding modules or units in the above-mentioned traditional Chinese medicine ancient book knowledge question-answering system, and will not be described in detail here.
[0046] A third aspect of the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the aforementioned method for question-and-answering questions about ancient Chinese medical texts based on a multi-agent framework.
[0047] Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A question-and-answer system for ancient Chinese medical texts based on a multi-agent framework, characterized in that, The system includes: The interface module is used to acquire data to be processed and present the processing results. The data to be processed includes at least one of the following: images of ancient Chinese medicine books and user query questions. The knowledge base module is used to store standardized text data of ancient Chinese medicine books, knowledge graphs in the field of Chinese medicine, and rule data of Chinese medicine experts. The core intelligent agent cluster includes a text region detection intelligent agent unit, an identification and correction intelligent agent unit, a knowledge graph construction intelligent agent unit, and a retrieval enhancement and question-answer generation intelligent agent unit; The text region detection intelligent agent unit is used to perform adaptive layered layout parsing on images of ancient Chinese medicine books and output layout structured data. The recognition and correction intelligent agent unit is used to perform text recognition on the image of the ancient Chinese medicine book based on the layout structured data, correct the recognition results, and output the corrected standardized text data to the knowledge base module. The knowledge graph construction intelligent agent unit is used to extract TCM entities, attributes and relationships between entities from the standardized text data of the knowledge base module according to the TCM syndrome differentiation logic, and to construct and update the TCM domain knowledge graph in the knowledge base module. The retrieval-enhanced question-answering intelligent agent unit is used to perform hybrid retrieval and generative question answering based on standardized text data in the knowledge base module and knowledge graphs in the field of traditional Chinese medicine. The scheduling and coordination module is connected to the interface module, the core intelligent agent cluster, and the knowledge base module, respectively. It includes identifying the type of the data to be processed and dynamically planning the execution path of the core intelligent agent cluster based on the identified type, so as to complete the end-to-end processing from ancient book image parsing and knowledge graph construction to intelligent question answer generation.
2. The question-and-answer system for ancient Chinese medical texts according to claim 1, characterized in that, The text region detection intelligent agent unit includes: The layout parsing subunit is used to segment the input image of ancient Chinese medicine books, identify and locate the corresponding text regions according to the adaptive hierarchical layout of the main text, title, annotation, seal, and image, and output the layout structured data containing the coordinates and type labels of each region. The visualization annotation subunit is used to perform regional annotation on the original image of ancient Chinese medicine books based on the layout structured data and output the annotation results.
3. The question-and-answer system for ancient Chinese medical texts according to claim 1, characterized in that, The recognition and correction intelligent agent unit adopts a large-model OCR decomposition recognition architecture, specifically including: The layout analysis subunit is used to locate global text regions in the image of ancient Chinese medicine books with reading order based on the layout structured data and a large model. The text segmentation subunit is used to perform secondary fine-grained cell segmentation of text regions with different locations based on the global text region location and using a large model. The visual encoding recognition subunit is used to recognize single characters and lines of text after finely segmented cell text. The text correction subunit is used to filter special characters, correct rare characters and variant characters in traditional Chinese medicine, and convert between simplified and traditional characters in the recognition results, and output the corrected standardized text data.
4. The question-and-answer system for ancient Chinese medical texts according to claim 1, characterized in that, The knowledge graph construction agent unit includes: The dialectical reasoning chain extraction subunit is used to identify and extract dialectical reasoning chains that conform to the progressive logic of symptoms-syndromes-treatment principles-prescriptions from standardized text data using customized prompt word templates. The dialectical reasoning chain includes symptom entities, syndrome entities, treatment principle entities, and prescription entities, and each entity is connected by the dialectical logical relationship of "diagnosis as", "treatment with", and "prescription application". The knowledge fusion alignment subunit is used to resolve common references and align knowledge from multiple dialectical reasoning chains extracted from standardized text data from different sources, thereby eliminating knowledge redundancy and conflict and fusion to form a network knowledge structure that spans diseases and prescriptions. The knowledge graph update subunit is used to construct and update the knowledge graph in the field of traditional Chinese medicine by integrating the fused network knowledge structure.
5. The question-and-answer system for ancient Chinese medical texts according to claim 1, characterized in that, The retrieval-enhanced question-answering intelligent agent unit includes: The query intent parsing subunit is used to perform semantic parsing on the user's natural language query, extract the target entity, attribute intent and logical constraints, generate a query intent vector and a set of constraints, and use the set as a query perception representation. The hybrid retrieval subunit is used to perform hybrid retrieval of the standardized text data and the knowledge graph of the traditional Chinese medicine field concurrently or in association in the knowledge base module according to the query perception representation, so as to obtain retrieval results from different data sources; The knowledge fusion and rearrangement subunit is used to dynamically weight and sort the retrieval results from different data sources obtained by the hybrid retrieval subunit based on the intent weight of the query perception representation, and to fuse multi-source features to remove redundancy and form a unified knowledge context. The question-answering generation subunit is used to inject the knowledge context as constraint information into the large language model, guide the generation of answers in the field of traditional Chinese medicine that match the query, and label the source of the answer in the knowledge base module to generate question-answering results with traceability information.
6. The question-and-answer system for ancient Chinese medical texts according to claim 5, characterized in that, The hybrid retrieval subunit performs hybrid retrieval in the knowledge base module based on the query-aware representation, including the following three retrieval paths: The first approach involves performing dense vector retrieval in standardized text data to obtain semantically similar unstructured text fragments. The second approach involves performing entity matching and direct relationship queries within the knowledge graph of the traditional Chinese medicine domain to obtain structured knowledge triples. The third approach uses the target entity as the central node in the knowledge graph of traditional Chinese medicine to perform indirect relationship queries, expands outward to related entities, completes indirect dialectical relationships, and extracts and forms a complete implicit dialectical reasoning relationship chain.
7. The question-and-answer system for ancient Chinese medical texts according to claim 1, characterized in that, The scheduling and coordination module performs state routing and task scheduling between image parsing, text correction, knowledge extraction, and question-and-answer generation stages according to the type of data to be processed, in order to adapt to the entire processing flow of ancient Chinese medicine books.
8. The question-and-answer system for ancient Chinese medical texts according to claim 1, characterized in that, The scheduling and coordination module is specifically used for: When the data to be processed contains only images of ancient Chinese medicine books, a first execution path is planned, and the scheduling and coordination module sequentially calls the text region detection intelligent agent unit, the recognition and correction intelligent agent unit and the knowledge graph construction intelligent agent unit. When the data to be processed contains only user query questions, a second execution path is planned, and the scheduling and coordination module directly calls the retrieval enhancement question-answering intelligent agent unit. When the data to be processed contains images of ancient Chinese medicine books and user query questions, a third execution path is planned, and the scheduling and coordination module sequentially calls the text region detection intelligent agent unit, the recognition and correction intelligent agent unit, the knowledge graph construction intelligent agent, and the retrieval enhancement and question-answer generation intelligent agent unit.
9. A question-and-answer method for ancient Chinese medical texts based on a multi-agent framework, applied to the system described in any one of claims 1-8, characterized in that, Includes the following steps: S1: Receive data to be processed, the data to be processed including at least one of images of ancient Chinese medical books and user query questions; S2: Identify the type of the data to be processed, and dynamically plan the execution path of the core intelligent agent cluster based on the identified type; S3: According to the triggered execution path, schedule the core intelligent agent cluster to process the data to be processed. The processing flow includes at least one or more of the following: The image layout parsing and text standardization process is used to adaptively parse the layout of the images of the ancient Chinese medicine books and output the layout structured data; based on the layout structured data, the text recognition of the images of the ancient Chinese medicine books is performed, and the recognition results are filtered for special characters, corrected for rare and variant characters in Chinese medicine, and converted between traditional and simplified characters. The corrected standardized text data is then output and stored in the knowledge base module. The knowledge automation construction process is used to extract the dialectical reasoning chain of symptom-syndrome-treatment principle-prescription progression logic based on the standardized text data and using customized prompt word templates. After coreference resolution and knowledge alignment, it is integrated into a network knowledge structure and updated to the knowledge graph of the traditional Chinese medicine field. The hybrid retrieval-enhanced generative question-answering process is used to perform retrieval-enhanced generative question-answering on the user query question by using hybrid retrieval and knowledge fusion rearrangement based on the constructed knowledge graph of the traditional Chinese medicine field and the standardized text data, and outputs traceable traditional Chinese medicine question-answering results.
10. A computer-readable storage medium storing a computer program, characterized in that, The computer program is executed by a processor to implement the question-and-answer method for ancient Chinese medical texts based on a multi-agent framework as described in claim 9.
