Medical field retrieval enhancement method based on graph embedding, question and answer system and equipment
By adopting a search enhancement method based on graph embedding in the field of medicine, a problem map is constructed and graph embedding vector representation is obtained, the problems of semantic understanding fragmentation and information loss in the prior art are solved, and more accurate information retrieval and knowledge generation are achieved.
Patent Information
- Application Number
- CN202411872799.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2044-12-18
AI Technical Summary
The existing search-enhanced generation methods based on sentence vector models have problems of semantic understanding fragmentation and information loss in the medical field, and the knowledge retrieved directly using user questions may not be enough to guide the generation of high-quality answers.
The medical field search enhancement method based on graph embedding is adopted, and the data set is collected by collecting question-and-answer questions and answers in the medical field, problem classification and medical entity extraction are carried out, problem graph map is constructed, and the graph embedding is obtained as a vector representation of nodes through random walk and Word2Vec algorithm, and stored in the vector database, thereby improving the accuracy and relevance of information retrieval.
Effectively capture the correlation and semantic similarity between medical problems, improve the accuracy and relevance of information retrieval, and support accurate information retrieval and knowledge enhancement generation in the medical field.
Smart Images

Figure CN119807332A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of natural language processing of artificial intelligence, and specifically relates to a medical field retrieval enhancement method based on graph embedding, a question-answering system and a device. Background Art
[0002] As public health awareness continues to increase, the demand for medical knowledge is also increasing. The importance of medical knowledge in chronic disease management, rehabilitation treatment and personalized health guidance is becoming increasingly prominent. Especially for chronic diseases closely related to precision medicine such as cardiovascular disease, diabetes and chronic obstructive pulmonary disease, scientific, timely and personalized medical intervention is particularly important for alleviating the development of the disease. However, in today's society, there is still an imbalance in the distribution of medical resources and uneven medical levels, making it difficult for residents to obtain scientific and authoritative medical knowledge in a timely manner. Around 2023, the generative large language model (LLM) developed rapidly. Relying on the prior knowledge learned by LLM in the pre-training stage, it can communicate with users in any field. Therefore, people have also begun to try to use LLM to obtain medical-related knowledge.
[0003] However, considering that most LLMs are pre-trained based on general domain corpora, the prior knowledge they contain may be "general but not precise". Therefore, for tasks in specific fields, relevant corpora in that field are often required to "fine-tune" LLM. However, the tens of billions of parameters of LLM require high computing resources for "fine-tuning", which is unaffordable for most individual developers and small and medium-sized enterprises. In response to this, researchers proposed Retrieval-Augmented Generation (RAG), which relies on "external knowledge bases" to improve the accuracy and scientificity of LLM's answers. Specifically, when a user asks LLM a question in a health field, LLM will first retrieve relevant information from a large external document collection, and then use the retrieved information to guide the generation of text, thereby improving the quality and accuracy of the generated answers. This large external document collection is usually referred to as an "external knowledge base".
[0004] It can be seen that although RAG can improve the quality and accuracy of LLM's answers, its effect depends greatly on the "relevant information" retrieved from the external knowledge base. At present, the commonly used retrieval method is to first divide the knowledge in the external knowledge base into sentences, and call the sentence vector model to obtain the vector representation of the sentence, and then store these vector representations in the vector database. When the user asks a question, the sentence vector model is also called to obtain the vector representation of the user's question sentence, and the cosine similarity is calculated with the vector data in the vector database in turn to find the most similar N knowledge sentences, and based on this, a prompt is constructed to guide LLM to generate a more appropriate answer. Therefore, whether it is the vector representation of the sentence in the knowledge base or the vector representation of the user's question, it should be able to "sufficiently" represent the current sentence. However, RAG based on the current vector representation method has the following problems:
[0005] Currently, the vector representation of sentences is obtained through sentence vector models. However, traditional sentence vector models such as all-mpnet-base-v2 only focus on the semantic expression of the current sentence when generating the vector representation of each sentence, lacking the ability to model the relationship between sentences, which may lead to the fragmentation of semantic understanding and information loss.
[0006] At present, the RAG methods based on sentence vector models all retrieve relevant knowledge from the vector database based on the user's question. However, the knowledge retrieved directly using the question may only be sentences similar to the question, and does not contain the answer to the question. Therefore, the sentences retrieved directly using the "question" may not guide LLM to generate more reasonable answers. Summary of the invention
[0007] The present invention proposes a medical field retrieval enhancement method, device and storage medium based on graph embedding, which can at least solve one of the technical problems in the background technology.
[0008] To achieve the above object, the present invention adopts the following technical solutions:
[0009] A medical field retrieval enhancement method based on graph embedding includes the following steps:
[0010] S100, collecting a question-answer pair dataset in the medical field, and merging the questions in the question-answer pair dataset and the questions queried by the user to establish a question set;
[0011] S200, classify the sentences in the question set through the large language model LLM and determine the category of the corresponding department;
[0012] S300, for questions in the same category, extract the medical entities through the UIE model and construct a question map;
[0013] S400, based on the obtained problem graph, obtain a number of walk sequences through random walks, and then obtain the graph embedding of each node in the sequence as a vector representation of the node through the Word2Vec algorithm, and store it in a vector database;
[0014] S500, based on the user's question, retrieve the most similar N questions from the vector database, and construct a search prompt based on the answers corresponding to the N questions;
[0015] S600: Input the search prompt to the large language model LLM. After obtaining the search prompt, the generator uses the search prompt as additional context to generate a final answer.
[0016] Furthermore, the specific steps of step S100 are:
[0017] S110, collecting question-answer data in the medical field and obtaining the questions therein;
[0018] S120, merging the acquired questions with the questions queried by the user to form a question set;
[0019] S130. Construct the corresponding answers in the question set into an answer set.
[0020] Furthermore, the departments described in step S200 are composed of internal medicine, surgery, gynecology and pediatrics.
[0021] Furthermore, in step S300, the medical entities contained in each specific category of questions are extracted as keywords through the UIE model, and graph data is constructed using the keywords;
[0022] The medical entity contains a "probability" parameter, and only medical entities with a "probability" parameter value greater than 50% are retained; the graph data contains two types of nodes: extracted medical entities and question IDs.
[0023] Furthermore, the walking method in step S400 randomly walks in the graph n times through m walking objects to generate m*n walking paths;
[0024] There are two random walk paths, labeled p1 and p2:
[0025] p1={q1,e1,q2,e2,q4}
[0026] p2={q1,e1,q2,e2,q2}
[0027] Among them, q represents the problem node and e represents the entity node;
[0028] After obtaining m*n random paths, the embedding representation of each node in these paths is obtained through the Word2Vec algorithm;
[0029] The random walk path is regarded as a node sequence, and the Word2Vec algorithm is used to calculate the node embedding according to the principle that "similar nodes share similar neighbor nodes". Given the one-hot encoding h of the t-th node in the path p t , the vector representation of this node is w t It is expressed as:
[0030] w t =W*h t
[0031] Where w is a learnable parameter, given the representation w of the central node t .
[0032] Furthermore, the probability of occurrence of the step path p is:
[0033]
[0034] The training goal is to maximize this likelihood function and minimize the following loss function:
[0035]
[0036] Among them, t represents the position of the current node, T represents the length of the entire sequence, k represents the window size, and j represents the jth element in the current window of length k.
[0037] Furthermore, the specific steps of retrieving the most similar N questions from the vector database in step S500 are:
[0038] S510, through the retriever P with parameter η η (Z|q ′ i ) for user query q ′ i In the problem set Q ′ Retrieve the text collection Z from the source and provide it to the generator as additional context;
[0039] S520: For a given user query q ′ i , assuming its graph embedding is u q , corresponding to each element u in the ChromaDB vector database i (i∈0,…,N-1), use cosine similarity to calculate u q and u i Similarity between:
[0040]
[0041] S530, then select the top N elements with the highest similarity, which are the graph embeddings of the problem ID node in the corresponding graph, u qj u ij The vector (embedding) uq representing the user query and the j-th vector value in a vector ui in the vector database is a specific number.
[0042] On the other hand, the present invention also discloses a graph-embedded medical field retrieval question-answering system, which is used to implement the graph-embedded medical field retrieval question-answering method described above, including a graph-embedded builder, a retriever, and a generator;
[0043] The graph embedding builder is mainly used to extract the question set in the data set, classify it, extract entities to build graph data, and then obtain graph embedding through random walk phenomenon and Word2Vec algorithm to provide the retriever with the vector database required for similarity comparison;
[0044] The retriever is mainly used to compare the cosine similarity of the vector database and provide the generator with the data set required to generate the final answer;
[0045] The generator is mainly used to extract the data set provided by the retriever to produce the final answer to the question raised by the user.
[0046] On the other hand, a computer device includes a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any one of the above methods.
[0047] It can be seen from the above technical solution that the present invention provides a medical field retrieval enhancement method based on graph embedding. Compared with the prior art, the present invention has the following advantages:
[0048] 1. The present invention can better capture the correlation between medical questions by converting the question set in the medical field into a graph structure. In traditional RAG, questions are usually stored and indexed in a simple text format, ignoring the correlation and semantic similarity between sentences. The present invention constructs a question set and classifies the questions, combines the extraction of medical entities (such as parts, diseases, symptoms, drugs, etc.), and generates a graph structure containing rich medical knowledge, which can effectively represent the multi-level relationship between medical questions and entities, and improve the accuracy and relevance of information retrieval.
[0049] 2. The present invention adopts graph embedding technology, calculates the vector representation of nodes through random walk method, and converts each question into a high-dimensional vector containing the correlation between questions. This method can capture the semantic similarity between questions and entities, and obtain the graph embedding of questions as their vector representation through the Word2Vec algorithm model. After retrieving the most similar N questions from the vector database based on the query graph embedding, the prompt is constructed through their corresponding answers, and then the final answer is generated in combination with LLM. This multi-level retrieval and generation method not only enhances the system's understanding and reasoning ability of user questions, but also effectively supports accurate information retrieval and knowledge enhancement generation in the medical field.
[0050] In summary, the present invention solves the problems of insufficient precision and insufficient information in traditional medical information retrieval by introducing graph embedding technology, medical entity extraction, and multi-level retrieval and generation methods, and provides a more effective solution for accurate information retrieval and knowledge enhancement generation in the medical field, with significant technical advantages and application prospects. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 This is a flow chart of the index enhancement method of the present invention;
[0052] Figure 2 A schematic diagram of the process of constructing graph data of the present invention;
[0053] Figure 3 Schematic diagram of the random walk phenomenon in the present invention;
[0054] Figure 4 A schematic diagram of generating a final answer through the retrieved results in the present invention;
[0055] Figure 5 Schematic diagram of the model structure of the method of the present invention. DETAILED DESCRIPTION
[0056] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. In the absence of conflict, the embodiments in this application and the features in the embodiments can be combined with each other. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0057] The embodiment of the present invention aims to propose a medical field retrieval enhancement generation method based on graph embedding to improve the performance of LLM in medical field question answering tasks. The main technical problems solved by the present invention are as follows:
[0058] The first problem that the embodiments of the present invention are intended to solve is the limitation of the current sentence vector model, that is, it cannot reflect the correlation between sentences. At present, the RAG method usually generates a vector representation of a sentence through a sentence vector model, such as all-mpnet-base-v2. However, this type of traditional sentence vector model only focuses on the semantic expression of a single sentence when generating a vector representation, and lacks the ability to model the relationship between sentences. This limitation may lead to the fragmentation of semantic understanding and information loss, and it is difficult to accurately capture the intrinsic connection of contextual information or related knowledge. Therefore, it is considered to first construct the sentences in the form of a graph structure, and model the correlation between sentences through graph embedding.
[0059] The second problem that the embodiment of the present invention intends to solve is how to construct sentences into graphs. Sentence text, as a kind of unstructured data, is difficult to directly convert into graph data, so a method is needed to construct sentences into graphs. You can try to extract medical entities in sentences as keywords, connect sentences with the same keywords to form graph data. Then, obtain the graph embedding of each sentence node in the graph through random walks as the vector representation of the sentence.
[0060] The third problem that the embodiments of the present invention are intended to solve is the disconnection between knowledge retrieval and answer generation. The existing RAG method retrieves relevant knowledge in the vector database based on the user's question. However, the knowledge retrieved directly using the user's question is often only a sentence that is semantically similar to the question, and may not contain the exact answer to the question. Such retrieval results may not be sufficient to provide key information to support LLM to generate high-quality answers, resulting in limited rationality and accuracy of the generated results.
[0061] Therefore, an embodiment of the present invention aims to propose an improved method to solve the above problems by obtaining a graph embedding representation of a sentence to enhance its relational modeling capability and optimize the collaborative mechanism of knowledge retrieval and answer generation.
[0062] The following is a detailed description with reference to the accompanying drawings:
[0063] like Figure 1 As shown, the medical field retrieval enhancement method based on graph embedding proposed in the embodiment of the present invention includes the following specific steps:
[0064] S100, collect a question-answer pair dataset in the medical field, merge the questions in the question-answer pair dataset and the questions queried by the user to establish a question set, the specific steps are:
[0065] S110, collecting question-answer data in the medical field and obtaining the questions therein;
[0066] In one example, the question-answer pair data can be collected through the public dataset CMedQA V1.0 to obtain the questions therein;
[0067] In another example, the question-answer pair data can be collected through the public dataset CMedQA V2.0 to obtain the questions therein;
[0068] In another example, question-answer pair data can be collected by publicly using Chinese medical dialogue datasets, Huatuo-26M datasets, and MedDG datasets to obtain the questions therein;
[0069] S120, merging the acquired questions with the questions queried by the user to form a question set;
[0070] S130. Construct the corresponding answers in the question set into an answer set.
[0071] S200, classify the sentences in the question set question set through the large language model LLM, and determine the category of the corresponding department;
[0072] In one embodiment, if Figure 2 As shown, the departments are composed of internal medicine, surgery, gynecology and pediatrics. The sentences in the question set are divided into four categories: "internal medicine, surgery, gynecology and pediatrics". For all sentences in the question set, LLM (ChatGLM is used in the present invention) is used to classify them according to the department that the patient should visit. Assume that the sentence to be classified is the question with ID 2902 in the question set: "Can a one-year-old baby take amoxicillin for vomiting?"; Based on the template "The question raised by the patient is: [question], please select the department that the patient's question is most likely to correspond to from the four categories of "internal medicine", "surgery", "gynecology" and "pediatrics"; limited to these four departments, do not classify to other departments" to build a prompt and enter it into LLM; LLM selects the query classification from "internal medicine", "surgery", "gynecology" and "pediatrics"; considering that the generative model may not always output the results in the expected format, the present invention adds four rounds of pre-dialogue and manually reviews the final output.
[0073] S300, for questions in the same category, extract the medical entities through the UIE model and construct a question graph;
[0074] In one embodiment, if Figure 2As shown in the figure, medical entities in sentences are extracted and graph data is constructed. For the classified sentences in the question set, the UIE model provided by PaddleNLP (a natural language processing development library) is used to extract the medical entities of "part", "disease", "symptom" and "drug" from the question sentences; taking the sentence with ID 2902 as an example, the entities extracted by the UIE model are as follows Figure 2 As shown. It is worth noting that the entity has a "probability" parameter, and only entities with a value greater than 50% are retained. The judgment of the "probability" parameter uses the UIE model to extract entities in the sentence; the input of the UIE model is the sentence of the entity to be extracted. For example, if "Can a one-year-old baby take amoxicillin when vomiting?" is input into the UIE model, its output is:
[0075] [{'Symptoms':[{'end':6,'probability':0.993517213015167,'start':4,'text':'Vomiting'}],'Medications':[{'end':13,'probability':0.9730174568528014,'start':9,'text':'Amoxicillin'}]}]
[0076] It includes the entity's starting position, ending position, entity name, and probability. The above process is implemented in a python script. Python is then used to determine whether the probability is greater than 0.5. Entities with a probability greater than 0.5 are retained, and entities with a probability less than or equal to 0.5 are discarded.
[0077] According to the above, the medical entities contained in each specific category of questions are extracted as their keywords, and then the keywords are used to construct graph data; Figure 2 As shown, in the given graph data, there are two types of nodes: extracted medical entities and question IDs; edges (indicating that the entity is included in the question) only exist between the entity and question ID nodes, indicating that these medical entities exist in the question; there are no edges between entity nodes and between question ID nodes; follow the above steps to use the Networkx package in Python to save the graph data corresponding to the four categories.
[0078] S400, based on the obtained question graph, a graph embedding is obtained by using a random walk method and a Word2Vec algorithm, and used as a vector representation of a node in the question graph;
[0079] In one embodiment, the four graph data are obtained, and graph embedding is obtained by random walk method and Word2Vec method (the working principle of Word2Vec method is "similar words share similar contexts"); after obtaining four subgraphs, random walk and Word2Vec are used to calculate embedding for each node in the graph data; the core idea of this method is that nodes with similar contexts in the walking path are likely to have similar embedding characteristics; specifically, m walkers randomly walk n times in the graph, thereby generating m*n walking paths.
[0080] The walk method randomly walks n times in the graph through m walker objects, generating m*n walk paths;
[0081] like Figure 3 As shown, there are two random walk paths, labeled p1 and p2:
[0082] p1={q1,e1,q2,e2,q4}
[0083] p2={q1,e1,q2,e2,q2}
[0084] Among them, q represents the problem node and e represents the entity node;
[0085] After obtaining m*n random paths, the embedding representation of each node in these paths is obtained through the Word2Vec algorithm;
[0086] The random walk path is regarded as a node sequence, and the Word2Vec algorithm is used to calculate the node embedding according to the principle that "similar nodes share similar neighbor nodes". Given the one-hot encoding h of the t-th node in the path p t , the vector representation of this node is w t It is expressed as:
[0087] w t =W*h t
[0088] Where w is a learnable parameter, given the representation w of the central node t ;
[0089] The probability of Lu Jin p appearing is:
[0090]
[0091] The training goal is to maximize this likelihood function and minimize the following loss function:
[0092]
[0093] Among them, t represents the position of the current node, T represents the length of the entire sequence, k represents the window size, and j represents the jth element in the current window of length k.
[0094] S500: based on the user's query, retrieve the most similar N questions from the vector database, and construct a search prompt using the answers corresponding to the N questions. The specific implementation steps are:
[0095] S510, through the retriever P with parameter η η (Z|q ′ i ) for user query q ′ i In the problem set Q ′ Retrieve the text collection Z from the source and provide it to the generator as additional context;
[0096] S520: For a given user query q ′ ′ , assuming its graph embedding is u q , corresponding to each element u in the ChromaDB vector database i (i∈0,…,N-1), use cosine similarity to calculate u q and u i Similarity between:
[0097]
[0098] S530, then select the top N elements with the highest similarity, which are the graph embeddings of the problem ID node in the corresponding graph, u qj u ij The vector (embedding) uq representing the user query and the j-th vector value in a vector ui in the vector database is a specific number.
[0099] S600, inputting the search prompt to the large language model LLM, after obtaining the search prompt, the generator uses the search prompt as additional context to generate a final answer;
[0100] like Figure 4 As shown, the user's query q i i The retrieved result set Z is used to form a new prompt based on the template, which is then input into the generative LLM. Finally, the LLM generates the answer generated by the RAG optimized by this method.
[0101] In one embodiment, let the user's query x be "What is the cause of back pain?", and the graph-embedded medical field search and answer system retrieves similar answers z1 from the vector database: "According to the description, it is considered to be a lumbar disc herniation, accompanied by discomfort in the right lower limb", Z2: "There are many causes of low back pain, such as lumbar muscle strain, herniated disc, etc.", and then constructs a prompt "Please imitate the tone of an experienced doctor and briefly answer the patient's question "x: What is the cause of back pain?" You can refer to z1: "According to the description, it is considered to be a lumbar disc herniation, accompanied by discomfort in the right lower limb" and z2: "There are many causes of low back pain, such as lumbar muscle strain, herniated disc, etc." as appropriate, and input the constructed prompt into the large language model LLM, and finally input it into the large language model LLM to generate the result "Hello, based on the symptoms you described, it may be caused by lumbar disc herniation or lumbar muscle strain. It is recommended that you seek medical attention immediately and receive professional examination and treatment. ".
[0102] In summary, the present invention proposes a medical field retrieval enhancement method based on graph embedding representation by obtaining question-answering (QA) data in the medical field. These data come from public data sets, such as the CMedQA data set. All the questions Q in the CMedQA data set are taken out and merged with the user's query to construct a question set. For the sentences in the question set, LLM is first used to classify the questions in the question set, and by constructing prompts, LLM is allowed to determine which department of "Internal and External Medicine, Gynecology and Pediatrics" the question belongs to. Next, for the questions belonging to a certain department, the UIE model is first used to extract the medical entities contained therein. The types of these medical entities include: "part", "disease", "symptom" and "drug". Then, a graph is constructed based on the medical entities contained in the question. There are two types of nodes in the graph: a question belonging to a certain department, and a medical entity extracted from the question. If a question contains a medical entity, it is connected, that is, there is an edge between the two nodes. Through the above method, four question graphs can be obtained, each of which corresponds to a department in "Internal and External Medicine, Women and Children". Then, the vector representation of the nodes in each graph, i.e., graph embeddings, can be calculated by the random walk method. The random walk method is used to randomly walk between the nodes in the graph, and finally a number of sequences of length l are obtained, which contain the nodes visited by the random walk. Based on the idea that "nodes with similar contexts must be similar", the vector representation of each node in the sequence, i.e., the graph embedding of each node, is obtained by calling the Word2Vec algorithm. The graph embeddings of the questions in the four graphs calculated are used as their vector representations and stored in four vector databases ChromaDB. At this point, the graph embedding of the user's query is obtained. The most similar N questions (questions) can be found from the vector database of the corresponding department according to the cosine similarity, and their answers (the answers corresponding to the N questions) are returned as the search results of RAG. Based on these answers, a prompt is constructed and input into LLM to obtain the final answer. Considering that the prompt contains relevant answers retrieved from the user's query, it can guide the LLM to generate more scientific and appropriate answers, enhance the model's understanding and reasoning ability of user questions, and better support accurate information retrieval and knowledge enhancement generation in the medical field.
[0103] On the other hand, Figure 5 As shown, the embodiment of the present invention also discloses a graph-embedded medical field retrieval question-answering system;
[0104] The question answering system includes: graph embedding builder, retriever and generator;
[0105] The graph embedding builder is mainly used to extract the question set in the CMedQA dataset, classify it, extract entities to build graph data, and then obtain graph embedding through the random walk phenomenon and Word2Vec algorithm to provide the retriever with the vector database required for similarity comparison;
[0106] The retriever is mainly used to compare the cosine similarity of the vector database and provide the generator with the data set required to generate the final answer;
[0107] The generator is mainly used to extract the data set provided by the retriever to produce the final answer to the question raised by the user.
[0108] On the other hand, the present invention further discloses a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above method.
[0109] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any of the medical field retrieval enhancement methods based on graph embedding in the above embodiments.
[0110] It is understandable that the system, device and storage medium provided in the embodiments of the present invention correspond to the method provided in the embodiments of the present invention, and the explanation, examples and beneficial effects of the relevant contents can refer to the corresponding parts in the above methods.
[0111] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0112] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0113] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0114] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A medical field retrieval enhancement method based on graph embedding, characterized in that: The following steps are involved: S100, collecting a question-answer pair dataset in the medical field, and merging the questions in the question-answer pair dataset and the questions queried by the user to establish a question set; S200, classify the sentences in the question set through the large language model LLM and determine the category of the corresponding department; S300, for questions in the same category, extract the medical entities through the UIE model and construct a question map; S400, based on the obtained problem graph, obtain a number of walk sequences through random walks, and then obtain the graph embedding of each node in the sequence as a vector representation of the node through the Word2Vec algorithm, and store it in a vector database; S500, based on the user's question, retrieve the most similar N questions from the vector database, and construct a search prompt based on the answers corresponding to the N questions; S600: Input the search prompt to the large language model LLM. After obtaining the search prompt, the generator uses the search prompt as additional context to generate a final answer.
2. The medical field retrieval enhancement method based on graph embedding according to claim 1, characterized in that: The specific steps of step S100 are: S110, collecting question-answer data in the medical field and obtaining the questions therein; S120, merging the acquired questions and the questions queried by the user to form a question set; S130. Construct the corresponding answers in the question set into an answer set.
3. The medical field retrieval enhancement method based on graph embedding according to claim 1 is characterized in that: The departments described in step S200 include internal medicine, surgery, gynecology and pediatrics.
4. The medical field retrieval enhancement method based on graph embedding according to claim 1, characterized in that: In the step S300, the medical entities contained in each set category of questions are extracted as keywords through the UIE model, and the keywords are used to construct graph data; The medical entity contains a "probability" parameter, and only medical entities with a "probability" parameter value greater than 50% are retained; the graph data contains two types of nodes: extracted medical entities and question IDs.
5. The medical field retrieval enhancement method based on graph embedding according to claim 1, characterized in that: The random walk method in step S400 generates m*n walk paths by randomly walking m walker objects in the graph n times; There are two random walk paths, labeled p1 and p2: p1={q1,e1,q2,e2,q4} p2={q1,e1,q2,e2,q2} Among them, q represents the problem node and e represents the entity node; After obtaining m*n random paths, the graph embedding representation of each node in these paths is obtained through the Word2Vec algorithm; The random walk path is regarded as a node sequence, and the Word2Vec algorithm is used to calculate the node embedding based on the principle that similar nodes share similar neighbor nodes. Given the one-hot encoding h of the t-th node in the path p, t , the vector representation of the node w t It is expressed as: w t =W*h t Where w is a learnable parameter, given the vector representation w of the central node t .
6. The medical field retrieval enhancement method based on graph embedding according to claim 5, characterized in that: The probability of occurrence of the path p is: The training goal is to maximize this likelihood function and minimize the following loss function: Among them, t represents the position of the current node, T represents the length of the entire sequence, k represents the window size; j represents the jth element in the current window of length k.
7. The medical field retrieval enhancement method based on graph embedding according to claim 6 is characterized in that: The specific steps of retrieving the most similar N questions from the vector database in step S500 are: S510, through the retriever P with parameter η η (Z|q ′ i ) for user query q i i In the problem set Q ′ Retrieve the text collection Z from the source and provide it to the generator as additional context; S520: For a given user query q ′ i , assuming its graph embedding is u q , corresponding to each element u in the ChromaDB vector database i , i∈0,…,N-1, use cosine similarity to calculate u q and u i Similarity between: S530, then select the first N elements with the highest similarity, which are the graph embeddings of the problem ID node in the corresponding graph, u qj u ij The vector representing the user query is the j-th vector value embedded in uq and a vector ui in the vector database, which is a specific number.
8. A graph-embedded medical field search and answering system, used to implement the graph-embedded medical field search and answering method according to any one of claims 1 to 7, characterized in that: Includes graph embedding builders, retrievers, and generators; The graph embedding builder is mainly used to extract the question set in the data set, classify it, extract entities to build graph data, and then obtain graph embedding through the random walk phenomenon and Word2Vec algorithm to provide the retriever with the vector database required for similarity comparison; The retriever is mainly used to compare the cosine similarity of the vector database and provide the generator with the data set required to generate the final answer; The generator is mainly used to extract the data set provided by the retriever to produce the final answer to the question raised by the user.
9. A computer device comprising a memory and a processor, characterized in that: The memory stores a computer program, and when the computer program is executed by the processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Semantically sensitive knowledge graph random walk sampling method
CN111444317A
Construction and application method of teaching and employment auxiliary knowledge graph
CN115544268A
Intelligent question and answer implementation method and system based on large model and semantic map
CN117271724A
Semantic search method and related device
CN117992585A
Context-based search query formation
EP2820578A1
Cited By
Retrieval enhancement generation method and device based on knowledge graph in medical education scene
CN120067137A
Medical entity linking
US20260252591A1