Entity query method, device, equipment and medium
By determining the basic entity in information retrieval technology and extracting and filtering the entity topology diagram based on the entity, the limitations of understanding user intentions and handling complex queries in the prior art are solved, and higher relevance and accuracy of search results are achieved.
Patent Information
- Application Number
- CN202411841775.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-13
- Publication Date
- 2025-04-04
AI Technical Summary
Existing information retrieval technologies have limitations in understanding user intentions and handling complex queries, resulting in low correlation and inaccurate relevance of search results with user input information.
By determining the base entity corresponding to the entity query statement, extracting the entity topology diagram based on the base entity, obtaining the associated sub-graph, and inputting it into the graph filtering model to obtain the target graph branch, and finally determining the target entity that satisfies the entity query statement.
It improves the correctness of understanding user intentions, and the generated target entity has a high correlation with entity query statements and is more accurate. It is suitable for complex query scenarios and is suitable for real-time processing of large-scale data.
Smart Images

Figure CN119760189A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of information retrieval technology, and in particular to an entity query method, device, equipment and medium. Background Art
[0002] With the development of information retrieval technology, the application of information retrieval is becoming more and more extensive. In related technologies, information retrieval is achieved by matching user input information with database keywords. However, this method has limitations in understanding user intentions and processing complex queries, which makes the retrieval results less relevant to the user input information and less accurate. Summary of the invention
[0003] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides an entity query method, device, equipment and medium.
[0004] The present disclosure provides an entity query method, including:
[0005] Determine a basic entity corresponding to an entity query statement; wherein the entity query statement is used to query entities that satisfy the query logic with the basic entity;
[0006] The entity topology graph is extracted and processed according to the entity query statement and the basic entity to obtain a related subgraph; wherein the entity topology graph is used to represent the relationship between entities recorded in a preset database;
[0007] Input the associated subgraph and the entity query statement into a graph screening model to obtain a target graph branch corresponding to the entity query statement; wherein the target graph branch is a branch in the associated subgraph;
[0008] A target entity that satisfies the entity query statement is determined according to the target graph branch.
[0009] The present disclosure also provides an entity query device, including:
[0010] A first determination module is used to determine a basic entity corresponding to an entity query statement; wherein the entity query statement is used to query entities that satisfy the query logic with the basic entity;
[0011] An extraction module, used to extract and process the entity topology map according to the entity query statement and the basic entity to obtain a related subgraph; wherein the entity topology map is used to represent the relationship between entities recorded in a preset database;
[0012] A screening module, used to input the associated subgraph and the entity query statement into a graph screening model to obtain a target graph branch corresponding to the entity query statement; wherein the target graph branch is a branch in the associated subgraph;
[0013] The second determination module is used to determine the target entity that satisfies the entity query statement according to the target graph branch.
[0014] An embodiment of the present disclosure also provides an electronic device, which includes: a processor; a memory for storing executable instructions of the processor; the processor is used to read the executable instructions from the memory and execute the instructions to implement the entity query method provided by the embodiment of the present disclosure.
[0015] The embodiment of the present disclosure further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is used to execute the entity query method provided by the embodiment of the present disclosure.
[0016] The technical solution provided by the embodiments of the present disclosure has the following advantages over the prior art: the entity query solution provided in the embodiments of the present disclosure, the method comprising: determining the basic entity corresponding to the entity query statement; wherein the entity query statement is used to query entities that satisfy the query logic with the basic entity; extracting and processing the entity topology graph according to the entity query statement and the basic entity to obtain an associated subgraph; wherein the entity topology graph is used to characterize the relationship between entities recorded in a preset database; inputting the associated subgraph and the entity query statement into a graph screening model to obtain a target graph branch corresponding to the entity query statement; wherein the target graph branch is a branch in the associated subgraph; determining the target entity that satisfies the entity query statement according to the target graph branch. By adopting the above technical scheme, the basic entity in the entity query statement is first extracted, and the basic entity is used as the query basis to extract the overall topological graph in combination with the entity query statement to obtain a subgraph, and then the branch in the subgraph is extracted based on the entity query statement to determine the graph branch, and the final target entity is determined according to the graph branch. By extracting the basic entity and retrieving the entity topological graph containing contextual information based on the basic entity, the possibility of misunderstanding the entity query statement is reduced, the correctness of understanding the user's intention is improved, and the query scope is gradually narrowed through matching based on the entity topological graph. It is suitable for scenarios with complex queries, and the generated target entity has a high correlation with the entity query statement and good accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0019] Figure 1 A flowchart of an entity query method provided by an embodiment of the present disclosure;
[0020] Figure 2 A schematic diagram of the structure of an entity query device provided by an embodiment of the present disclosure;
[0021] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0022] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0023] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0024] With the development of information retrieval technology, the application of information retrieval is becoming more and more extensive. In related technologies, information retrieval is achieved by matching user input information with database keywords.
[0025] However, in some scenarios, the user input information cannot clearly represent the user's actual intention, and the information retrieval based on the user input information is also difficult to retrieve results that meet the user's intention. In addition, this method focuses on the successfully matched keywords and cannot accurately capture the contextual information related to the user's query information in the database. Therefore, this method has obvious limitations in understanding user intentions and processing complex queries, making the retrieval results less relevant to the user input information and less accurate. In addition, when the database and / or input information is large, directly matching the input information with the entire database for keywords is inefficient and difficult to meet the real-time requirements of the query.
[0026] In order to solve the above problems, the embodiments of the present disclosure provide an entity query method, which is introduced below in conjunction with specific embodiments.
[0027] Figure 1The present invention provides a flowchart of an entity query method provided by an embodiment of the present invention. The entity query method can be applied to an entity query device. The entity query device can be implemented by software and / or hardware, and the entity query device can generally be integrated in an electronic device. Figure 1 As shown, the entity query method includes:
[0028] Step 101, determining a basic entity corresponding to an entity query statement; wherein the entity query statement is used to query entities that satisfy the query logic with the basic entity.
[0029] Among them, the entity query statement can be used to query entities whose entity relationship with the basic entity satisfies the query logic, and the entity query statement can be a natural statement input by the user. This embodiment does not limit the entity query statement. For example, the entity query statement can be used to determine the company established by personnel A, personnel B, and personnel C, or the entity query statement can be used to determine the company that has a cooperative relationship with the company established by personnel A, personnel B, and personnel C. The basic entity can be the entity corresponding to the basic query statement as the query basis, and the basic entity can be understood as the subject entity corresponding to the entity query statement. The entity can be an object or a concept. This embodiment does not limit the type of the entity. For example, the type of the entity can include people, organizations, places, etc. The basic entity is an entity included in the entity query statement, or the basic entity may not be included in the entity query statement but is implicitly included in the entity query statement. The basic entity can be determined by performing semantic analysis, error correction processing, etc. on the entity query statement. The query logic can represent the logic of performing entity query based on the basic entity, and the query logic can be the entity relationship between the basic entity and the target entity finally determined.
[0030] In the disclosed embodiment, a user may input an entity query statement into the entity query device, and the entity query device obtains the entity query statement and performs semantic analysis on the entity query statement to determine a basic entity corresponding to the entity query statement.
[0031] In some embodiments of the present disclosure, determining a basic entity corresponding to an entity query statement includes: inputting the entity query statement, library entities in a preset database, and entity extraction prompt words into a preset entity extraction model to obtain a basic entity.
[0032] The preset database may be a pre-set knowledge base, and the preset database may be understood as a data basis for entity query. The library entity may be an entity recorded in the preset database. The entity extraction prompt word may be used to prompt the large language model to extract entities from the entity query statement according to the library entity. The entity extraction model may be used to extract entities corresponding to the statement. This embodiment does not limit the entity extraction model. For example, the entity extraction model may be a large language model.
[0033] In this embodiment, the preset database may have a corresponding entity topology map, which represents the relationship between entities recorded in the preset database. The entity topology map may include multiple nodes and lines between nodes. The nodes in the entity topology map may represent entities, and the lines between nodes may represent the relationship between entities. It can be understood that the lines between the nodes represent part of the contextual relationship recorded in the preset database. The entity query device can extract entities in the entity topology map to obtain library entities corresponding to the preset database. Further, the entity query statement, the library entity, and the entity extraction prompt word are input into the entity extraction model, and the entity extraction model extracts the entity query statement within the scope of the library entity under the prompt of the entity extraction prompt word, and obtains the basic entity output by the entity extraction model. For example, the entity query statement can be a query based on person A, but the entity query statement includes a description statement related to person A and the specific name of person A does not appear. Person A is included in the library entity. Through the processing of the entity episode model, it can be determined that the basic entity includes person A. If the entity query statement includes: determining the company established by person A, person B, and person C, or determining the company that has a cooperative relationship with the company established by person A, person B, and person C, then the basic entity may include person A, person B, and person C.
[0034] In the above scheme, entity extraction is performed on the entity query statement based on the library entity, and the basic entities in the library entity are obtained. When the entity query statement does not directly contain the name of the basic entity, the accurate extraction of the basic entity is achieved, and a foundation is created for the subsequent extraction of the entity topology map corresponding to the preset database based on the basic entity.
[0035] Step 102: extract and process the entity topology graph according to the entity query statement and the basic entity to obtain a related subgraph; wherein the entity topology graph is used to represent the relationship between entities recorded in a preset database.
[0036] The associated subgraph may be a part of the entity topology graph, and the associated subgraph may be a topology graph obtained by deleting entities from the entity topology graph based on the basic entity.
[0037] In the disclosed embodiment, the entity query device may delete entities with less association with the basic entity in the entity topology graph according to the entity query statement and the basic entity to obtain an associated subgraph.
[0038] In some embodiments of the present disclosure, extracting and processing the entity topology graph according to the entity query statement and the basic entity to obtain the associated subgraph includes: determining a structural distance threshold according to the entity query statement; taking the basic entity as a reference, extracting and processing the entity topology graph according to the structural distance threshold to obtain the associated subgraph. The structural distance threshold may be the maximum value of the distance between the outermost entity in the associated subgraph and the basic entity.
[0039] In this embodiment, the entity query device can perform semantic analysis on the entity query statement, determine the maximum distance between the entity to be screened by the entity query statement and the basic entity in the entity topology map, and obtain a structural distance threshold. This embodiment does not limit the semantic analysis method. For example, the semantic analysis can be implemented through a large language model, or the semantic analysis can be implemented by keyword extraction and matching the keywords with preset relationships, and the preset relationship records the thresholds corresponding to different keywords. Furthermore, the entity query device can perform sub-graph extraction on the entity topology map based on the basic entity and the structural distance threshold to obtain an associated sub-graph.
[0040] In some embodiments of the present disclosure, the entity topology graph is extracted and processed based on a structural distance threshold with a basic entity as a benchmark to obtain an associated subgraph, including: determining a first coding distance between a library entity in the entity topology graph and the basic entity, deleting library entities in the entity topology graph whose first coding distance is greater than the structural distance threshold to obtain an associated subgraph.
[0041] Among them, the first coding distance can be the coding distance between the library entity and the basic entity in the entity topology diagram. The coding distance can be used to characterize the closeness of the relationship between entities. There are many types of coding distances, which are not limited in this embodiment. For example, the coding distance can be directional distance encoding (Directional Distance Encoding, DDE).
[0042] In this embodiment, for the library entity in the entity topology map, the entity query device can determine the first coding distance between the library entity and the basic entity in the entity topology map according to a preset distance calculation algorithm, and judge whether the first coding distance is greater than the structural distance threshold. If so, it means that the relationship between the library entity and the basic entity is relatively distant, and then delete the library entity and the branch of the library entity far away from the basic entity to obtain an associated subgraph. For example, if the entity query statement is to determine the company that has a cooperative relationship with the company established by personnel A, personnel B, and personnel C, the associated subgraph may include a triple graph that records personnel-established company-cooperated company. Thereby, the redundant information in the entity topology map is filtered out, and the query scope is narrowed based on the basic entity and the entity query statement.
[0043] Step 103, input the associated subgraph and the entity query statement into the graph screening model to obtain the target graph branch corresponding to the entity query statement; wherein the target graph branch is a branch in the associated subgraph.
[0044] Among them, the graph screening model can be used to screen the branches in the topological graph according to the semantics represented by the statement, and the graph screening model can be a trained neural network model. This embodiment does not limit the type of the graph screening model. For example, the graph screening model can be a model built based on a lightweight multi-layer perceptron (MLP). The target graph branch can be a target graph branch that meets the description of the entity query statement among multiple candidate graph branches of the associated subgraph. The branch can be a branch decomposed from the overall topological graph, and there is no fork in the branch.
[0045] In the disclosed embodiment, the graph screening model is trained in advance so that the graph screening model has the function of screening graph branches according to the entity query statement. The entity query device can input the associated subgraph and the entity query statement into the graph screening model, and the graph screening model uses the entity query statement as a screening condition to perform branch screening on the associated subgraph to obtain the target graph branch.
[0046] In some embodiments of the present disclosure, the associated subgraph and the entity query statement are input into the graph screening model to obtain the target graph branch corresponding to the entity query statement, including:
[0047] The associated subgraph is branch-split to obtain multiple candidate graph branches; each candidate graph branch and an entity query statement are input into a graph screening model to obtain the relevance of each candidate graph branch and the entity query statement; and a target graph branch among the multiple candidate graph branches is determined according to the relevance.
[0048] The multiple candidate graph branches may be all branches decomposed by traversing the associated subgraph. The entity at one end of the candidate graph branch may be the basic entity, and the entity at the other end of the candidate branch may be the entity at the end of the candidate graph branch. The relevance may represent the degree of match between the candidate graph branch and the entity query statement.
[0049] In this embodiment, the entity query device can traverse the links in the associated subgraph, split the associated subgraph into multiple candidate graph branches, and convert the entity query statement into a corresponding query expression through a large language model. Furthermore, the entity query device can input each candidate graph branch and the query expression into a graph screening model respectively, and the graph screening model matches the candidate graph branch and the query expression, determines the degree of match between the candidate graph branch and the query expression, and obtains the correlation. And determine the target graph branch based on the correlation. There are many methods for determining the target graph branch, which is not limited by this embodiment. For example, the entity query device can determine the candidate graph branch whose correlation is greater than a preset correlation threshold as the target graph branch, or the entity query can determine the candidate graph branch whose correlation is in the top N presets as the target graph branch.
[0050] In the above scheme, after the entity topology graph is screened based on distance, the associated subgraphs are screened by whether they are consistent with the rules represented by the entity query statement to obtain a target graph branch, in which the distance between the entity and the basic entity meets the distance requirement represented by the entity query statement, and the relationship between the entities recorded in the target graph branch meets the entity relationship represented by the entity query statement.
[0051] Step 104: determine the target entity that satisfies the entity query statement according to the target graph branch.
[0052] The target entity may be an entity that satisfies the query logic with the basic entity, and the target entity may be a finally determined entity.
[0053] In the embodiment of the present disclosure, after determining the target graph branch, the entity query device can determine the target entity in the entity recorded in the target graph branch according to the relationship between each entity represented in the target graph branch and the basic entity. Optionally, the entity query method also includes: combining the target entity with a preset prompt template to generate feedback text.
[0054] In some embodiments of the present disclosure, a target entity that satisfies an entity query statement is determined based on a target graph branch, including: determining a structural distance interval based on the entity query statement; determining a second coding distance between a candidate entity in the target graph branch and a base entity, and determining the candidate entity whose second coding distance is within the structural distance interval as the target entity.
[0055] Among them, the structural distance interval can be the range of distances between entities that satisfy the entity query statement and the basic entity, and the upper limit of the structural distance interval can be less than the structural distance threshold, thereby reducing the probability of accidental deletion of entities in the entity topology graph due to model output fluctuations, and gradually narrowing the query range, making the query more logical. The candidate entity can be an entity recorded in the target graph branch. The second encoding distance can be the encoding distance between the candidate entity recorded in the target graph branch and the basic entity.
[0056] In this embodiment, the entity query device can perform semantic analysis on the entity query statement, determine the distance range between the entity to be screened by the entity query statement and the basic entity in the target graph branch, and obtain the structural distance interval. This embodiment does not limit the semantic analysis method. For example, the semantic analysis can be implemented through a large language model, or the semantic analysis can be implemented by keyword extraction and matching the keywords with preset relationships, and the preset relationship records the ranges corresponding to different keywords.
[0057] Furthermore, the entity query device can screen the candidate entities according to the basic entity and the structural distance range. Specifically, the entity query device can determine the second coding distance between the candidate entity and the basic entity in the target graph branch according to a preset distance calculation algorithm, and determine whether the second coding distance is within the structural distance interval. If so, the candidate entity is determined as the target entity. For example, the target graph branch is: Person A-Company 1-Company 2, wherein Company 1 represents the company established by Person A, Company 2 represents the relationship with Company 1 that has a cooperative relationship, the second coding distance between Company 1 and the person is 0.5, the second coding distance between Company 2 and the person is 1.5, and the structural distance interval is 1-2, then the target entity can be Company 2. Thus, the target graph branch with a strong correlation with the entity query statement is determined by screening, and a high-precision entity matching is performed based on the target graph branch and the entity query statement to determine the queried target entity, thereby achieving accurate query.
[0058] In the above scheme, entities within the structural distance threshold in the entity topology graph are retained first, entities that are closely related to the basic entities are retained and the relationship between the entities is recorded, which provides a basis for subsequent more detailed screening. Then, the entities in the target graph branch are screened according to the structural distance interval, and accurate screening of entities is achieved based on the contextual information retained in the target graph branch.
[0059] The entity query method provided by the embodiment of the present disclosure includes: determining the basic entity corresponding to the entity query statement; wherein the entity query statement is used to query the entity that satisfies the query logic with the basic entity; extracting and processing the entity topology graph according to the entity query statement and the basic entity to obtain the associated subgraph; wherein the entity topology graph is used to characterize the relationship between the entities recorded in the preset database; inputting the associated subgraph and the entity query statement into the graph screening model to obtain the target graph branch corresponding to the entity query statement; wherein the target graph branch is the branch in the associated subgraph; and determining the target entity that satisfies the entity query statement according to the target graph branch. The above technical scheme is adopted to first extract the basic entity in the entity query statement, extract the subgraph from the overall topology graph based on the basic entity as the query basis and the entity query statement, then extract the branch in the subgraph based on the entity query statement to determine the graph branch, and determine the final target entity according to the graph branch. By extracting the basic entity and retrieving the entity topology graph containing context information based on the basic entity, the possibility of misunderstanding the entity query statement is reduced, the correctness of understanding the user's intention is improved, and the query scope is gradually narrowed by matching based on the entity topology graph, which is suitable for the scene of complex query, and the generated target entity has a high correlation with the entity query statement and good accuracy.
[0060] In addition, by performing entity queries based on the entity topology graph, matching all the data in the preset database is avoided, the efficiency of processing large-scale data is improved, and the real-time requirements of entity queries are met.
[0061] In some embodiments of the present disclosure, an entity query statement includes a first entity query statement and a second entity query statement. The first entity query statement and the second entity query statement are connected by a set processing statement. The target entity corresponding to the first entity query statement is the first target entity, and the target entity corresponding to the second entity query statement is the second target entity.
[0062] Among them, the first entity query statement and the second entity query statement can be different entity query statements. For example, the first entity query statement and the second entity query statement can correspond to the same basic entity, but the query logic is different; or, the first entity query statement and the second entity query statement can correspond to the same query logic, but the basic entity is different; or, the first entity query statement and the second entity query statement can correspond to different query logic and basic entities. The first target entity can be an entity range determined according to the first entity query statement, and the second target entity can be an entity range determined according to the second entity query statement. The set processing statement can represent the set operation processing performed on the entity corresponding to the first entity query statement and the entity corresponding to the second entity query statement. This embodiment does not limit the set processing statement. For example, the set processing statement may include: and is not, and, merge, etc.
[0063] Correspondingly, the entity query method further includes: determining a set operator according to a set processing statement; performing set operation processing on the first target entity and the second target entity according to the set operator to obtain a result entity.
[0064] In this embodiment, the entity query device can perform the steps included in the above entity query method on the first entity query statement to obtain the first target entity; and perform the steps included in the above entity query method on the second entity query statement to obtain the second target entity. Specifically, for the first entity query statement, the entity query device can determine the first basic entity corresponding to the first entity query statement; extract and process the entity topology graph according to the first entity query statement and the first basic entity to obtain the first associated subgraph; input the first associated subgraph and the first entity query statement into the graph screening model to obtain the first target graph branch corresponding to the first entity query statement; determine the first target entity that satisfies the first entity query statement according to the first target graph branch. For the second entity query statement, the entity query device can determine the second basic entity corresponding to the second entity query statement; extract and process the entity topology graph according to the second entity query statement and the second basic entity to obtain the second associated subgraph; input the second associated subgraph and the second entity query statement into the graph screening model to obtain the second target graph branch corresponding to the second entity query statement; determine the second target entity that satisfies the second entity query statement according to the second target graph branch.
[0065] Furthermore, a processing keyword in the set processing statement is extracted, a set operator is determined according to the processing keyword, and a set operation is performed on the first target entity and the second target entity according to the set operator to obtain a result entity.
[0066] For example, if the statement input by the user is to determine the company that has a cooperative relationship with the company established by personnel A, personnel B, and personnel C, and is not a company established by personnel A, personnel B, and personnel C. Then the first entity query statement can be companies that have a cooperative relationship with the company established by personnel A, personnel B, and personnel C, the second entity query statement can be companies established by personnel A, personnel B, and personnel C, and the set processing statement can be and is not. If the first target entity includes company 1, company 2, and company 3, and the second target entity includes company 3, then the result entities include company 1 and company 2.
[0067] The above solution implements entity queries with more complex logic and is applicable to a wider range of application scenarios.
[0068] Next, the entity query method in the embodiment of the present disclosure is further explained through a specific example.
[0069] In the entity query method provided in this embodiment, the basic entity is first identified. Specifically, the basic entity is identified according to the entity query statement input by the user. Further, the first coding distance between the basic entity and the library entity in the entity topology graph is determined, and the library entities in the entity topology graph are screened according to the first coding distance to obtain an associated subgraph. The associated subgraph is input into the graph screening model, and the query expression determined according to the entity query statement is input into the graph screening model, and the query expression records the query logic corresponding to the entity query statement in the form of an expression. The graph screening model evaluates each candidate graph branch in the associated subgraph through coding and determines the relevance corresponding to each candidate graph branch, and determines the target graph branch according to the relevance. The target entity is determined according to the target graph branch, and the target entity is combined with a preset prompt template to obtain feedback text.
[0070] In the entity query method provided by the embodiment of the present disclosure, by extracting the associated subgraph from the entity topology graph, the associated subgraph records the relationship between entities in the preset database, so that the entity query based on the associated subgraph can more accurately capture the context information of the basic entity, improve the accuracy of the query to obtain the target entity, and improve the relevance of the target entity to the entity query statement. In addition, the method can be applied to preset databases in different fields, has good scalability, and can be applied to a variety of entity query scenarios. Through graph matching, the most relevant retrieval results can be quickly generated and returned.
[0071] Figure 2 This is a schematic diagram of the structure of an entity query device provided by an embodiment of the present disclosure. The device can be implemented by software and / or hardware, and the device can also be integrated in an electronic device. Figure 2 As shown, the entity query device includes:
[0072] The first determination module 201 is used to determine the basic entity corresponding to the entity query statement; wherein the entity query statement is used to query the entity that satisfies the query logic with the basic entity;
[0073] An extraction module 202 is used to extract and process the entity topology graph according to the entity query statement and the basic entity to obtain a related subgraph; wherein the entity topology graph is used to represent the relationship between entities recorded in a preset database;
[0074] A screening module 203 is used to input the associated subgraph and the entity query statement into a graph screening model to obtain a target graph branch corresponding to the entity query statement; wherein the target graph branch is a branch in the associated subgraph;
[0075] The second determination module 204 is used to determine the target entity that satisfies the entity query statement according to the target graph branch.
[0076] Optionally, determining a basic entity corresponding to the entity query statement includes:
[0077] The entity query statement, the library entities in the preset database, and the entity extraction prompt words are input into a preset entity extraction model to obtain the basic entity.
[0078] Optionally, the extracting and processing the entity topology graph according to the entity query statement and the basic entity to obtain a related subgraph includes:
[0079] Determining a structural distance threshold according to the entity query statement;
[0080] Taking the basic entity as a benchmark, the entity topology graph is extracted and processed according to the structural distance threshold to obtain the associated subgraph.
[0081] Optionally, taking the basic entity as a reference and performing extraction processing on the entity topology graph according to the structural distance threshold to obtain the associated subgraph includes:
[0082] The first coding distance between the library entity and the basic entity in the entity topology graph is determined, and the library entity whose first coding distance in the entity topology graph is greater than a structural distance threshold is deleted to obtain the associated subgraph.
[0083] Optionally, the step of inputting the associated subgraph and the entity query statement into a graph screening model to obtain a target graph branch corresponding to the entity query statement includes:
[0084] Perform branch splitting processing on the associated subgraph to obtain multiple candidate graph branches;
[0085] Inputting each of the candidate graph branches and the entity query statement into the graph screening model to obtain the relevance between each of the candidate graph branches and the entity query statement;
[0086] According to the relevance, the target graph branch among the multiple candidate graph branches is determined.
[0087] Optionally, determining a target entity satisfying the entity query statement according to the target graph branch includes:
[0088] Determine a structural distance interval according to the entity query statement;
[0089] A second encoding distance between a candidate entity in the target graph branch and the basic entity is determined, and the candidate entity whose second encoding distance is within the structural distance interval is determined as the target entity.
[0090] Optionally, the entity query statement includes a first entity query statement and a second entity query statement, the first entity query statement and the second entity query statement are connected by a set processing statement, the target entity corresponding to the first entity query statement is a first target entity, and the target entity corresponding to the second entity query statement is a second target entity;
[0091] Accordingly, the method further comprises:
[0092] Determining a set operator according to the set processing statement;
[0093] A set operation is performed on the first target entity and the second target entity according to the set operator to obtain a result entity.
[0094] It should be noted that Figure 2 The entity query apparatus 200 shown can execute each step in the above entity query method embodiment, and realize each process and effect in the above entity query method embodiment, which will not be described in detail here.
[0095] Figure 3 The structure diagram of an electronic device provided by the embodiment of the present disclosure is shown in FIG. Figure 3 As shown, the electronic device 300 includes one or more processors 301 and a memory 302 .
[0096] The processor 301 may be a central processing unit (CPU) or other forms of processing units having entity query capability and / or instruction execution capability, and may control other components in the electronic device 300 to perform desired functions.
[0097] The memory 302 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, a random access memory (RAM) and / or a cache memory (cache), etc. The non-volatile memory may include, for example, a read-only memory (ROM), a hard disk, a flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 301 may run the program instructions to implement the entity query method of the embodiment of the present disclosure described above and / or other desired functions. Various contents such as input signals, signal components, noise components, etc. may also be stored in the computer-readable storage medium.
[0098] In one example, the electronic device 300 may further include: an input device 303 and an output device 304 , and these components are interconnected via a bus system and / or other forms of connection mechanisms (not shown).
[0099] In addition, the input device 303 may also include, for example, a keyboard, a mouse, and the like.
[0100] The output device 304 can output various information to the outside, including the determined distance information, direction information, etc. The output device 304 can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, and the like.
[0101] Of course, to simplify, Figure 3 Only some of the components related to the present disclosure in the electronic device 300 are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application situations, the electronic device 300 may also include any other appropriate components.
[0102] In addition to the above-mentioned method and device, the embodiment of the present disclosure may also be a computer program product, which includes computer program instructions, and when the computer program instructions are executed by a processor, the processor executes the entity query method provided by the embodiment of the present disclosure.
[0103] The computer program product may be written in any combination of one or more programming languages to write program code for performing the operations of the disclosed embodiments, 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.
[0104] In addition, the embodiment of the present disclosure may also be a computer-readable storage medium on which computer program instructions are stored. When the computer program instructions are executed by a processor, the processor executes the entity query method provided by the embodiment of the present disclosure.
[0105] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an 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 above.
[0106] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0107] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An entity query method, characterized in that: include: Determine a basic entity corresponding to an entity query statement; wherein the entity query statement is used to query entities that satisfy the query logic with the basic entity; The entity topology graph is extracted and processed according to the entity query statement and the basic entity to obtain a related subgraph; wherein the entity topology graph is used to represent the relationship between entities recorded in a preset database; Input the associated subgraph and the entity query statement into a graph screening model to obtain a target graph branch corresponding to the entity query statement; wherein the target graph branch is a branch in the associated subgraph; A target entity that satisfies the entity query statement is determined according to the target graph branch.
2. The method according to claim 1, characterized in that The determining the basic entity corresponding to the entity query statement includes: The entity query statement, the library entities in the preset database, and the entity extraction prompt words are input into a preset entity extraction model to obtain the basic entity.
3. The method according to claim 1, characterized in that The extracting and processing the entity topology graph according to the entity query statement and the basic entity to obtain the associated subgraph includes: Determining a structural distance threshold according to the entity query statement; Taking the basic entity as a benchmark, the entity topology graph is extracted and processed according to the structural distance threshold to obtain the associated subgraph.
4. The method according to claim 3, characterized in that The extracting and processing the entity topology graph based on the basic entity and the structural distance threshold to obtain the associated subgraph includes: The first coding distance between the library entity and the basic entity in the entity topology graph is determined, and the library entity whose first coding distance in the entity topology graph is greater than a structural distance threshold is deleted to obtain the associated subgraph.
5. The method according to claim 1, characterized in that: The step of inputting the associated subgraph and the entity query statement into a graph screening model to obtain a target graph branch corresponding to the entity query statement includes: Perform branch splitting processing on the associated subgraph to obtain multiple candidate graph branches; Inputting each of the candidate graph branches and the entity query statement into the graph screening model to obtain the relevance between each of the candidate graph branches and the entity query statement; According to the relevance, the target graph branch among the multiple candidate graph branches is determined.
6. The method according to claim 1, characterized in that The determining, according to the target graph branch, a target entity that satisfies the entity query statement comprises: Determine a structural distance interval according to the entity query statement; A second encoding distance between a candidate entity in the target graph branch and the basic entity is determined, and the candidate entity whose second encoding distance is within the structural distance interval is determined as the target entity.
7. The method according to claim 1, characterized in that The entity query statement includes a first entity query statement and a second entity query statement, the first entity query statement and the second entity query statement are connected by a set processing statement, the target entity corresponding to the first entity query statement is a first target entity, and the target entity corresponding to the second entity query statement is a second target entity; Accordingly, the method further comprises: Determining a set operator according to the set processing statement; A set operation is performed on the first target entity and the second target entity according to the set operator to obtain a result entity.
8. An entity query device, characterized in that: include: A first determination module is used to determine a basic entity corresponding to an entity query statement; wherein the entity query statement is used to query entities that satisfy the query logic with the basic entity; An extraction module, used to extract and process the entity topology map according to the entity query statement and the basic entity to obtain a related subgraph; wherein the entity topology map is used to represent the relationship between entities recorded in a preset database; A screening module, used to input the associated subgraph and the entity query statement into a graph screening model to obtain a target graph branch corresponding to the entity query statement; wherein the target graph branch is a branch in the associated subgraph; The second determination module is used to determine the target entity that satisfies the entity query statement according to the target graph branch.
9. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor; The processor is used to read the executable instructions from the memory and execute the instructions to implement the entity query method described in any one of claims 1-7 above.
10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and the computer program is used to execute the entity query method described in any one of claims 1 to 7.