Method, system, terminal and storage medium for constructing medical knowledge graph based on large language model
By preprocessing and deduplicating medical text information using methods based on large language models, the difficulty in knowledge fusion and duplication in the construction of knowledge graphs caused by multiple data sources is solved, and the structured presentation and concise and accurate extraction of medical knowledge are achieved. , improve the dissemination and popularization of medical knowledge.
Patent Information
- Application Number
- CN202410918507.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-10
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2044-07-10
AI Technical Summary
In the process of building a medical knowledge graph, multiple data sources lead to differences in knowledge descriptions, leading to difficulties in knowledge fusion and duplication.
A method based on a large language model is used to preprocess medical text information, extract triples, and construct a medical knowledge graph through deduplication processing and vectorization similarity judgment to ensure data accuracy and simplicity.
It improves the availability of medical data, reduces redundant information, ensures that the extracted knowledge is concise and accurate, is suitable for professional medical treatment and the general public, and improves the dissemination and popularization of medical knowledge.
Smart Images

Figure CN118469005B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence technology, and specifically relates to a method, system, terminal and storage medium for constructing a medical knowledge graph based on a large language model. Background Art
[0002] With the gradual maturity of technologies such as natural language processing, medical artificial intelligence has become a strong driving force for the development of the industry. However, in order for machines to be intelligent and able to understand and think like humans, they must have knowledge. In the medical field where the degree of specialization is concentrated, this knowledge often comes from content that has undergone strict industry review and reached consensus within the industry, such as textbooks, clinical guidelines, clinical pathways and other materials. However, most of these materials are presented in an unstructured form, with complex data processing and high development barriers, which limits the release of knowledge capabilities.
[0003] In the previous knowledge graph construction process, models are generally used to identify entities and relationships, and then knowledge fusion and knowledge storage are performed. Due to the large volume of knowledge graphs, it is difficult to ensure the accuracy of data when producing data on a large scale. In the process of building a knowledge graph, there will be multiple data sources, and different data sources may have different descriptions of knowledge, resulting in difficulties and duplications when fusing knowledge from different sources. Summary of the invention
[0004] In the process of constructing knowledge graphs in the prior art, there are multiple data sources, and the descriptions of knowledge from different data sources may be different, resulting in difficulties and duplications when integrating knowledge from different sources. The present invention provides a method, system, terminal and storage medium for constructing a medical knowledge graph based on a large language model to solve the above technical problems.
[0005] In a first aspect, the present invention provides a method for constructing a medical knowledge graph based on a large language model, comprising:
[0006] Preprocess the historical medical text information acquired in advance to obtain source split sentences;
[0007] Based on the source split sentence, the triples required for building the medical knowledge graph are extracted to obtain a triple list;
[0008] The first entity, the last entity, and the attributes corresponding to the first entity and the last entity in each triple extracted are converted into vectors, and the triple list is deduplicated based on the similarity of the attributes corresponding to each first entity, the last entity, and the first entity and the last entity in the triple list;
[0009] Import the deduplicated triple list into the graph database, and use the graph database to build a medical knowledge graph.
[0010] Furthermore, the previously acquired historical medical text information is preprocessed to obtain source split sentences, including:
[0011] Traversing the historical medical text information acquired in advance, when full-width spaces and half-width spaces appear, deleting the full-width spaces and half-width spaces in the medical text information;
[0012] When punctuation marks or special characters indicating the end of a sentence appear, the medical text information is split to obtain a plurality of split sentences, wherein the punctuation marks indicating the end of a sentence include a period, a semicolon, an exclamation mark, and a question mark, and the special characters include a tab character, a carriage return character, and a line feed character;
[0013] Add source information with quotation marks before each split sentence and record it as a source split sentence.
[0014] Furthermore, based on the source split sentences, the triples required for building the medical knowledge graph are extracted to obtain a triple list, including:
[0015] When traversing the first source split sentence, the pre-created keyword list is empty, a medical keywords in the first source split sentence are found, put into the keyword list, and the trained large language model is used to annotate the triples in the first source split sentence;
[0016] When traversing the mth source split sentence, find b medical keywords in the mth source split sentence, and determine whether the b medical keywords are in the current keyword list. If c medical keywords among the b medical keywords are in the current keyword list, then according to the formula Calculate whether the triples in the mth source split sentence need to be labeled. If p is greater than the preset threshold, the triples in the mth source split sentence are not labeled; if p is less than or equal to the preset threshold, the trained large language model is used to label the triples in the mth source split sentence, where K is the number of keywords recognized in the current sentence that overlap with the current keyword list, and M is the total number of keywords recognized in the current sentence;
[0017] And so on, until all source split sentences are traversed and all the labeled source split sentence triplets are obtained.
[0018] Furthermore, it also includes:
[0019] The steps to verify the accuracy of extracting the triples required to build the medical knowledge graph include:
[0020] Input source split sentence;
[0021] Based on the input source split sentence, output the extracted triples, based on the formula: accuracy , calculate the accuracy of the extracted triples;
[0022] If the accuracy is greater than or equal to the preset accuracy threshold, the verification is passed;
[0023] If the accuracy is less than the preset accuracy threshold, the verification fails and fine-tuning continues.
[0024] Further, the first entity, the last entity, and the attributes corresponding to the first entity and the last entity in each triple extracted are converted into vectors, and the triple list is deduplicated based on the similarity of the attributes corresponding to each first entity, the last entity, and the first entity and the last entity in the triple list, including:
[0025] The triple includes a first entity, a last entity, and attributes corresponding to the first entity and the last entity;
[0026] Determine the similarity between each extracted first entity and the first entity, the similarity between the last entity and the last entity, and the similarity between the attributes corresponding to the first entity and the last entity and the attributes corresponding to the first entity and the last entity;
[0027] If the determined similarity is greater than or equal to a preset similarity threshold, then deleting the attributes corresponding to the first entity, the last entity, or the first entity and the last entity corresponding to the similarity greater than or equal to the preset similarity threshold;
[0028] If the determined similarity is less than a preset similarity threshold, the attributes corresponding to the first entity, the last entity, or the first entity and the last entity corresponding to the similarity less than the preset similarity threshold are retained.
[0029] Further, determining the similarity between each extracted first entity and the first entity, the similarity between the last entity and the last entity, and the similarity between the attributes corresponding to the first entity and the last entity and the attributes corresponding to the first entity and the last entity, including:
[0030] Create a new vector database, use the BEG model to convert each extracted first entity, last entity, and the text of the attributes corresponding to the first entity and last entity into a vector, and put each vector into the newly created vector database;
[0031] Based on the formula , determine the similarity of the angle between any two vectors. If the angle between any two vectors is greater than or equal to the preset similarity threshold, the two vectors are similar. Then delete the first entity, the last entity, and the attributes corresponding to the first entity and the last entity corresponding to any one of the vectors, where A and B are any two vectors;
[0032] If the angle between any two vectors is less than a preset similarity threshold, the two vectors are dissimilar, and the first entity, the last entity, and the attributes corresponding to the first entity and the last entity corresponding to the two vectors are retained.
[0033] Furthermore, the method further includes: updating the constructed medical knowledge graph, specifically including:
[0034] A new vector library is created, and the first entity, the last entity, and the attributes corresponding to the first entity and the last entity in the knowledge graph to be updated are extracted, and the extracted first entity, the last entity, and the attributes corresponding to the first entity and the last entity are converted into a first vector group using the BEG model, and each vector in the first vector group is placed into the new vector library;
[0035] Using the BEG model, outputting the retained first entity, last entity, and attributes corresponding to the first entity and last entity, converting the output first entity, last entity, and attributes corresponding to the first entity and last entity into a second vector group, and placing each vector in the second vector group into the newly created vector database;
[0036] Based on the vectors in the newly created vector database, the similarity of the angle between any two vectors is determined. If the angle between any two vectors is greater than or equal to a preset similarity threshold, the two vectors are similar. Then, the first entity, the last entity, and the attributes corresponding to the first entity and the last entity corresponding to any one of the vectors are deleted.
[0037] If the angle between any two vectors is less than a preset similarity threshold, the two vectors are dissimilar, and the first entity, the last entity, and the attributes corresponding to the first entity and the last entity corresponding to the two vectors are retained;
[0038] Based on all the retained vectors, the first entity, the last entity and the attributes corresponding to the first entity and the last entity corresponding to all the retained vectors are output to construct an updated medical knowledge graph.
[0039] In a second aspect, the present invention provides a medical knowledge graph construction system based on a large language model, comprising:
[0040] The preprocessing module develops a python script to preprocess the pre-acquired historical medical text information and obtain source split sentences;
[0041] The triple extraction module extracts the triples required for building the medical knowledge graph based on the source split sentence and obtains the triple list;
[0042] A similarity judgment module is used to convert the first entity, the last entity, and the attributes corresponding to the first entity and the last entity in each triple extracted into vectors through the Faiss vector library, and perform deduplication processing on the triple list based on the size of the similarity of each first entity, the last entity, and the attributes corresponding to the first entity and the last entity in the triple list;
[0043] The medical knowledge graph construction module imports the deduplicated triple list into the graph database and uses the graph database to build a medical knowledge graph.
[0044] In a third aspect, a terminal is provided, including:
[0045] processor, memory, wherein:
[0046] The memory is used to store computer programs.
[0047] The processor is used to call and run the computer program from the memory, so that the terminal executes the above-mentioned terminal method.
[0048] According to a fourth aspect, a computer storage medium is provided, wherein the computer-readable storage medium stores instructions, and when the instructions are executed on a computer, the computer executes the methods described in the above aspects.
[0049] The beneficial effects of the present invention are that the method, system, terminal and storage medium for constructing a medical knowledge graph based on a large language model provided by the present invention can present textbooks, clinical guidelines, clinical pathways and other materials in a structured manner by splitting and annotating sentences in medical text information, greatly improving the availability of medical materials and documents; by only annotating sentences that need to be annotated and deleting triples with high similarity, not only unnecessary information processing is avoided and efficiency is improved, but also the presentation of redundant information in medical text information is avoided, ensuring that the extracted medical knowledge is more concise and accurate. The medical information processed by these technical means in this application can be used not only by professional medical personnel, but also by the general public. By structuring, simplifying and refining complex medical knowledge, non-professionals can also more easily understand and use this information, thereby improving the dissemination and popularization of medical knowledge.
[0050] In addition, the invention has a reliable design principle, a simple structure and a very broad application prospect. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0052] Figure 1 is a schematic flow chart of a method according to an embodiment of the present invention.
[0053] Figure 2 It is a schematic flow chart of the preprocessing of the method according to one embodiment of the present invention.
[0054] Figure 3 It is a schematic flowchart of the verification and extraction accuracy of triples required for constructing a medical knowledge graph according to a method of an embodiment of the present invention.
[0055] Figure 4 It is a schematic flow chart of determining the similarity of each extracted triplet according to a method of an embodiment of the present invention.
[0056] Figure 5 It is a schematic flowchart of a method according to an embodiment of the present invention for updating an already constructed medical knowledge graph.
[0057] Figure 6 is a schematic block diagram of a system according to an embodiment of the present invention.
[0058] Figure 7 A schematic diagram of the structure of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0059] In order to enable those skilled in the art to better understand the technical solutions in the present invention, 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, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0060] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.
[0061] The key terms appearing in the present invention are explained below.
[0062] BEG model: BAAI General Embedding semantic vector model.
[0063] OCR: Optical Character Recognition, optical character recognition, refers to the process in which an electronic device (such as a scanner or digital camera) examines characters printed on paper, determines their shapes by detecting dark and light patterns, and then uses character recognition methods to translate the shapes into computer text; that is, for printed characters, an optical method is used to convert the text in a paper document into a black and white dot matrix image file, and recognition software is used to convert the text in the image into text format for further editing and processing by word processing software.
[0064] TF-IDF algorithm: term frequency–inverse document frequency, is a commonly used weighting technique for information retrieval and data mining. TF stands for term frequency, and IDF stands for inverse document frequency.
[0065] Faiss: Facebook AI Similarity Search is an open source library developed by Facebook AI Research for efficient similarity search and clustering of dense vectors.
[0066] The method for constructing a medical knowledge graph based on a large language model provided in an embodiment of the present invention is executed by a computer device. Accordingly, the method for constructing a medical knowledge graph based on a large language model runs in a computer device.
[0067] To facilitate understanding of the present invention, the following is a further description of the method for constructing a medical knowledge graph based on a large language model provided by the present invention, based on the principle of the method for constructing a medical knowledge graph based on a large language model and in combination with the process of constructing a medical knowledge graph in the embodiments.
[0068] Specifically, Figure 1 As shown, the method for constructing a medical knowledge graph based on a large language model includes:
[0069] S1. Preprocess the historical medical text information acquired in advance to obtain source split sentences.
[0070] like Figure 2As shown, the historical medical text information acquired in advance is traversed, and when full-width spaces and half-width spaces appear, the full-width spaces and half-width spaces in the medical text information are deleted. When punctuation marks or special characters indicating the end of a sentence appear, the medical text information is split to obtain a number of split sentences. The punctuation marks indicating the end of a sentence include a period, a semicolon, an exclamation mark, and a question mark. The special characters include a tab character, a carriage return character, and a line feed character. The source information with quotation marks is added before each split sentence, which is recorded as a source split sentence.
[0071] Specifically, when obtaining medical text information, medical books and documents can be converted into text information through OCR, or publicly crawlable medical knowledge websites can be crawled through crawlers and converted into text information.
[0072] Specifically, the preprocessing step may include removing special characters and sentence segmentation. The removed special characters include but are not limited to \u3000, \u000d, \x7f, etc. The sentence segmentation logic is: when encountering symbols such as Chinese and English periods, semicolons, exclamation marks, etc. that represent the end of a sentence, or special characters such as tabs, carriage returns, and line breaks, the sentence is split. Due to different sources, the same sentence may have different meanings. Therefore, to ensure the accuracy of the knowledge graph, after the sentence is split, the source information is added to the beginning of each sentence and marked with book marks, for example: "Interpretation of the Guidelines for the Treatment of Severe Traumatic Brain Trauma (ICU Part) - Liu Changwen" Early tracheotomy or extubation in patients with severe brain trauma did not change the pneumonia rate, but the former may reduce the duration of mechanical ventilation.
[0073] S2. Split the sentences based on the source, extract the triples needed to construct the medical knowledge graph, and obtain a triple list.
[0074] When traversing the first source split sentence, the pre-created keyword list is empty, and a medical keywords in the first source split sentence are found and put into the keyword list, and the trained large language model is used to annotate the triples in the first source split sentence. When traversing the mth source split sentence, b medical keywords in the mth source split sentence are found, and it is determined whether the b medical keywords are in the current keyword list. If c medical keywords among the b medical keywords are in the current keyword list, then according to the formula Calculate whether the triples in the mth source split sentence need to be labeled. If p is greater than the preset threshold, the triples in the mth source split sentence are not labeled; if p is less than or equal to the preset threshold, the trained large language model is used to label the triples in the mth source split sentence, where K is the number of keywords recognized by the current sentence that overlap with the current keyword list, and M is the total number of keywords recognized by the current sentence. This process is repeated until all source split sentences are traversed and all labeled source split sentence triples are obtained.
[0075] Specifically, the large language model can be any one of the large language models that have been open sourced at home and abroad or the large language models that are not yet open sourced, including LLaMA, ChatGLM, Baichuan, Tongyi Qianwen, GPT, and Wenxin Yiyan. When selecting, priority is given to the Chinese and English large language models developed domestically, including any of the open source ChatGLM, Baichuan, and Tongyi Qianwen, because they have stronger adaptability in the Chinese field and can be better adopted as the base model for Chinese vertical domain training.
[0076] For example, Tongyi Qianwen 1.5-14b is used as the base model, and supervised fine-tuning is performed based on the base model through SFT. The training method is to construct the labeled data into question-answer pairs.
[0077] For example,
[0078] {
[0079] "instruction": "Please analyze the provided text carefully and identify all named entities within the range. Entity range: ['disease', 'drug', 'human morphology and structure', 'severity', 'clinical findings', 'operation', 'substance', 'gene mutation', 'biology', 'physical entity', 'digital', 'human', 'transmission route', 'population', 'gene', 'medical device', 'organization'].",
[0080] "input": "Medical text: "Anxiety disorder" "Symptoms" Patients experience symptoms such as loss of appetite, abdominal distension and burning sensation, gastric neurosis, nervous diarrhea or constipation.",
[0081] "output": "{'Disease': ['Anxiety disorder'], 'Clinical findings': ['Loss of appetite', 'Constipation', 'Gastric neurosis', 'Neurogenic diarrhea', 'Abdominal distension and burning sensation']}"
[0082] }.
[0083] Afterwards, the constructed question-answer pairs are input into the model for training.
[0084] Specifically, taking the first entity as syphilis, the last entity as vesicular-bullous skin lesions, and the attribute as clinical manifestation-symptoms as an example, the presentation form of data annotation is:
[0085] "Text":"Syphilis"Symptoms: Skin lesions appear about 6 weeks after birth, presenting as vesicular-bullous lesions (syphilitic pemphigus) or maculopapular or papulosquamous lesions."
[0086] Annotation results: {"start":1,"end":3,"text":"Syphilis","labels":["Disease"]},{"start":22,"end":30,"text":"Blister-bullous skin lesions","labels":["Clinical findings"]},{"from_id":"Syphilis","to_id":"Blister-bullous skin lesions","type":"relation","direction":"right","labels":["Clinical manifestations-symptoms"]}
[0087] In some embodiments, Figure 3 As shown, it also includes the steps of verifying the accuracy of the triples required for extracting and constructing the medical knowledge graph, including:
[0088] Input the source split sentence; based on the source split sentence, extract the first entity, the last entity, and the attributes corresponding to the first entity and the last entity, based on the formula: Accuracy , calculate the accuracy of the extracted triples; if the accuracy is greater than or equal to the preset accuracy threshold, the verification is passed; if the accuracy is less than the preset accuracy threshold, the verification is not passed and fine-tuning continues.
[0089] S3, converting the first entity, the last entity, and the attributes corresponding to the first entity and the last entity in each triple extracted into a vector, and performing deduplication processing on the triple list based on the similarity of each first entity, the last entity, and the attributes corresponding to the first entity and the last entity in the triple list, wherein the triple includes the first entity, the last entity, and the attributes corresponding to the first entity and the last entity, such as Figure 4 As shown, it specifically includes steps S31-S33.
[0090] S31, determining the similarity between each extracted first entity and the first entity, the similarity between the last entity and the last entity, and the similarity between the attributes corresponding to the first entity and the last entity and the attributes corresponding to the first entity and the last entity, including steps S311-S313.
[0091] S311. Create a new vector database, use the BEG model to convert each extracted first entity, last entity, and the text of the attributes corresponding to the first entity and the last entity into a vector, and put each vector into the newly created vector database.
[0092] S312, based on formula , determine the similarity of the angle between any two vectors. If the angle between any two vectors is greater than or equal to the preset similarity threshold, the two vectors are similar. Then delete the first entity, the last entity, and the attributes corresponding to the first entity and the last entity corresponding to any one of the vectors, where A and B are any two vectors.
[0093] S313: If the angle between any two vectors is smaller than a preset similarity threshold, the two vectors are dissimilar, and the first entity, the last entity, and the attributes corresponding to the first entity and the last entity corresponding to the two vectors are retained.
[0094] S32: If the determined similarity is greater than or equal to a preset similarity threshold, then deleting the attributes corresponding to the first entity, the last entity, or the first entity and the last entity whose similarity is greater than or equal to the preset similarity threshold.
[0095] S33: If the determined similarity is less than a preset similarity threshold, retain the attributes corresponding to the first entity, the last entity, or the first entity and the last entity corresponding to the similarity less than the preset similarity threshold.
[0096] S4. Import the triple list after deduplication into the graph database, and use the graph database to build a medical knowledge graph.
[0097] Specifically, select a suitable graph database (such as Neo4j, ArangoDB, etc.), install and configure the graph database, create a database schema, including node types and relationship types. Import the first and last entities as nodes in the graph database and the relationship as the edge between the two nodes into the graph database to generate a medical knowledge graph.
[0098] In some embodiments, Figure 5 As shown, it also includes the step of updating the constructed medical knowledge graph, specifically including steps Q1-Q5:
[0099] Q1. Create a new vector library, extract the first entity, the last entity, and the attributes corresponding to the first entity and the last entity in the knowledge graph to be updated, use the BEG model to convert the extracted first entity, the last entity, and the attributes corresponding to the first entity and the last entity into a first vector group, and put each vector in the first vector group into the newly created vector library.
[0100] Q2. Use the BEG model to output the retained first entity, last entity, and the attributes corresponding to the first entity and the last entity, and convert them into a second vector group based on the output first entity, last entity, and the attributes corresponding to the first entity and the last entity, and put each vector in the second vector group into the newly created vector database.
[0101] Q3. Based on the vectors in the newly created vector database, determine the similarity of the angle between any two vectors. If the angle between any two vectors is greater than or equal to the preset similarity threshold, the two vectors are similar. In this case, delete the first entity, the last entity, and the attributes corresponding to the first entity and the last entity corresponding to any one of the vectors.
[0102] Q4. If the angle between any two vectors is less than a preset similarity threshold, the two vectors are dissimilar, and the first entity, the last entity, and the attributes corresponding to the first entity and the last entity corresponding to the two vectors are retained.
[0103] Q5. Based on all retained vectors, output the first entity, the last entity, and the attributes corresponding to the first entity and the last entity corresponding to all retained vectors to construct an updated medical knowledge graph.
[0104] For example, a new vector database needs to be created each time data is fused. The vector database selected in this embodiment is faiss. The method for creating a new vector database is to extract the existing data in the current knowledge graph, convert the text into vectors through the BGE model, and then put the generated vectors into the vector database and build an index. Since all data in the vector database are represented by vectors, it is possible to determine whether two vectors are similar by judging the angle between them. If two vectors are exactly the same, the angle is 0. If the two vectors are similar, the angle should be smaller; if the two vectors are not similar, the angle is larger. When performing data fusion, use the new data to query the vector database. The vector database will return the most similar data and their similarity. The returned example is as follows {
[0105] "id": "3",
[0106] "result": [
[0107] {
[0108] "similarity_score": 1.2491623163223267,
[0109] "similarity_entity": {
[0110] "id": "8e9f180ff8c011ee9c68ac8247d53deb",
[0111] "name_cn": "Mollaret meningitis",
[0112] },
[0113] "candidate_entity": {
[0114] "id": "f4e59d3ec16148f59bdf83a27dbdf9d0",
[0115] "name_cn": "Mollaret meningitis",
[0116] }
[0117] } ]
[0119] },
[0120] To determine whether two vectors are similar, a threshold is set. When the similarity_score returned by the vector database is greater than the threshold, the two vectors are considered similar. If it is less than the threshold, the two vectors are considered dissimilar.
[0121] The method for constructing a medical knowledge graph based on a large language model provided in an embodiment of the present invention is executed by a computer device, and correspondingly, the system for constructing a medical knowledge graph based on a large language model runs in the computer device.
[0122] In some embodiments, the medical knowledge graph construction system based on a large language model may include multiple functional modules composed of computer program segments. The computer program of each program segment in the medical knowledge graph construction system based on a large language model may be stored in the memory of a computer device and executed by at least one processor to perform (see Figure 1 Description) Functions built on the medical knowledge graph based on a large language model.
[0123] In this embodiment, the medical knowledge graph construction system based on the large language model can be divided into multiple functional modules according to the functions it performs, such as Figure 6 As shown. The functional modules of the system 200 may include: a preprocessing module 210, a triple extraction module 220, a similarity judgment module 230 and a medical knowledge graph construction module 240. The module referred to in the present invention refers to a series of computer program segments that can be executed by at least one processor and can complete fixed functions, which are stored in a memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.
[0124] The preprocessing module develops a python script to preprocess the pre-acquired historical medical text information and obtain source split sentences;
[0125] The triple extraction module extracts the triples required for building the medical knowledge graph based on the source split sentence and obtains the triple list;
[0126] The similarity judgment module converts the first entity, the last entity, and the attributes corresponding to the first entity and the last entity in each triple extracted into vectors through the Faiss vector library, and performs deduplication processing on the triple list based on the similarity of each first entity, the last entity, and the attributes corresponding to the first entity and the last entity in the triple list;
[0127] The medical knowledge graph construction module imports the deduplicated triple list into the graph database and uses the graph database to build a medical knowledge graph.
[0128] Optionally, as an embodiment of the present invention, the preprocessing module includes:
[0129] Deleting character units, used to traverse the pre-acquired historical medical text information, and when full-width spaces and half-width spaces appear, deleting the full-width spaces and half-width spaces in the medical text information;
[0130] A sentence splitting unit is used to split the medical text information when a punctuation mark or special character indicating the end of a sentence appears, so as to obtain a plurality of split sentences. The punctuation mark indicating the end of a sentence includes a period, a semicolon, an exclamation mark and a question mark, and the special characters include a tab character, a carriage return character and a line feed character;
[0131] The source adding unit is used to add source information with quotation marks before each split sentence, which is recorded as a source split sentence.
[0132] Optionally, as an embodiment of the present invention, it further includes: a triple extraction module, including:
[0133] A first labeling unit is used for, when traversing the first source split sentence, if the pre-created keyword list is empty, finding a medical keywords in the first source split sentence, putting them into the keyword list, and labeling the triples in the first source split sentence using the trained large language model;
[0134] The second marking unit is used to traverse the mth source split sentence, find b medical keywords in the mth source split sentence, and determine whether the b medical keywords are in the current keyword list. If c medical keywords among the b medical keywords are in the current keyword list, then according to the formula Calculate whether the triples in the mth source split sentence need to be labeled. If p is greater than the preset threshold, the triples in the mth source split sentence are not labeled; if p is less than or equal to the preset threshold, the trained large language model is used to label the triples in the mth source split sentence, where K is the number of keywords recognized in the current sentence that overlap with the current keyword list, and M is the total number of keywords recognized in the current sentence;
[0135] It is also used in this way until all source split sentences are traversed to obtain the triplets of all annotated source split sentences.
[0136] Optionally, as an embodiment of the present invention, the system further includes:
[0137] Accuracy verification module, including:
[0138] An input unit, used for inputting source split sentences;
[0139] The accuracy calculation unit is used to split the sentence based on the input source and output the extracted triples based on the formula: , calculate the accuracy of the extracted triples;
[0140] A verification passing unit, used to pass the verification if the accuracy is greater than or equal to a preset accuracy threshold;
[0141] The verification failure unit is used to fail the verification if the accuracy is less than a preset accuracy threshold, and continue fine-tuning.
[0142] Optionally, as an embodiment of the present invention, the similarity judgment module includes:
[0143] A similarity judgment unit, wherein the triple includes a first entity, a last entity, and attributes corresponding to the first entity and the last entity, and is used to judge the similarity between each extracted first entity and the first entity, the similarity between the last entity and the last entity, and the similarity between the attributes corresponding to the first entity and the last entity and the attributes corresponding to the first entity and the last entity;
[0144] It is also used to delete the attributes corresponding to the first entity, the last entity, or the first entity and the last entity corresponding to the similarity greater than or equal to the preset similarity threshold if the determined similarity is greater than or equal to the preset similarity threshold;
[0145] It is also used to retain the attributes corresponding to the first entity, the last entity, or the first entity and the last entity corresponding to the similarity less than the preset similarity threshold if the determined similarity is less than the preset similarity threshold.
[0146] Optionally, as an embodiment of the present invention, the similarity judgment unit includes:
[0147] The vector import module is used to create a new vector database. It uses the BEG model to convert each extracted first entity, last entity, and the text of the attributes corresponding to the first entity and the last entity into a vector, and puts each vector into the newly created vector database.
[0148] Vector judgment module, used to judge based on formula , determine the similarity of the angle between any two vectors. If the angle between any two vectors is greater than or equal to the preset similarity threshold, the two vectors are similar. Then delete the first entity, the last entity, and the attributes corresponding to the first entity and the last entity corresponding to any one of the vectors, where A and B are any two vectors;
[0149] It is also used to determine that if the angle between any two vectors is less than a preset similarity threshold, the two vectors are dissimilar, and the first entity, the last entity, and the attributes corresponding to the first entity and the last entity corresponding to the two vectors are retained.
[0150] Optionally, as an embodiment of the present invention, the system further includes:
[0151] Knowledge graph update module, including:
[0152] A vector extraction module is used to create a new vector library, extract the first entity, the last entity and the attributes corresponding to the first entity and the last entity in the knowledge graph to be updated, use the BEG model to convert the extracted first entity, the last entity and the attributes corresponding to the first entity and the last entity into a first vector group, and put each vector in the first vector group into the newly created vector library;
[0153] A vector import module is used to use the BEG model to output the retained first entity, last entity, and attributes corresponding to the first entity and the last entity, convert the output first entity, last entity, and attributes corresponding to the first entity and the last entity into a second vector group, and put each vector in the second vector group into the newly created vector database;
[0154] A vector judgment module is used to judge the similarity of the angle between any two vectors based on the vectors in the newly created vector database. If the angle between any two vectors is greater than or equal to a preset similarity threshold, the two vectors are similar, and the first entity, the last entity, and the attributes corresponding to the first entity and the last entity corresponding to any one of the vectors are deleted;
[0155] The vector judgment module is also used for retaining the first entity, the last entity and the attributes corresponding to the first entity and the last entity corresponding to the two vectors if the angle between the two vectors is less than a preset similarity threshold, then the two vectors are dissimilar;
[0156] The medical knowledge graph updating module is used to output the first entity, the last entity and the attributes corresponding to the first entity and the last entity corresponding to all the retained vectors based on all the retained vectors, and construct an updated medical knowledge graph.
[0157] Figure 7 A schematic diagram of the structure of a terminal 300 provided in an embodiment of the present invention. The terminal 300 can be used to execute the method for constructing a medical knowledge graph based on a large language model provided in an embodiment of the present invention.
[0158] The terminal 300 may include: a processor 310, a memory 320 and a communication unit 330. These components communicate via one or more buses. Those skilled in the art will appreciate that the server structure shown in the figure does not limit the present invention, and it may be a bus structure or a star structure, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0159] The memory 320 can be used to store the execution instructions of the processor 310, and the memory 320 can be implemented by any type of volatile or non-volatile storage terminal or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. When the execution instructions in the memory 320 are executed by the processor 310, the terminal 300 can perform some or all of the steps in the following method embodiments.
[0160] The processor 310 is the control center of the storage terminal, and uses various interfaces and lines to connect various parts of the entire electronic terminal. It runs or executes software programs and / or modules stored in the memory 320, and calls data stored in the memory to perform various functions of the electronic terminal and / or process data. The processor can be composed of an integrated circuit (IC), for example, it can be composed of a single packaged IC, or it can be composed of multiple packaged ICs with the same or different functions. For example, the processor 310 can only include a central processing unit (CPU). In the embodiment of the present invention, the CPU can be a single computing core or multiple computing cores.
[0161] The communication unit 330 is used to establish a communication channel so that the storage terminal can communicate with other terminals, receive user data sent by other terminals or send user data to other terminals.
[0162] The present invention also provides a computer storage medium, wherein the computer storage medium may store a program, and when the program is executed, the program may include some or all of the steps in each embodiment provided by the present invention. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM).
[0163] Therefore, the present invention splits and annotates sentences in medical text information so that textbooks, clinical guidelines, clinical pathways and other materials can be presented in a structured manner, greatly improving the availability of medical materials and documents; by only annotating sentences that need to be annotated and deleting triples with high similarity, not only unnecessary information processing is avoided and efficiency is improved, but also the presentation of redundant information in medical text information is avoided, ensuring that the extracted medical knowledge is more concise and accurate. The medical information processed by these technical means in this application can be used not only by professional medical personnel, but also by the general public. By structuring, simplifying and refining complex medical knowledge, non-professionals can also more easily understand and use this information, thereby improving the dissemination and popularization of medical knowledge.
[0164] The technical effects that can be achieved by this embodiment can be found in the above description and will not be repeated here.
[0165] Those skilled in the art can clearly understand that the technology in the embodiments of the present invention can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution in the embodiments of the present invention, in essence or in other words, the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, and other media that can store program codes, including several instructions for enabling a computer terminal (which can be a personal computer, a server, or a second terminal, a network terminal, etc.) to execute all or part of the steps of the methods described in each embodiment of the present invention.
[0166] In this specification, the same or similar parts between the various embodiments can be referred to each other. In particular, for the terminal embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description in the method embodiment.
[0167] In the several embodiments provided by the present invention, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of systems or modules, which can be electrical, mechanical or other forms.
[0168] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0169] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.
[0170] Although the present invention has been described in detail by referring to the accompanying drawings and in combination with the preferred embodiments, the present invention is not limited thereto. Without departing from the spirit and essence of the present invention, a person of ordinary skill in the art may make various equivalent modifications or substitutions to the embodiments of the present invention, and these modifications or substitutions shall be within the scope of the present invention. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, and all of these shall be within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.
Claims
1. A method for constructing a medical knowledge graph based on a large language model, characterized in that: include: Preprocess the historical medical text information acquired in advance to obtain source split sentences; Based on the source split sentence, the triples required for building the medical knowledge graph are extracted to obtain a triple list; The first entity, the last entity, and the attributes corresponding to the first entity and the last entity in each triple extracted are converted into vectors, and the triple list is deduplicated based on the similarity of the attributes corresponding to each first entity, the last entity, and the first entity and the last entity in the triple list; Import the triple list after deduplication into the graph database, and use the graph database to build a medical knowledge graph; Based on the source split sentence, the triples required for building the medical knowledge graph are extracted to obtain a triple list, including: When traversing the first source split sentence, the pre-created keyword list is empty, a medical keywords in the first source split sentence are found, put into the keyword list, and the trained large language model is used to annotate the triples in the first source split sentence; When traversing the mth source split sentence, find b medical keywords in the mth source split sentence, and determine whether the b medical keywords are in the current keyword list. If c medical keywords among the b medical keywords are in the current keyword list, then according to the formula Calculate whether the triples in the mth source split sentence need to be labeled. If p is greater than the preset threshold, the triples in the mth source split sentence are not labeled; if p is less than or equal to the preset threshold, the trained large language model is used to label the triples in the mth source split sentence, where K is the number of keywords recognized in the current sentence that overlap with the current keyword list, and M is the total number of keywords recognized in the current sentence; And so on, until all source split sentences are traversed and all the triples of the marked source split sentences are obtained; Also includes: The steps to verify the accuracy of extracting the triples required to build the medical knowledge graph include: Input source split sentence; Based on the input source split sentence, output the extracted triples, based on the formula: accuracy , calculate the accuracy of the extracted triples; If the accuracy is greater than or equal to the preset accuracy threshold, the verification is passed; If the accuracy is less than the preset accuracy threshold, the verification fails and fine-tuning continues; The first entity, the last entity, and the attributes corresponding to the first entity and the last entity in each triple extracted are converted into vectors, and the triple list is deduplicated based on the similarity of the attributes corresponding to each first entity, the last entity, and the first entity and the last entity in the triple list, including: The triple includes a first entity, a last entity, and attributes corresponding to the first entity and the last entity; Determine the similarity between each extracted first entity and the first entity, the similarity between the last entity and the last entity, and the similarity between the attributes corresponding to the first entity and the last entity and the attributes corresponding to the first entity and the last entity; If the determined similarity is greater than or equal to a preset similarity threshold, then deleting the attributes corresponding to the first entity, the last entity, or the first entity and the last entity corresponding to the similarity greater than or equal to the preset similarity threshold; If the determined similarity is less than a preset similarity threshold, the attributes corresponding to the first entity, the last entity, or the first entity and the last entity corresponding to the similarity less than the preset similarity threshold are retained.
2. The method according to claim 1, characterized in that Preprocess the historical medical text information obtained in advance to obtain source split sentences, including: Traversing the historical medical text information acquired in advance, when full-width spaces and half-width spaces appear, deleting the full-width spaces and half-width spaces in the medical text information; When punctuation marks or special characters indicating the end of a sentence appear, the medical text information is split to obtain a plurality of split sentences, wherein the punctuation marks indicating the end of a sentence include a period, a semicolon, an exclamation mark, and a question mark, and the special characters include a tab character, a carriage return character, and a line feed character; Add source information in quotation marks before each split sentence and record it as a source split sentence.
3. The method according to claim 1, characterized in that Determine the similarity between each extracted first entity and the first entity, the similarity between the last entity and the last entity, and the similarity between the attributes corresponding to the first entity and the last entity and the attributes corresponding to the first entity and the last entity, including: Create a new vector database, use the BEG model to convert each extracted first entity, last entity, and the text of the attributes corresponding to the first entity and last entity into a vector, and put each vector into the newly created vector database; Based on the formula , determine the similarity of the angle between any two vectors. If the angle between any two vectors is greater than or equal to the preset similarity threshold, the two vectors are similar. Then delete the first entity, the last entity, and the attributes corresponding to the first entity and the last entity corresponding to any one of the vectors, where A and B are any two vectors; If the angle between any two vectors is less than a preset similarity threshold, the two vectors are dissimilar, and the first entity, the last entity, and the attributes corresponding to the first entity and the last entity corresponding to the two vectors are retained.
4. The method according to claim 1, characterized in that: Also includes: The steps to update the constructed medical knowledge graph include: A new vector library is created, and the first entity, the last entity, and the attributes corresponding to the first entity and the last entity in the knowledge graph to be updated are extracted, and the extracted first entity, the last entity, and the attributes corresponding to the first entity and the last entity are converted into a first vector group using the BEG model, and each vector in the first vector group is placed into the new vector library; Using the BEG model, outputting the retained first entity, last entity, and attributes corresponding to the first entity and last entity, converting the output first entity, last entity, and attributes corresponding to the first entity and last entity into a second vector group, and placing each vector in the second vector group into the newly created vector database; Based on the vectors in the newly created vector database, the similarity of the angle between any two vectors is determined. If the angle between any two vectors is greater than or equal to a preset similarity threshold, the two vectors are similar. Then, the first entity, the last entity, and the attributes corresponding to the first entity and the last entity corresponding to any one of the vectors are deleted. If the angle between any two vectors is less than a preset similarity threshold, the two vectors are dissimilar, and the first entity, the last entity, and the attributes corresponding to the first entity and the last entity corresponding to the two vectors are retained; Based on all the retained vectors, the first entity, the last entity and the attributes corresponding to the first entity and the last entity corresponding to all the retained vectors are output to construct an updated medical knowledge graph.
5. A medical knowledge graph construction system based on a large language model, characterized in that: include: The preprocessing module develops a python script to preprocess the pre-acquired historical medical text information and obtain source split sentences; The triple extraction module extracts the triples required for building the medical knowledge graph based on the source split sentence and obtains the triple list; The similarity judgment module converts the first entity, the last entity, and the attributes corresponding to the first entity and the last entity in each triple extracted into vectors through the Faiss vector library, and performs deduplication processing on the triple list based on the similarity of each first entity, the last entity, and the attributes corresponding to the first entity and the last entity in the triple list; The medical knowledge graph construction module imports the triple list after deduplication into the graph database and uses the graph database to build the medical knowledge graph; The triple extraction module comprises: A first labeling unit is used for, when traversing the first source split sentence, if the pre-created keyword list is empty, finding a medical keywords in the first source split sentence, putting them into the keyword list, and labeling the triples in the first source split sentence using the trained large language model; The second marking unit is used to traverse the mth source split sentence, find b medical keywords in the mth source split sentence, and determine whether the b medical keywords are in the current keyword list. If c medical keywords among the b medical keywords are in the current keyword list, then according to the formula Calculate whether the triples in the mth source split sentence need to be labeled. If p is greater than the preset threshold, the triples in the mth source split sentence are not labeled; if p is less than or equal to the preset threshold, the trained large language model is used to label the triples in the mth source split sentence, where K is the number of keywords recognized in the current sentence that overlap with the current keyword list, and M is the total number of keywords recognized in the current sentence; It is also used in this way until all source split sentences are traversed to obtain the triplets of all annotated source split sentences; Also includes: The accuracy verification module includes: An input unit, used for inputting source split sentences; The accuracy calculation unit is used to split the sentence based on the input source and output the extracted triples based on the formula: , calculate the accuracy of the extracted triples; A verification passing unit, used to pass the verification if the accuracy is greater than or equal to a preset accuracy threshold; A verification failure unit is used to fail the verification if the accuracy is less than a preset accuracy threshold, and continue fine-tuning; The similarity judgment module comprises: A similarity judgment unit, wherein the triple includes a first entity, a last entity, and attributes corresponding to the first entity and the last entity, and is used to judge the similarity between each extracted first entity and the first entity, the similarity between the last entity and the last entity, and the similarity between the attributes corresponding to the first entity and the last entity and the attributes corresponding to the first entity and the last entity; It is also used to delete the attributes corresponding to the first entity, the last entity, or the first entity and the last entity corresponding to the similarity greater than or equal to the preset similarity threshold if the determined similarity is greater than or equal to the preset similarity threshold; It is also used to retain the attributes corresponding to the first entity, the last entity, or the first entity and the last entity corresponding to the similarity less than the preset similarity threshold if the determined similarity is less than the preset similarity threshold.
6. A terminal, characterized in that: include: A memory, used for storing a medical knowledge graph construction program based on a large language model; A processor, used to implement the steps of the method for constructing a medical knowledge graph based on a large language model as described in any one of claims 1 to 4 when executing the medical knowledge graph construction program based on a large language model.
7. A computer-readable storage medium storing a computer program, characterized in that: The readable storage medium stores a medical knowledge graph construction program based on a large language model, and when the medical knowledge graph construction program based on a large language model is executed by a processor, the steps of the medical knowledge graph construction method based on a large language model as described in any one of claims 1 to 4 are implemented.
