Knowledge retrieval method, device and equipment
By employing a graph-free entity perception mechanism and a lightweight entity-block inverted index table, the high cost and insufficient context awareness of knowledge graph-based RAG methods are resolved, achieving low-latency, high-efficiency knowledge retrieval and providing accurate contextual information.
Patent Information
- Application Number
- CN202511492323.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-17
- Publication Date
- 2026-02-17
AI Technical Summary
Existing knowledge graph-based RAG methods are costly to build and maintain, difficult to update, contain a lot of irrelevant information in the search results, have slow response times, and cannot understand and retrieve complex relationship information between entities, and lack context awareness.
A graph-free entity perception mechanism is adopted. By evaluating complexity, an appropriate retrieval strategy is selected, entity extraction and processing are performed on the query statement, retrieval instructions are generated, target context knowledge data is retrieved and scored from the knowledge vector base, and a lightweight entity-block inverted index table is used for retrieval.
It achieves accurate retrieval with low cost and low latency, and can dynamically adjust according to query complexity and context requirements, providing compact and non-redundant contextual information that is highly relevant to the user's query intent.
Smart Images

Figure CN121542372A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical fields of knowledge retrieval, and in particular to a knowledge retrieval method, apparatus, and device. Background Technology
[0002] Retrieval-Augmented Generation (RAG) has become a key technology for knowledge-intensive natural language processing applications such as question answering, summarizing, and decision support. It involves retrieving relevant information from external knowledge bases during reasoning and providing this information as context to a Large Language Model (LLM).
[0003] The relevant technologies employ a knowledge graph-based RAG approach. In the indexing phase, a knowledge graph is constructed using techniques such as entity linking and relation extraction. In the retrieval phase, key entities in the query are first identified, then these entity nodes are located in the knowledge graph, and a subgraph containing relevant entities and relations is obtained through graph traversal algorithms (such as subgraph retrieval). However, the construction and maintenance of knowledge graph-based RAGs are costly, requiring operations such as entity recognition, linking, relation extraction, and subgraph refinement. Updates are difficult, and costs increase dramatically with the size of the corpus. Retrieval results contain a large amount of irrelevant information, leading to slow response times. Furthermore, flat representations cannot understand and retrieve complex relationships between entities, and insufficient context awareness makes it difficult to provide answers to user queries. Summary of the Invention
[0004] The embodiments of the present invention aim to at least partially solve one of the technical problems in related technologies. Therefore, one object of the present invention is to provide a knowledge retrieval method, apparatus, device, and medium capable of providing users with accurate retrieval contextual information.
[0005] This invention provides a knowledge retrieval method, which includes: evaluating the complexity of a user-input query to obtain a complexity evaluation result; based on the complexity evaluation result, selecting a retrieval strategy corresponding to the complexity evaluation result to perform entity extraction processing on the query to obtain target entity information; based on the retrieval strategy, selecting and merging the target entity information and the query to generate a retrieval instruction; based on the retrieval instruction, retrieving from a knowledge vector database to obtain multiple knowledge retrieval results; and performing a scoring and selection process on the multiple knowledge retrieval results to construct target context knowledge data.
[0006] For example, based on the complexity assessment result, a retrieval strategy corresponding to the complexity assessment result is selected to perform entity extraction processing on the query statement to obtain target entity information. This includes: if the complexity assessment result is less than a preset complexity threshold, a first retrieval strategy is selected to perform entity extraction processing on the query statement to obtain target entity information; if the complexity assessment result is greater than or equal to the preset complexity threshold, a second retrieval strategy is selected to split the query statement into substatements and perform entity extraction processing on the substatements to obtain target entity information. The complexity assessment result is obtained by weighting the number of target entity information, the types of target entity information, the length of the query statement, and the logical word score of the query statement.
[0007] For example, based on a retrieval strategy, the target entity information and query statement are selected and merged to generate a retrieval instruction, including: when the retrieval strategy is a first retrieval strategy, the target entity information and query statement are selected for embedding and merging processing to generate a retrieval instruction; when the retrieval strategy is a second retrieval strategy, the target entity information is selected to embed and weight the sub-statements to generate a retrieval instruction. For example, the knowledge vector base includes knowledge entity vectors and knowledge paragraph vectors; based on the retrieval command, a retrieval is performed from the knowledge vector base to obtain multiple knowledge retrieval results, including: calculating the similarity between the target entity information and the knowledge entity vector in the retrieval command to obtain the hit entity vector and the corresponding hit entity information; based on the hit entity information and the inverted index table, multiple knowledge retrieval results are obtained, wherein the inverted index represents the index relationship between knowledge entity information and knowledge paragraph information, with knowledge entity information corresponding to knowledge entity vectors and knowledge paragraph information corresponding to knowledge paragraph vectors. For example, the process of scoring and selecting multiple knowledge retrieval results to construct target context knowledge data includes: scoring multiple knowledge retrieval results to obtain scoring results; selecting at least one knowledge retrieval result from multiple knowledge retrieval results based on the scoring results; and constructing target context knowledge data based on at least one knowledge retrieval result. For example, multiple knowledge retrieval results are scored to obtain a scoring result, including at least one of the following: calculating similarity based on the query statement in the retrieval instruction and the knowledge retrieval results to obtain a similarity score; calculating weight based on the hit entity information and the knowledge retrieval results to obtain a weight score; and performing weighted processing based on the similarity score and the weight score to obtain a scoring result; or calculating similarity based on the sub-statements in the retrieval instruction and the knowledge retrieval results to obtain a similarity score; calculating weight based on the hit entity information and the knowledge retrieval results to obtain a weight score; and performing weighted processing based on the similarity score and the weight score to obtain a scoring result. For example, the knowledge vector library is constructed in the following way: the knowledge file is segmented to obtain multiple knowledge segment information; entity extraction and entity deduplication processing are performed on the multiple knowledge segment information to obtain multiple knowledge entity information; the knowledge entity information and knowledge segment information are embedded to obtain knowledge entity vectors and knowledge segment vectors; and the knowledge entity vectors and knowledge segment vectors are stored in the knowledge vector library.
[0008] For example, the knowledge retrieval method is implemented by a retrieval model, and the method further includes: providing target context knowledge data to the user; obtaining explicit and implicit feedback information from the user regarding the target context knowledge data; and adjusting the parameters of the retrieval model based on the explicit and implicit feedback information.
[0009] Another embodiment of the present invention provides a knowledge retrieval device, comprising: an evaluation module for evaluating the complexity of a user-input query statement and obtaining a complexity evaluation result; an extraction module for performing entity extraction processing on the query statement based on the complexity evaluation result and selecting a retrieval strategy corresponding to the complexity evaluation result to obtain target entity information; a generation module for performing selection and merging processing on the target entity information and the query statement based on the retrieval strategy to generate a retrieval instruction; a retrieval module for performing retrieval from a knowledge vector base based on the retrieval instruction to obtain multiple knowledge retrieval results; and an acquisition module for performing scoring and selection processing on the multiple knowledge retrieval results to construct target context knowledge data. Another embodiment of the present invention provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method of any of the above embodiments.
[0010] Another embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method of any of the above embodiments.
[0011] In the above embodiments, the knowledge retrieval method includes: evaluating the complexity of a user-input query to obtain a complexity evaluation result; based on the complexity evaluation result, selecting a retrieval strategy corresponding to the complexity evaluation result to perform entity extraction processing on the query to obtain target entity information; based on the retrieval strategy, selecting and merging the target entity information and the query to generate a retrieval instruction; based on the retrieval instruction, retrieving from a knowledge vector base to obtain multiple knowledge retrieval results; and performing scoring and selection processing on the multiple knowledge retrieval results to construct target contextual knowledge data. Through a graph-free entity perception mechanism, semantic similarity and relevance are distinguished, and the retrieval strategy is dynamically adjusted according to query complexity and contextual requirements in a low-cost, low-latency manner. This allows for the accurate retrieval and assembly of a compact and non-redundant context highly relevant to the user's query intent from a large-scale corpus.
[0012] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0013] Figure 1 A flowchart of a knowledge retrieval method provided for embodiments of the present invention; Figure 2 A detailed flowchart of the knowledge retrieval method provided for embodiments of the present invention; Figure 3 A block diagram of a knowledge retrieval device provided for another embodiment of the present invention; Figure 4 A block diagram of an electronic device provided for another embodiment of the present invention. Detailed Implementation
[0014] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.
[0015] Retrieval-Augmented Generation (RAG) has become a key technology for knowledge-intensive natural language processing applications such as question answering, summarizing, and decision support. By retrieving relevant information from external knowledge bases during reasoning and providing it as context to a Large Language Model (LLM), the model can generate more accurate and richer responses, overcoming the limitations of relying solely on knowledge stored in the model's internal parameters. A typical RAG workflow includes segmenting a document into chunks, indexing the chunks, retrieving the most relevant chunks based on the user query, and finally integrating the content of these chunks and inputting them into the Large Language Model for generation.
[0016] The relevant technology employs a knowledge graph-based RAG approach, which overcomes the problems of context overlap and broken logical chains caused by traditional flat indexing by introducing structured knowledge. In the indexing stage, entities are extracted from the original corpus, and a knowledge graph is constructed using techniques such as entity linking and relation extraction. Nodes in the graph are typically entities, and edges represent relationships between entities. In the retrieval stage, key entities in the query are first identified, then these entity nodes are located in the knowledge graph, and a subgraph containing relevant entities and relationships is obtained through graph traversal algorithms (such as subgraph retrieval). However, the construction and maintenance of knowledge graph-based RAGs are costly, requiring operations such as entity identification, linking, relation extraction, and subgraph refinement. Updates are difficult, and costs increase dramatically with the size of the corpus. Equating semantic similarity with semantic relevance results in search results containing a large amount of irrelevant information, leading to slow response times. Furthermore, flat indexing cannot understand and retrieve complex relationships between entities, and insufficient context awareness makes it difficult to provide answers to user queries.
[0017] Therefore, this invention provides a knowledge retrieval method, which is a lightweight, scalable and efficient RAG method. Through a graph-free entity perception mechanism, it distinguishes between semantic similarity and relevance. In a low-cost and low-latency manner, it dynamically adjusts the retrieval strategy according to the query complexity and context requirements, and accurately retrieves and assembles a compact and non-redundant context that is highly relevant to the user's query intent from a large-scale corpus.
[0018] Figure 1 A flowchart of a knowledge retrieval method provided for embodiments of the present invention.
[0019] like Figure 1 As shown, the knowledge retrieval method 100 includes steps S110 to S150.
[0020] Step S110: Perform a complexity evaluation on the query statement entered by the user and obtain the complexity evaluation result. For example, complexity assessment includes evaluating the types and number of entities in the query statement, the length of the query statement, and whether the query statement contains logical operators. The complexity assessment result can be obtained by weighting the assessment results and normalizing the results. Step S120: Based on the complexity assessment result, select the retrieval strategy corresponding to the complexity assessment result to perform entity extraction processing on the query statement to obtain the target entity information. For example, the retrieval strategy includes a first retrieval strategy and a second retrieval strategy. When the complexity evaluation result is less than a preset threshold, the first retrieval strategy is selected for entity extraction. When the complexity evaluation result is greater than or equal to the preset threshold, the second retrieval strategy is selected for entity extraction.
[0021] Step S130: Based on the retrieval strategy, the target entity information and query statement are selected and merged to generate a retrieval instruction. For example, the extracted target entity information is deduplicated. When the first retrieval strategy is selected, the extracted target entity information and query statement are embedded to obtain vector representations of the target entity information and query statement. The embedding process is implemented based on an embedding model, such as the text-embedding-3 model, which concatenates the target entity information to generate retrieval instructions. When the second retrieval strategy is selected, the query statement is split into multiple sub-statements. The splitting is implemented based on a large language model (such as deepseek_v3). Each sub-statement is embedded and weighted separately to obtain vector representations of the target entity information and query statement, as well as the weights corresponding to each sub-question.
[0022] Step S140: Based on the search instructions, a search is performed from the knowledge vector base to obtain multiple knowledge search results. For example, a knowledge vector library, such as the Faiss vector library, performs segmentation, entity extraction, deduplication, and embedding on knowledge files, and stores the processed knowledge files in the knowledge vector library for retrieval. Before retrieval, an inverted index table between entities and knowledge file segments is also created.
[0023] Step S150: The multiple knowledge retrieval results are scored and selected to construct the target context knowledge data. For example, multiple knowledge retrieval results are scored separately. The score includes the similarity between the knowledge retrieval result and the query statement, as well as the weight of the hit entities in the knowledge retrieval result. The final score is obtained by weighting the two parts. The knowledge retrieval results with the highest scores are selected as the target context knowledge data by sorting.
[0024] In the above embodiments, a graph-free entity perception mechanism is used to distinguish between semantic similarity and relevance. In a low-cost and low-latency manner, the retrieval strategy is dynamically adjusted according to query complexity and context requirements. This allows for the accurate retrieval and assembly of a compact and non-redundant context that is highly relevant to the user's query intent from a large-scale corpus.
[0025] In one example, based on the complexity assessment result, a retrieval strategy corresponding to the complexity assessment result is selected to perform entity extraction processing on the query statement to obtain target entity information. This includes: if the complexity assessment result is less than a preset complexity threshold, a first retrieval strategy is selected to perform entity extraction processing on the query statement to obtain target entity information; if the complexity assessment result is greater than or equal to the preset complexity threshold, a second retrieval strategy is selected to split the query statement into substatements and perform entity extraction processing on the substatements to obtain target entity information. The complexity assessment result is obtained by weighting the number of target entity information, the types of target entity information, the length of the query statement, and the logical word score of the query statement.
[0026] For example, entity extraction is implemented based on a large language model, such as deepseek_v3. If the complexity evaluation result is less than a preset complexity threshold, the query statement is considered a simple query. If the complexity evaluation result is greater than or equal to the preset complexity threshold, the query statement is considered a complex query and needs to be split into multiple sub-statements. The multiple sub-statements are then processed as simple queries.
[0027] LLM models (such as deepseek_v3) can be used to split queries into multiple sub-queries. An example of an LLM model's prompt: You are a query decomposition expert in a question-answering system. Your task is to break down complex user-posed questions into several simpler, semantically clear, and independently searchable sub-questions to help downstream models find answers more efficiently. If there are logical relationships between sub-questions, please indicate the logical category (e.g., [cause and effect], [comparison], [chronological order]) before each sub-question.
[0028] The decomposition principles are as follows: 1. If the original question contains multiple entities, events, causal relationships, comparisons, or logical connections (such as "and", "separately", "whether all"), it should be decomposed into multiple sub-questions; 2. Each sub-question must be a semantically complete natural language question with a clear subject and predicate; 3. Sub-questions should be as independent as possible, and vague referents such as "it" or "this" should not be used; 4. The decomposed questions should not omit any important information from the original question.
[0029] Output format requirements: Please output in JSON format, as follows: "json{"sub_questions: ["subquestion1","subquestion2", ...]}".
[0030] Example question: "Did entrepreneur A found company A before company B? When entrepreneur A launched product C, had company B already launched product D?". Sub-question output: {"sub_questions": ["When did entrepreneur A found company A?", "When was company B established?", "When did entrepreneur A launch product C?", "Did company B launch product D before that?"]}.
[0031] Specifically, the query complexity score is evaluated based on the number of query entities, the number of query entity types, the query length, and logical words. A score below 0.3 (preset complexity threshold) indicates a simple query, while a score greater than or equal to 0.3 indicates a complex query. The query granularity features are extracted from the query, including the number of entities in the query statement, the number of query entity types, the original query length, and whether the original query contains logical words ("and", "or", "not", "simultaneously", "separately", etc.). The evaluation score function is defined as shown in the following formula (1).
[0032] Complexity assessment result = number of query entities * 0.4 + number of query entity types * 0.3 + whether the query contains logical operators * 0.2 + query length / 100 * 0.1 (1) In formula (1), whether the query contains logical words indicates the logical word score of the query statement. If the query contains logical words, the logical word score of the query statement can be 1, and whether the query contains logical words * 0.2 is 1 * 0.2. If the query does not contain logical words, the logical word score of the query statement can be 0, and whether the query contains logical words * 0.2 is 0 * 0.2. Alternatively, if the query contains x logical words, the logical word score of the query statement can be x, and whether the query contains logical words * 0.2 is x * 0.2.
[0033] The complexity evaluation results obtained above are normalized. The sigmoid function is used to normalize the score by adjusting the center point and slope so that the score is normalized between 0 and 1. The larger the score, the more complex the query statement is, as shown in formula (2).
[0034]
[0035] Where x is the complexity evaluation result (e.g., 0.5-5), x0 is a value of medium complexity (e.g., 2.5), for example, if a user inputs multiple query statements, the average of the complexity evaluation results of multiple query statements can be used to obtain a value of medium complexity, and k is the slope, which controls the rate of change (e.g., 1.0). In the above, x0 and k are hyperparameters that are adjusted according to the experiment.
[0036] In one example, based on a retrieval strategy, target entity information and query statements are selected and merged to generate a retrieval instruction. This includes: when the retrieval strategy is the first retrieval strategy, selecting target entity information and query statements for embedding and merging processing to generate a retrieval instruction; and when the retrieval strategy is the second retrieval strategy, selecting target entity information for embedding and weighting sub-statements to generate a retrieval instruction. For example, the obtained target entity information and query statement are embedded and represented as vectors. When the retrieval strategy is the first retrieval strategy, the embedded target entity information and query statement are concatenated to obtain the retrieval instruction.
[0037] Embedding processing is based on embedding models, such as the text-embedding-3 model. Embedding processing can convert words, phrases, or sentences into points (i.e., vectors / embeddings) in a high-dimensional space. Texts with similar semantics have vectors that are closer together in space. Merging processing includes concatenation, such as concatenating multiple target entities to form a new query statement. The new query statement is then processed by embedding to obtain a query vector. The query vector is used to match the entity knowledge vectors and knowledge paragraph vectors in the knowledge vector base to obtain knowledge retrieval results.
[0038] When the retrieval strategy is the second retrieval strategy, the target entity information and sub-statements are embedded, and the weight of each sub-statement is obtained by weighting it according to the ratio of the number of target entity information in each sub-statement to the total number of target entity information in all sub-statements.
[0039] Specifically, the LLM model is used to extract entities from the question. Each sub-question is traversed, and entities (target entity information) in the question are extracted. The frequency of entity occurrence in all sub-questions (sub-statements) is counted. The normalized score of the ratio of the sub-question entity frequency to the total entity frequency in all questions is used as the weight of the sub-question to reflect their relative importance to the overall query intent.
[0040] Entity extraction is performed on each of the decomposed sub-statements to obtain the target entity information corresponding to each sub-statement. For example, if a query statement is decomposed into three sub-statements, namely sub-statement A, sub-statement B, and sub-statement C, the target entity information extracted from sub-statement A is 5, from sub-statement B is 3, and from sub-statement C is 4, then the total target entity information for all sub-statements is 12. The weight of sub-statement A is 5 / 12, the weight of sub-statement B is 3 / 12, and the weight of sub-statement C is 4 / 12. The target entity information corresponding to each sub-statement is embedded using an embedding model to obtain a target entity vector. Based on the target entity vector, a knowledge vector database is retrieved to obtain multiple knowledge retrieval results. The weight of each sub-statement is scored against the knowledge retrieval results, and the scores are then ranked. The few with higher scores are selected as the target context knowledge data.
[0041] In the above embodiments, the graph-free entity-aware retrieval architecture abandons the complex and costly graph structure and adopts a lightweight entity-block inverted index table as the core data structure. This frees RAG from its dependence on "relationships" and shifts to the direct utilization of "entity existence", thereby achieving a reduction in system complexity, cost and latency by orders of magnitude without sacrificing or even improving performance.
[0042] The knowledge vector library is constructed in the following way: the knowledge file is segmented to obtain multiple knowledge segment information; entity extraction and deduplication processing are performed on the multiple knowledge segment information to obtain multiple knowledge entity information; the knowledge entity information and knowledge segment information are embedded to obtain knowledge entity vectors and knowledge segment vectors; and the knowledge entity vectors and knowledge segment vectors are stored in the knowledge vector library.
[0043] Specifically, the knowledge vector library is constructed in the following way: (1) Document segmentation: Segment a doc or pdf document by paragraph or sentence.
[0044] (2) Entity extraction: Use an LLM model (such as deepseek_v3) to perform coreference resolution and entity recognition extraction on the segmented content.
[0045] For example, a prompt for entity extraction: "You are a professional information extraction expert. Your task is to extract all named entities (e.g., names of people, organizations, locations, products, etc.) from the input text. You need to perform the following operations: 1. Coreference resolution: Identify and resolve the actual entities referred to by pronouns (such as "he," "she," "its," etc.) or referential phrases; 2. Entity normalization: Unify different expressions referring to the same object (e.g., unify "his company" to "Company B"); 3. Only return named entities, avoiding abstract concepts or generic terms. Output format: Return a list of strings in JSON format, where each string represents a unique entity name."
[0046] Example 1: Text Input: The text is as follows: "Entrepreneur A co-founded Company A in 1976. He later became its CEO and led the launch of Product C. Output: ["Entrepreneur A", "Company A", "Product C"]".
[0047] Example 2: Text Input: The text is as follows: "A (person's name) is the 44th president of country B. His wife, X (person's name), is a lawyer. The couple moved to location C in 2009. Output: ["A (person's name)", "country B", "X (person's name)", "location C"]".
[0048] (3) Establish entity set: remove duplicates, obtain the set of all entities in the document, and build a unique entity index.
[0049] (4) Construct the inverted index: Construct an inverted index table for entities and document segments. Traverse each entity and obtain all segment indexes containing the entity content.
[0050] (5) Semantic embedding: Use text-embedding-3 to embed entities and segments.
[0051] (6) Vector library storage: The Faiss vector library is used to store the embedding content.
[0052] In one example, the knowledge vector library includes knowledge entity vectors and knowledge paragraph vectors. After constructing the knowledge vector library, a search is performed based on the search command to obtain multiple knowledge search results. These include: calculating the similarity between the target entity information and the knowledge entity vector in the search command to obtain the hit entity vector and the corresponding hit entity information; and obtaining multiple knowledge search results based on the hit entity information and the inverted index table, where the inverted index represents the index relationship between knowledge entity information and knowledge paragraph information, with knowledge entity information corresponding to knowledge entity vectors and knowledge paragraph information corresponding to knowledge paragraph vectors. For example, similarity calculation, such as embedding similarity, can obtain knowledge entity vectors in the knowledge vector library that are semantically similar to the target entity information. All the obtained knowledge vector entities are used as the hit entity vectors, and the information corresponding to the hit entity vectors is the hit entity information. By querying the inverted index table through the hit entity information, multiple knowledge retrieval results can be obtained.
[0053] Specifically, the query is linked to a corpus-level entity set, and a semantic search is performed on each extracted query entity. Based on embedding similarity, the top K corpus entities most similar to each query entity are retrieved, and the union of all retrieved entities constitutes the hit entity set.
[0054] The target entity information in the search command may include vectors a, b, c; the knowledge entity vector may include vectors A, B, C, D, E, etc.; and the knowledge paragraph vector may include the paragraph vector containing vector A. By searching the target entity information in the search command, we can obtain the knowledge entity vectors in the knowledge vector library that are semantically similar to the target entity information. For example, for vector a, if the search determines that vectors A, B, and C are semantically similar to a, then we can determine that the matching entity vectors in the knowledge vector library are vectors A, B, and C. The matching entity information is the entity information corresponding to vectors A, B, and C. By querying the inverted index table, we can obtain the knowledge paragraph information and knowledge paragraph vectors corresponding to the entity information of vectors A, B, and C.
[0055] In one example, multiple knowledge retrieval results are scored and selected to construct target context knowledge data, including: scoring multiple knowledge retrieval results to obtain scoring results; selecting at least one knowledge retrieval result from multiple knowledge retrieval results based on the scoring results; and constructing target context knowledge data based on at least one knowledge retrieval result. For example, scoring the knowledge retrieval results includes two parts: a similarity score between the query and the knowledge retrieval results, and a weighted score between the hit entity information and the knowledge retrieval results. The final score is obtained by weighting the results of these two parts. Based on the score, the Top-K paragraphs are selected and assembled into context. The collected text blocks are sorted according to the scores, and the top K text blocks with the highest scores are selected to construct the final context. To ensure the coherence of the context, these text blocks are reordered according to their positions in the original document. Finally, the text of the selected text blocks is merged to form the final context.
[0056] Knowledge retrieval results include, for example, the knowledge paragraph information corresponding to the hit entity information of hit entity vectors A, B, and C. Knowledge paragraph information includes, for example, text blocks obtained by segmenting knowledge files. The scoring of knowledge retrieval results includes two parts, such as: (1) calculating the semantic similarity between the query vector and the knowledge paragraph vector (embedding text blocks), and (2) calculating the ratio of each hit entity information to the total number of knowledge entity information extracted from the text block (knowledge paragraph information), and summing them. The scoring results are obtained by weighting the two parts of the scoring. The knowledge paragraph information is sorted according to the scoring results, and the top K with higher scores are selected as target context knowledge data.
[0057] In one example, multiple knowledge retrieval results are scored to obtain a score result, which includes at least one of the following: A similarity score is obtained by calculating the similarity based on the query statement in the search command and the knowledge search results. A weight score is obtained by calculating the weight based on the hit entity information and the knowledge search results. The similarity score and the weight score are then weighted to obtain the final score. Similarity scores are calculated based on sub-statements in the search command and knowledge retrieval results. Weight scores are calculated based on the hit entity information and knowledge retrieval results. The similarity scores and weight scores are then weighted to obtain the final score.
[0058] For the query statement and sub-statements in the retrieval command, two factors are used for scoring: Specifically, each text block is scored based on two factors: the semantic similarity between the text block and the query, and the weighted sum of the matching entities contained in the text block. By weighting and summing these two factors to calculate the score, text blocks with high semantic similarity and high matching of query entities receive higher scores. Currently, α = 0.7 and β = 0.3 are used. The scoring formula is shown in formula (3).
[0059]
[0060] In formula (3), P j Q represents a candidate paragraph, such as the j-th candidate paragraph (e.g., a paragraph in Wikipedia), and Q represents the query question (e.g., "In what year did entrepreneur A release his first product C?"). This represents the semantic similarity between a query and a paragraph. It is typically a cosine similarity score or a cross-encoder score between 0 and 1. EQ represents the set of entities in the query (e.g., {"Entrepreneur A", "Product C"}). This represents the set of entities in a paragraph (such as the entities hit in each paragraph). The entity weights (normalized frequencies, e.g., "Entrepreneur A": 0.6, "Product C": 0.4) are represented by α and β, which are the weight coefficients of the two terms and control the weights of semantic matching and entity matching. They usually satisfy α + β = 1.
[0061] For the query statement in the retrieval command, a scoring selection process is performed based on the scoring results, and the few with higher scores are selected as target context knowledge data. For the sub-statements in the retrieval command, the scoring results and the weight of each sub-statement are calculated to obtain the final score. Based on the final score, the sub-statements are sorted, and the few with higher scores are selected as target context knowledge data.
[0062] In the above embodiments, the two-factor context scoring mechanism of entity counting is combined with the introduction of "number of hit entities" as a core scoring factor. The two-factor model can more robustly measure the true value of a text block and effectively suppress noise blocks that are only similar in topic but lack key entity information.
[0063] The knowledge retrieval method is implemented by a retrieval model, and the method also includes: providing target context knowledge data to the user; obtaining explicit and implicit feedback information from the user regarding the target context knowledge data; and adjusting the parameters of the retrieval model based on the explicit and implicit feedback information.
[0064] Specifically, explicit feedback is collected by the front-end page, including user ratings, likes / dislikes, and selections of "relevance." Implicit feedback includes data collected from event logs, such as the location of clicked paragraphs, dwell time, and whether generated content was used. The rating weights are dynamically adjusted based on feedback, with continuous learning and strategy adaptation. The collected feedback data is accumulated for long-term offline or online optimization of the system's core components. This can include: fine-tuning the rating function: using user feedback as a supervisory signal to adjust the weights of each factor in the two-factor rating model; and optimizing the embedding model: using feedback data (such as using query-text pairs deemed relevant by users as positive examples) to fine-tune the text embedding model, making it better able to capture task-related semantics.
[0065] In the above embodiments, a complete closed-loop learning system from user feedback to model optimization was designed. By collecting and utilizing explicit or implicit user feedback, the system can fine-tune model parameters (such as scoring functions and embedding models). This makes the described system no longer static, but a continuously evolving and self-improving "living" system whose performance will continuously improve with use.
[0066] Figure 2 A detailed flowchart of the knowledge retrieval method provided for embodiments of the present invention.
[0067] like Figure 2As shown, the knowledge retrieval method includes an indexing stage and a retrieval stage. The indexing stage includes the following steps: S201, segmented processing.
[0068] For example, the original forecast is segmented.
[0069] S202, Entity Extraction.
[0070] S203, Entity-Paragraph Inverted Index.
[0071] S204, Construct an entity index storage vector library.
[0072] For example, entity vectors and segment vectors are obtained through semantic embedding.
[0073] The retrieval phase includes the following steps: S210, Query complexity evaluation.
[0074] S211, dynamic switching of retrieval strategy.
[0075] S212, Select search strategy.
[0076] S213, Simple Search (First Search Strategy).
[0077] S214, Complex Search (Second Search Strategy).
[0078] S215, Relevant Text Block Retrieval and Scoring.
[0079] S216, Top-K candidates are concatenated to generate the context.
[0080] S217, User Behavior.
[0081] S218, Feedback Collection.
[0082] For example, the information collected includes explicit feedback information and implicit feedback information.
[0083] S219, Optimize scoring weights (adjust parameters of the retrieval model).
[0084] The knowledge retrieval method proposed in this invention has the following beneficial effects: (1) The graph-free entity-aware retrieval architecture abandons the complex and costly graph structure in the existing technology and instead adopts a lightweight entity-block inverted index table as the core data structure. It liberates RAG from its dependence on "relationships" and turns to the direct utilization of "entity existence", thereby reducing the system complexity, cost and latency by a magnitude without sacrificing or even improving performance. (2) It achieves the systematic decoupling of semantic similarity and relevance. Similarity is used for entity semantic matching in the indexing stage to expand recall; while the more rigorous entity-centric relevance dominates the ranking in the retrieval stage through a two-factor scoring mechanism to ensure the accuracy of the final context. (3) It adopts a two-factor context scoring mechanism that combines entity counting. It does not only rely on the traditional query-text similarity, but also innovatively introduces "the number of hit entities" as a core scoring factor. This two-factor model can more robustly measure the true value of a text block and effectively suppress noise blocks that are only similar in topic but lack key entity information. (4) A closed-loop user feedback-driven adaptive optimization system is adopted, realizing a complete closed-loop learning system from user feedback to model optimization. By collecting and utilizing explicit or implicit user feedback, the system can fine-tune model parameters (such as scoring functions and embedding models). This makes the described system no longer static, but a "living" system that can continuously evolve and improve itself, and its performance will continue to improve with use.
[0085] Figure 3 A block diagram of a knowledge retrieval device provided for another embodiment of the present invention.
[0086] This invention provides a knowledge retrieval device 300. Please refer to [link / reference]. Figure 3 The knowledge retrieval device 300 includes: an evaluation module 310, an extraction module 320, a generation module 330, a retrieval module 340, and an acquisition module 350.
[0087] For example, the evaluation module 310 is used to evaluate the complexity of the query statement input by the user and obtain the complexity evaluation result.
[0088] For example, the extraction module 320 is used to perform entity extraction processing on the query statement based on the complexity evaluation result and select the retrieval strategy corresponding to the complexity evaluation result to obtain target entity information.
[0089] For example, the generation module 330 is used to select and merge target entity information and query statements based on a retrieval strategy to generate a retrieval instruction.
[0090] For example, the retrieval module 340 is used to retrieve multiple knowledge retrieval results from the knowledge vector base based on retrieval instructions.
[0091] For example, module 350 is used to perform scoring and selection processing on multiple knowledge retrieval results to construct target context knowledge data. It is understood that a detailed description of the knowledge retrieval device 300 can be found in the description of the knowledge retrieval method above, and will not be repeated here.
[0092] For example, the extraction module 320 is further configured to select a first retrieval strategy to perform entity extraction processing on the query statement to obtain target entity information when the complexity evaluation result is less than a preset complexity threshold; and select a second retrieval strategy to split the query statement into substatements and perform entity extraction processing on the substatements to obtain target entity information when the complexity evaluation result is greater than or equal to the preset complexity threshold. The complexity evaluation result is obtained by weighting the number of target entity information, the type of target entity information, the length of the query statement, and the logical word score of the query statement. For example, the generation module 330 is further configured to, when the retrieval strategy is the first retrieval strategy, select target entity information and query statement for embedding and merging processing to generate a retrieval instruction; and when the retrieval strategy is the second retrieval strategy, select target entity information to perform embedding and weighting processing on substatements to generate a retrieval instruction. For example, the knowledge vector base includes knowledge entity vectors and knowledge paragraph vectors; the retrieval module 340 is also used to perform similarity calculation on the target entity information and knowledge entity vectors in the retrieval instruction to obtain the hit entity vector and the corresponding hit entity information; based on the hit entity information and the inverted index table, multiple knowledge retrieval results are obtained, wherein the inverted index represents the index relationship between knowledge entity information and knowledge paragraph information, knowledge entity information corresponds to knowledge entity vectors, and knowledge paragraph information corresponds to knowledge paragraph vectors. For example, the obtaining module 350 is further configured to score multiple knowledge retrieval results to obtain a scoring result; select at least one knowledge retrieval result from the multiple knowledge retrieval results based on the scoring result; and construct target context knowledge data based on at least one knowledge retrieval result. For example, the obtaining module 350 is further configured to perform similarity calculation based on the query statement in the retrieval instruction and the knowledge retrieval results to obtain a similarity score; perform weight calculation based on the hit entity information and the knowledge retrieval results to obtain a weight score; and perform weighted processing based on the similarity score and the weight score to obtain a scoring result; and perform similarity calculation based on the sub-statements in the retrieval instruction and the knowledge retrieval results to obtain a similarity score; perform weight calculation based on the hit entity information and the knowledge retrieval results to obtain a weight score; and perform weighted processing based on the similarity score and the weight score to obtain a scoring result. For example, the knowledge vector library is constructed in the following way: the knowledge file is segmented to obtain multiple knowledge segment information; entity extraction and entity deduplication processing are performed on the multiple knowledge segment information to obtain multiple knowledge entity information; the knowledge entity information and knowledge segment information are embedded to obtain knowledge entity vectors and knowledge segment vectors; and the knowledge entity vectors and knowledge segment vectors are stored in the knowledge vector library.
[0093] For example, the knowledge retrieval method is implemented by a retrieval model, and the knowledge retrieval device 300 further includes: an adjustment module for providing target context knowledge data to the user; obtaining explicit feedback information and implicit feedback information from the user regarding the target context knowledge data; and adjusting the parameters of the retrieval model based on the explicit feedback information and implicit feedback information. Figure 4 A block diagram of an electronic device provided for another embodiment of the present invention.
[0094] This application provides an electronic device, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described above.
[0095] like Figure 4 As shown, for ease of understanding, embodiments of this application illustrate a specific electronic device 400.
[0096] Electronic device 400 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. Electronic device 400 may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0097] like Figure 4 As shown, the electronic device 400 includes a computing unit 401, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 402 or a computer program loaded from a storage unit 408 into a random access memory (RAM) 403. The RAM 403 may also store various programs and data required for the operation of the electronic device 400. The computing unit 401, ROM 402, and RAM 403 are interconnected via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0098] Multiple components in electronic device 400 are connected to input / output (I / O) interface 405. These components include: input unit 406, such as a keyboard or mouse; output unit 407, such as various types of displays or speakers; storage unit 408, such as a hard disk or optical disk; and communication unit 409, such as a network interface card (NIC), modem, or wireless transceiver. Communication unit 409 allows electronic device 400 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0099] The computing unit 401 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 401 performs the various methods described above. For example, in some embodiments, any one or more of the various methods described above can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 408. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 400 via ROM 402 and / or communication unit 409. When the computer program is loaded into RAM 403 and executed by the computing unit 401, one or more steps of any one or more of the various methods described above can be performed. Alternatively, in other embodiments, the computing unit 401 can be configured to perform any one or more of the various methods described above by any other suitable means (e.g., by means of firmware).
[0100] The present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method of any of the above embodiments.
[0101] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this invention, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.
[0102] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0103] In the description of this invention, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this invention, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0104] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," "clockwise," "counterclockwise," "axial," "radial," and "circumferential" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing this invention and simplifying the description, and are not intended to indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.
[0105] Furthermore, the terms "first," "second," etc., used in the embodiments of this invention are for descriptive purposes only and should not be construed as indicating or implying relative importance, or implicitly specifying the number of technical features indicated in this embodiment. Therefore, features defined with terms such as "first" and "second" in the embodiments of this invention can explicitly or implicitly indicate that the embodiment includes at least one of those features. In the description of this invention, the word "multiple" means at least two or more, such as two, three, four, etc., unless otherwise explicitly specified in the embodiments.
[0106] In this invention, unless otherwise explicitly specified or limited in the embodiments, the terms "installation," "connection," "joining," and "fixing" appearing in the embodiments should be interpreted broadly. For example, a connection can be a fixed connection, a detachable connection, or an integral part; it can also be a mechanical connection, an electrical connection, etc. Of course, it can also be a direct connection, or an indirect connection through an intermediate medium, or it can be the internal communication of two components, or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific implementation.
[0107] In this invention, unless otherwise explicitly specified and limited, "above" or "below" the second feature can mean that the first feature is in direct contact with the second feature, or that the first feature is in indirect contact with the second feature through an intermediate medium. Furthermore, "above," "over," and "on top" of the second feature can mean that the first feature is directly above or diagonally above the second feature, or simply that the first feature is at a higher horizontal level than the second feature. "Below," "below," and "under" the second feature can mean that the first feature is directly below or diagonally below the second feature, or simply that the first feature is at a lower horizontal level than the second feature.
[0108] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A knowledge retrieval method characterized by, The method comprises: complexity evaluation is carried out on a query sentence input by a user to obtain a complexity evaluation result; based on the complexity evaluation result, a retrieval strategy corresponding to the complexity evaluation result is selected to perform entity extraction processing on the query sentence to obtain target entity information; based on the retrieval strategy, the target entity information and the query sentence are selected and merged to generate a retrieval instruction; based on the retrieval instruction, retrieval is performed from a knowledge vector library to obtain a plurality of knowledge retrieval results; the plurality of knowledge retrieval results are scored and selected to construct target context knowledge data.
2. The method of claim 1, wherein, The method comprises: in a case where the complexity evaluation result is less than a preset complexity threshold, a first retrieval strategy is selected to perform entity extraction processing on the query sentence to obtain target entity information; in a case where the complexity evaluation result is greater than or equal to the preset complexity threshold, a second retrieval strategy is selected to perform sub-sentence splitting on the query sentence and to perform entity extraction processing on the sub-sentence to obtain target entity information, wherein the complexity evaluation result is obtained by weighted calculation on the number of the target entity information, the type of the target entity information, the length of the query sentence and the logical word score of the query sentence.
3. The method of claim 2, wherein, The method comprises: in a case where the retrieval strategy is the first retrieval strategy, the target entity information and the query sentence are selected for embedding processing and merging processing to generate a retrieval instruction; in a case where the retrieval strategy is the second retrieval strategy, the target entity information is selected for embedding processing and weight processing on the sub-sentence to generate a retrieval instruction.
4. The method of claim 1, wherein, The knowledge vector library comprises knowledge entity vectors and knowledge paragraph vectors; the method comprises: similarity calculation is performed on the target entity information in the retrieval instruction and the knowledge entity vectors to obtain hit entity vectors and corresponding hit entity information; based on the hit entity information and an inverted index table, a plurality of knowledge retrieval results are obtained, wherein the inverted index represents an index relationship between knowledge entity information and knowledge paragraph information, the knowledge entity information corresponds to the knowledge entity vectors, and the knowledge paragraph information corresponds to the knowledge paragraph vectors.
5. The method of claim 4, wherein, The method comprises: scoring is performed on the plurality of knowledge retrieval results to obtain a scoring result; based on the scoring result, at least one knowledge retrieval result is selected from the plurality of knowledge retrieval results; based on the at least one knowledge retrieval result, target context knowledge data is constructed.
6. The method of claim 5, wherein, The method comprises at least one of the following: The similarity score is obtained by performing similarity calculation based on the query statement in the search instruction and the knowledge search result, the weight score is obtained by performing weight calculation based on the hit entity information and the knowledge search result, and the scoring result is obtained by performing weighted processing based on the similarity score and the weight score. The similarity score is obtained by performing similarity calculation based on the sub-statement in the search instruction and the knowledge search result, the weight score is obtained by performing weight calculation based on the hit entity information and the knowledge search result, and the scoring result is obtained by performing weighted processing based on the similarity score and the weight score.
7. The method according to any one of claims 1 to 6, characterized in that, The knowledge vector library is constructed by the following method: The knowledge file is segmented to obtain a plurality of knowledge paragraph information; The plurality of knowledge paragraph information is subjected to entity extraction processing and entity deduplication processing to obtain a plurality of knowledge entity information; The knowledge entity information and the knowledge paragraph information are subjected to embedding processing to obtain knowledge entity vectors and knowledge paragraph vectors; The knowledge entity vectors and the knowledge paragraph vectors are stored in the knowledge vector library.
8. The method according to any one of claims 1 to 6, characterized in that, The knowledge search method is realized by a search model, and the method further comprises: providing the target context knowledge data to a user; obtaining explicit feedback information and implicit feedback information of the user on the target context knowledge data; adjusting parameters of the search model based on the explicit feedback information and the implicit feedback information.
9. A knowledge retrieval apparatus characterized by comprising: The device comprises: an evaluation module configured to evaluate the complexity of a query statement input by a user to obtain a complexity evaluation result; an extraction module configured to perform entity extraction processing on the query statement based on the complexity evaluation result and a selected search strategy corresponding to the complexity evaluation result to obtain target entity information; a generation module configured to perform selection and merging processing on the target entity information and the query statement based on the search strategy to generate a search instruction; a search module configured to search from a knowledge vector library based on the search instruction to obtain a plurality of knowledge search results; an obtaining module configured to perform scoring and selection processing on the plurality of knowledge search results to obtain target context knowledge data.
10. An electronic device comprising a memory and a processor, the memory storing a computer program, characterized in that, The processor executes the computer program to realize the steps of the method of any one of claims 1-8. The processor executes the computer program to realize the steps of the method of any one of claims 1-8.