Knowledge slice recall method and device, equipment, medium and program product
The target keywords and scores of the user problem text are extracted through the AC automata, and the knowledge slices are correlated, and the correlation scores are calculated to determine the target knowledge slices. This solves the problem of poor correlation of knowledge slice recall in the existing technology, improves the accuracy and efficiency of retrieval, and optimizes the user experience.
Patent Information
- Application Number
- CN202510318442.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-18
- Publication Date
- 2025-06-27
AI Technical Summary
In the prior art, the user input problems are usually shorter, and the number of words in the knowledge slice is large, resulting in a low similarity score between the problem vector and the slice vector, affecting the correlation between the recalled knowledge slice and the user problem, and thus affecting the user experience.
The target keywords and scores of the user's problem text are extracted through the AC automata, and the knowledge slice is associated. The correlation scores of the knowledge slice and the problem text are calculated based on the keyword scores, and the target knowledge slice is determined and recalled.
Effectively filter out the knowledge slices that are most relevant to the problem text, improve the accuracy and efficiency of knowledge slice retrieval, and optimize the user experience.
Smart Images

Figure CN120216667A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of data processing, and particularly to a knowledge slice recall method, apparatus, device, medium and program product. Background Art
[0002] In the related art, RAG (Retrieval-Augmented Generation) re-ranking usually calculates the similarity between the vector of the recalled knowledge slice and the vector of the user's question to obtain a relevance score. However, since the questions input by users are usually relatively short, while the number of words in the knowledge slices is usually large, the similarity score between the question vector and the slice vector will be low, resulting in poor relevance between the recalled knowledge slices and the user's questions, thus affecting the user experience. Summary of the Invention
[0003] The present disclosure provides a knowledge slice recall method, apparatus, device, medium and program product. The technical solution of the present disclosure is as follows:
[0004] In a first aspect, the present disclosure provides a knowledge slice recall method, including:
[0005] When receiving the user's question text, extracting the target keywords of the question text, the target score corresponding to each target keyword, and the knowledge slices associated with the target keywords through an AC automaton; wherein, the AC automaton pre-stores a plurality of keywords and the score of each keyword, and the keywords include the target keywords;
[0006] Calculating the relevance score between each knowledge slice and the question text based on the target score corresponding to each target keyword;
[0007] Determining the target knowledge slice according to the relevance score between each knowledge slice and the question text;
[0008] Recalling the target knowledge slice.
[0009] In a possible implementation manner, before the step of extracting the target keywords of the question text, the target score corresponding to each target keyword, and the knowledge slices associated with the target keywords through an AC automaton when receiving the user's question text, the method further includes:
[0010] Based on the preset sample document data, using a pre-trained large model to extract keywords from each sample document;
[0011] Scoring each keyword of each sample document through the pre-trained large model to obtain the score of each keyword of each sample document;
[0012] Store the scores of each keyword of each of the sample documents in the Aho-Corasick automaton.
[0013] In a possible implementation, before extracting keywords from each sample document by using a pre-trained large model based on the preset sample document data, it further includes:
[0014] Slice the sample documents according to a first preset length and set an overlapping second preset length to generate a plurality of knowledge slices;
[0015] Construct the preset sample document data based on the plurality of knowledge slices.
[0016] In a possible implementation, calculating the relevance score between each knowledge slice and the question text based on the target score corresponding to each of the target keywords includes:
[0017] Calculate the vector similarity between the vector of each knowledge slice and the vector of the question text based on the vector of each knowledge slice and the vector of the question text;
[0018] Calculate the relevance score between each knowledge slice and the question text based on the target score corresponding to each of the target keywords, the preset keyword weight, and the vector similarity between the vector of each knowledge slice and the vector of the question text.
[0019] In a possible implementation, the calculation method for calculating the relevance score between each knowledge slice and the question text based on the target score corresponding to each of the target keywords, the preset keyword weight, and the vector similarity between the vector of each knowledge slice and the vector of the question text is:
[0020] final_similarity = cos_similarity + (keyword1_score +... + keywordN_score) * (1)
[0021] keyword_coefficent
[0022] Among them, final_similarity represents the relevance score between each of the knowledge slices and the question text; cos_similarity represents the vector similarity between the vector of each knowledge slice and the question text; keyword1_score +... + keywordN_score represents the sum of the target scores corresponding to the target keywords, where N represents the total number of keywords, and N ∈ N*; keyword_coefficent represents the preset keyword weight.
[0023] In a possible implementation manner, determining the target knowledge slice according to the relevance score between each knowledge slice and the question text includes:
[0024] Sorting the knowledge slices according to the relevance scores of the knowledge slices in a preset sorting manner to obtain a knowledge slice sequence; wherein, the preset sorting method includes sorting from high to low or from low to high;
[0025] Selecting a preset number of knowledge slices with the highest similarity scores in the knowledge slice sequence as the target knowledge slices.
[0026] In a second aspect, the present disclosure provides a knowledge slice recall device, including:
[0027] An extraction module, configured to, when receiving the question text of the user, extract the target keywords of the question text, the target scores corresponding to each of the target keywords, and the knowledge slices associated with the target keywords through an AC automaton; wherein, the AC automaton prestores a plurality of keywords and the scores of each keyword, and the keywords include the target keywords;
[0028] A calculation module, configured to calculate the relevance score between each knowledge slice and the question text based on the target scores corresponding to each of the target keywords;
[0029] A determination module, configured to determine the target knowledge slice according to the relevance score between each knowledge slice and the question text;
[0030] A recall module, configured to recall the target knowledge slice.
[0031] In a third aspect, the present disclosure provides an electronic device, including:
[0032] A processor;
[0033] A memory for storing executable instructions of the processor;
[0034] Wherein, the processor is configured to execute the instructions to implement the method described in the first aspect.
[0035] In a fourth aspect, the present disclosure provides a computer-readable storage medium, on which a computer program is stored, wherein the computer program, when executed by a processor, implements the method described in the first aspect.
[0036] In a fifth aspect, the present disclosure provides a computer program product, including a computer program / instructions, wherein the computer program / instructions, when executed by a processor, implement the method described in the first aspect.
[0037] The technical solutions disclosed in the present disclosure at least bring the following beneficial effects:
[0038] In an embodiment of the present disclosure, when a question text of a user is received, an AC automaton is used to extract target keywords of the question text, target scores corresponding to each of the target keywords, and knowledge slices associated with the target keywords; wherein, the AC automaton pre-stores a plurality of keywords and scores of each of the keywords, and the keywords include the target keywords; based on the target scores corresponding to each of the target keywords, a relevance score between each of the knowledge slices and the question text is calculated; according to the relevance scores between each of the knowledge slices and the question text, target knowledge slices are determined; and the target knowledge slices are recalled. In this way, by using the AC automaton to extract keywords, calculate relevance scores, and determine target knowledge slices, the knowledge slices most relevant to the question text can be effectively screened out from a large number of knowledge slices, thereby improving the accuracy and efficiency of knowledge slice retrieval and optimizing the user experience.
[0039] It should be understood that the above general description and subsequent detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure, and do not constitute an improper limitation to the present disclosure.
[0041] Figure 1 is a flowchart of a method for recalling knowledge slices provided by an embodiment of the present disclosure;
[0042] Figure 2 is a logical diagram of a method for recalling knowledge slices provided by an embodiment of the present disclosure;
[0043] Figure 3 is a structural diagram of a device for recalling knowledge slices provided by an embodiment of the present disclosure;
[0044] Figure 4 is a structural diagram of an electronic device provided by an embodiment of the present disclosure. Detailed implementation manners
[0045] In order to enable those of ordinary skill in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0046] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0047] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data for analysis, stored data, displayed data, etc.) and signals involved in the present disclosure are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of relevant countries and regions.
[0048] In the technical solutions of the present disclosure, the acquisition, storage, use, processing, etc. of data all comply with the relevant provisions of national laws and regulations.
[0049] It should be noted that in the embodiments of the present disclosure, there may be existing solutions in the industry for certain software, components, models, etc. They should be regarded as exemplary, and their purpose is only to illustrate the feasibility in the implementation of the technical solutions of the present disclosure, but it does not mean that the applicant has already or necessarily used this solution.
[0050] In the embodiments of the present disclosure, the explanations of some terms are as follows:
[0051] Rearrangement: Rearrange the multiple knowledge slices recalled in the recall stage, rank the knowledge slices highly relevant to the user's question at the front, and only leave the N knowledge slices with the highest relevance scores;
[0052] Vector: A digital representation of text or a picture, which is a multi-dimensional floating-point matrix;
[0053] Milvus: An open-source database for storing and retrieving vectors;
[0054] Prompt: Prompt word;
[0055] RAG: A retrieval-augmented technology, commonly used in large model knowledge base systems, which slices the knowledge base by retrieving the user's question, finds the knowledge slices relevant to the question, and provides more accurate answers to the large model.
[0056] AC automaton (Aho-Corasick automaton): An efficient multi-pattern string matching algorithm, whose core idea combines the failure pointer mechanism of the Trie tree (prefix tree) and the KMP (The Knuth-Morris-Pratt Algorithm), and can match multiple pattern strings during a single pass through the text.
[0057] The following will describe in detail the technical solutions provided by each embodiment of the present disclosure in conjunction with the accompanying drawings.
[0058] Figure 1 It is a flowchart of a knowledge slice recall method provided by an embodiment of the present disclosure. This method can be applied to a server, such as a single server or a server cluster. As Figure 1 shown, the knowledge slice recall method may include the following steps:
[0059] S101, when receiving the user's question text, extract the target keywords of the question text, the target score corresponding to each target keyword, and the knowledge slices associated with the target keywords through the AC automaton.
[0060] Among them, the AC automaton pre-stores multiple keywords and the score of each keyword, and the keywords include the target keywords. The AC automaton is pre-constructed, and the score assigned to each keyword can be used to reflect the importance of the keyword in the knowledge slice.
[0061] In an embodiment of the present disclosure, when a question text input by a user is received, the question text can be processed to extract keywords therein, that is, target keywords. As an example, the question text can be a query in natural language form, such as: "How to improve the efficiency of document retrieval". Then, the user's question text can be input into a pre-constructed Aho-Corasick automaton (AC automaton), which can quickly match the pre-stored keywords in the question text and extract these keywords as target keywords. For example, assume the question text is: "How to improve the efficiency of document retrieval", and the keywords stored in the AC automaton include "document retrieval" and "efficiency", then the AC automaton will extract "document retrieval" and "efficiency" as target keywords. When the AC automaton matches a target keyword, it will simultaneously return the score corresponding to this keyword (i.e., the target score), that is, the AC automaton will output each target keyword and the target score corresponding to each target keyword. For example, assume the score of "document retrieval" is 0.8 and the score of "efficiency" is 0.7, then the extraction result is: Keyword: "document retrieval", Score: 0.8; Keyword: "efficiency", Score: 0.7. Moreover, when the AC automaton matches a target keyword, it can also simultaneously return the knowledge slices associated with these keywords, that is, the AC automaton will also output the knowledge slices associated with the target keywords. For example, assume the knowledge slice associated with "document retrieval" is: "Document retrieval can improve efficiency by optimizing the index structure." And the knowledge slice associated with "efficiency" is: "The key to improving retrieval efficiency lies in reducing unnecessary calculations." Then the extraction result is: Keyword: "document retrieval", Score: 0.8, Associated slice: "Document retrieval can improve efficiency by optimizing the index structure." Keyword: "efficiency", Score: 0.7, Associated slice: "The key to improving retrieval efficiency lies in reducing unnecessary calculations." In this way, the AC automaton can complete keyword matching in a short time, improving the retrieval efficiency; moreover, by associating with knowledge slices, not only can keywords be extracted, but also the context information of the keywords can be retained, which helps subsequent semantic understanding and relevance calculation; at the same time, the keyword scores can provide data basis for subsequent weighted calculation, enabling a more accurate evaluation of the relevance between the knowledge slices and the question text.
[0062] S102, Calculate the relevance score between each knowledge slice and the question text based on the target score corresponding to each target keyword.
[0063] In an embodiment of the present disclosure, the relevance between each knowledge slice and the question text can be quantitatively evaluated. The higher the relevance score, the more closely the knowledge slice matches the question text. Exemplarily, for each knowledge slice, the relevance score between the knowledge slice and the question text can be calculated based on the target score corresponding to the target keyword associated therewith. It can be understood that if multiple knowledge slices are matched, the relevance scores between each knowledge slice and the question text can be calculated respectively, and this process can be parallel. In this way, a final relevance score will be calculated for each knowledge slice, and these relevance scores will be used for subsequent sorting and selection. The higher the relevance score, the more relevant the knowledge slice is to the question text, which can provide a data basis for the sorting of knowledge slices, enabling the system to more accurately select the slice most relevant to the question.
[0064] S103. Determine the target knowledge slice according to the relevance score between each knowledge slice and the question text.
[0065] In a possible implementation manner, it is possible to:
[0066] Sort the knowledge slices according to the relevance scores of the knowledge slices in a preset sorting manner to obtain a knowledge slice sequence; wherein, the preset sorting method includes from high to low or from low to high;
[0067] Select a preset number of knowledge slices with the highest similarity scores in the knowledge slice sequence as the target knowledge slices.
[0068] In an embodiment of the present disclosure, after obtaining the relevance scores between each knowledge slice and the question text, the knowledge slices can be reordered, and the most relevant slice can be selected as the target knowledge slice. Exemplarily, according to a preset sorting method, the knowledge slices can be sorted according to their relevance scores. For example, it can be from high to low (descending order) or from low to high (ascending order). Suppose the knowledge slices and their relevance scores are as follows: Knowledge slice 1: final_similarity = 1.2; Knowledge slice 2: final_similarity = 0.9; Knowledge slice 3: final_similarity = 1.5; Knowledge slice 4: final_similarity = 1.1. According to the sorting method from high to low, the sorted sequence of knowledge slices is: Knowledge slice 3: final_similarity = 1.5; Knowledge slice 1: final_similarity = 1.2; Knowledge slice 4: final_similarity = 1.1; Knowledge slice 2: final_similarity = 0.9. In the sorted sequence of knowledge slices, a preset number of knowledge slices with the highest relevance scores are selected as the target knowledge slices. The preset number can be determined according to actual needs. For example, it can be 1, 2, etc. Suppose the preset number is 2. Still referring to the previous example, the first two sorted knowledge slices are selected as the target knowledge slices: Knowledge slice 3: final_similarity = 1.5, Knowledge slice 1: final_similarity = 1.2. The target knowledge slices can be provided as output to the user. These slices are the most relevant knowledge fragments to the question text and can be used to answer the user's question or provide relevant information. In this way, by sorting and selecting the knowledge slices, the most relevant knowledge slices can be filtered out from multiple candidate knowledge slices, so that the most accurate information can be provided to the user. In this way, not only can the retrieval efficiency be improved, but also the output result of the system can be optimized to better meet the user's needs.
[0069] S104, recall the target knowledge slice.
[0070] In an embodiment of the present disclosure, after determining the target knowledge slice, the target knowledge slice can be recalled and returned to the user and presented to the user as the answer to the question text input by the user.
[0071] In an embodiment of the present disclosure, when receiving the user's question text, the target keywords of the question text, the target score corresponding to each target keyword, and the knowledge slice associated with the target keyword are extracted through an AC automaton; wherein, the AC automaton pre-stores a plurality of keywords and the score of each keyword, and the keywords include the target keywords; based on the target score corresponding to each target keyword, the relevance score between each knowledge slice and the question text is calculated; according to the relevance score between each knowledge slice and the question text, the target knowledge slice is determined; and the target knowledge slice is recalled. In this way, by using the AC automaton to extract keywords, calculate the relevance score, and determine the target knowledge slice, the most relevant knowledge slice to the question text can be effectively screened out from a large number of knowledge slices, thereby improving the accuracy and efficiency of knowledge slice retrieval and optimizing the user experience.
[0072] In some possible implementation manners, before extracting the target keywords of the question text, the target score corresponding to each target keyword, and the knowledge slice associated with the target keyword through an AC automaton when receiving the user's question text, it further includes:
[0073] Based on the preset sample document data, keyword extraction is performed on each sample document by using a pre-trained large model;
[0074] Each keyword of each sample document is scored by using a pre-trained large model to obtain the score of each keyword of each sample document;
[0075] The score of each keyword of each sample document is stored in the AC automaton.
[0076] In an embodiment of the present disclosure, sample document data (preset sample document data) can be constructed for model training, used to build a knowledge base, and a pre-trained large model, such as BERT (Bidirectional Encoder Representations from Transformers), GPT (Chat Generative Pre-trained Transformer), or other NLP (Natural Language Processing) models, can be used to process each sample document, extract keywords therein, and obtain a keyword set for each sample document. For example, assume the content of the sample document is: "Document retrieval can improve efficiency by optimizing the index structure", and the extracted keywords may be: "document retrieval", "optimize", "index structure", "efficiency". Then, the pre-trained large model can score each keyword of each sample document to obtain the score of each keyword. For example, the large model can evaluate and score the importance of each keyword in the document, and the basis for scoring may be the semantic importance of the keyword, the occurrence frequency (TF-IDF), the context relevance, etc., and then output the score of each keyword. For example, keyword: "document retrieval", score: 0.8; keyword: "efficiency", score: 0.7; keyword: "optimize", score: 0.6; keyword: "index structure", score: 0.5. After that, the scores of each keyword of each sample document can be stored in the AC automaton to obtain the constructed AC automaton, which contains the keywords and their scores. In this way, by pre-extracting keywords, scoring, and storing, it can provide a data basis for extracting target keywords and their scores from the user question text subsequently, so as to provide data support for accurate knowledge slice recall and improve the recall efficiency.
[0077] In some possible implementation manners, before using the pre-trained large model to extract keywords from each sample document based on the preset sample document data, it further includes:
[0078] Slice the sample document according to the first preset length and set the overlapping second preset length to generate multiple knowledge slices;
[0079] Construct the preset sample document data based on the multiple knowledge slices.
[0080] In an embodiment of the present disclosure, a fixed length (the first preset length), for example, 1000 words, can be set as the length of each knowledge slice according to system requirements; to preserve the coherence of context information, an overlapping length (the second preset length), for example, 200 words, can be set. Then, starting from the beginning of the sample document, slicing can be performed according to the set length and overlapping length until the end of the document, and multiple knowledge slices can be obtained. Then, these knowledge slices can be used as new sample document data for subsequent keyword extraction and index construction. The preset sample document data constructed is such that each document is divided into multiple knowledge slices, and each slice contains a meaningful text content. These slices will be used for subsequent keyword extraction and index construction. In this way, by dividing the sample document into multiple overlapping segments (knowledge slices), a data basis can be provided for subsequent keyword extraction and index construction, thereby not only improving the retrieval and recall efficiency but also optimizing the quality of retrieval results.
[0081] In some possible implementation manners, based on the target scores corresponding to each target keyword, calculating the relevance score between each knowledge slice and the question text includes:
[0082] Calculating the vector similarity between the vector of each knowledge slice and the vector of the question text;
[0083] Based on the target scores corresponding to each target keyword, the preset keyword weights, and the vector similarity between the vector of each knowledge slice and the vector of the question text, calculating the relevance score between each knowledge slice and the question text.
[0084] In an embodiment of the present disclosure, the relevance score between the knowledge slice and the question text can be calculated in combination with the vector similarity. Exemplarily, the vector representation of each knowledge slice and the vector representation of the question text can be obtained first. For example, the cosine similarity can be used to calculate the similarity between the vector of each knowledge slice and the vector of the question text, and the vector similarity score between each knowledge slice and the question text can be obtained. As an example, assuming the vector of knowledge slice 1 is v1 and the vector of the question text is v2, the vector similarity score is:
[0085]
[0086] Then, based on the target scores of each target keyword, the preset keyword weights, and the vector similarity scores between each knowledge slice and the question text, the score of each target keyword can be multiplied by the corresponding preset keyword weight, and the weighted keyword scores and the vector similarity scores can be combined to calculate the correlation score between each knowledge slice and the question text. As an example, the calculation method for calculating the correlation score between each knowledge slice and the question text based on the target scores corresponding to each target keyword, the preset keyword weights, and the vector similarity between the vector of each knowledge slice and the question text is as follows:
[0087] final_similarity = cos_similarity + (keyword1_score +... + keywordN_score) * (1)
[0088] keyword_coefficent
[0089] where final_similarity represents the correlation score between each of the knowledge slices and the question text;
[0090] cos_similarity represents the vector similarity between the vector of each knowledge slice and the question text;
[0091] keyword1_score +... + keywordN_score represents the sum of the target scores corresponding to the target keywords, N represents the total number of keywords, N ∈ N*; keyword_coefficent represents the preset keyword weight.
[0092] As a specific example, assume that knowledge slice 1 contains the target keywords "document retrieval" and "efficiency", with scores of 0.8 and 0.7 respectively, the preset keyword weight is 0.5, and the vector similarity score is 0.6. Then the correlation score is: final_similarity = 0.6 + (0.8 × 0.5 + 0.7 × 0.5) = 0.6 + 0.75 = 1.35. In this way, by comprehensively considering the vector similarity and the keyword scores, calculating the correlation score between each knowledge slice and the question text can not only avoid the limitations of a single indicator, optimize the calculation of the correlation score, but also improve the accuracy of the recalled knowledge slices.
[0093] To make the knowledge slice recall method provided by the embodiments of the present disclosure clearer, the following specific examples are used for illustration.
[0094] Assume that the first preset length is 1000 and the second preset length is 200. Then the knowledge slice recall method includes:
[0095] Step 1: Construction of the AC automaton for keyword groups: Use the large model to extract and score keywords from the sliced document knowledge in advance, construct the vocabulary of keyword groups, and build the AC automaton of keyword groups in the system memory. Today, it includes:
[0096] ① Document slicing: Slice the document based on 1000 words with an overlap of 200 words to obtain slices of each document;
[0097] ② Keyword extraction and scoring: Use the large model to extract keywords from each document slice, and let the large model evaluate and score the importance of each keyword according to the context content of the slice;
[0098] ③ AC automaton construction: After obtaining the keywords with the scores from the large model, construct the AC automaton and store it in the memory of the service.
[0099] Step 2: Extraction of problem keyword groups: Use the AC automaton to extract the keywords and corresponding scores in the problem. Specifically, it includes:
[0100] ① Keyword group extraction: The AC automaton has been constructed in the memory in Step 1. Next, use the AC automaton to extract the keywords in the problem, and these keywords have been scored by the large model in advance.
[0101] Step 3: Re-ranking and weighting: Re-rank the slices obtained in the recall stage, weight the slices with keyword groups, and calculate the final slice relevance score by formula using the keyword scores and vector scores of the slices. The formula is as follows:
[0102] final_similarity = cos_similarity + (keyword1_score +... + keywordN_score) * (1)
[0103] keyword_coefficent
[0104] Among them, final_similarity represents the relevance score between each of the knowledge slices and the problem text;
[0105] cos_similarity represents the vector similarity between the vector of each of the knowledge slices and the problem text;
[0106] keyword1_score +... + keywordN_score represents the sum of the target scores corresponding to the target keywords, N represents the total number of keywords, N ∈ N*; keyword_coefficent represents the preset keyword weight.
[0107] The following will be described in conjunction with Figure 2 the logical schematic diagram of the knowledge slice recall method shown in the figure. As Figure 2 shown, the knowledge slice recall method includes the following processes:
[0108] 1. Intent recognition and keyword extraction:
[0109] "intent_module" is the intent recognition step, which is used to determine the intent of the user's question. "Keyword selection" is the keyword extraction and scoring step, which can provide a basis for subsequent retrieval and relevance calculation.
[0110] 2. Knowledge slice query:
[0111] The queries of "ES_Device_Params", "ES_Docs" and "Milvus.Docs" refer to knowledge slice retrieval, which retrieves relevant knowledge slices from different data sources through keywords.
[0112] 3. Answer screening:
[0113] The "topk answers greater than the threshold" screening step refers to the preliminary screening, which selects the knowledge slices most relevant to the question.
[0114] 4. Cache query:
[0115] "cache_module" refers to the cache mechanism, which is used for fast retrieval and reuse of existing relevance calculation results.
[0116] 5. Similarity calculation and relevance score calculation:
[0117] The queries of "Milvus.Gen_QA" and "Milvus.History_QA", as well as the similarity calculation step, refer to vector similarity calculation and relevance score calculation, which comprehensively consider vector similarity and keyword scores to evaluate the relevance of knowledge slices.
[0118] 6. Answer selection and multi-round result processing:
[0119] The processing steps of "whether the similarity is greater than 0.95" and "multi-round results" refer to the determination of the target knowledge slice and multi-round judgment, which select the most relevant knowledge slice according to the relevance score, or perform multi-round interactions to clarify the question when necessary.
[0120] 7. Question clarification and final answer determination:
[0121] The "question clarification module" and "final answer determination" steps refer to question clarification and final answer selection, ensuring that the user gets an accurate and satisfactory answer.
[0122] The specific implementation and technical effects of each step in this embodiment are similar to those in the above method embodiment, and will not be elaborated here.
[0123] Based on the same inventive concept, an embodiment of the present disclosure further provides a knowledge slice recall device. As Figure 3 shown, the knowledge slice recall device 300 includes:
[0124] An extraction module 310, configured to, when receiving a question text of a user, extract target keywords of the question text, target scores corresponding to each of the target keywords, and knowledge slices associated with the target keywords through an AC automaton; wherein, the AC automaton prestores a plurality of keywords and scores of each keyword, and the keywords include the target keywords;
[0125] A calculation module 320, configured to calculate a relevance score between each knowledge slice and the question text based on the target scores corresponding to each of the target keywords;
[0126] A determination module 330, configured to determine a target knowledge slice according to the relevance scores between each knowledge slice and the question text;
[0127] A recall module 340, configured to recall the target knowledge slice.
[0128] In a possible implementation manner, it further includes:
[0129] A sample extraction module, configured to extract keywords from each sample document by using a pre-trained large model based on preset sample document data;
[0130] A scoring module, configured to score each keyword of each sample document through the pre-trained large model to obtain scores of each keyword of each sample document;
[0131] A storage module, configured to store the scores of each keyword of each sample document in the AC automaton.
[0132] In a possible implementation manner, it further includes:
[0133] A slicing module, configured to slice a sample document according to a first preset length and set an overlapping second preset length to generate a plurality of knowledge slices;
[0134] A construction module, configured to construct preset sample document data based on the plurality of knowledge slices.
[0135] In a possible implementation manner, the calculation module 320 is configured to:
[0136] Calculate the vector similarity between the vector of each of the knowledge slices and the vector of the question text;
[0137] Based on the target scores corresponding to each of the target keywords, the preset keyword weights, and the vector similarity between the vector of each of the knowledge slices and the vector of the question text, calculate the relevance scores between each of the knowledge slices and the question text.
[0138] In a possible implementation manner, the calculation method for calculating the relevance scores between each of the knowledge slices and the question text based on the target scores corresponding to each of the target keywords, the preset keyword weights, and the vector similarity between the vector of each of the knowledge slices and the vector of the question text is as follows:
[0139] final_similarity = cos_similarity+(keyword1_score+...+keywordN_score)*keyword_coefficent(1)
[0140] where final_similarity represents the relevance scores between each of the knowledge slices and the question text; cos_similarity represents the vector similarity between the vector of each of the knowledge slices and the vector of the question text; keyword1_score+...+keywordN_score represents the sum of the target scores corresponding to the target keywords, N represents the total number of keywords, N∈N*; keyword_coefficent represents the preset keyword weight.
[0141] In a possible implementation manner, the determining module 330 is configured to:
[0142] Sort the knowledge slices based on the relevance scores of the knowledge slices according to a preset sorting method to obtain a knowledge slice sequence; where the preset sorting method includes from high to low or from low to high;
[0143] Select a preset number of knowledge slices with the highest similarity scores in the knowledge slice sequence as the target knowledge slices.
[0144] The specific implementation manners and technical effects of the device provided by the embodiments of the present disclosure are similar to those of the above method embodiments and will not be described in detail here.
[0145] According to the embodiments of the present disclosure, the present disclosure also discloses an electronic device, a computer-readable storage medium, and a computer program product.
[0146] Figure 4FIG. shows a schematic block diagram of an exemplary electronic device 400 that can be used to implement embodiments of the present disclosure. The electronic device 400 is intended to represent various forms of digital computers, such as, for example, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as, personal digital processors, cellular telephones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely exemplary and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0147] As Figure 4 shown, the electronic device 400 includes a computing unit 401 that can perform various appropriate actions and processes in accordance with 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. In the RAM 403, various programs and data required for the operation of the electronic device 400 can also be stored. The computing unit 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0148] A plurality of components in the electronic device 400 are connected to the I / O interface 405, including: an input unit 406, such as a keyboard, a mouse, etc.; an output unit 407, such as various types of displays, speakers, etc.; a storage unit 408, such as a magnetic disk, an optical disk, etc.; and a communication unit 409, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 409 allows the electronic device 400 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0149] The computing unit 401 can be various 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 dedicated 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 executes the various methods and processes described above, such as the knowledge slice recall method. For example, in some embodiments, the knowledge slice recall method can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 408. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 400 via the ROM 402 and / or the communication unit 409. When the computer program is loaded into the RAM 403 and executed by the computing unit 401, one or more steps of the knowledge slice recall method described above can be executed. Alternatively, in other embodiments, the computing unit 401 can be configured to execute the knowledge slice recall method by any other suitable means (e.g., by means of firmware).
[0150] The various embodiments of the systems and techniques described above in this document can be implemented in digital electronic circuitry, integrated circuit systems, field programmable gate arrays (FPGA), application specific integrated circuits (ASIC), application specific standard products (ASSP), system-on-a-chip systems (SOC), complex programmable logic devices (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special-purpose or general-purpose programmable processor that receives data and instructions from a storage system, at least one input device, and at least one output device, and transmits the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0151] The program code of the computer program product for implementing the methods of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the program codes are executed by the processor or controller, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The program codes can be executed entirely on the machine, partially on the machine, as a stand-alone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0152] In the context of this disclosure, a computer-readable storage medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A computer-readable storage medium can be a machine-readable signal medium or a machine-readable storage medium. A computer-readable storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a computer-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0153] In order to provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0154] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.
[0155] A computer system may include a client and a server. The client and the server are generally far from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the respective computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system, solving the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services ("Virtual Private Server", or simply "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain.
[0156] It should be understood that various forms of processes shown above can be used, steps can be reordered, added or deleted. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and no limitations are imposed herein.
[0157] The above specific embodiments do not constitute a limitation on the protection scope of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principle of this disclosure shall be included within the protection scope of this disclosure.
Claims
1. A knowledge slice recall method, characterized in that: include: When receiving a question text from a user, extracting a target keyword of the question text, a target score corresponding to each target keyword, and a knowledge slice associated with the target keyword through an AC automaton; wherein the AC automaton pre-stores a plurality of keywords and a score for each keyword, and the keywords include the target keyword; Based on the target score corresponding to each of the target keywords, calculate the relevance score between each of the knowledge slices and the question text; Determine a target knowledge slice according to the relevance score between each of the knowledge slices and the question text; Recall the target knowledge slice.
2. The knowledge slice recall method according to claim 1, characterized in that: In the case of receiving a question text from a user, before extracting the target keywords of the question text, the target score corresponding to each of the target keywords, and the knowledge slices associated with the target keywords through the AC automaton, the method further includes: Based on the preset sample document data, use the pre-trained large model to extract keywords from each sample document; Scoring each keyword of each sample document by using the pre-trained large model to obtain a score for each keyword of each sample document; The score of each keyword of each of the sample documents is stored in the AC automaton.
3. The knowledge slice recall method according to claim 2, characterized in that: Before extracting keywords from each sample document using a pre-trained large model based on the preset sample document data, the method further includes: Slice the sample document according to a first preset length, and set the overlap to a second preset length to generate multiple knowledge slices; Construct preset sample document data based on the multiple knowledge slices.
4. The knowledge slice recall method according to claim 2, characterized in that: The step of calculating the relevance score between each of the knowledge slices and the question text based on the target score corresponding to each of the target keywords includes: Based on the vector of each of the knowledge slices and the vector of the question text, calculating the vector similarity between the vector of each of the knowledge slices and the question text; Based on the target score corresponding to each of the target keywords, the preset keyword weight, and the vector similarity between the vector of each of the knowledge slices and the question text, the correlation score between each of the knowledge slices and the question text is calculated.
5. The knowledge slice recall method according to claim 4, characterized in that: The calculation method of calculating the correlation score between each of the knowledge slices and the question text based on the target score corresponding to each of the target keywords, the preset keyword weight, and the vector similarity between the vector of each of the knowledge slices and the question text is: final_similarity=cos_similarity + (keyword1_score + ... + keywordN_score) * (1) keyword_coefficent Among them, final_similarity represents the correlation score between each of the knowledge slices and the question text; cos_similarity represents the vector similarity between the vector of each knowledge slice and the question text; keyword1_score+...+keywordN_score represents the sum of the target scores corresponding to the target keywords, N represents the total number of keywords, N∈N*; keyword_coefficent represents the preset keyword weight.
6. The knowledge slice recall method according to any one of claims 1 to 5, characterized in that: Determining the target knowledge slice according to the correlation score between each of the knowledge slices and the question text includes: Sorting the knowledge slices based on the relevance scores of the knowledge slices in a preset sorting manner to obtain a knowledge slice sequence; wherein the preset sorting method includes from high to high or from low to high; A preset number of knowledge slices with the highest similarity scores are selected from the knowledge slice sequence as target knowledge slices.
7. A knowledge slice recall device, characterized in that: include: An extraction module is used to extract the target keywords of the question text, the target scores corresponding to each of the target keywords, and the knowledge slices associated with the target keywords through an AC automaton when receiving the question text of the user; wherein the AC automaton pre-stores a plurality of keywords and the scores of each of the keywords, and the keywords include the target keywords; A calculation module, used to calculate the relevance score between each of the knowledge slices and the question text based on the target score corresponding to each of the target keywords; A determination module, used for determining a target knowledge slice according to a correlation score between each of the knowledge slices and the question text; A recall module is used to recall the target knowledge slice.
8. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; Wherein, the processor is configured to execute the instructions to implement the knowledge slice recall method as described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the knowledge slice recall method described in any one of claims 1-6 is implemented.
10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the knowledge slice recall method described in any one of claims 1-6 is implemented.
Citation Information
Cited By
Knowledge base construction method and device and knowledge question and answer retrieval method and device
CN120562538A
Knowledge base construction method, device and knowledge question and answer retrieval method and device
CN120562538B