Knowledge graph construction method and system based on large language model
By preprocessing and entity classification of source text, using semantic structure and contextual relationships to form standard extracting entities and simplified relationships, the problems of entity classification and graph simplification in the prior art are solved, and the construction efficiency of knowledge graphs is improved. accuracy.
Patent Information
- Application Number
- CN202411053000.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-08-01
AI Technical Summary
The existing knowledge graph construction method based on large language models failed to effectively classify entities with the same meaning, resulting in the repetition and complex knowledge graph nodes, failure to simplify the graph structure, and affecting the construction efficiency.
By preprocessing the source text, extracting entities and forming similar entity groups, reclassifying entities using semantic structures and contextual relationships, forming standard extraction entities and simplified extraction relationships, and building a high-quality knowledge graph.
It effectively reduces the complexity of subsequent processing, improves the accuracy of entity classification and the efficiency of building knowledge graphs, ensures that entities with the same meaning are classified into the same group, and simplifies the construction results of the knowledge graphs.
Smart Images

Figure CN119047553A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of text processing technology, and in particular to a knowledge graph construction method and system based on a large language model. Background Art
[0002] At present, in the process of knowledge graph construction, accurately and effectively extracting entities from source text and classifying these entities is the basis for building high-quality knowledge graphs. However, due to the naturalness, complexity and diversity of text, this process faces a series of challenges. Entities with the same meaning are often used as different nodes in graph construction, resulting in repeated and complicated nodes in the constructed knowledge graph. Therefore, how to classify extracted entities with the same meaning into the same node and how to simplify the knowledge graph have become urgent issues.
[0003] However, the existing knowledge graph construction method and system based on a large language model only performs text clustering on knowledge text data to obtain several knowledge text data sets of different text types, and constructs graph node links between each knowledge entity according to the association information of each knowledge entity in the knowledge text data sets of different text types to obtain a knowledge graph, but does not consider how to classify extracted entities with the same meaning, and does not consider how to simplify the knowledge graph. For example, the patent with the publication number of "CN117150050A" and the name of the patent is "A method and system for constructing a knowledge graph based on a large language model", and the method includes the following steps: performing text clustering on the knowledge text data to obtain a number of knowledge text data sets of different text types; submitting the knowledge text data sets to the first HDFS for distributed file storage; extracting the knowledge texts treorganizations from the first HDFS in order according to the length of the knowledge texts treorganizations, and using the preset large language model Creorganization to perform knowledge entity recognition on the extracted knowledge texts treorganizations to obtain the associated information of each knowledge entity; submitting the associated information of each knowledge entity to the second HDFS for distributed file storage; constructing the graph node links between each knowledge entity according to the associated information of each knowledge entity stored in the second HDFS to obtain a knowledge graph. However, this patent can only adapt to the language processing and storage functions of massive knowledge text data, and handle the construction of knowledge graphs of large-scale text types. It does not consider how to classify the extracted entities with the same meaning, and does not consider how to simplify the knowledge graph.
[0004] Therefore, the present invention proposes a knowledge graph construction method and system based on a large language model. Summary of the invention
[0005] The present invention provides a knowledge graph construction method and system based on a large language model, which are used to obtain all first-determined similar entity groups of the source text according to all extracted entities of all text processing sentences of the source text, effectively preliminarily integrate and classify entities with the same representation meaning, reduce the complexity of subsequent processing, and obtain all text sentence groups of the source text according to all text processing sentences of the source text and all first-determined similar entity groups, so as to facilitate the subsequent re-classification of extracted entities according to the semantic structure and contextual relationship of the sentences in the text sentence groups, obtain all second-determined similar entity groups of the source text according to all text sentence groups of the source text, and further improve the accuracy of classification of extracted entities according to semantic structure and contextual relationship, ensure that extracted entities with the same meaning are classified into the same group, and facilitate the accuracy of knowledge graph construction, obtain all standard extracted entities of all text processing sentences of the source text according to all second-determined similar entity groups of the source text, and facilitate the accurate acquisition of subsequent knowledge graph construction results, and obtain the knowledge graph construction results according to all standard extracted entities of all text processing sentences of the source text and the extraction relationships within all pre-text processing sentences, so as to simplify the knowledge graph and improve the efficiency of knowledge graph construction.
[0006] The present invention provides a method for constructing a knowledge graph based on a large language model, comprising:
[0007] S1: performing data preprocessing on the source text to obtain all source text sentences of the source text, and obtaining all pre-text processed sentences of the source text based on all source text sentences of the source text;
[0008] S2: based on all pre-text processing sentences of the source text and a preset large language model, all extracted entities and all extracted relations in all pre-text processing sentences of the source text are obtained, and based on all extracted entities of all pre-text processing sentences, all text processing sentences of the source text are obtained;
[0009] S3: based on all extracted entities of all text processing sentences of the source text, all first-determined similar entity groups of the source text are obtained, and based on all text processing sentences of the source text and all first-determined similar entity groups, all text sentence groups of the source text are obtained, based on all text sentence groups of the source text, all second-determined similar entity groups of the source text are obtained, and based on all second-determined similar entity groups of the source text, all standard extracted entities of all text processing sentences of the source text are obtained;
[0010] S4: Obtain the knowledge graph construction result based on all standard extracted entities of all text processing sentences of the source text and the extracted relations within all pre-text processing sentences.
[0011] Preferably, the knowledge graph construction method based on the large language model, S1: performing data preprocessing on the source text to obtain all source text sentences of the source text, and obtaining all pre-text processed sentences of the source text based on all source text sentences of the source text, including:
[0012] Receive the source text uploaded to the knowledge graph construction system, and use all sentence symbols in the source text as sentence markers, segment the source text based on all sentence markers, and obtain all source text sentences of the source text;
[0013] All pre-text processing sentences of the source text are obtained based on all source text sentences of the source text.
[0014] Preferably, the knowledge graph construction method based on the large language model obtains all pre-text processed sentences of the source text based on all source text sentences of the source text, including:
[0015] Eliminate the removable words in each source text sentence of the source text to obtain a text-removed sentence corresponding to each source text sentence;
[0016] Select all the texts to remove all the unknown words in the sentences, and use all the texts before each unknown word in the source text as the analysis text corresponding to the unknown word;
[0017] Based on each unknown word and the corresponding analysis text and the unknown word analysis model, a replacement word for the corresponding unknown word is obtained, and all unknown words in all text-eliminating sentences in the source text are replaced with corresponding replacement words to obtain all pre-text-processed sentences of the source text.
[0018] Preferably, the knowledge graph construction method based on the large language model, S2: based on all pre-text processing sentences of the source text and the preset large language model, all extracted entities and all extracted relations in all pre-text processing sentences of the source text are obtained, and all text processing sentences of the source text are obtained based on all extracted entities of all pre-text processing sentences, including:
[0019] Obtain all extracted entities and all extracted relations of each pre-text processing sentence of the source text based on a preset large language model;
[0020] Treat the pre-text processing sentence with zero number of extracted entities in the source text as an invalid text processing sentence;
[0021] All pre-text processing sentences in the source text except all invalid text sentences are taken as text processing sentences of the source text.
[0022] Preferably, the knowledge graph construction method based on the large language model obtains all first-determined similar entity groups of the source text based on all extracted entities of the sentence processing of all texts of the source text, including:
[0023] Taking any two different extracted entities from all extracted entities of all text processing sentences of the source text as a group of entity groups, obtaining all group entity groups;
[0024] All entity groups in the source text that contain overlapping characters between two extracted entities are regarded as all first verification entity groups of the source text;
[0025] Obtain the frequency of each word in the source text, use the frequency of each word as the vector element representation of the corresponding word, and obtain the vector representation of each extracted entity in each first verification entity group based on the vector element representation of each word;
[0026] Based on the vector representations of the two extracted entities in the first verification entity group and all invalid text processing sentences of the source text, the judgment substitution value between the two extracted entities in the first verification entity group is obtained, which is:
[0027]
[0028] Where δ is the judgment substitution value between the two extracted entities in the currently calculated first verification entity group, S0 is the total number of words in the source text, m is the number of overlapping words between the two extracted entities in the currently calculated verification entity group, S1 is the sum of the number of words in all invalid text processing sentences in the source text, and q i is the i-th vector element of the first extracted entity in the currently calculated verification entity group, w i is the i-th vector element of the second extracted entity in the currently calculated verification entity group, n is the number of characters of the extracted entity with fewer characters in the currently calculated verification entity group, ln is the natural logarithm, and the value of the natural constant e is 2.718;
[0029] All first verification entity groups whose judgment substitution values are greater than a preset judgment substitution value threshold are regarded as the first judgment similar entity groups of the source text.
[0030] Preferably, the knowledge graph construction method based on the large language model processes all text sentences and all first-determined similar entity groups of the source text to obtain all text sentence groups of the source text, including:
[0031] Determine the two extracted entities in each first similarity group as first entities of the same type, and aggregate all the extracted entities of the same type in the source text as first entities of the same type as the first similarity group;
[0032] The extracted entity with the largest number of occurrences in the source text among all the extracted entities in the first similar determination group is taken as the first replacement entity, and all the first replacement entities are used to replace all the remaining extracted entities in the first similar determination group except the corresponding first replacement entity in all the text processing sentences of the source text, to obtain all the text sentences of the source text;
[0033] If all the extracted entities in the first similar determination group have the same number of occurrences in the source text, the extracted entity that first appears in the source text among all the extracted entities in the first similar determination group is taken as the first replacement entity, and all the first replacement entities are used to replace all the remaining extracted entities in the first similar determination group except the corresponding first replacement entity in all the text processing sentences of the source text, so as to obtain all the text sentences of the source text;
[0034] Each text sentence of the source text and the corresponding adjacent previous text sentence and the corresponding adjacent next text sentence are combined to obtain all text sentence groups.
[0035] Preferably, the knowledge graph construction method based on the large language model obtains all second-determined similar entity groups of the source text based on all text sentence groups of the source text, including:
[0036] Obtain all extracted entities of each text sentence in each text sentence group based on a preset large language model;
[0037] Based on the vector element representation of each word, the vector representation of all extracted entities of each text sentence in each text sentence group is obtained, and any two different extracted entities in each text sentence group are taken as a set of comparison groups to obtain all comparison groups, wherein the two extracted entities in each comparison group are comparison entities;
[0038] Obtain the sum of the number of times the two comparison entities of each comparison group appear in the corresponding text sentence group as the calculation number of the corresponding comparison group;
[0039] Based on the vector representation of the two extracted entities in each alignment group and the number of calculations of the corresponding alignment group, the calculated substitution value between the two extracted entities in the corresponding alignment group is obtained, which is:
[0040]
[0041] Where σ is the calculated substitution value between two extracted entities in the currently calculated comparison group, ε is the number of calculations of the currently calculated comparison group, z0 is the sum of the number of all extracted entities in all text sentences in the text sentence group corresponding to the currently calculated comparison group, and r ( is the jth vector element of the first extracted entity in the currently calculated alignment group, c (is the jth vector element of the second extracted entity in the currently calculated comparison group, k is the number of words of the extracted entity with fewer words in the currently calculated comparison group, ln is the natural logarithm, and the value of the natural constant e is 2.718;
[0042] All comparison groups whose calculated substitution values are greater than a preset calculated substitution value threshold are taken as all second-determined similar entity groups of the source text.
[0043] Preferably, the knowledge graph construction method based on the large language model obtains all standard extraction entities of all text processing sentences of the source text based on all second judgment similar entity groups of the source text, including:
[0044] Determine the two extracted entities in each second similarity group as second similar entities to each other, and aggregate all the extracted entities in the source text that are second similar entities to each other as a second similarity determination group;
[0045] The extracted entity with the highest number of occurrences in the source text among all the extracted entities in the second similar determination group is regarded as the second replacement entity, and all the second replacement entities are used to replace all the remaining extracted entities in the second similar determination group except the corresponding second replacement entity in all the text processing sentences of the source text, to obtain all the replaced text processing sentences;
[0046] If all the extracted entities in the second similar determination group have the same number of occurrences in the source text, the extracted entity that first appears in the source text among all the extracted entities in the second similar determination group is taken as the second replacement entity, and all the second replacement entities are used to replace all the remaining extracted entities in the second similar determination group except the corresponding second replacement entity in all the text processing sentences of the source text, to obtain all the replaced text processing sentences;
[0047] All extracted entities in each replaced text processing sentence are used as standard extracted entities of the corresponding text processing sentence.
[0048] Preferably, the knowledge graph construction method based on the large language model, S4: obtaining the knowledge graph construction result based on all standard extraction entities of all text processing sentences of the source text and extraction relations within all pre-text processing sentences, including:
[0049] Simplifying the extraction relations in all pre-text processing sentences based on all standard extraction entities of all text processing sentences of the source text to obtain all simplified extraction relations;
[0050] All standard extracted entities of all text processing sentences of the source text are taken as nodes, and all simplified extracted relations are taken as relation edges to obtain the knowledge graph construction result.
[0051] The present invention provides a knowledge graph construction system based on a large language model, which is used to execute any one of the knowledge graph construction methods based on a large language model in embodiments 1 to 9, including:
[0052] A preprocessing module, used for performing data preprocessing on the source text, obtaining all source text sentences of the source text, and obtaining all pre-text processed sentences of the source text based on all source text sentences of the source text;
[0053] An extraction module, used for obtaining all extraction entities and all extraction relations in all pre-text processing sentences of the source text based on all pre-text processing sentences of the source text and a preset large language model, and obtaining all text processing sentences of the source text based on all extraction entities of all pre-text processing sentences;
[0054] A calculation module, configured to obtain all first-determined similar entity groups of the source text based on all extracted entities of all text processing sentences of the source text, obtain all text sentence groups of the source text based on all text processing sentences of the source text and all first-determined similar entity groups, obtain all second-determined similar entity groups of the source text based on all text sentence groups of the source text, and obtain all standard extracted entities of all text processing sentences of the source text based on all second-determined similar entity groups of the source text;
[0055] A construction module is used to obtain a knowledge graph construction result based on all standard extracted entities of all text processing sentences of the source text and the extracted relations within all pre-text processing sentences.
[0056] The beneficial effects of the present invention compared with the prior art are as follows: all first-determination similar entity groups of the source text are obtained according to all extracted entities of all text processing sentences of the source text, entities with the same representation meaning are effectively preliminarily integrated and classified, and the complexity of subsequent processing is reduced; all text sentence groups of the source text are obtained according to all text processing sentences of the source text and all first-determination similar entity groups, which is convenient for subsequent re-classification of extracted entities according to the semantic structure and contextual relationship of the sentences in the text sentence groups; all second-determination similar entity groups of the source text are obtained according to all text sentence groups of the source text, and the accuracy of classification of extracted entities is further improved according to the semantic structure and contextual relationship, ensuring that extracted entities with the same meaning are classified into the same group, which is convenient for the accuracy of knowledge graph construction; all standard extracted entities of all text processing sentences of the source text are obtained according to all second-determination similar entity groups of the source text, which is convenient for accurate acquisition of subsequent knowledge graph construction results; the knowledge graph construction results are obtained according to all standard extracted entities of all text processing sentences of the source text and the extraction relationships within all pre-text processing sentences, which simplifies the knowledge graph and improves the efficiency of knowledge graph construction.
[0057] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or be understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structure specifically pointed out in the written application document.
[0058] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0060] Figure 1 This is a flow chart of a method for constructing a knowledge graph based on a large language model in an embodiment of the present invention;
[0061] Figure 2 A schematic diagram of a knowledge graph construction system based on a large language model in an embodiment of the present invention. DETAILED DESCRIPTION
[0062] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0063] Embodiment 1:
[0064] The present invention provides a method for constructing a knowledge graph based on a large language model. Figure 1 ,include:
[0065] S1: performing data preprocessing on the source text to obtain all source text sentences of the source text, and obtaining all pre-text processed sentences of the source text based on all source text sentences of the source text;
[0066] S2: based on all pre-text processing sentences of the source text and a preset large language model, all extracted entities and all extracted relations in all pre-text processing sentences of the source text are obtained, and based on all extracted entities of all pre-text processing sentences, all text processing sentences of the source text are obtained;
[0067] S3: based on all extracted entities of all text processing sentences of the source text, all first-determined similar entity groups of the source text are obtained, and based on all text processing sentences of the source text and all first-determined similar entity groups, all text sentence groups of the source text are obtained, based on all text sentence groups of the source text, all second-determined similar entity groups of the source text are obtained, and based on all second-determined similar entity groups of the source text, all standard extracted entities of all text processing sentences of the source text are obtained;
[0068] S4: Obtain the knowledge graph construction result based on all standard extracted entities of all text processing sentences of the source text and the extracted relations within all pre-text processing sentences.
[0069] In this embodiment, the source text is the text input into the knowledge graph construction system based on the large language model. The knowledge graph construction system based on the large language model can represent the extracted entities and extracted relationships in the source text in the form of a knowledge graph (a graph-based data structure used to represent extracted entities and the extracted relationships between them. These extracted entities and extracted relationships are usually composed of attributes, edges and nodes, forming a complex network structure).
[0070] In this embodiment, data preprocessing is a process of obtaining all source text sentences of the source text based on the source text.
[0071] In this embodiment, the source text sentences are sentences of the source text obtained by segmenting the source text.
[0072] In this embodiment, the pre-text processed sentence is a sentence obtained by removing removable words and replacing unknown words in the source text sentence.
[0073] In this embodiment, the preset large language model is an existing model that is pre-set to extract all extracted entities (such as names of people, places, organization names, etc.) and all extracted relations (such as "born in", "belongs to", etc.) in a pre-text processing sentence or a text sentence, such as GPT, BERT, etc.
[0074] In this embodiment, the text processing sentences are all pre-text processing sentences in the source text except all invalid text sentences.
[0075] In this embodiment, the first determined similar entity group is a first verification entity group whose determined replacement value is greater than a preset determined replacement value threshold.
[0076] In this embodiment, the text sentence group is a combination of each text sentence of the source text and the corresponding adjacent previous text sentence and the corresponding adjacent next text sentence.
[0077] In this embodiment, the second determined similar entity group is a comparison group whose calculated substitution value is greater than a preset calculated substitution value threshold.
[0078] In this embodiment, the standard extracted entities are extracted entities obtained after deduplication of all extracted entities in all text processing sentences of the source text (the deduplication here targets extracted entities with the same representation meaning, such as potato and potato, etc.).
[0079] In this embodiment, the knowledge graph construction result is a network structure representing the extraction entities and the extraction relations between them, obtained based on all standard extraction entities of all text processing sentences of the source text and the extraction relations within all pre-text processing sentences.
[0080] The beneficial effects of the above technology are as follows: all first-determination similar entity groups of the source text are obtained according to all extracted entities of all text processing sentences of the source text, entities with the same representation meaning are effectively preliminarily integrated and classified, reducing the complexity of subsequent processing, and all text sentence groups of the source text are obtained according to all text processing sentences of the source text and all first-determination similar entity groups, which is convenient for subsequent re-classification of extracted entities according to the semantic structure and contextual relationship of the sentences in the text sentence groups, and all second-determination similar entity groups of the source text are obtained according to all text sentence groups of the source text, so as to further improve the accuracy of classification of extracted entities according to semantic structure and contextual relationship, ensure that extracted entities with the same meaning are classified into the same group, and facilitate the accuracy of knowledge graph construction, and all standard extracted entities of all text processing sentences of the source text are obtained according to all second-determination similar entity groups of the source text, so as to facilitate the accurate acquisition of subsequent knowledge graph construction results, and the knowledge graph construction results are obtained according to all standard extracted entities of all text processing sentences of the source text and the extraction relationships within all pre-text processing sentences, so as to simplify the knowledge graph and improve the efficiency of knowledge graph construction.
[0081] Embodiment 2:
[0082] Based on Example 1, a knowledge graph construction method based on a large language model, S1: performing data preprocessing on a source text to obtain all source text sentences of the source text, and obtaining all pre-text processed sentences of the source text based on all source text sentences of the source text, including:
[0083] Receive the source text uploaded to the knowledge graph construction system, and use all sentence symbols in the source text as sentence markers, segment the source text based on all sentence markers, and obtain all source text sentences of the source text;
[0084] All pre-text processing sentences of the source text are obtained based on all source text sentences of the source text.
[0085] In this embodiment, the sentence separator is a symbol in the source text that can separate text, such as a comma, a period, etc.
[0086] In this embodiment, the sentence marker is a position marker for sentence segmentation of the source text.
[0087] The beneficial effects of the above technology are as follows: data preprocessing is performed on the source text to obtain all the source text clauses of the source text, which is convenient for accurately identifying the extraction entities in the text subsequently, avoiding omission or misidentification of extraction entities due to the complex structure of long texts, and obtaining all the pre-text processing clauses of the source text based on all the source text clauses of the source text.
[0088] Example 3:
[0089] Based on the method for constructing a knowledge graph based on a large language model on the basis of Example 2, all the pre-text processing clauses of the source text are obtained based on all the source text clauses of the source text, including:
[0090] Eliminate the removable words in each source text clause of the source text to obtain the text elimination clause corresponding to each source text clause;
[0091] Select all the unclear words in all the text elimination clauses, and take all the text before each unclear word in the source text as the analysis text corresponding to the unclear word;
[0092] Based on each unclear word, the corresponding analysis text, and the unclear word analysis model, obtain the replacement word corresponding to the unclear word, and replace all the unclear words in all the text elimination clauses in the source text with the corresponding replacement words to obtain all the pre-text processing clauses of the source text.
[0093] In this embodiment, the removable words are words that are extremely common in each source text clause but usually have no actual meaning compared with other words and can be eliminated, such as "le" as a modal particle, "zai" as a preposition, etc.
[0094] In this embodiment, the unclear words are words with unclear references in each text elimination clause, such as "it", "this", etc.
[0095] In this embodiment, the unclear word analysis model is pre-trained with a large number of unclear words and the analysis text corresponding to each unclear word as the model input, and the replacement word manually selected for the corresponding unclear word as the model output, and it is a model that can input the unclear word and the corresponding analysis text and output the replacement word corresponding to the unclear word.
[0096] The beneficial effects of the above technology are as follows: eliminating the removable words and replacing the unclear words in all the source text clauses of the source text helps to highlight the semantic structure in the text, obtain all the pre-text processing clauses of the source text, and is convenient for subsequent acquisition of extraction entities and extraction relationships.
[0097] Example 4:
[0098] Based on Example 1, a knowledge graph construction method based on a large language model, S2: based on all pre-text processing sentences of the source text and a preset large language model, all extracted entities and all extracted relations in all pre-text processing sentences of the source text are obtained, and all text processing sentences of the source text are obtained based on all extracted entities of all pre-text processing sentences, including:
[0099] Obtain all extracted entities and all extracted relations of each pre-text processing sentence of the source text based on a preset large language model;
[0100] Treat the pre-text processing sentence with zero number of extracted entities in the source text as an invalid text processing sentence;
[0101] All pre-text processing sentences in the source text except all invalid text sentences are taken as text processing sentences of the source text.
[0102] In this embodiment, the invalid text processing sentence is a pre-text processing sentence that has zero extracted entities and is not helpful for knowledge graph construction.
[0103] The beneficial effects of the above technology are: accurately obtaining all extracted entities and all extracted relations within all pre-text processing sentences of the source text based on all pre-text processing sentences of the source text and the preset large language model, obtaining all text processing sentences of the source text based on all extracted entities of all pre-text processing sentences, screening out pre-text processing sentences that are not helpful for knowledge graph construction in all pre-text processing sentences, and reducing the complexity of subsequent processing.
[0104] Embodiment 5:
[0105] On the basis of Example 4, the knowledge graph construction method based on the large language model obtains all first-determined similar entity groups of the source text based on all extracted entities of the sentence processing of all texts of the source text, including:
[0106] Taking any two different extracted entities from all extracted entities of all text processing sentences of the source text as a group of entity groups, obtaining all group entity groups;
[0107] All entity groups in the source text that contain overlapping characters between two extracted entities are regarded as all first verification entity groups of the source text;
[0108] Obtain the frequency of each word in the source text, use the frequency of each word as the vector element representation of the corresponding word, and obtain the vector representation of each extracted entity in each first verification entity group based on the vector element representation of each word;
[0109] Based on the vector representations of the two extracted entities in the first verification entity group and all invalid text processing sentences of the source text, the judgment substitution value between the two extracted entities in the first verification entity group is obtained, which is:
[0110]
[0111] Where δ is the judgment substitution value between the two extracted entities in the currently calculated first verification entity group, S0 is the total number of words in the source text, m is the number of overlapping words between the two extracted entities in the currently calculated verification entity group, S1 is the sum of the number of words in all invalid text processing sentences in the source text, and q i is the i-th vector element of the first extracted entity in the currently calculated verification entity group, w i is the i-th vector element of the second extracted entity in the currently calculated verification entity group, n is the number of characters of the extracted entity with fewer characters in the currently calculated verification entity group, ln is the natural logarithm, and the value of the natural constant e is 2.718;
[0112] All first verification entity groups whose judgment substitution values are greater than a preset judgment substitution value threshold are regarded as the first judgment similar entity groups of the source text.
[0113] In this embodiment, the overlapping characters are repeated characters existing between two extracted entities.
[0114] In this embodiment, the first verification entity group is a group of all entities that contain overlapping characters between two extracted entities.
[0115] In this embodiment, the word frequency is the number of times each word in the source text appears in the source text.
[0116] In this embodiment, the vector representation of the extracted entity is a vector group representation obtained by taking the frequency of each word as the vector element representation of the corresponding word and taking the order of the corresponding words in the extracted entity as the vector element order.
[0117] In this embodiment, the judgment replacement value between two extracted entities in the first verification entity group is a degree value obtained based on the vector representation of the two extracted entities in the first verification entity group and all invalid text processing sentences of the source text, which can reflect whether the two extracted entities in the corresponding first verification entity group can be preliminarily integrated and classified.
[0118] In this embodiment, the preset determination substitution value threshold is a preset determination substitution value threshold used to determine whether the first verification entity group is the first determination similar entity group of the source text.
[0119] The beneficial effects of the above technology are: all the first-judgment similar entity groups of the source text are obtained based on all the extracted entities of all the text processing sentences of the source text, and the entities representing the same meanings are effectively preliminarily integrated and classified based on the repeated words between different extracted entities, thereby reducing the complexity of subsequent processing. This embodiment provides a specific method for obtaining all the first-judgment similar entity groups of the source text based on all the extracted entities of all the text processing sentences of the source text.
[0120] Embodiment 6:
[0121] On the basis of Example 5, the knowledge graph construction method based on the large language model processes all text sentences and all first-determined similar entity groups of the source text to obtain all text sentence groups of the source text, including:
[0122] Determine the two extracted entities in each first similarity group as first entities of the same type, and aggregate all the extracted entities of the same type in the source text as first entities of the same type as the first similarity group;
[0123] The extracted entity with the largest number of occurrences in the source text among all the extracted entities in the first similar determination group is taken as the first replacement entity, and all the first replacement entities are used to replace all the remaining extracted entities in the first similar determination group except the corresponding first replacement entity in all the text processing sentences of the source text, to obtain all the text sentences of the source text;
[0124] If all the extracted entities in the first similar determination group have the same number of occurrences in the source text, the extracted entity that first appears in the source text among all the extracted entities in the first similar determination group is taken as the first replacement entity, and all the first replacement entities are used to replace all the remaining extracted entities in the first similar determination group except the corresponding first replacement entity in all the text processing sentences of the source text, so as to obtain all the text sentences of the source text;
[0125] Each text sentence of the source text and the corresponding adjacent previous text sentence and the corresponding adjacent next text sentence are combined to obtain all text sentence groups.
[0126] In this embodiment, the first same category determination similarity group is that all extracted entities in the source text are first same category entities.
[0127] The beneficial effect of the above technology is: based on all text processing sentences and all first-judgment similar entity groups of the source text, all text sentence groups of the source text are obtained, which is convenient for subsequent extraction and reclassification of entities based on the semantic structure and contextual relationship of the sentences in the text sentence groups. This embodiment provides a specific method for obtaining all text sentence groups of the source text based on all text processing sentences and all first-judgment similar entity groups of the source text.
[0128] Embodiment 7:
[0129] On the basis of Example 5, the knowledge graph construction method based on the large language model obtains all second judgment similar entity groups of the source text based on all text sentence groups of the source text, including:
[0130] Obtain all extracted entities of each text sentence in each text sentence group based on a preset large language model;
[0131] Based on the vector element representation of each word, the vector representation of all extracted entities of each text sentence in each text sentence group is obtained, and any two different extracted entities in each text sentence group are taken as a set of comparison groups to obtain all comparison groups, wherein the two extracted entities in each comparison group are comparison entities;
[0132] Obtain the sum of the number of times the two comparison entities of each comparison group appear in the corresponding text sentence group as the calculation number of the corresponding comparison group;
[0133] Based on the vector representation of the two extracted entities in each alignment group and the number of calculations of the corresponding alignment group, the calculated substitution value between the two extracted entities in the corresponding alignment group is obtained, which is:
[0134]
[0135] Where σ is the calculated substitution value between two extracted entities in the currently calculated comparison group, ε is the number of calculations of the currently calculated comparison group, z0 is the sum of the number of all extracted entities in all text sentences in the text sentence group corresponding to the currently calculated comparison group, and r j is the jth vector element of the first extracted entity in the currently calculated alignment group, c j is the jth vector element of the second extracted entity in the currently calculated comparison group, k is the number of words of the extracted entity with fewer words in the currently calculated comparison group, ln is the natural logarithm, and the value of the natural constant e is 2.718;
[0136] All comparison groups whose calculated substitution values are greater than a preset calculated substitution value threshold are taken as all second-determined similar entity groups of the source text.
[0137] In this embodiment, the calculated substitution value between two extracted entities in a comparison group is obtained based on the vector representation of the two extracted entities in each comparison group and the number of calculations of the corresponding comparison group, and can reflect the degree value of whether the two extracted entities in the corresponding comparison group can be reintegrated and classified.
[0138] In this embodiment, the preset calculated replacement value threshold is a preset value that the corresponding calculated replacement value must be greater than when the comparison group is determined to be the second determined similar entity group.
[0139] The beneficial effects of the above technology are: all second-determined similar entity groups of the source text are obtained according to all text sentence groups of the source text, the accuracy of the classification of the extracted entities is further improved according to the semantic structure and contextual relationship, and it is ensured that the extracted entities with the same meaning are classified into the same group, which facilitates the accuracy of the knowledge graph construction. This embodiment provides a specific method for obtaining all second-determined similar entity groups of the source text based on all text sentence groups of the source text.
[0140] Embodiment 8:
[0141] On the basis of Example 7, the knowledge graph construction method based on the large language model obtains all standard extraction entities of all text processing sentences of the source text based on all second judgment similar entity groups of the source text, including:
[0142] Determine the two extracted entities in each second similarity group as second similar entities to each other, and aggregate all the extracted entities in the source text that are second similar entities to each other as a second similarity determination group;
[0143] The extracted entity with the highest number of occurrences in the source text among all the extracted entities in the second similar determination group is regarded as the second replacement entity, and all the second replacement entities are used to replace all the remaining extracted entities in the second similar determination group except the corresponding second replacement entity in all the text processing sentences of the source text, to obtain all the replaced text processing sentences;
[0144] If all the extracted entities in the second similar determination group have the same number of occurrences in the source text, the extracted entity that first appears in the source text among all the extracted entities in the second similar determination group is taken as the second replacement entity, and all the second replacement entities are used to replace all the remaining extracted entities in the second similar determination group except the corresponding second replacement entity in all the text processing sentences of the source text, to obtain all the replaced text processing sentences;
[0145] All extracted entities in each replaced text processing sentence are used as standard extracted entities of the corresponding text processing sentence.
[0146] In this embodiment, the second same type determination similarity group is that all extracted entities in the source text are second same type entities.
[0147] The beneficial effect of the above technology is: all standard extraction entities of all text processing sentences of the source text are obtained according to all second-determination similar entity groups of the source text, which facilitates the accurate acquisition of subsequent knowledge graph construction results. This embodiment provides a specific method for obtaining all standard extraction entities of all text processing sentences of the source text based on all second-determination similar entity groups of the source text.
[0148] Embodiment 9:
[0149] Based on Example 1, the knowledge graph construction method based on the large language model, S4: obtaining the knowledge graph construction result based on all standard extraction entities of all text processing sentences of the source text and extraction relations in all pre-text processing sentences, including:
[0150] Simplifying the extraction relations in all pre-text processing sentences based on all standard extraction entities of all text processing sentences of the source text to obtain all simplified extraction relations;
[0151] All standard extracted entities of all text processing sentences of the source text are taken as nodes, and all simplified extracted relations are taken as relation edges to obtain the knowledge graph construction result.
[0152] In this embodiment, all extraction relations in all pre-text processing sentences are simplified based on all standard extraction entities of all text processing sentences of the source text to obtain all simplified extraction relations, namely:
[0153] The extraction relationships of all replaced extraction entities are retained on the corresponding replaced and currently retained standard extraction entities, and the original extraction relationships of the standard extraction entities and the retained extraction relationships of the replaced extraction entities are summarized as simplified extraction relationships between all standard extraction entities.
[0154] The beneficial effects of the above technology are: the knowledge graph construction result is obtained according to all standard extraction entities of all text processing sentences of the source text and the extraction relations within all pre-text processing sentences, which simplifies the knowledge graph and improves the accuracy of knowledge graph construction.
[0155] Embodiment 10:
[0156] The present invention provides a knowledge graph construction system based on a large language model, which is used to execute any one of the knowledge graph construction methods based on a large language model in embodiments 1 to 9, referring to Figure 2 ,include:
[0157] A preprocessing module, used for performing data preprocessing on the source text, obtaining all source text sentences of the source text, and obtaining all pre-text processed sentences of the source text based on all source text sentences of the source text;
[0158] An extraction module, used for obtaining all extraction entities and all extraction relations in all pre-text processing sentences of the source text based on all pre-text processing sentences of the source text and a preset large language model, and obtaining all text processing sentences of the source text based on all extraction entities of all pre-text processing sentences;
[0159] A calculation module, configured to obtain all first-determined similar entity groups of the source text based on all extracted entities of all text processing sentences of the source text, obtain all text sentence groups of the source text based on all text processing sentences of the source text and all first-determined similar entity groups, obtain all second-determined similar entity groups of the source text based on all text sentence groups of the source text, and obtain all standard extracted entities of all text processing sentences of the source text based on all second-determined similar entity groups of the source text;
[0160] A construction module is used to obtain a knowledge graph construction result based on all standard extracted entities of all text processing sentences of the source text and the extracted relations within all pre-text processing sentences.
[0161] The beneficial effects of the above technology are as follows: all first-determination similar entity groups of the source text are obtained according to all extracted entities of all text processing sentences of the source text, entities with the same representation meaning are effectively preliminarily integrated and classified, reducing the complexity of subsequent processing, and all text sentence groups of the source text are obtained according to all text processing sentences of the source text and all first-determination similar entity groups, which is convenient for subsequent re-classification of extracted entities according to the semantic structure and contextual relationship of the sentences in the text sentence groups, and all second-determination similar entity groups of the source text are obtained according to all text sentence groups of the source text, so as to further improve the accuracy of classification of extracted entities according to semantic structure and contextual relationship, ensure that extracted entities with the same meaning are classified into the same group, and facilitate the accuracy of knowledge graph construction, and all standard extracted entities of all text processing sentences of the source text are obtained according to all second-determination similar entity groups of the source text, so as to facilitate the accurate acquisition of subsequent knowledge graph construction results, and the knowledge graph construction results are obtained according to all standard extracted entities of all text processing sentences of the source text and the extraction relationships within all pre-text processing sentences, so as to simplify the knowledge graph and improve the efficiency of knowledge graph construction.
[0162] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A knowledge graph construction method based on a large language model, characterized in that: include: S1: performing data preprocessing on the source text to obtain all source text sentences of the source text, and obtaining all pre-text processed sentences of the source text based on all source text sentences of the source text; S2: based on all pre-text processing sentences of the source text and a preset large language model, all extracted entities and all extracted relations in all pre-text processing sentences of the source text are obtained, and based on all extracted entities of all pre-text processing sentences, all text processing sentences of the source text are obtained; S3: based on all extracted entities of all text processing sentences of the source text, all first-determined similar entity groups of the source text are obtained, and based on all text processing sentences of the source text and all first-determined similar entity groups, all text sentence groups of the source text are obtained, based on all text sentence groups of the source text, all second-determined similar entity groups of the source text are obtained, and based on all second-determined similar entity groups of the source text, all standard extracted entities of all text processing sentences of the source text are obtained; S4: Obtain the knowledge graph construction result based on all standard extracted entities of all text processing sentences of the source text and the extracted relations within all pre-text processing sentences.
2. The method for constructing a knowledge graph based on a large language model according to claim 1, characterized in that: S1: Perform data preprocessing on the source text to obtain all source text sentences of the source text, and obtain all pre-text processed sentences of the source text based on all source text sentences of the source text, including: Receive the source text uploaded to the knowledge graph construction system, and use all sentence symbols in the source text as sentence markers, segment the source text based on all sentence markers, and obtain all source text sentences of the source text; All pre-text processing sentences of the source text are obtained based on all source text sentences of the source text.
3. The method for constructing a knowledge graph based on a large language model according to claim 2, characterized in that: All pre-text processing sentences of the source text are obtained based on all source text sentences of the source text, including: Eliminate the removable words in each source text sentence of the source text to obtain a text-removed sentence corresponding to each source text sentence; Select all the texts to remove all the unknown words in the sentences, and use all the texts before each unknown word in the source text as the analysis text corresponding to the unknown word; Based on each unknown word and the corresponding analysis text and the unknown word analysis model, a replacement word for the corresponding unknown word is obtained, and all unknown words in all text-eliminating sentences in the source text are replaced with corresponding replacement words to obtain all pre-text-processed sentences of the source text.
4. The method for constructing a knowledge graph based on a large language model according to claim 1, characterized in that: S2: Based on all pre-text processing sentences of the source text and the preset large language model, all extracted entities and all extracted relations in all pre-text processing sentences of the source text are obtained, and all text processing sentences of the source text are obtained based on all extracted entities of all pre-text processing sentences, including: Obtain all extracted entities and all extracted relations of each pre-text processing sentence of the source text based on a preset large language model; Treat the pre-text processing sentence with zero number of extracted entities in the source text as an invalid text processing sentence; All pre-text processing sentences in the source text except all invalid text sentences are taken as text processing sentences of the source text.
5. The method for constructing a knowledge graph based on a large language model according to claim 4, characterized in that: All the extracted entities of the sentences are processed based on all the texts of the source text to obtain all the first-determined similar entity groups of the source text, including: Taking any two different extracted entities from all extracted entities of all text processing sentences of the source text as a group of entity groups, obtaining all group entity groups; All entity groups in the source text that contain overlapping characters between two extracted entities are regarded as all first verification entity groups of the source text; Obtain the frequency of each word in the source text, use the frequency of each word as the vector element representation of the corresponding word, and obtain the vector representation of each extracted entity in each first verification entity group based on the vector element representation of each word; Based on the vector representations of the two extracted entities in the first verification entity group and all invalid text processing sentences of the source text, the judgment substitution value between the two extracted entities in the first verification entity group is obtained, which is: Where δ is the judgment substitution value between the two extracted entities in the currently calculated first verification entity group, S0 is the total number of words in the source text, m is the number of overlapping words between the two extracted entities in the currently calculated verification entity group, S1 is the sum of the number of words in all invalid text processing sentences in the source text, and q i is the i-th vector element of the first extracted entity in the currently calculated verification entity group, w i is the i-th vector element of the second extracted entity in the currently calculated verification entity group, n is the number of characters of the extracted entity with fewer characters in the currently calculated verification entity group, ln is the natural logarithm, and the value of the natural constant e is 2.718; All first verification entity groups whose judgment substitution values are greater than a preset judgment substitution value threshold are regarded as the first judgment similar entity groups of the source text.
6. The method for constructing a knowledge graph based on a large language model according to claim 5, characterized in that: Based on all text processing sentences of the source text and all first determined similar entity groups, all text sentence groups of the source text are obtained, including: Determine the two extracted entities in each first similarity group as first entities of the same type, and aggregate all the extracted entities of the same type in the source text as first entities of the same type as the first similarity group; The extracted entity with the largest number of occurrences in the source text among all the extracted entities in the first similar determination group is taken as the first replacement entity, and all the first replacement entities are used to replace all the remaining extracted entities in the first similar determination group except the corresponding first replacement entity in all the text processing sentences of the source text, to obtain all the text sentences of the source text; If all the extracted entities in the first similar determination group have the same number of occurrences in the source text, the extracted entity that first appears in the source text among all the extracted entities in the first similar determination group is taken as the first replacement entity, and all the first replacement entities are used to replace all the remaining extracted entities in the first similar determination group except the corresponding first replacement entity in all the text processing sentences of the source text, so as to obtain all the text sentences of the source text; Each text sentence of the source text and the corresponding adjacent previous text sentence and the corresponding adjacent next text sentence are combined to obtain all text sentence groups.
7. The method for constructing a knowledge graph based on a large language model according to claim 5, characterized in that: Obtaining all second-determined similar entity groups of the source text based on all text sentence groups of the source text, including: Obtain all extracted entities of each text sentence in each text sentence group based on a preset large language model; Based on the vector element representation of each word, the vector representation of all extracted entities of each text sentence in each text sentence group is obtained, and any two different extracted entities in each text sentence group are taken as a set of comparison groups to obtain all comparison groups, wherein the two extracted entities in each comparison group are comparison entities; Obtain the sum of the number of times the two comparison entities of each comparison group appear in the corresponding text sentence group as the calculation number of the corresponding comparison group; Based on the vector representation of the two extracted entities in each alignment group and the number of calculations of the corresponding alignment group, the calculated substitution value between the two extracted entities in the corresponding alignment group is obtained, which is: Where σ is the calculated substitution value between two extracted entities in the currently calculated comparison group, ε is the number of calculations of the currently calculated comparison group, z0 is the sum of the number of all extracted entities in all text sentences in the text sentence group corresponding to the currently calculated comparison group, and r j is the jth vector element of the first extracted entity in the currently calculated alignment group, c j is the jth vector element of the second extracted entity in the currently calculated comparison group, k is the number of words of the extracted entity with fewer words in the currently calculated comparison group, ln is the natural logarithm, and the value of the natural constant e is 2.718; All comparison groups whose calculated substitution values are greater than a preset calculated substitution value threshold are taken as all second-determined similar entity groups of the source text.
8. The method for constructing a knowledge graph based on a large language model according to claim 7, characterized in that: All standard extraction entities of all text processing sentences of the source text are obtained based on all second judgment similar entity groups of the source text, including: Determine the two extracted entities in each second similarity group as second similar entities to each other, and aggregate all the extracted entities in the source text that are second similar entities to each other as a second similarity determination group; The extracted entity with the highest number of occurrences in the source text among all the extracted entities in the second similar determination group is regarded as the second replacement entity, and all the second replacement entities are used to replace all the remaining extracted entities in the second similar determination group except the corresponding second replacement entity in all the text processing sentences of the source text, to obtain all the replaced text processing sentences; If all the extracted entities in the second similar determination group have the same number of occurrences in the source text, the extracted entity that first appears in the source text among all the extracted entities in the second similar determination group is taken as the second replacement entity, and all the second replacement entities are used to replace all the remaining extracted entities in the second similar determination group except the corresponding second replacement entity in all the text processing sentences of the source text, to obtain all the replaced text processing sentences; All extracted entities in each replaced text processing sentence are used as standard extracted entities of the corresponding text processing sentence.
9. The method for constructing a knowledge graph based on a large language model according to claim 1, characterized in that: S4: Obtain the knowledge graph construction results based on all standard extracted entities of all text processing sentences of the source text and the extracted relations within all pre-text processing sentences, including: Simplifying the extraction relations in all pre-text processing sentences based on all standard extraction entities of all text processing sentences of the source text to obtain all simplified extraction relations; All standard extracted entities of all text processing sentences of the source text are taken as nodes, and all simplified extracted relations are taken as relation edges to obtain the knowledge graph construction result.
10. A knowledge graph construction system based on a large language model, characterized in that: A method for constructing a knowledge graph based on a large language model according to any one of claims 1 to 9, comprising: A preprocessing module, used for performing data preprocessing on the source text, obtaining all source text sentences of the source text, and obtaining all pre-text processed sentences of the source text based on all source text sentences of the source text; An extraction module, used for obtaining all extraction entities and all extraction relations in all pre-text processing sentences of the source text based on all pre-text processing sentences of the source text and a preset large language model, and obtaining all text processing sentences of the source text based on all extraction entities of all pre-text processing sentences; A calculation module, configured to obtain all first-determined similar entity groups of the source text based on all extracted entities of all text processing sentences of the source text, obtain all text sentence groups of the source text based on all text processing sentences of the source text and all first-determined similar entity groups, obtain all second-determined similar entity groups of the source text based on all text sentence groups of the source text, and obtain all standard extracted entities of all text processing sentences of the source text based on all second-determined similar entity groups of the source text; A construction module is used to obtain a knowledge graph construction result based on all standard extracted entities of all text processing sentences of the source text and the extracted relations within all pre-text processing sentences.
Citation Information
Patent Citations
Medical knowledge graph building method and device
CN113590817A
Knowledge graph construction method and device, equipment and storage medium
CN117910563A
Cited By
Advanced mathematics problem solving model reasoning strengthening method based on hierarchical thinking chain
CN120654837A
Higher mathematics problem solving model reasoning reinforcement method based on hierarchical thinking chain
CN120654837B
