Traditional Chinese medicine large model construction method and system, electronic equipment and storage medium

By constructing a combination of traditional Chinese medicine models and knowledge graphs, the problem of easy absorption of error preferences in the learning process of Chinese medicine models is solved, and the recovery efficiency and output accuracy of the model can be improved, so that it can accurately generate the answer that is consistent with human preferences.

CN119378694AInactive Publication Date: 2025-01-28ANHUI UNIVERSITY OF TRADITIONAL CHINESE MEDICINE

Patent Information

Application Number
CN202411980414.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-01-28
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing large traditional Chinese medicine models are prone to absorb wrong preferences during the learning process, and are difficult to capture copying or fuzzy preferences. The preference settings are relatively single, and there is a lack of an effective feedback mechanism, resulting in low model reply efficiency and insufficient output accuracy.

Method used

By obtaining traditional Chinese medicine source data, generate large model dialogue data, establish a traditional Chinese medicine data set for model training, extract entity and relationship data into the diagram database to generate the knowledge map, and connect the major traditional Chinese medicine model with the database, and use natural language issues to generate query statements instructions Find the knowledge diagram and expand the context to generate answers.

Benefits of technology

It has improved the generalization of the sample sample samples of the Chinese medicine set, enhanced the knowledge and content generation ability of the model itself, enhanced the retrieval ability when using natural language problems, eliminating the model to answer the illusion, so that the model can accurately generate the consistency as the human preferences. Answer.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119378694A_ABST
    Figure CN119378694A_ABST
Patent Text Reader

Abstract

The invention provides a traditional Chinese medicine large model construction method and system, electronic equipment and a storage medium, and relates to the technical field of artificial intelligence, and the large model construction method comprises the following steps: obtaining traditional Chinese medicine source data, and generating large model dialogue data; establishing a traditional Chinese medicine data set based on the large model dialogue data; performing model training on the traditional Chinese medicine data set to obtain a traditional Chinese medicine large model; extracting entity and relational data in the traditional Chinese medicine source data; importing the entity and relational data into a graph database to generate a knowledge graph; connecting the traditional Chinese medicine large model with the graph database; and obtaining a natural language question, and converting the natural language question into a query statement instruction corresponding to the incomplete triad through the traditional Chinese medicine large model. According to the large model construction method and system, the electronic equipment and the storage medium provided by the invention, the hallusion question answering by the model can be effectively eliminated, and the questions and answers of the traditional Chinese medicine large model are enabled to better conform to human preferences.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method, system, electronic device and storage medium for constructing a large model of traditional Chinese medicine. Background Art

[0002] Traditional Chinese medicine has a unique theoretical system, involving concepts such as yin and yang, the five elements, and internal organs. Many of them are based on experience and abstract theories, and high-quality, standardized data is relatively limited. For a data-driven TCM big model, the results generated by the model when doing TCM question-answering tasks should meet the standards of TCM theory and clinical practice, and accurately understanding and applying this knowledge is undoubtedly a severe challenge.

[0003] The existing TCM models are prone to absorbing erroneous preferences during the learning process and have difficulty capturing duplicate or ambiguous preferences. The preference settings are relatively simple and lack an effective feedback mechanism, which leads to low model response efficiency and insufficient output accuracy. Summary of the invention

[0004] In view of the shortcomings of the prior art mentioned above, the purpose of the present invention is to provide a method, system, electronic device and storage medium for constructing a large model of traditional Chinese medicine, so as to solve the problems in the prior art that the large model of traditional Chinese medicine is easy to absorb erroneous preferences during the learning process, and it is difficult to capture duplicated or vague preferences, the preference settings are relatively simple, and there is a lack of effective feedback mechanism, which leads to low model response efficiency and insufficient output result accuracy.

[0005] To achieve the above-mentioned purpose and other related purposes, the present invention provides a method for constructing a large model of traditional Chinese medicine, comprising the following steps: obtaining traditional Chinese medicine source data and generating large model dialogue data; establishing a traditional Chinese medicine data set based on the large model dialogue data; performing model training on the traditional Chinese medicine data set to obtain a large model of traditional Chinese medicine; extracting entity and relationship data from the traditional Chinese medicine source data; importing the entity and relationship data into a graph database to generate a knowledge graph; connecting the large model of traditional Chinese medicine and the graph database; obtaining natural language questions and converting them into query statement instructions corresponding to incomplete triples through the large model of traditional Chinese medicine; searching for corresponding knowledge graph subgraphs in the graph database according to the query statement instructions; and according to the found knowledge graph subgraphs, performing context expansion on the complete triples corresponding to the knowledge graph subgraphs through the large model of traditional Chinese medicine to obtain answers.

[0006] In one embodiment of the present invention, TCM source data is obtained and large model dialogue data is generated, including: converting the TCM source data into text data; and converting the text data into question content and answer content corresponding to the large model dialogue data through a large language model.

[0007] In one embodiment of the present invention, the TCM source data includes public data sets in the field of TCM, TCM field data on web pages extracted by crawler technology, and text-extracted data from ancient medical records.

[0008] In one embodiment of the present invention, entity and relationship data in TCM source data are extracted, including: pre-extracting entity and relationship data from TCM source data through an information extraction model; labeling and verifying the pre-extracted entity and relationship data in turn; converting the data format of the verified entity and relationship data into a model pre-training format for the information extraction model; fine-tuning the information extraction model based on the entity and relationship data in the model pre-training format; and extracting entity and relationship data from the TCM source data again through the fine-tuned information extraction model.

[0009] In one embodiment of the present invention, entity and relationship data are imported into a graph database to generate a knowledge graph, including: converting the entity and relationship data extracted from the TCM source data into a corresponding format of the graph database; importing the entity and relationship data after format conversion into the graph database to establish a knowledge graph.

[0010] In one embodiment of the present invention, a natural language question is obtained and converted into a query statement instruction corresponding to an incomplete triple through a large model of traditional Chinese medicine, including: performing entity and relationship detection on the natural language question; converting the existing entities and relationships in the detected natural language question into query statement instructions.

[0011] In one embodiment of the present invention, according to the query statement instruction, the corresponding knowledge graph subgraph is searched in the graph database, including: according to the existing entities and relationships corresponding to the query statement instruction, missing entity detection of the knowledge graph subgraph is performed in the graph database to obtain the knowledge graph subgraph.

[0012] The present invention also provides a system for building a large model of traditional Chinese medicine, including: a dialogue generation unit, used to obtain traditional Chinese medicine source data and generate large model dialogue data; a data set establishment unit, used to establish a traditional Chinese medicine data set based on the large model dialogue data; a model training unit, used to perform model training on the traditional Chinese medicine data set to obtain a large model of traditional Chinese medicine; a data extraction unit, used to extract entity and relationship data from the traditional Chinese medicine source data; a graph creation unit, used to import entity and relationship data into a graph database to generate a knowledge graph; a model communication unit, used to connect the large model of traditional Chinese medicine and the graph database; a sentence conversion unit, used to obtain natural language questions and convert them into query statement instructions corresponding to incomplete triples through the large model of traditional Chinese medicine; a graph query unit, used to search for corresponding knowledge graph subgraphs in the graph database according to the query statement instructions; and a model retrieval unit, used to perform context expansion on the complete triples corresponding to the knowledge graph subgraph through the large model of traditional Chinese medicine according to the found knowledge graph subgraph to obtain an answer.

[0013] The present invention further provides an electronic device, which includes: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by one or more processors, the electronic device implements the aforementioned method for constructing a large model of traditional Chinese medicine.

[0014] The present invention further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor of a computer, the computer executes the aforementioned method for constructing a large model of traditional Chinese medicine.

[0015] As described above, a method, system, electronic device and storage medium for constructing a large model of traditional Chinese medicine of the present invention have the following effects: by adopting a data processing method that combines self-supervision and supervised technologies, large model dialogue data is generated through data from three data sources: web crawlers, public data sets, and ancient medical records, and a traditional Chinese medicine data set is established based on the large model dialogue data for model training to obtain a large model of traditional Chinese medicine, thereby improving the generalization degree of samples in the traditional Chinese medicine data set and greatly expanding the number of samples in the traditional Chinese medicine data set. At the same time, by extracting entity and relationship data from TCM source data, a knowledge graph is established, and then a connection is established between the TCM big model and the graph database storing entity and relationship data. When searching for the corresponding answer using natural language questions, the corresponding query statement instruction is first generated in the TCM big model according to the natural language question, and then the knowledge graph subgraph with complete triples is further found according to the query statement instruction, so that the TCM big model can perform context expansion on the complete triples corresponding to the knowledge graph subgraph according to the knowledge graph subgraph, thereby enhancing the knowledge and content generation of the model itself, and enhancing the retrieval ability when searching using natural language questions, eliminating the illusion of model answers, and enabling the model to accurately generate answers consistent with human preferences. In addition, the TCM big model can be continuously improved and perfected by enhancing the interaction between clinical medical experts and the model, establishing an effective feedback mechanism, and using supervised learning algorithms combined with new standardized data. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 A schematic diagram of the process of constructing a large model of traditional Chinese medicine provided in an embodiment of the present invention.

[0017] Figure 2 A flowchart showing the TCM model question-answering process provided by one embodiment of the present invention Figure 3 A flowchart showing the process of constructing a large model of traditional Chinese medicine provided by an embodiment of the present invention Figure 4 A flowchart showing data construction and preprocessing provided by an embodiment of the present invention Figure 5 A flowchart showing a knowledge graph construction process provided by an embodiment of the present invention Figure 6 A schematic diagram showing the process of converting a natural language question into a cypher (query statement) according to an embodiment of the present invention Figure 7 Shown is an architecture diagram of a system for constructing a large model of traditional Chinese medicine provided by one embodiment of the present invention.

[0018] Figure 8 Shown is a structural schematic diagram of an electronic device according to an embodiment of the present invention.

[0019] Component number description Electronic device 1; large model building system 11; memory 12; processor 13; dialogue generation unit 111; data set establishment unit 112; model training unit 113; data extraction unit 114; graph creation unit 115; model communication unit 116; sentence conversion unit 117; graph query unit 118; model retrieval unit 119. DETAILED DESCRIPTION

[0020] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.

[0021] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0022] In the following description, numerous details are discussed to provide a more thorough explanation of the embodiments of the present invention. However, it is obvious to those skilled in the art that the embodiments of the present invention can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present invention difficult to understand.

[0023] See also Figure 1 In one embodiment of the present invention, the present invention provides a method for constructing a large model of traditional Chinese medicine, comprising the following steps: Step 10: Obtain TCM source data and generate large model dialogue data; Step 20: Establish a TCM dataset based on the large model conversation data; Step 30: Perform model training on the TCM data set to obtain a TCM large model; Step 40: extracting entity and relationship data from TCM source data; Step 50: Import entity and relationship data into the graph database to generate a knowledge graph; Step 60: Connect the TCM model and the graph database; Step 70: Obtain a natural language question and convert it into a query statement instruction corresponding to an incomplete triple through the TCM model; Step 80: According to the query statement instruction, search for the corresponding knowledge graph subgraph in the graph database; Step 90: Based on the found knowledge graph subgraph, the complete triples corresponding to the knowledge graph subgraph are contextually expanded through the TCM big model to obtain the answer.

[0024] In this embodiment, through step 10: obtaining TCM source data and generating large model dialogue data, it can be seen that when obtaining TCM source data, the TCM source data can be text data, and of course, it can also be image data. Therefore, it is necessary to further extract unified text data through preprocessing, and convert the TCM source data into large model dialogue data in the form of dialogue / question and answer according to the content of the text data. Through the above steps, the conversion of the obtained TCM source data to the large model dialogue data can be realized, and then the large model dialogue data can be further applied to the model training of the TCM large model.

[0025] Through step 20: establishing a TCM dataset based on the big model conversation data, it can be seen that after generating the big model conversation data using the TCM source data, a TCM dataset for training the TCM big model can be further established based on the big model conversation data, thereby increasing the diversity of questions and answers in the big model conversation data, improving the generalization of TCM dataset samples, and greatly expanding the number of samples in the TCM dataset.

[0026] Through step 30: training the model on the TCM dataset to obtain the TCM big model, it can be seen that after obtaining a more generalized TCM dataset, the model can be trained through the TCM dataset to obtain the TCM big model. The TCM big model obtained through training can realize the processing of natural language questions to convert them into query statement instructions. And further, according to the query statement instructions obtained through conversion, the corresponding knowledge graph subgraph is found, and then the TCM big model is used to expand the context of the complete triples corresponding to the knowledge graph subgraph according to the found knowledge graph subgraph to obtain the answer to the question and answer.

[0027] Through step 40: extracting entities and relationship data from TCM source data, it can be seen that TCM source data is also needed when creating a knowledge graph. Specifically, entities and relationship data from TCM source data are extracted and the knowledge graph is constructed by using the entities and relationship data.

[0028] Through step 50: importing entity and relationship data into the graph database to generate a knowledge graph, it can be seen that after obtaining the entity and relationship data, the entity and relationship data can be first imported into the graph database, and then further in the graph database, according to the entity and relationship data, a knowledge graph is generated accordingly. Among them, the knowledge graph can contain several knowledge graph subgraphs, and each knowledge graph subgraph corresponds to at least one complete triple.

[0029] Through step 60: connecting the TCM big model and the graph database, it can be seen that after obtaining the TCM big model and the graph database, by establishing a connection between the TCM big model and the graph database, it is possible to retrieve answers to natural language questions through the TCM big model. In the graph database, the corresponding knowledge graph subgraph can be obtained according to the natural language question query, and then the complete triples corresponding to the knowledge graph subgraph are contextually expanded through the TCM big model, so that a more accurate answer that meets human preferences can be generated.

[0030] Through step 70: obtaining a natural language question and converting it into a query statement instruction corresponding to an incomplete triple through the TCM model, it can be seen that when the TCM model inputs a natural language question to retrieve an answer, the natural language question will be analyzed first to convert the natural language question into a query statement instruction corresponding to an incomplete triple. It should be added that the knowledge graph subgraph corresponds to a complete triple, so through the query statement instruction, the corresponding complete triple can be further searched in the graph database according to the incomplete triple corresponding to the query statement instruction.

[0031] Through step 80: according to the query statement instruction, the corresponding knowledge graph subgraph is searched in the graph database. It can be seen that when the natural language question is converted into a query statement instruction, the query statement instruction corresponds to an incomplete triple, and the knowledge graph subgraph corresponds to a complete triple. Therefore, when searching for the knowledge graph subgraph according to the query statement instruction, the corresponding complete triple can be searched in the graph database according to the incomplete triple corresponding to the query statement instruction, so as to determine the knowledge graph subgraph corresponding to the query statement instruction. Furthermore, the context expansion of the complete triple corresponding to the knowledge graph subgraph can be achieved through the TCM big model, so that the answer to the natural language question can be more in line with human preferences.

[0032] Through step 90: According to the retrieved knowledge graph sub-graph, the complete triples corresponding to the knowledge graph sub-graph are contextually expanded through the traditional Chinese medicine large model to obtain the answer. It can be seen that by connecting the graph database with the traditional Chinese medicine large model, when inputting a natural language question, after the natural language question is transformed into a query statement instruction by the traditional Chinese medicine large model, the corresponding knowledge graph sub-graph can be searched in the graph database through the query statement instruction. And after finding the knowledge graph sub-graph, the complete triples corresponding to the knowledge graph sub-graph are contextually expanded through the traditional Chinese medicine large model to obtain the contextually expanded answer. Through the above steps, the retrieval ability for natural language questions can be effectively enhanced by using the knowledge graph sub-graph, and through the question-and-answer feedback mechanism of the traditional Chinese medicine large model, the traditional Chinese medicine large model can generate answers consistent with human preferences.

[0033] Please refer to Figure 2 , in the process of establishing the question-and-answer mechanism of the traditional Chinese medicine large model, it can be realized that the natural language question is processed into a Cypher (query statement) command by using the traditional Chinese medicine large model, such as "MATCH {j: Physician {name: \"Cheng Liuru\"}}-[:Physician-Disease]->(d: Disease) RETURN d.name". And the corresponding knowledge graph sub-graph is queried in the graph database through the Cypher statement command, and according to the retrieved knowledge graph sub-graph of the query result, the complete triples corresponding to the knowledge graph sub-graph are further contextually expanded through the traditional Chinese medicine large model, and finally the retrieved answer is obtained. Through the above method, the problem of model answer hallucination can be effectively eliminated, making the question-and-answer of the traditional Chinese medicine large model more in line with human preferences.

[0034] In an embodiment of the present invention, after obtaining the traditional Chinese medicine source data, due to different data types, it is also necessary to further convert the traditional Chinese medicine source data into text data that can be processed by the large language model, and then generate large model dialogue data. Specifically, obtaining the traditional Chinese medicine source data and generating large model dialogue data includes: converting the traditional Chinese medicine source data into text data; converting the text data into the question content and answer content corresponding to the large model dialogue data through the large language model. In this embodiment, after converting the traditional Chinese medicine source data into text data, the large language model will summarize the dialogue or question-and-answer content according to the text data. Through this method, it can be realized to automatically generate the question content asked by the large language model itself and the answer content answered by itself by using the text data.

[0035] In a preferred embodiment of the present invention, when using a large language model to convert text data into question content and answer content corresponding to the large model dialogue data, Prompt (prompt word, the main function of Prompt is to prompt the AI ​​model of the context of input information and parameter information of the input model) is set first, and the ChatPromptTemplate (a template class commonly used in software development) in the LangChain (a programming framework that helps use large language models (LLM) in applications) tool is used to integrate the set Prompt, LLM (large language model) and input data set, extract the large model generation results, and construct a traditional Chinese medicine data set.

[0036] In one embodiment of the present invention, the TCM source data includes a public data set in the field of TCM, TCM field data on web pages extracted by crawler technology, and text extraction data of ancient medical records. In this embodiment, when obtaining the TCM data set, the TCM data set can be a public data set in the field of TCM collected and sorted; or it can be TCM field data obtained by extracting web page content through xpath (XML path language) using crawler technology; or it can be collected and systematically sorted out in ancient medical records (such as Xin'an ancient medical records) in cooperation with school libraries and school inheritors. After obtaining the ancient medical records, the ancient medical records are scanned to obtain digital images, and optical character recognition (OCR) technology is used to extract text from the ancient data, so that the text data in the ancient medical records can be extracted, and the text extraction data of the ancient medical records can be obtained.

[0037] In a preferred embodiment of the present invention, when training the TCM large model, chatglm3-6b (a dialogue pre-training model) can be selected as the basic model of the TCM large model, and self-supervised learning is adopted, and the model is fine-tuned using the LORA (low rank adaptation in English, low rank adaptation of large language models (LLM)) fine-tuning method. Of course, other large language models can also be selected as the basic model, and other methods can also be used for fine-tuning. After obtaining the TCM data set, the TCM data set is randomly divided into a training set e and a test set f according to the proportion. Multiple rounds of iterations are performed on the training set. After the training is completed, the initially trained TCM large model is used to infer the test set f to generate a prediction result g. The predicted result g and the true label in the test set f are feature engineered using the embedding (an embedded model) model bge-large-zh (a large-scale language model), converted into a feature vector representation, and the matching degree between the predicted result g and the true label h is calculated by cosine similarity for comparison, and the cosine similarity between the generated answer and the reference answer is calculated. The calculation formula for cosine similarity is as follows: , where g is the predicted result and h is the real result in the cosine similarity calculation formula. Set a similarity threshold. When the cosine similarity between the generated answer and the reference answer is higher than the threshold, the prediction is considered "correct". Obtain n matching degrees respectively and calculate the accuracy. Calculate the recall rate and F1 value of the TCM model dialogue at the same time, and adjust the model hyperparameters to avoid overfitting. When calculating, the accuracy ; Recall rate , , where PT is the number of times the answer generated by the model completely matches the reference answer, n is the total number of questions, TP is the number of relevant answers correctly generated or selected by the model, FN is the number of correct answers that should be generated but the model fails to generate, and TP+FN is all relevant correct answers. In this embodiment, when the predicted result g and the true label in the test set f are feature engineered using the embedding (an embedded model) model bge-large-zh (a large-scale language model), the embedding model can also select other embedding models for feature vector conversion when selected, and the selected embedding model can also be fine-tuned to improve the effect.

[0038] See also Figure 3 In the process of constructing the TCM big model of the present invention, by collecting and organizing relevant TCM data, a data set is constructed, and the knowledge graph is constructed and the TCM big model is fine-tuned and trained according to the TCM data set. Then, when a natural language question is obtained, a Cypher statement can be generated based on the TCM big model. And based on the Cypher statement, the graph database is queried to obtain the corresponding knowledge graph subgraph, and the knowledge graph subgraph is combined with the TCM big model to generate an answer corresponding to the natural language question. Then, through feedback optimization by domain experts, the TCM big model is fine-tuned again, and then the optimized and fine-tuned TCM big model is obtained, thereby eliminating the problem of model answering hallucinations, making the TCM big model more in line with human preferences.

[0039] See also Figure 4In the process of integrating TCM source data, the data sources include web crawler data, public data sets and Xin'an ancient book data. When processing web crawler data, by extracting the URL (a specific web page address used to locate resources on the Internet) and adding it to the task pool, after the captured data enters the task pool, the web page content is extracted through xpath to obtain TCM data, and then the TCM data is engineered through the prompt question and answer template to generate large model dialogue data. For public data sets, the prompt question and answer template can be directly set to generate large model dialogue data. For Xin'an ancient book data, the text of the ancient book can be burned to obtain image data, and OCR (optical character recognition) can be used to identify it to obtain the text data of the new case medical case, and then the large model dialogue data can be generated through the set prompt question and answer template. Finally, the TCM data set is further created through the large model dialogue data obtained above.

[0040] In one embodiment of the present invention, entities and relationship data in TCM source data are extracted, including: pre-extracting entities and relationship data from TCM source data through an information extraction model; labeling and verifying the pre-extracted entities and relationship data in turn; converting the data format of the verified entity and relationship data into a model pre-training format for the information extraction model; fine-tuning the information extraction model based on the entity and relationship data in the model pre-training format; and extracting entities and relationship data from the TCM source data again through the fine-tuned information extraction model.

[0041] In this embodiment, when extracting entity and relationship data from TCM source data, the information extraction model can be used to pre-extract entity and relationship data from TCM source data, and then the extracted entity and relationship data are annotated to construct a standardized corpus. Further verification is required after annotation. After the verification is completed, the verified entity and relationship data are converted into a model pre-training format, and then the entity and relationship data in the model pre-training format are further optimized to the information extraction model, thereby improving the accuracy of model extraction.

[0042] In a preferred embodiment of the present invention, the information extraction model can be a UIE general information extraction model. By using the UIE general information extraction model, entities and relationships are pre-extracted. Afterwards, an automatic annotation system is created in combination with the data annotation platform doccano (a natural language processing tool based on deep learning), and a standardized corpus is constructed with manual assisted review. After the pre-extraction of entities and relationships is completed, the pre-extracted entities and relationships are imported into the doccano annotation platform for detailed manual annotation and verification, and the verified data is further converted into a model pre-training format again. The TrainerAPI (a tool mainly used for training and evaluating machine learning models) method provided by PaddleNLP (a natural language processing (NLP) tool library based on the PaddlePaddle deep learning platform) is used to optimize the UIE general information extraction model using the verified data in the model pre-training format, and the model extraction accuracy is improved by fine-tuning the UIE general information extraction model. Specifically, the UIE model's Structural Extraction Language (SEL) and Structural Schema Instructor (SSI) are combined to extract entity and relationship data. The SEL syntax unifies the output structure of the task, and SSI is a Schema-based prompt used to guide the model to perform entity and relationship extraction tasks.

[0043] When fine-tuning the UIE general information extraction model, you can also use the cross-entropy loss function (Cross-EntropyLoss) to calculate the gap between the probability distribution of the model output and the true label, and obtain the model parameters and use the Adam (a stochastic optimization method with adaptive momentum) optimization algorithm to dynamically adjust the learning rate of different parameters, so that it performs more efficiently on parameters with different gradients. Specifically, the calculation formula for calculating the gap between the probability distribution of the model output and the true label using the cross-entropy loss function (Cross-EntropyLoss) is: , where N is the total number of entities / entity relations, C is the number of entity / entity relation categories, yij is the true category label, represented by one-hot encoding, if the (i)th entity / entity relation belongs to the (j)th category, then yij=1, otherwise yij=0, and pij is the probability predicted by the model that the i-th entity / entity relation belongs to the j-th category.

[0044] In one embodiment of the present invention, entity and relationship data are imported into a graph database to generate a knowledge graph, including: converting the entity and relationship data extracted from the TCM source data into the corresponding format of the graph database; importing the entity and relationship data after format conversion into the graph database to establish a knowledge graph. In this embodiment, after the entity and relationship data are extracted, in order to ensure the correspondence between the format of the entity and relationship data and the format of the graph database, the entity and relationship data also need to be converted into the corresponding format of the graph database. And, the entity and relationship data after format conversion is imported into the graph database, so as to achieve the establishment of a knowledge graph based on the entity and relationship data.

[0045] In a preferred embodiment of the present invention, the graph database can use Neo4j (a high-performance NOSQL graph database) graph database to implement the storage of the entity and relationship data after format conversion, and can connect the graph database by using py2neo (Py2neo is a library for connecting and operating Neo4j graph database in Python). After the entity and relationship data are labeled, the labeled entity and relationship data are converted into csv files, and then the concepts, attributes, relationships, etc. of the entity and relationship data after format conversion are matched and merged corresponding to the Neo4j graph database, and finally imported into the graph database to build a knowledge graph.

[0046] In a preferred embodiment of the present invention, when connecting the TCM model and the graph database, the built-in chain GraphCypherQAChain provided by LangChain (a built-in chain, encapsulated in LangChain, which can facilitate the use of the graph database for query) can be used to connect the TCM model and the graph database.

[0047] See also Figure 5When constructing the knowledge graph, the UIE model is used to extract the entities and relationship data in the TCM source data. When extracting entities, it can be processed by the automatic annotation system. For example, when the TCM source data is "Children's salt asthma cough, Jiang Jin's treatment of phlegm and asthma prescription 2. Use sea cucumber, scrape, grind into fine powder, eat with white sugar, and it will be cured", the disease "salt asthma", the symptom "asthma and cough", the prescription "Jiang Jin's treatment of phlegm and asthma prescription 2", the drugs "sea cucumber" and "white sugar", and the recovery is "cured". When extracting relationships, for example, in "Children's salt asthma cough, Jiang Jin's treatment of phlegm and asthma prescription 2. Use sea cucumber, scrape, grind into fine powder, eat with white sugar, and it will be cured", the disease prescription of "salt asthma" corresponds to "Jiang Jin's treatment of phlegm and asthma prescription 2", the symptom of "salt asthma" corresponds to "asthma and cough", and the prescription of "Jiang Jin's treatment of phlegm and asthma prescription 2" corresponds to "sea cucumber" and "white sugar". After obtaining entities and relationships, the entity and relationship data are integrated and the knowledge is stored in a third-party database. Then, through data framework matching, entity alignment, and knowledge storage, the Neo4j graph database is obtained to generate a knowledge graph.

[0048] In a preferred embodiment of the present invention, a natural language question is obtained and converted into a query statement instruction corresponding to an incomplete triple through the TCM model, including: performing entity and relationship detection on the natural language question; converting the existing entities and relationships in the detected natural language question into query statement instructions. In this embodiment, when a natural language question is input into the TCM model for retrieval, the TCM model will first perform entity and relationship detection on the natural language question to determine the existing entities and relationships in the natural language question, and then convert the existing entities and relationships into query statement instructions. In the existing entities and relationships, the entities that constitute the triples are missing relative to the knowledge graph subgraph, and therefore, the triples corresponding to the existing entities and relationships are incomplete.

[0049] In one embodiment of the present invention, according to the query statement instruction, the corresponding knowledge graph subgraph is searched in the graph database, including: according to the existing entities and relationships corresponding to the query statement instruction, the missing entity detection of the knowledge graph subgraph is performed in the graph database to obtain the knowledge graph subgraph. In this embodiment, after determining the existing entities and relationships and their corresponding query statement instructions, when querying the corresponding knowledge graph subgraph in the graph database according to the query statement instruction, the missing entity detection of the knowledge graph subgraph can be performed in the graph database, and then the corresponding knowledge graph subgraph is obtained, which includes the existing entities and relationships corresponding to the query statement instruction and the missing entities corresponding to the missing entity detection.

[0050] See also Figure 6, the natural language question is converted into a Cypher statement, the instruction is "You are a neo4j Cypher expert, please generate a Cypher query statement based on the given graph Schema and question"; Node properties include "doctor, disease, prescription, drug cause, treatment principle and method, symptoms, pulse, syndrome"; The relationships are "(doctor)-[doctor's disease]->(disease), (disease)-[cause]->(cause), (disease)-[prescription]->(prescription), question" "What are the diseases related to the doctor Cheng Liuru?"}", ""Output" "MATCH (jdoctor {name "Cheng Liuru"})-[doctor's disease]->(ddisease)", "ETURN d.name(disease)-[disease treatment]->(treatment principle and treatment method),(disease)-[symptoms]->(symptoms),(disease)-[disease pulse]->(pulse condition),(disease)-[disease syndrome]->(syndrome),(prescription)-[prescription reduction]->(drug),(prescription)-[prescription and medicine]->(drug)(syndrome)-[syndrome treatment]->(treatment principle and treatment method),(syndrome)-[syndrome prescription]->(prescription)". Among them, the natural language question is "What are the diseases related to the doctor Cheng Liuru?", and the converted output cypher statement is "MATCH(jdoctor {name "Cheng Liuru"})-[doctor disease]->(ddisease) RETURN d.name".

[0051] Specifically, among all knowledge graphs in the graph database, when some entities and relationships in the knowledge graph are consistent with existing entities and relationships, and the existing entities and relationships are missing entities relative to the knowledge graph, the corresponding knowledge graph including the complete entities and relationships is output; wherein the complete entities and relationships include two partial entities and the relationship between the two partial entities. The two partial entities are the existing entity and the missing entity, respectively.

[0052] In a preferred embodiment of the present invention, the knowledge graph can be represented as a set of triples G={(j,r,k)}, where j is the head entity, k is the tail entity, and r is the relationship between the two. A can be used to represent the entity set consisting of j and k, and B represents the relationship set between j and k. When querying the graph, an incomplete triple (j,r,?) or (?,r,k) is given as the query condition, and the goal of the query is to find the missing entity (represented by ?). The nodes (Node) and relationships (Relationship) are specified through the MATCH (a syntax that can quickly detect expressions) statement. The graph database searches for matching subgraphs in the graph based on these conditions, finds the missing entities, and feeds the query results back to the large language model to generate answers.

[0053] In one embodiment of the present invention, when using query statement instructions to search for knowledge graph subgraphs in the Neo4j graph database, a plug-in APOC (Awesome Procedure on Cypher) can be added to supplement the complex graph algorithms and data operation functions that Cypher (query statement instructions) cannot provide.

[0054] Furthermore, in order to enhance the interaction between clinical medical experts and the TCM big model, an effective feedback mechanism can be established, and the TCM big model can be used to assist clinical medical experts in making diagnostic decisions. Medical experts review the TCM big model questions and answers, and modify and save the information that does not meet the preference requirements. The TCM big model is iteratively optimized through supervised learning for the questions that do not meet the preference requirements, thereby achieving continuous improvement of the TCM big model preference alignment and continuous improvement of the feedback mechanism.

[0055] like Figure 7 As shown, in one embodiment of the present invention, the present invention also provides a TCM big model construction system 11, including: a dialogue generation unit 111, used to obtain TCM source data and generate big model dialogue data; a data set establishment unit 112, used to establish a TCM data set based on the big model dialogue data; a model training unit 113, used to perform model training on the TCM data set to obtain a TCM big model; a data extraction unit 114, used to extract entity and relationship data from the TCM source data; a graph creation unit 115, used to import entity and relationship data into a graph database to generate a knowledge graph; a model communication unit 116, used to connect the TCM big model and the graph database; a statement conversion unit 117, used to obtain natural language questions and convert them into query statement instructions corresponding to incomplete triples through the TCM big model; a graph query unit 118, used to search for corresponding knowledge graph subgraphs in the graph database according to the query statement instructions; and a model retrieval unit 119, used to perform context expansion on the complete triples corresponding to the knowledge graph subgraph through the TCM big model according to the found knowledge graph subgraph to obtain an answer.

[0056] In this embodiment, in the TCM big model construction system 11 of the present invention, the acquisition of TCM source data can be realized by generating a dialogue unit 111, and the big model dialogue data for model training is generated according to the acquired TCM source data. The big model dialogue data can be further processed by the data set establishment unit 112 to establish a TCM data set. Further, the basic model of the TCM big model is trained by the model training unit 113 using the established TCM data set, so as to obtain the TCM big model. After the TCM source data is acquired by generating a dialogue unit 111, the entity and relationship data in the TCM source data are further extracted by the data extraction unit 114. And after the entity and relationship data are extracted, the knowledge graph is further created by the graph creation unit 115 according to the entity and relationship data, and stored by the graph database. After the TCM big model and the graph database are obtained, the TCM big model and the graph database are connected by the model communication unit 116, so as to realize that when the natural language question is retrieved, the natural language question is converted into a query statement instruction by the sentence conversion unit 117. The query statement instruction is then used by the graph query unit 118 to search the corresponding knowledge graph subgraph in the graph database, and the knowledge graph subgraph is further used by the model retrieval unit 119 to accurately generate the desired answers to natural language questions in the TCM big model in accordance with human preferences.

[0057] It should be noted that the TCM model building system 11 provided in the above embodiment and the TCM model building method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs operations has been described in detail in the method embodiment and will not be repeated here. In actual applications, the TCM model building system 11 provided in the above embodiment can allocate the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.

[0058] See also Figure 8 The electronic device 1 may include a memory 12, a processor 13 and a bus, and may also include a computer program stored in the memory 12 and executable on the processor 13, such as a TCM model building program.

[0059] Among them, the memory 12 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 12 can be an internal storage unit of the electronic device 1, such as a mobile hard disk of the electronic device 1. In other embodiments, the memory 12 can also be an external storage device of the electronic device 1, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 1. Further, the memory 12 can also include both an internal storage unit of the electronic device 1 and an external storage device. The memory 12 can not only be used to store application software and various types of data installed in the electronic device 1, such as the code for constructing a large model of traditional Chinese medicine, but also can be used to temporarily store data that has been output or is to be output.

[0060] In some embodiments, the processor 13 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 13 is the control core (Control Unit) of the electronic device 1, and uses various interfaces and lines to connect the various components of the entire electronic device 1, and executes or executes programs or modules (such as a TCM model building program, etc.) stored in the memory 12, and calls the data stored in the memory 12 to execute various functions of the electronic device 1 and process data.

[0061] The processor 13 executes the operating system and various installed applications of the electronic device 1. The processor 13 executes the application to implement the steps in the above-mentioned method for constructing a large model of traditional Chinese medicine.

[0062] Exemplarily, the computer program can be divided into one or more modules, one or more modules are stored in the memory 12, and are executed by the processor 13 to complete the present application. One or more modules can be a series of computer program instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the computer program in the electronic device 1. For example, the computer program can be divided into a dialogue generation unit 111, a data set establishment unit 112, a model training unit 113, a data extraction unit 114, a graph creation unit 115, a model communication unit 116, a sentence conversion unit 117, a graph query unit 118, and a model retrieval unit 119.

[0063] The above-mentioned integrated unit implemented in the form of a software function module can be stored in a computer-readable storage medium, and the computer-readable storage medium can be non-volatile or volatile. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a computer device, or a network device, etc.) or a processor to perform part of the functions of the medical university model construction method in each embodiment of the present application.

[0064] In summary, the present invention discloses a method, system, electronic device and storage medium for constructing a large model of traditional Chinese medicine. By adopting a data processing method that combines self-supervision and supervised technologies, large model dialogue data is generated through data from three data sources: web crawlers, public data sets, and ancient medical records. A traditional Chinese medicine data set is established based on the large model dialogue data for model training to obtain a large model of traditional Chinese medicine, thereby improving the generalization degree of samples in the traditional Chinese medicine data set and greatly expanding the number of samples in the traditional Chinese medicine data set. At the same time, by extracting the entities and relationship data in the source data of traditional Chinese medicine, a knowledge graph is established, and then a connection is established between the traditional Chinese medicine model and the graph database storing the entities and relationship data, so that when the corresponding answer is retrieved using a natural language question, the corresponding query statement instruction is first generated in the traditional Chinese medicine model according to the natural language question, and then the knowledge graph subgraph with a complete triple is further found according to the query statement instruction, and the complete triple corresponding to the knowledge graph subgraph is expanded in context by the traditional Chinese medicine model according to the found knowledge graph subgraph, thereby enhancing the knowledge and content generation of the model itself, and enhancing the retrieval ability when retrieving using natural language questions, eliminating the model answer illusion, so that the model can accurately generate answers consistent with human preferences. In addition, by enhancing the interaction between clinical medical experts and the model, an effective feedback mechanism is established, and the traditional Chinese medicine model is continuously improved and perfected by using a supervised learning algorithm combined with new standardized data. Therefore, the present invention effectively overcomes various shortcomings in the prior art and has a high industrial utilization value.

[0065] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.

Claims

1. A method for constructing a large model of traditional Chinese medicine, characterized in that: The steps include: Obtain TCM source data and generate large model dialogue data; Based on the large model conversation data, a traditional Chinese medicine data set is established; Performing model training on the TCM data set to obtain a large TCM model; Extracting entity and relationship data from the TCM source data; Importing the entity and relationship data into a graph database to generate a knowledge graph; Connecting the TCM big model with the graph database; Obtaining a natural language question, and converting it into a query statement instruction corresponding to an incomplete triple through the TCM model; According to the query statement instruction, searching the corresponding knowledge graph subgraph in the graph database; According to the found knowledge graph subgraph, the complete triples corresponding to the knowledge graph subgraph are contextually expanded through the TCM big model to obtain the answer.

2. The method for constructing a large model of traditional Chinese medicine according to claim 1, characterized in that: Obtain TCM source data and generate large model dialogue data, including: Converting the TCM source data into text data; The text data is converted into question content and answer content corresponding to the large model dialogue data through a large language model.

3. The method for constructing a large model of traditional Chinese medicine according to claim 1, characterized in that: The TCM source data include public data sets in the field of TCM, TCM data on web pages extracted by crawler technology, and text-extracted data from ancient medical records.

4. The method for constructing a large model of traditional Chinese medicine according to claim 1, characterized in that: Extracting entity and relationship data from the TCM source data, including: Pre-extracting the entity and relationship data from the TCM source data through an information extraction model; Annotating and verifying the pre-extracted entity and relationship data in turn; Converting the data format of the verified entity and relationship data into a model pre-training format for the information extraction model; Fine-tuning the information extraction model based on the entity and relationship data in the model pre-trained format; The entity and relationship data in the TCM source data are extracted again through the fine-tuned information extraction model.

5. The method for constructing a large model of traditional Chinese medicine according to claim 1, characterized in that: Import the entity and relationship data into the graph database to generate a knowledge graph, including: Converting the entity and relationship data extracted from the TCM source data into a corresponding format of a graph database; The entity and relationship data after format conversion are imported into the graph database to establish the knowledge graph.

6. The method for constructing a large model of traditional Chinese medicine according to claim 1, characterized in that: Obtain a natural language question and convert it into a query statement instruction corresponding to an incomplete triple through the TCM model, including: Performing entity and relationship detection on the natural language question; The detected existing entities and relations in the natural language question are converted into the query statement instructions.

7. The method for constructing a large model of traditional Chinese medicine according to claim 6, characterized in that: According to the query statement instruction, searching the corresponding knowledge graph subgraph in the graph database includes: According to the existing entities and relationships corresponding to the query statement instructions, missing entity detection is performed on the knowledge graph subgraph in the graph database to obtain the knowledge graph subgraph.

8. A large model construction system for traditional Chinese medicine, characterized in that: include: A dialogue generation unit is used to obtain TCM source data and generate large model dialogue data; A data set establishment unit, used for establishing a traditional Chinese medicine data set based on the large model dialogue data; A model training unit, used for performing model training on the TCM data set to obtain a large TCM model; A data extraction unit, used for extracting entity and relationship data from the TCM source data; A graph creation unit, used to import the entity and relationship data into a graph database to generate a knowledge graph; A model communication unit, used to connect the TCM big model with the graph database; A sentence conversion unit, used for obtaining natural language questions and converting them into query sentence instructions corresponding to incomplete triples through the TCM big model; A graph query unit, used to search for a corresponding knowledge graph subgraph in the graph database according to the query statement instruction; as well as The model retrieval unit is used to perform context expansion on the complete triples corresponding to the knowledge graph subgraph through the TCM big model according to the found knowledge graph subgraph to obtain the answer.

9. An electronic device, characterized in that: The electronic device comprises: one or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, enables the electronic device to implement the method for constructing a large model of traditional Chinese medicine as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor of a computer, the computer is enabled to execute the method for constructing a large model of traditional Chinese medicine as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Knowledge graph generation type question answering method and system based on large language model

    CN117033608A

  • Traditional Chinese medicine question-answering system construction method based on large language model and knowledge graph

    CN118838996A

Cited By

  • Locomotive maintenance data standardization method and device, electronic equipment and storage medium

    CN120910585A

  • Data retrieval method for graph database, terminal equipment and server

    CN121144573A