Knowledge graph-based text retrieval method and related equipment

By converting the initial problem text into structured problem text and performing vector processing, matching it with the knowledge graph vector library, the problems of low knowledge graph retrieval efficiency and large results deviation in the existing technology are solved, and more efficient and accurate search results are achieved.

CN119884315APending Publication Date: 2025-04-25CHINA TELECOM CORP LTD TECHNOLOGY INNOVATION CENTER +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411961013.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

Existing knowledge graph retrieval methods are inefficient and have large results deviations, especially when dealing with knowledge graphs with a large number of entities and relationships, direct use of vector similarity calculations will lead to increased search time and inaccurate results.

Method used

By entering the initial problem text into a pre-trained large language model, structured problem text is generated based on the pre-determined target format template and prompt words, and vectorized it. Then, the processed vectorized problem text is matched with the pre-constructed knowledge graph vector library to obtain the target reply text collection.

Benefits of technology

It improves the efficiency of knowledge graph retrieval and the accuracy of output results, reduces the result bias caused by user input differences, and significantly reduces the search time when processing large-scale knowledge graphs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119884315A_ABST
    Figure CN119884315A_ABST
Patent Text Reader

Abstract

The invention provides a text retrieval method and device based on a knowledge graph, equipment, a medium and a program product, and relates to the technical field of knowledge graphs. The method comprises the steps of obtaining an initial question text; the initial problem text is input into a pre-trained large language model, a target problem text is output based on a predetermined target format template and cue words, and the cue words are used for guiding the large language model to output a structured problem text according to the target format template; the target question text is subjected to vectorization processing, then the vectorized target question text is matched with a pre-constructed knowledge graph vector library, a target reply text set is obtained, and the target reply text set comprises multiple target reply texts related to the initial question text. The knowledge graph retrieval efficiency and the accuracy of the output result can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] Knowledge graph is a data model used to represent entities and their relationships in the real world. It structures information in a symbolic way, usually using nodes and edges to express entities and their relationships. It is widely used in different scenarios, such as search recommendation, and integration with large models. The knowledge graph retrieval process plays a vital role in these fields, and accurate information retrieval is conducive to improving user perception.

[0003] In related technologies, the commonly used knowledge graph retrieval method is to first vectorize the knowledge graph instance and import it into the vector database, vectorize the user's question during retrieval, and then obtain similar knowledge graph instances through vector similarity analysis. However, due to differences in the way different users ask questions, background knowledge, vocabulary choices, etc., there are large differences in user input, and direct vector similarity processing may lead to large deviations. Especially for knowledge graphs with a large number of entities and relationships, directly using vector similarity to calculate similarity with all the content in the knowledge graph will greatly increase the retrieval time.

[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention

[0005] The present disclosure provides a knowledge graph-based text retrieval method, apparatus, device, medium and program product, which at least to a certain extent overcome the problems of low knowledge graph retrieval efficiency and large result deviation in related technologies.

[0006] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.

[0007] According to one aspect of the present disclosure, a text retrieval method based on a knowledge graph is provided, comprising: obtaining an initial question text; inputting the initial question text into a pre-trained large language model, and outputting a target question text based on a predetermined target format template and prompt words, wherein the prompt words are used to guide the large language model to output a structured question text according to the target format template; vectorizing the target question text, and then matching it with a pre-constructed knowledge graph vector library to obtain a target answer text set, wherein the target answer text set includes multiple target answer texts related to the initial question text.

[0008] In some embodiments, before the initial question text is input into a pre-trained large language model and the target question text is output based on a predetermined target format template and prompt words, the method further includes: obtaining a text knowledge graph instance, wherein the text knowledge graph instance is used to reflect the relationship between entities and the relationship between entities and corresponding attributes; generating structured text conforming to the target format based on the text knowledge graph instance according to a predetermined target format template; vectorizing the structured text to obtain a vectorized text; matching the vectorized text with a preset text label to construct a knowledge graph vector library.

[0009] In some embodiments, the text label includes a first text label and a second text label, wherein the first text label is used to represent the relationship between entities, and the second text label is used to represent the relationship between an entity and an attribute.

[0010] In some embodiments, the target question text is vectorized and then matched with a pre-built knowledge graph vector library to obtain a target reply text set, including: vectorizing the target question text to obtain a vectorized target question text; matching the vectorized target question text with a preset text label, and then performing similarity calculation with a pre-built knowledge graph vector library to obtain multiple text similarities; sorting the multiple text similarities in descending order; obtaining reply texts corresponding to a preset number of text similarities that rank top, to form a target reply text set.

[0011] In some embodiments, before sorting the multiple text similarities in descending order, the method further includes: setting a preset text similarity threshold; removing text similarities from the multiple text similarities that are lower than the preset text similarity threshold, so that the remaining text similarities are sorted in descending order.

[0012] According to another aspect of the present disclosure, a text retrieval device based on a knowledge graph is also provided, including: a question text acquisition module, used to acquire an initial question text; a question text structuring module, used to input the initial question text into a pre-trained large language model, and output a target question text based on a predetermined target format template and prompt words, wherein the prompt words are used to guide the large language model to output a structured question text according to the target format template; a reply text output module, used to vectorize the target question text, and then match it with a pre-constructed knowledge graph vector library to obtain a target reply text set, wherein the target reply text set includes multiple target reply texts related to the initial question text.

[0013] In some embodiments, the device also includes: a knowledge graph instance acquisition module, used to obtain a text knowledge graph instance, wherein the text knowledge graph instance is used to reflect the relationship between entities and the relationship between entities and corresponding attributes; a text structuring module, used to generate structured text that conforms to the target format based on the text knowledge graph instance according to a predetermined target format template; a text vectorization module, used to vectorize the structured text to obtain the vectorized text; a knowledge graph vector library construction module, used to match the vectorized text with preset text tags to construct a knowledge graph vector library.

[0014] According to another aspect of the present disclosure, an electronic device is also provided, which includes: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute any one of the above-mentioned knowledge graph-based text retrieval methods by executing the executable instructions.

[0015] According to another aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the text retrieval method based on the knowledge graph described above is implemented.

[0016] According to another aspect of the present disclosure, a computer program product is also provided, including a computer program, which implements any of the above-mentioned knowledge graph-based text retrieval methods when executed by a processor.

[0017] The text retrieval method, device, equipment, medium and program product based on knowledge graph provided in the embodiments of the present disclosure, after obtaining the initial question text, input it into a pre-trained large language model, output the target question text based on the pre-determined target format template and prompt words, then vectorize the target question text, match the processed target question text with the pre-built knowledge graph vector library, and obtain the target answer text set. The embodiments of the present disclosure can improve the efficiency of knowledge graph retrieval and the accuracy of output results.

[0018] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.

[0020] Figure 1 A flowchart of a knowledge graph retrieval method in related art is shown;

[0021] Figure 2 A schematic diagram of a system architecture for implementing a text retrieval method based on a knowledge graph in an embodiment of the present disclosure is shown;

[0022] Figure 3 A flow chart of a text retrieval method based on a knowledge graph in an embodiment of the present disclosure is shown;

[0023] Figure 4 A schematic diagram showing the process of constructing a knowledge graph vector library in an embodiment of the present disclosure is shown;

[0024] Figure 5 A schematic diagram showing a knowledge graph retrieval process in an embodiment of the present disclosure is shown;

[0025] Figure 6 A schematic diagram of a text retrieval device based on a knowledge graph in an embodiment of the present disclosure is shown;

[0026] Figure 7 A schematic diagram of another text retrieval device based on a knowledge graph in an embodiment of the present disclosure is shown;

[0027] Figure 8 A structural block diagram of an electronic device is shown. DETAILED DESCRIPTION

[0028] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the disclosure will be more comprehensive and complete and to fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0029] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.

[0030] For ease of understanding, before introducing the embodiments of the present disclosure, several terms involved in the embodiments of the present disclosure are first explained as follows:

[0031] LLM: Large Language Model, a type of artificial intelligence model designed to understand and generate human language. They are trained on large amounts of text data and can perform a wide range of tasks, including text summarization, translation, sentiment analysis, and more.

[0032] Prompt: Prompt words are used in large language models to guide the generation of responses. By properly selecting prompt words, the model can be guided to generate the desired content.

[0033] Knowledge Graph: A knowledge graph consists of nodes and edges, where nodes represent entities or concepts in the real world, and edges represent the relationships between these entities or concepts. Each node and edge can be accompanied by attribute information, such as name, definition, description, attribute value, etc. In this way, the knowledge graph can capture the associations and semantic relationships between various entities.

[0034] The specific implementation of the embodiment of the present disclosure is described in detail below with reference to the accompanying drawings.

[0035] Figure 1 A flowchart of a knowledge graph retrieval method in related art is shown, such as Figure 1 As shown, the method includes:

[0036] S101, receiving a question text raised by a user in natural language.

[0037] S102, preprocessing the question text to extract key information for structured question sentences.

[0038] S103, matching and embedding the processed question text with the entities and relations in the knowledge graph.

[0039] S104, based on the processed question, search in the knowledge graph to find entities and relationships related to the question text.

[0040] S105, further filter out the most relevant parts from the retrieved related entities and relationships to form a knowledge graph subgraph.

[0041] S106, filtering the knowledge graph subgraph through the latent Dirichlet allocation LDA model, and generating the final answer based on the filtered knowledge graph subgraph.

[0042] In one embodiment of the present disclosure, there are a question processing module and a knowledge graph embedding module, based on which the entities and relations of the input question are obtained, and the embedding module is used to convert the entities and predicates into low-dimensional dense vectors. The candidate knowledge graph subgraph is obtained by vector similarity, and then the LDA model is used to screen the subgraph nodes to obtain the output.

[0043] In one embodiment of the present disclosure, due to the large differences in user inputs caused by different users' questioning methods, background knowledge, vocabulary selection, etc., direct vector similarity processing may lead to large deviations. In addition, for knowledge graphs with a large number of entities and relationships, directly using vector similarity to calculate similarity with all the content in the graph will increase the corresponding retrieval time.

[0044] Figure 2 A schematic diagram of the system architecture for implementing a text retrieval method based on a knowledge graph in an embodiment of the present disclosure is shown. Figure 2 As shown, the system may include: a knowledge graph vector library, a large model, a prompt word library and a similarity analysis module.

[0045] In one embodiment of the present disclosure, first, the two structures in the knowledge graph instance are rewritten based on the ontology design (i.e., the preset target format template), and structured text that conforms to the target format is generated according to the rules. Then, the structured text is vectorized using the vector model, and the vectorized text is compared with the preset ontology label (i.e., the text label, Figure 2 Finally, the matched vectorized text is input into the knowledge graph vector library.

[0046] In one embodiment of the present disclosure, the target format may be that the “attribute name” of the “entity name” is the “attribute value” and the “relationship name” of the “entity name” is the “entity name”.

[0047] In one embodiment of the present disclosure, the preset ontology tag may be an entity pair, which is used to represent the relationship between entities; the preset ontology tag may also be an entity attribute pair, which is used to represent the relationship between entities and attributes.

[0048] In one embodiment of the present disclosure, the received question text is input into the large language model LLM, and the question text is rewritten according to the target format in combination with the ontology design corresponding to the knowledge graph instance and the prompt words corresponding to the LLM to obtain a structured question text that conforms to the target format, and the structured question text is matched with the ontology label.

[0049] In one embodiment of the present disclosure, a structured question text is input into a similarity analysis module, vectorized, and matched with a knowledge graph vector library through ontology tags. Through similarity calculation, a preset number of target answer texts with high similarity are output to form a retrieval result set.

[0050] In one embodiment of the present disclosure, the question text input by the user is rewritten by LLM in combination with prompt words, so that the question text is rewritten into a structured question text that conforms to the target format, and the corresponding text tag is matched thereto, which is conducive to improving the accuracy of similarity analysis.

[0051] In one embodiment of the present disclosure, each group of entity pairs or entity attribute pairs is used as a text label of a knowledge graph vector, and combined with the text label matched with the structured question text to filter out less relevant content to improve the speed of similarity analysis.

[0052] Figure 3 A flow chart of a text retrieval method based on a knowledge graph in an embodiment of the present disclosure is shown as follows: Figure 3 As shown, the method comprises the following steps:

[0053] S302, obtaining an initial question text.

[0054] In one embodiment of the present disclosure, the initial question text is a question or query in a natural language form received from a user, and may be any form of natural language text.

[0055] S304, inputting the initial question text into a pre-trained large language model, and outputting the target question text based on a predetermined target format template and prompt words, wherein the prompt words are used to guide the large language model to output the structured question text according to the target format template.

[0056] In one embodiment of the present disclosure, a pre-trained large language model LLM is used to rewrite the initial question text input by the user according to the target format template and prompt words to ensure that it meets the structural requirements, so as to obtain a structured question text output according to the target format template.

[0057] S306, vectorize the target question text, and then match it with a pre-built knowledge graph vector library to obtain a target answer text set, wherein the target answer text set includes multiple target answer texts related to the initial question text.

[0058] In one embodiment of the present disclosure, the rewritten question text is converted into a numerical vector to facilitate matching with the knowledge graph vector library. For example, the text can be converted into a vector representation by using a pre-trained language model. Multiple vectors with high similarity are found in the pre-built knowledge graph vector library to form a target answer text set.

[0059] As can be seen from the above, after obtaining the initial question text, the disclosed embodiment inputs it into a pre-trained large language model, outputs the target question text based on the pre-determined target format template and prompt words, and then vectorizes the target question text, matches the processed target question text with the pre-built knowledge graph vector library, and obtains a target answer text set. The disclosed embodiment can improve the efficiency of knowledge graph retrieval and the accuracy of output results.

[0060] In one embodiment of the present disclosure, before the above S304, the method also includes: obtaining a text knowledge graph instance, wherein the text knowledge graph instance is used to reflect the relationship between entities and the relationship between entities and corresponding attributes; generating a structured text conforming to the target format based on the text knowledge graph instance according to a predetermined target format template; vectorizing the structured text to obtain a vectorized text; matching the vectorized text with a preset text tag to construct a knowledge graph vector library.

[0061] In one embodiment of the present disclosure, the text label includes a first text label and a second text label, wherein the first text label is used to represent the relationship between entities, and the second text label is used to represent the relationship between an entity and an attribute.

[0062] In one embodiment of the present disclosure, after obtaining a knowledge graph instance, two structures in the knowledge graph instance can be rewritten based on a target format template, and structured text that conforms to the target format can be generated according to the rules, wherein the structure included in the knowledge graph instance can be: entity name-relationship name-entity name, entity name-attribute name-attribute value. Correspondingly, text labels can be generated based on the structure of the knowledge graph instance, that is, the first text label can be an entity pair, used to represent the relationship between entities, and the second text label can be an entity attribute pair, used to represent the relationship between entities and attributes.

[0063] In one embodiment of the present disclosure, the target format may be "attribute name" of "entity name" is "attribute value" and "relationship name" of "entity name" is "entity name". That is, the target question text may be a combination of "attribute name" of "entity name" or "relationship name" of "entity name"; the target answer text may be a combination of "attribute name" of "entity name" is "attribute value" or "relationship name" of "entity name" is "entity name".

[0064] In one embodiment of the present disclosure, structured text can be vectorized using a pre-trained language model, word embedding method, etc. to obtain vectorized text, and the vectorized text is matched with preset text tags to construct a knowledge graph vector library.

[0065] It should be noted that the above-mentioned text vectorization method is only an example. Any method that can achieve text vectorization can be adopted according to actual conditions, model performance and resources, and the embodiments of the present disclosure do not make specific limitations on this.

[0066] In one embodiment of the present disclosure, Figure 4 A schematic diagram showing the process of constructing a knowledge graph vector library in an embodiment of the present disclosure is shown in FIG. Figure 4 As shown, the ontology design (i.e., the above-mentioned target format) can identify the relationship between entity attribute pairs, for example, "movie" can correspond to "name", "director", "release date", "type" and "rating", and "actor" can correspond to "name", "date of birth" and "nationality" respectively; the ontology design can also identify the relationship between entity pairs, for example, the relationship between "movie", "starring" and "actor". The knowledge graph example shows the relationship between entities, for example, the "starring" of the "movie" Kung Fu is the "actor" Stephen Chow; and the entity "movie" also corresponds to other attributes, for example, "name" is Kung Fu, "director" is Stephen Chow, "release date" is December 2004, "type" is comedy, action, and "rating" is 9.4; the entity "actor" also corresponds to other attributes, for example, "name" is Stephen Chow, "date of birth" is June 22, 1962, and "nationality" is China.

[0067] In one embodiment of the present disclosure, Figure 4 As shown, based on the ontology design, the knowledge graph instance is rewritten to obtain a structured text rewritten according to the ontology design. For example, based on the text tags "movie" and "director", the structured text is that the director of Kung Fu is Stephen Chow; based on the text tags "movie" and "release date", the structured text is that the release date of Kung Fu is December 2004; based on the text tags "movie" and "type", the structured text is that the type of Kung Fu is comedy and action; based on the text tags "movie" and "rating", the structured text is that the rating of Kung Fu is 9.4; based on the text tags "actor" and "date of birth", the structured text is that Stephen Chow's date of birth is June 22, 1962; based on the text tags "actor" and "nationality", the structured text is that Stephen Chow's nationality is China; based on the text tags "movie", "starring" and "actor", the structured text that the star of Kung Fu is Stephen Chow.

[0068] In one embodiment of the present disclosure, Figure 4 As shown in the figure, the structured text is vectorized and the vectorized text is matched with the text label to build a knowledge graph vector library. The obtained knowledge graph vector library can be shown in the following table:

[0069] Table 1

[0070] text Text Vector Label The director of Kung Fu is Stephen Chow [0.7,0.78,0.86,……] "Movie", "Director" The genres of Kung Fu are comedy, action [0.5,0.68,0.96,……] "Movie", "Genre" … … …

[0071] In one embodiment of the present disclosure, the above S306 includes: performing vectorization calculation on the target question text to obtain the vectorized target question text; matching the vectorized target question text with a preset text label, and then performing similarity calculation with a pre-built knowledge graph vector library to obtain multiple text similarities; sorting the multiple text similarities in descending order; obtaining the reply texts corresponding to the top preset number of text similarities to form a target reply text set.

[0072] In one embodiment of the present disclosure, the target question text is vectorized and matched with a preset text tag so that the vectorized target question text can be directly mapped to specific entities and relationships in the knowledge graph, thereby facilitating subsequent similarity analysis and other operations.

[0073] It should be noted that the above-mentioned text vectorization method is only an example. Any method that can achieve text vectorization can be adopted according to actual conditions, model performance and resources, and the embodiments of the present disclosure do not make specific limitations on this.

[0074] In one embodiment of the present disclosure, the vectorized target question text is similarly calculated with the pre-built knowledge graph vector library. For example, a similarity measurement method such as cosine similarity and Euclidean distance is used to obtain multiple text similarities, which are sorted in descending order, and the answer texts corresponding to the top preset number of text similarities are obtained to form a target answer text set. The output target answer text may include not only the text itself corresponding to the text similarity, but also its context information in the knowledge graph, such as entities and relationships associated with the text corresponding to the text similarity.

[0075] It should be noted that the above similarity measurement method is only for illustrative purposes, and any similarity calculation method can be adopted according to actual conditions, and the embodiments of the present disclosure do not make specific limitations on this.

[0076] In one embodiment of the present disclosure, before sorting multiple text similarities in descending order, the method further includes: setting a preset text similarity threshold; removing text similarities below the preset text similarity threshold from the multiple text similarities, so that the remaining text similarities are sorted in descending order.

[0077] In one embodiment of the present disclosure, Figure 5 A schematic diagram of a knowledge graph retrieval process in an embodiment of the present disclosure is shown. Figure 5 As shown, the initial question text is input into the LLM, and the initial question text is rewritten in combination with the predetermined ontology design and prompt words to obtain a structured question text output in the target format, namely, the target question text.

[0078] In one embodiment of the present disclosure, the initial question text may be, for example, "Kung Fu was released in 2004 and is a comedy film directed by Stephen Chow. Can you tell me how many points Kung Fu scored?". The ontology design may identify the relationship between pairs of entity attributes, for example, "movie" may correspond to "name", "director", "release date", "type" and "rating", and "actor" may correspond to "name", "date of birth" and "nationality" respectively; the ontology design may also identify the relationship between pairs of entities, for example, the relationship between "movie", "starring" and "actor". The prompt words may be, for example, "You need to extract questions from the input text and rewrite the extracted questions according to the ontology design and rewriting requirements. Please follow the output format to output the content. Input text: {}; ontology design: {}; rewriting requirements: {}; output format: {'extracted question': xxx, 'rewritten text': xxx, 'ontology design': xxx}". The target question text can be, for example, “{'extracted question': 'Can you tell me how many points Kung Fu gets?', 'rewritten text': 'Kung Fu rating', 'ontology design': ("movie", "rating")}”.

[0079] In one embodiment of the present disclosure, Figure 5 As shown, through the similarity analysis module, the target question text with text tags is matched with the data in the knowledge graph vector library. Specifically, a similarity measurement method such as cosine similarity and Euclidean distance can be used to obtain multiple text similarities, which are sorted in descending order, and the reply texts corresponding to the top preset number of text similarities are obtained to form a target reply text set. Among them, the output target reply text can include not only the text itself corresponding to the text similarity, but also its context information in the knowledge graph, such as the entities and relationships associated with the text corresponding to the text similarity.

[0080] It should be noted that the above similarity measurement method is only for illustrative purposes, and any similarity calculation method can be adopted according to actual conditions, and the embodiments of the present disclosure do not make specific limitations on this.

[0081] In one embodiment of the present disclosure, entity pairs or entity attribute pairs in a knowledge graph instance are constructed in a specific format and vectorized to obtain a knowledge graph vector library with ontology labels; based on the excellent text understanding ability of the large model, the user input question is preprocessed to obtain the ontology pair corresponding to the input question, and the ontology pair is rewritten to obtain a text in a specific format. The embodiment of the present disclosure uses the excellent text understanding ability of LLM to implement the knowledge graph retrieval task end-to-end according to the ontology design, and for knowledge graphs with a large number of entities and relationships, it efficiently retrieves and matches relevant content to improve the query accuracy and efficiency of user questions and knowledge graph content.

[0082] Based on the same inventive concept, the present disclosure also provides a text retrieval device based on a knowledge graph, as described in the following embodiments. Since the principle of solving the problem in the device embodiment is similar to that in the above method embodiment, the implementation of the device embodiment can refer to the implementation of the above method embodiment, and the repeated parts will not be repeated.

[0083] Figure 6 A schematic diagram of a text retrieval device based on a knowledge graph in an embodiment of the present disclosure is shown. Figure 6 As shown, the device includes: a question text acquisition module 601, a question text structuring module 602 and a reply text output module 603.

[0084] Among them, the question text acquisition module 601 is used to obtain the initial question text; the question text structuring module 602 is used to input the initial question text into a pre-trained large language model, and output the target question text based on a predetermined target format template and prompt words, wherein the prompt words are used to guide the large language model to output structured question text according to the target format template; the reply text output module 603 is used to vectorize the target question text, and then match it with a pre-constructed knowledge graph vector library to obtain a target reply text set, wherein the target reply text set includes multiple target reply texts related to the initial question text.

[0085] As can be seen from the above, after obtaining the initial question text, the disclosed embodiment inputs it into a pre-trained large language model, outputs the target question text based on the pre-determined target format template and prompt words, and then vectorizes the target question text, matches the processed target question text with the pre-built knowledge graph vector library, and obtains a target answer text set. The disclosed embodiment can improve the efficiency of knowledge graph retrieval and the accuracy of output results.

[0086] In one embodiment of the present disclosure, Figure 7 A schematic diagram of another text retrieval device based on a knowledge graph in an embodiment of the present disclosure is shown. Figure 7 As shown, the device also includes: a knowledge graph instance acquisition module 701, a text structuring module 702, a text vectorization module 703 and a knowledge graph vector library construction module 704.

[0087] Among them, the knowledge graph instance acquisition module 701 is used to obtain a text knowledge graph instance, wherein the text knowledge graph instance is used to reflect the relationship between entities and the relationship between entities and corresponding attributes; the text structuring module 702 is used to generate structured text that conforms to the target format based on the text knowledge graph instance according to a predetermined target format template; the text vectorization module 703 is used to vectorize the structured text to obtain the vectorized text; the knowledge graph vector library construction module 704 is used to match the vectorized text with the preset text label to construct a knowledge graph vector library.

[0088] In one embodiment of the present disclosure, the text label includes a first text label and a second text label, wherein the first text label is used to represent the relationship between entities, and the second text label is used to represent the relationship between an entity and an attribute.

[0089] In one embodiment of the present disclosure, after obtaining a knowledge graph instance, two structures in the knowledge graph instance can be rewritten based on a target format template, and structured text that conforms to the target format can be generated according to the rules, wherein the structure included in the knowledge graph instance can be: entity name-relationship name-entity name, entity name-attribute name-attribute value. Correspondingly, text labels can be generated based on the structure of the knowledge graph instance, that is, the first text label can be an entity pair, used to represent the relationship between entities, and the second text label can be an entity attribute pair, used to represent the relationship between entities and attributes.

[0090] In one embodiment of the present disclosure, the target format may be that the “attribute name” of the “entity name” is the “attribute value” and the “relationship name” of the “entity name” is the “entity name”.

[0091] In one embodiment of the present disclosure, structured text can be vectorized using a pre-trained language model, word embedding method, etc. to obtain vectorized text, and the vectorized text is matched with preset text tags to construct a knowledge graph vector library.

[0092] It should be noted that the above-mentioned text vectorization method is only an example. Any method that can achieve text vectorization can be adopted according to actual conditions, model performance and resources, and the embodiments of the present disclosure do not make specific limitations on this.

[0093] In one embodiment of the present disclosure, the above-mentioned question text structuring module 602 is also used to perform vectorization calculation on the target question text to obtain a vectorized target question text; match the vectorized target question text with a preset text label, and then perform similarity calculation with a pre-built knowledge graph vector library to obtain multiple text similarities; sort the multiple text similarities in descending order; obtain the reply texts corresponding to the top preset number of text similarities to form a target reply text set.

[0094] In one embodiment of the present disclosure, the target question text is vectorized and matched with a preset text tag so that the vectorized target question text can be directly mapped to specific entities and relationships in the knowledge graph, thereby facilitating subsequent similarity analysis and other operations.

[0095] It should be noted that the above-mentioned text vectorization method is only an example. Any method that can achieve text vectorization can be adopted according to actual conditions, model performance and resources, and the embodiments of the present disclosure do not make specific limitations on this.

[0096] In one embodiment of the present disclosure, the vectorized target question text is similarly calculated with the pre-built knowledge graph vector library. For example, a similarity measurement method such as cosine similarity and Euclidean distance is used to obtain multiple text similarities, which are sorted in descending order, and the answer texts corresponding to the top preset number of text similarities are obtained to form a target answer text set. The output target answer text may include not only the text itself corresponding to the text similarity, but also its context information in the knowledge graph, such as entities and relationships associated with the text corresponding to the text similarity.

[0097] It should be noted that the above similarity measurement method is only for illustrative purposes, and any similarity calculation method can be adopted according to actual conditions, and the embodiments of the present disclosure do not make specific limitations on this.

[0098] In one embodiment of the present disclosure, the question text structuring module 602 is further used to set a preset text similarity threshold; remove text similarities below the preset text similarity threshold from multiple text similarities, so that the remaining text similarities are sorted in descending order.

[0099] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".

[0100] Refer to the following Figure 8 The electronic device 800 according to this embodiment of the present disclosure is described. Figure 8 The electronic device 800 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0101] like Figure 8 As shown, the electronic device 800 is in the form of a general computing device. The components of the electronic device 800 may include but are not limited to: at least one processing unit 810, at least one storage unit 820, and a bus 830 connecting different system components (including the storage unit 820 and the processing unit 810).

[0102] Among them, the storage unit stores a program code, and the program code can be executed by the processing unit 810, so that the processing unit 810 executes the steps described in the above "Exemplary Method" section of this specification according to various exemplary embodiments of the present disclosure. For example, the processing unit 810 can execute the following steps of the above method embodiment: obtaining an initial question text; inputting the initial question text into a pre-trained large language model, and outputting a target question text based on a predetermined target format template and prompt words, wherein the prompt words are used to guide the large language model to output a structured question text according to the target format template; vectorizing the target question text, and then matching it with a pre-constructed knowledge graph vector library to obtain a target answer text set, wherein the target answer text set includes multiple target answer texts related to the initial question text.

[0103] The storage unit 820 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 8201 and / or a cache memory unit 8202 , and may further include a read-only memory unit (ROM) 8203 .

[0104] The storage unit 820 may also include a program / utility 8204 having a set (at least one) of program modules 8205, such program modules 8205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0105] Bus 830 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.

[0106] The electronic device 800 may also communicate with one or more external devices 840 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 800, and / or communicate with any device that enables the electronic device 800 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 850. Furthermore, the electronic device 800 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 860. As shown, the network adapter 860 communicates with other modules of the electronic device 800 via a bus 830. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 800, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.

[0107] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0108] Based on the same inventive concept, a computer-readable storage medium is also provided in the embodiment of the present disclosure, on which a computer program is stored, and when the computer program is executed by a processor, any of the above-mentioned text retrieval methods based on knowledge graphs is implemented. Since the principle of solving the problem in the embodiment of the computer-readable storage medium is similar to that in the above-mentioned method embodiment, the implementation of the embodiment of the computer-readable storage medium can refer to the implementation of the above-mentioned method embodiment, and the repeated parts will not be repeated.

[0109] More specific examples of computer-readable storage media in the present disclosure may include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0110] In the present disclosure, a computer readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, wherein a readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0111] Alternatively, the program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.

[0112] In a specific implementation, the program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).

[0113] Based on the same inventive concept, a computer program product is also provided in the embodiments of the present disclosure, including a computer program product, including: a computer program or an instruction, which, when executed by a processor, implements any one of the text retrieval methods based on a knowledge graph in the above method embodiments. Since the principle of solving the problem in the computer program product embodiment is similar to that in the above method embodiment, the implementation of the computer program product embodiment can refer to the implementation of the above method embodiment, and the repeated parts will not be repeated.

[0114] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.

[0115] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.

[0116] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0117] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the appended claims.

Claims

1. A text retrieval method based on knowledge graph, characterized in that: include: Get the initial question text; Inputting the initial question text into a pre-trained large language model, and outputting a target question text based on a predetermined target format template and prompt words, wherein the prompt words are used to guide the large language model to output a structured question text according to the target format template; The target question text is vectorized and then matched with a pre-constructed knowledge graph vector library to obtain a target answer text set, wherein the target answer text set includes multiple target answer texts related to the initial question text.

2. The text retrieval method based on knowledge graph according to claim 1, characterized in that: Before inputting the initial question text into a pre-trained large language model and outputting a target question text based on a predetermined target format template and prompt words, the method further includes: Obtaining a text knowledge graph instance, wherein the text knowledge graph instance is used to reflect the relationship between entities and the relationship between entities and corresponding attributes; According to a predetermined target format template, based on the text knowledge graph instance, generate a structured text that conforms to the target format; Performing vectorization processing on the structured text to obtain vectorized text; The vectorized text is matched with preset text labels to construct a knowledge graph vector library.

3. The text retrieval method based on knowledge graph according to claim 2 is characterized in that: The text label includes a first text label and a second text label, wherein the first text label is used to represent the relationship between entities, and the second text label is used to represent the relationship between an entity and an attribute.

4. The text retrieval method based on knowledge graph according to claim 2, characterized in that: The target question text is vectorized and then matched with a pre-built knowledge graph vector library to obtain a target answer text set, including: Perform vectorization calculation on the target question text to obtain the vectorized target question text; Match the vectorized target question text with the preset text label, and then calculate the similarity with the pre-built knowledge graph vector library to obtain multiple text similarities; Sorting the multiple text similarities in descending order; The reply texts corresponding to the preset number of text similarities ranked top are obtained to form a target reply text set.

5. The text retrieval method based on knowledge graph according to claim 4 is characterized in that: Before sorting the plurality of text similarities in descending order, the method further comprises: Set a preset text similarity threshold; The text similarities that are lower than the preset text similarity threshold are removed from the multiple text similarities, so that the remaining text similarities are sorted in descending order.

6. A text retrieval device based on knowledge graph, characterized in that: include: A question text acquisition module is used to acquire the initial question text; A question text structuring module, used for inputting the initial question text into a pre-trained large language model, and outputting a target question text based on a predetermined target format template and prompt words, wherein the prompt words are used to guide the large language model to output a structured question text according to the target format template; The reply text output module is used to vectorize the target question text and then match it with a pre-built knowledge graph vector library to obtain a target reply text set, wherein the target reply text set includes multiple target reply texts related to the initial question text.

7. The text retrieval device based on knowledge graph according to claim 6 is characterized in that: The device also includes: A knowledge graph instance acquisition module, used to acquire a text knowledge graph instance, wherein the text knowledge graph instance is used to reflect the relationship between entities and the relationship between entities and corresponding attributes; A text structuring module, used to generate structured text conforming to the target format based on the text knowledge graph instance according to a predetermined target format template; A text vectorization module, used for performing vectorization processing on the structured text to obtain a vectorized text; The knowledge graph vector library construction module is used to match the vectorized text with preset text tags to construct a knowledge graph vector library.

8. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; Wherein, the processor is configured to execute the knowledge graph-based text retrieval method described in any one of claims 1 to 5 by executing the executable instructions.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the knowledge graph-based text retrieval method described in any one of claims 1 to 5 is implemented.

10. A computer program product comprising: A computer program or instruction, characterized in that when the computer program or instruction is executed by a processor, it implements the text retrieval method based on the knowledge graph as described in any one of claims 1 to 5.