Language model query request processing method based on knowledge graph and service equipment

By introducing subgraph information extracted by knowledge graphs into language models, the problem of semantic understanding and entity association difficulties in complex queries is solved in the prior art, and the accuracy and applicability of query responses are improved, especially in specific fields. middle.

CN119003784AActive Publication Date: 2024-11-22SHANGHAI XUANTU INTELLIGENT TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411009747.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-25
Publication Date
2024-11-22
Estimated Expiration
2044-07-25

AI Technical Summary

Technical Problem

When existing search enhancement generation methods deal with complex queries, it is difficult to accurately control entity interaction and association, resulting in the incomplete matching of the query semantic requirements of the generation response, especially in multi-entity and complex relationship scenarios, which lacks deep semantic understanding and adaptability.

Method used

The language model query request processing method based on knowledge graphs. By obtaining the semantic information of the query request, the relevant sub-graph information is extracted from the preset knowledge graph as a reference, and input it into the language model to provide contextual knowledge, improving the accuracy and correlation of the response. sex.

Benefits of technology

Improve the response accuracy and relevance of language models when processing complex queries, especially in specific fields, reduce the need for manual intervention, and enhance the adaptability to diversified queries.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119003784A_ABST
    Figure CN119003784A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a language model query request processing method based on a knowledge graph and service equipment, and relates to the technical field of artificial intelligence. The language model query request processing method based on the knowledge graph comprises the steps of obtaining semantic information of a received query request; based on the semantic information of the query request, obtaining sub-graph information related to the semantic of the query request from a preset knowledge graph; and inputting the query request and the subgraph information semantically related to the query request into a preset language model to obtain response information of the query request. According to the invention, the accuracy and correlation of the preset language model response are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a language model query request processing method and service device based on a knowledge graph. Background Art

[0002] In recent years, with the rapid development of artificial intelligence technology, retrieval-augmented generation (RAG) has become a popular strategy that combines large language models with external knowledge bases to enhance the performance of generation tasks. In this framework, the large model first retrieves the documents or data fragments that best match the query entered by the user from a large amount of candidate materials, and then fuses the retrieved information to generate a more accurate and comprehensive response. This strategy of combining retrieval and generation has shown significant advantages in application scenarios that require external knowledge support. However, existing RAG methods still have certain limitations when processing complex queries. For example, when processing queries involving multiple key entities and complex semantic relationships, existing RAG methods often cannot accurately control the interactions and associations between entities during the retrieval process, resulting in the generated responses not being fully aligned with the semantic requirements of the query.

[0003] Retrieval-based generative models usually rely on keyword matching and lack an in-depth understanding of the deep semantics of the query. Models such as DPR (Dense Passage Retrieval) and REALM (Retrieval-Augmented Language Model) improve retrieval quality by learning dense embeddings, but when faced with queries containing multiple entities and complex relationships, they still find it difficult to accurately capture the user's true intentions, resulting in a mismatch between the generated content and the query requirements.

[0004] Although the prompt-based RAG method and multimodal retrieval method can provide effective assistance in specific scenarios, they still face similar challenges in semantic understanding, entity relationship utilization, and retrieval efficiency; they often require a lot of manual intervention and are difficult to adapt to diverse queries. Summary of the invention

[0005] The purpose of the present invention is to provide a language model query request processing method based on a knowledge graph, a service device and a readable storage medium, which extracts subgraph information related to the semantics of the query request in a preset knowledge graph based on the semantic information of the query request, and inputs the extracted subgraph information into the preset language model together with the query request as reference information. Since the subgraph information related to the semantics of the query request comes from the knowledge graph, it can provide the preset language model with accurate and rich contextual reference knowledge when responding to the query request, thereby improving the accuracy and relevance of the preset language model response, and especially can improve the applicability of the preset language model in a specific field by presetting a knowledge graph for a specific field.

[0006] To achieve the above-mentioned objectives, the present invention provides a language model query request processing method based on a knowledge graph, comprising: obtaining semantic information of a received query request; based on the semantic information of the query request, obtaining subgraph information semantically related to the query request from a preset knowledge graph; inputting the query request and the subgraph information semantically related to the query request into a preset language model to obtain response information of the query request.

[0007] The present invention also provides a service device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the language model query request processing method based on the knowledge graph as described above.

[0008] The present invention also provides a computer-readable storage medium, which is a non-volatile storage medium or a non-transient storage medium, on which a computer program is stored, and is characterized in that when the computer program is run by a processor, it executes the above-mentioned language model query request processing method based on the knowledge graph.

[0009] In one embodiment, obtaining semantic information of a received query request includes:

[0010] Obtaining key entities in the query request;

[0011] Acquire a first semantic feature of the query request and a second semantic feature of the key entity; the semantic information of the query request includes: the first semantic feature and the second semantic feature;

[0012] Based on the semantic information of the query request, obtaining subgraph information related to the semantics of the query request from a preset knowledge graph, including:

[0013] Acquire N designated entities similar to the semantic information from the knowledge vector library corresponding to the preset knowledge graph, wherein the N designated entities include designated entities similar to the first semantic feature and designated entities similar to the second semantic feature, and N is an integer greater than 1;

[0014] Obtain subgraph information related to the N specified entities from the preset knowledge graph.

[0015] In one embodiment, obtaining subgraph information related to the N specified entities from the preset knowledge graph includes:

[0016] Selecting K designated entities that are most relevant to the semantic features of the query request from the N designated entities, 1≤K≤N;

[0017] Obtain subgraph information related to the K specified entities from the preset knowledge graph.

[0018] In one embodiment, obtaining the key entity in the query request includes:

[0019] The query request is input into the small language model to obtain key entities in the query request.

[0020] In one embodiment, the number of designated entities corresponding to the first semantic feature is equal to the number of designated entities corresponding to the second semantic feature.

[0021] In one embodiment, the preset knowledge graph is generated in the following manner:

[0022] Obtain entities in knowledge documents, attribute information of entities, and relationships between entities;

[0023] Based on the entities in the knowledge document, the attribute information of the entities and the relationships between the entities, a knowledge graph of the knowledge document is constructed.

[0024] In one embodiment, the knowledge vector library corresponding to the preset knowledge graph includes: vectors of entities included in the preset knowledge graph;

[0025] The obtaining N specified entities similar to the semantic information from the knowledge vector library corresponding to the preset knowledge graph includes:

[0026] Comparing the first semantic feature with the vectors of each entity in the knowledge vector library to obtain the designated entity similar to the first semantic feature;

[0027] The second semantic feature is compared with the vectors of each entity in the knowledge vector library to obtain the designated entity similar to the second semantic feature.

[0028] In one embodiment, obtaining subgraph information related to the K specified entities from the preset knowledge graph includes:

[0029] For each of the K designated entities, obtain neighbor entities within H hops of the designated entity in the preset knowledge graph as subgraph information related to the designated entity, where H is an integer greater than or equal to 1. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 is a schematic diagram of a method for processing a language model query request based on a knowledge graph in a first embodiment of the present invention;

[0031] Figure 2 yes Figure 1 A specific flow chart of step 102 of the method for processing a language model query request based on a knowledge graph;

[0032] Figure 3 is an example diagram of a knowledge graph according to the first embodiment of the present invention;

[0033] Figure 4 It is a module structure diagram of a method for processing a language model query request based on a knowledge graph implemented by a service device in a second embodiment of the present invention. DETAILED DESCRIPTION

[0034] The following will be described in detail with reference to the accompanying drawings to provide a clearer understanding of the purpose, features and advantages of the present invention. It should be understood that the embodiments shown in the accompanying drawings are not intended to limit the scope of the present invention, but are only intended to illustrate the essential spirit of the technical solution of the present invention.

[0035] In the following description, certain specific details are set forth for the purpose of illustrating various disclosed embodiments to provide a thorough understanding of the various disclosed embodiments. However, those skilled in the relevant art will recognize that the embodiments may be practiced without one or more of these specific details. In other cases, well-known devices, structures, and techniques associated with the present application may not be shown or described in detail to avoid unnecessarily obscuring the description of the embodiments.

[0036] Unless the context requires otherwise, throughout the specification and claims, the word "comprise" and variations such as "include" and "have" should be construed in an open, inclusive sense, ie, should be interpreted as "including, but not limited to."

[0037] References throughout the specification to "one embodiment" or "an embodiment" indicate that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment. Thus, the appearances of "in one embodiment" or "in an embodiment" in various places throughout the specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any manner in one or more embodiments.

[0038] As used in this specification and the appended claims, the singular forms "a", "an", and "the" include plural referents unless the context clearly dictates otherwise. It should be noted that the term "or" is generally employed in its sense including "or / and" unless the context clearly dictates otherwise.

[0039] In the following description, in order to clearly show the structure and working mode of the present invention, many directional words will be used for description, but the words "front", "back", "left", "right", "outside", "inside", "outward", "inward", "up", "down", etc. should be understood as convenient terms and should not be understood as restrictive terms.

[0040] The first embodiment of the present invention relates to a language model query request processing method based on a knowledge graph, which is applied to a service device. The service device can be a server or a common computer device, such as a desktop host, a laptop computer, etc.

[0041] like Figure 1 As shown, it is a specific flow chart of the language model query request processing method based on the knowledge graph.

[0042] Step 101: Obtain semantic information of a received query request.

[0043] Specifically, a user may input a query request (Query) through a personal terminal (mobile phone, laptop computer, etc.), the input query request being, for example, a query statement, and the user terminal sends the query request to a service device. After receiving the query request from the user, the service device obtains semantic information of the query request.

[0044] Exemplarily, obtaining the semantic information of the query request includes: obtaining the key entity in the query request; obtaining the first semantic feature of the query request and the second semantic feature of the key entity; specifically, a small language model (SLM) is preset in the service device, which may also be called a small-scale language model. The small language model refers to a language model with a smaller scale and a smaller number of parameters; the small language model may be fine-tuned in advance, and the fine-tuning method is full-scale fine-tuning, that is, the small language model is trained using the training data of "query request-key entity" to obtain the small language model f after parameter fine-tuning. key; The service device inputs the received query request q into the small language model f key , to get the key entity q in the query request k ; Key entity q k =f key (q).

[0045] The service device then obtains the semantic features of the query request through a preconfigured semantic feature extraction model, recorded as the first semantic feature; and obtains the semantic features of the key entities of the query request, recorded as the second semantic feature. The semantic information of the query request includes: the first semantic feature and the second semantic feature. In this way, the semantic features of the key entity and the semantic features of the query request can be combined to reduce the errors caused by noise interference in the query request. Of course, in some scenarios, only the first semantic feature or the second semantic feature can be selected as the semantic information of the query request.

[0046] The first semantic feature v of the query request q It can be expressed as: q =f embed (q);

[0047] The second semantic feature v of the key entity in the query request qk It can be expressed as: qk =f embed (q k );

[0048] Among them, f embed Represents a semantic feature extraction model, for example, a sentence-transformer-based model, which is used to map input text into vectors to extract semantic features, and the extracted semantic features are represented by vectors.

[0049] Step 102, based on the semantic information of the query request, obtain subgraph information related to the semantics of the query request from a preset knowledge graph.

[0050] Please refer to Figure 2 , step 102 specifically includes the following sub-steps:

[0051] Sub-step 1021, obtaining N specified entities similar to the semantic information from the knowledge vector library corresponding to the preset knowledge graph, the N specified entities include specified entities similar to the first semantic feature and specified entities similar to the second semantic feature, and N is an integer greater than 1.

[0052] Sub-step 1022, obtaining sub-graph information related to N specified entities from the preset knowledge graph.

[0053] Specifically, there is a preset knowledge graph in the service device, which can be generated in the service device or sent to the service device after being generated by other devices; the preset knowledge graph can be for a single field, or it can be not limited to a single field, or different fields can correspond to different preset knowledge graphs, and these preset knowledge graphs are all configured in the service device.

[0054] The preset knowledge graph can be generated in advance and configured in the service device, or it can be generated instantly; further, the preset knowledge graph can be updated according to a set period.

[0055] Exemplarily, the generation method of the preset knowledge graph is:

[0056] Obtain entities in knowledge documents, attribute information of entities, and relationships between entities; specifically, first obtain existing knowledge documents, which can be any required related documents, such as papers, articles, etc., and can be for a single field or not limited to a single field; use an entity relationship extraction model to identify entities in knowledge documents, attribute information of entities, and relationships between entities. The entity relationship extraction model can be a pre-trained deep learning model, such as a Rebel model, or an existing large language model, which can identify entities, attribute information of entities, and relationships between entities from knowledge documents; wherein, the entities mentioned later can also be understood to include attribute information, and the attribute information of entities may include attribute names and attribute values, such as the attribute name is gender, and the attribute value is male.

[0057] Define the input knowledge document text as The entity relationship extraction model identifies entities, attribute information of entities, and relationships between entities from knowledge documents, forming entity sets and relationships between entities. It can be expressed as:

[0058]

[0059] Among them, f extract Represents the entity relationship extraction model, which is used to map knowledge documents to entity sets ε and relationship sets

[0060] The knowledge graph of the knowledge document is constructed based on the entities in the knowledge document, the attribute information of the entities, and the relationships between the entities. Specifically, the knowledge graph of the knowledge document is constructed based on the entities in the knowledge document and the relationships between the entities. Each node in the knowledge graph is an entity, and each node also includes the attribute information of the corresponding entity. The entities with mutual relationships are represented as interconnected nodes in the knowledge graph, thereby converting the unstructured knowledge document into a structured knowledge graph; that is, the entity set ε extracted from the knowledge document and the relationship between the entities Stored as a knowledge graph G, it can be specifically expressed as:

[0061] G=(V,E)

[0062] V={e i |e i ∈ε}

[0063] Among them, G represents the knowledge graph, V represents the node set in the knowledge graph (i.e., the entity in the knowledge document), and e i represents the i-th entity in the entity set ε, E represents the relationship between nodes in the knowledge graph, which is the basic unit of the knowledge graph and is represented by a triple of "entity-relationship-entity". m Represents the mth node in the node set V, v n Represents the nth node in the node set V, r mn Represents the relationship between the mth node and the nth node.

[0064] For example, please refer to Figure 3 , is a schematic diagram of a knowledge graph G, which includes 30 entities from S1 to S30. The knowledge graph also stores the attribute information of each entity.

[0065] Furthermore, the semantic feature extraction model f can be used embed The entities in the knowledge graph G are vectorized to obtain the vector representation of each entity in the knowledge graph G, forming the knowledge vector library X corresponding to the knowledge graph G:

[0066] X={x i |x i =f embed (v i ),v i ∈V}

[0067] Among them, f embed represents the semantic feature extraction model, x i The vector representing the i-th entity in the knowledge graph G.

[0068] The above-mentioned knowledge graph is configured in the service device as a preset knowledge graph. At the same time, the knowledge vector library X corresponding to the knowledge graph G can also be configured in the service device.

[0069] Retrieve the first semantic feature v corresponding to the query request in the knowledge vector base X q The most similar specified entity, that is, the first semantic feature v q Compare with the vectors of each entity in the knowledge vector library X to determine the first semantic feature v q The similarity between the entities in the knowledge vector library X can be determined to determine the entities in the knowledge vector library X that are similar to the first semantic feature v q Most similar N 1 Specified Entity I q For example, the cascade graph search method based on the Faiss tool is used to retrieve the first semantic feature v of the query request in the knowledge vector library X. q Most similar N 1 Specified Entity I q , then it can be expressed as:

[0070] I q =Top-Rank(f retriever (v q ,X),N 1 )

[0071] Among them, Top-Rank(f retriever (v q ,X),N 1 ) represents the first semantic feature v in the knowledge vector library X q The most similar top N 1 Specified Entity I q .

[0072] Retrieve the second semantic feature v of the key entity in the knowledge vector base X and the query request qk The most similar specified entity, that is, the second semantic feature v qk Compare with the vectors of each entity in the knowledge vector library X to determine the second semantic feature v qk The similarity between the entities in the knowledge vector library X can be used to determine the entities in the knowledge vector library X that are similar to the second semantic feature v qk Most similar N 2 For example, the cascade graph search method based on the Faiss tool is used to retrieve the second semantic feature v of the query request in the knowledge vector library X. qk Most similar N 2 Specified Entity I qk , then it can be expressed as:

[0073] I qk=Top-Rank(f retriever (v qk ,X),N 2 )

[0074] Among them, Top-Rank(f retriever (v qk ,X),N 2 ) represents the knowledge vector library X and the second semantic feature v qk The most similar top N 2 Specified Entity I qk .

[0075] The N specified entities similar to the semantic information obtained from the knowledge vector library corresponding to the preset knowledge graph include: q Most similar N 1 specified entity, and the second semantic feature v qk Most similar N 2 Specified entities. That is, N specified entities V similar to the semantic information obtained from the knowledge vector library X initial_reference Includes: knowledge vector library X and the first semantic feature v q The most similar top N 1 Specified Entity I q , and the second semantic feature v in the knowledge vector library X qk The most similar top N 2 Specified Entity I qk , which can be expressed as:

[0076] V initial_reference =V[I q ||I qk ]

[0077] In the above-obtained knowledge vector library X, the first semantic feature v q Most similar N 1 Specified Entity I q , and the second semantic feature v qk Most similar N 2 Specified Entity I qk , N 1 Can be equal to N 2 , that is, N 1 =N 2 =N / 2; in some embodiments, N 1 It may not be equal to N 2 .

[0078] Exemplarily, when obtaining subgraph information related to N specified entities from a preset knowledge graph, it is also possible to:

[0079] First, select K specified entities that are most relevant to the semantic features of the query request from N specified entities, 1≤K≤N; specifically, according to the N specified entities V initial_reference The semantic features of the query request (i.e., the first semantic features) are sorted by their relevance, for example, by using a preset model (e.g., a Transformer architecture network) to sort the N specified entities V initial_reference The relevance of the semantic feature of the query request (i.e., the first semantic feature) is sorted, and then the most relevant K specified entities V are selected from these N specified entities. reference , which can be expressed as:

[0080] I r =Top-Rank(f rerank (q,V initial_reference ),K)

[0081] V reference =V[I r ]

[0082] Among them, V reference Indicates the K specified entities that are most relevant to the semantic features of the query request among the N specified entities; Top-Rank (f rerank (q,V initial_reference ),K) represents N specified entities V initial_reference The semantic features v in the query request q The indexes of the top K most relevant specified entities I r .

[0083] Then obtain subgraph information related to K specified entities from the preset knowledge graph; specifically, for each specified entity in the K specified entities, obtain neighbor entities within H hops of the specified entity in the preset knowledge graph as subgraph information related to the specified entity, and the subgraph information related to each specified entity includes: the specified entity and its H hop neighbor entities, the relationship information between all entities (the specified entity and its H hop neighbor entities), and the attribute information of all entities; after obtaining the subgraph information of all specified entities in the K specified entities, combine the K specified entities and the subgraph information of each specified entity to obtain the subgraph information related to the query request semantics in the preset knowledge graph, which forms a graph query statement; wherein H is an integer greater than or equal to 1, such as 2, 3, 4, 5, etc. Exemplarily, the subgraph information related to the K specified entities V in the preset knowledge graph reference The relevant subgraph G reference It can be expressed as:

[0084] G reference = {G i |G i =Neighbor h (v i),v i ∈V reference}

[0085] Among them, Neighbor h (v i ) represents the K specified entities V in the preset knowledge graph reference The specified entity v i The set of H hop neighbors.

[0086] by Figure 3 Taking the knowledge graph G as an example, let H = 2, and the K specified entities include: specified entity S3, and specified entity S9; for the specified entity S3, its neighbor entities within 2 hops include: entity S1, entity S2, entity S30, entity S15, entity S16, entity S5, entity S4, entity S11, entity S6; for the specified entity S8, its neighbor entities within 2 hops include: entity S6, entity S5, entity S7, entity S27, entity S9, entity S26, entity S10; these include duplicate entities S5 and entity S6, which will be removed in subsequent statistics. The removal of duplicates is only for entities, not real entities. connection information between entities; thereby obtaining subgraph information of K specified entities, including: specified entity S3, specified entity S9, entity S1, entity S2, entity S30, entity S15, entity S16, entity S5, entity S4, entity S11, entity S6, entity S7, entity S27, entity S9, entity S26, entity S10, attribute information of these entities and relationship information between these entities, for example: the relationship between the specified entity S3 and entity S1, the relationship between the specified entity S3 and entity S2, the relationship between entity S2 and entity 30, and other relationships between all connected entities.

[0087] Step 103: input the query request and subgraph information semantically related to the query request into a preset language model to obtain response information of the query request.

[0088] Specifically, subgraph information related to the semantics of the query request is used as reference information, that is, entities related to the semantics of the query request (including entities and their attribute information) and the relationships between entities are used as query request context information, i.e., reference information, and the reference information is input into a preset language model together with the query request to obtain response information of the query request, which can then be sent to a user terminal for the user to view.

[0089] The preset language model in this embodiment may be a common large language model (LLM), but is not limited thereto, and may also be any model that can respond based on a user query request.

[0090] In this embodiment, subgraph information related to the semantics of the query request is extracted from the preset knowledge graph based on the semantic information of the query request, and the extracted subgraph information is input into the preset language model together with the query request as reference information. Since the subgraph information related to the semantics of the query request comes from the knowledge graph, it can provide the preset language model with accurate and rich contextual reference knowledge when responding to the query request, thereby improving the accuracy and relevance of the preset language model response. In particular, the applicability of the preset language model in a specific field can be improved by presetting a knowledge graph for a specific field.

[0091] Furthermore, in the above process, key entities in the query request can be extracted, and the semantic features of the query request and its key entities can be extracted at the same time. The semantic features of the query request and its key entities are then used to retrieve relevant specified entities in the knowledge graph, and subgraphs of each specified entity are extracted. Subsequently, the specified entities and the subgraphs of the specified entities are used as reference information, which is equivalent to parsing the query request in advance and then forming accurate and rich reference information to input into the preset language model, which improves the response performance of the preset language model when processing query requests involving multiple key entities and complex semantic relationships. This method has a strong processing capability for complex query requests.

[0092] The second embodiment of the present invention relates to a service device, which may be a server or a common computer device, such as a desktop host, a notebook computer, etc.

[0093] The service device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the language model query request processing method based on the knowledge graph in the first embodiment.

[0094] like Figure 4 As shown, it is a module structure diagram of the service device that implements the language model query request processing method based on the knowledge graph in the first embodiment.

[0095] The working process of the module in the service device is described below in conjunction with the specific process of the language model query request processing method based on the knowledge graph in the first embodiment:

[0096] The key entity recognition module is used to understand the query request and extract the key entities in the query request.

[0097] The semantic feature extraction module is used to obtain the semantic features of the query request and the key entities in the query request. The semantic feature is a high-dimensional semantic vector that can represent the deep semantic information of the query request.

[0098] The entity relationship extraction module is used to extract entities in knowledge documents and the relationships between entities from knowledge documents, that is, to extract entities, entity attribute information and relationships between entities from unstructured knowledge documents to form a structured knowledge graph, that is, a structured knowledge representation.

[0099] The subgraph search module is used to obtain subgraph information related to the semantics of the query request on the knowledge graph, so as to serve as structured reference knowledge for the preset language model to generate responses to the query request; the subgraph search module includes an entity search module, a rearrangement module and a graph query module;

[0100] The entity search module is used to retrieve N entities in the knowledge vector library corresponding to the knowledge graph that are most similar to the semantic features of the query request and the semantic features of the key entities in the query request;

[0101] The re-ranking module is used to sort N entities (including attribute information of entities) according to their semantic relevance to the query request, and return the K entities with the highest relevance;

[0102] The graph query module is used to return subgraph information related to K entities; the structured reference information formed by the subgraph information is input into the preset language model as the context of the query request. The preset language model combines the entities contained in the subgraph information and the relationship information between the entities to generate an accurate and comprehensive response to the query request.

[0103] Since the first embodiment corresponds to this embodiment, this embodiment can be implemented in conjunction with the first embodiment. The relevant technical details mentioned in the first embodiment are still valid in this embodiment, and the technical effects that can be achieved in the first embodiment can also be achieved in this embodiment. In order to reduce repetition, they are not repeated here. Accordingly, the relevant technical details mentioned in this embodiment can also be applied in the first embodiment.

[0104] It should be noted that the memory may include random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage. Similarly, the processor may also be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.

[0105] The third embodiment of the present invention relates to a computer-readable storage medium, which is a non-volatile storage medium or a non-transient storage medium, on which a computer program is stored, and is characterized in that when the computer program is run by a processor, the language model query request processing method based on the knowledge graph in the first embodiment is executed.

[0106] Since the first embodiment corresponds to this embodiment, this embodiment can be implemented in conjunction with the first embodiment. The relevant technical details mentioned in the first embodiment are still valid in this embodiment, and the technical effects that can be achieved in the first embodiment can also be achieved in this embodiment. In order to reduce repetition, they are not repeated here. Accordingly, the relevant technical details mentioned in this embodiment can also be applied in the first embodiment.

[0107] Preferred embodiments of the present invention have been described above in detail, but it should be understood that aspects of the embodiments can be modified, if necessary, to employ aspects, features and concepts of the various patents, applications and publications to provide further embodiments.

[0108] These and other changes can be made to the embodiments in light of the above detailed description.In general, in the claims, the terms used should not be considered limited to the specific embodiments disclosed in the specification and the claims, but should be construed to include all possible embodiments along with the full scope of equivalents to which these claims are entitled.

Claims

1. A method for processing language model query requests based on knowledge graph, characterized in that: include: Obtaining semantic information of the received query request; Based on the semantic information of the query request, obtaining subgraph information related to the semantics of the query request from a preset knowledge graph; The query request and subgraph information semantically related to the query request are input into a preset language model to obtain response information of the query request.

2. The method for processing language model query requests based on knowledge graph according to claim 1, characterized in that: Get the semantic information of the received query request, including: Obtaining key entities in the query request; Acquire a first semantic feature of the query request and a second semantic feature of the key entity; the semantic information of the query request includes: the first semantic feature and the second semantic feature; Based on the semantic information of the query request, obtaining subgraph information related to the semantics of the query request from a preset knowledge graph, including: Acquire N designated entities similar to the semantic information from the knowledge vector library corresponding to the preset knowledge graph, wherein the N designated entities include designated entities similar to the first semantic feature and designated entities similar to the second semantic feature, and N is an integer greater than 1; Obtain subgraph information related to the N specified entities from the preset knowledge graph.

3. The method for processing language model query requests based on knowledge graph according to claim 2, characterized in that: The obtaining subgraph information related to the N specified entities from the preset knowledge graph includes: Selecting K designated entities that are most relevant to the semantic features of the query request from the N designated entities, 1≤K≤N; Obtain subgraph information related to the K specified entities from the preset knowledge graph.

4. The method for processing language model query requests based on knowledge graph according to claim 2, characterized in that: Obtain key entities in the query request, including: The query request is input into a small language model to obtain key entities in the query request.

5. The method for processing language model query requests based on knowledge graph according to claim 2, characterized in that: The number of designated entities corresponding to the first semantic feature is equal to the number of designated entities corresponding to the second semantic feature.

6. The method for processing language model query requests based on knowledge graph according to claim 1, characterized in that: The preset knowledge graph is generated in the following way: Obtain entities in knowledge documents, attribute information of entities, and relationships between entities; Based on the entities in the knowledge document, the attribute information of the entities and the relationships between the entities, a knowledge graph of the knowledge document is constructed.

7. The method for processing language model query requests based on knowledge graph according to claim 2, characterized in that: The knowledge vector library corresponding to the preset knowledge graph includes: The vectors of entities included in the preset knowledge graph; The obtaining N specified entities similar to the semantic information from the knowledge vector library corresponding to the preset knowledge graph includes: Comparing the first semantic feature with the vectors of each entity in the knowledge vector library to obtain the designated entity similar to the first semantic feature; The second semantic feature is compared with the vectors of each entity in the knowledge vector library to obtain the designated entity similar to the second semantic feature.

8. The method for processing language model query requests based on knowledge graph according to claim 3, characterized in that: Obtaining subgraph information related to the K specified entities from the preset knowledge graph includes: For each of the K designated entities, obtain neighbor entities within H hops of the designated entity in the preset knowledge graph as subgraph information related to the designated entity, where H is an integer greater than or equal to 1.

9. A service device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the language model query request processing method based on the knowledge graph as described in any one of claims 1 to 8.

10. A computer-readable storage medium, wherein the computer-readable storage medium is a non-volatile storage medium or a non-transient storage medium, and a computer program is stored thereon, wherein: When the computer program is executed by a processor, the method for processing language model query requests based on a knowledge graph as described in any one of claims 1 to 8 is executed.

Citation Information

Patent Citations

  • Semantic retrieval method and device, equipment and storage medium

    CN112860866A

  • Intelligent retrieval method and system based on exploration and development knowledge graph and storage medium

    CN116401350A

  • Intelligent question and answer implementation method and system based on large model and semantic map

    CN117271724A

  • Government affair intelligent question answering system based on big data

    CN117453893A

  • Intelligent query reasoning method and device based on knowledge graph and large language model collaboration

    CN117743531A