Search-based content generation method and device, and electronic device
Patent Information
- Application Number
- CN202610812689.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-08
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2046-06-08
AI Technical Summary
[0003]然而,当用户问题涉及多个相关但不同层次的语义维度时,相关技术难以实现对相关文本块的精准定位与有效整合,导致检索结果的覆盖度和准确性难以满足复杂问答场景的需求
[0020]本申请实施例提供的基于检索的内容生成方法,接收用户输入的待解答问题,并基于待解答问题,从多个预设文本块中确定待解答问题对应的至少一个第一候选文本块;基于至少一个第一候选文本块和待解答问题,确定各第一候选文本块对应的第一贡献度;基于第一候选文本块对应的第一贡献度和第一候选文本块,查询文本块聚类树,得到第一候选文本块对应的聚类标签信息;基于第一候选文本块对应的第一贡献度和第一候选文本块对应的聚类标签信息,从多个预设文本块中确定至少一个第二候选文本块;基于第一候选文本块和/或至少一个第二候选文本块确定目标内容,并指示预设模型根据目标内容生成待解答问题对应的回答。
Smart Images

Figure CN122332550B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a retrieval-based content generation method, apparatus, and electronic device. Background Technology
[0002] With the rapid development of artificial intelligence technology, retrieval-based content generation methods have been widely applied in fields such as intelligent question answering and knowledge base retrieval. These technologies typically employ keyword matching or vector similarity calculation to retrieve candidate texts related to the user's question from a large-scale text database, and then generate an answer based on the retrieval results.
[0003] However, when user questions involve multiple related but different semantic dimensions, related technologies struggle to accurately locate and effectively integrate related text blocks, resulting in the retrieval results failing to meet the needs of complex question-and-answer scenarios in terms of coverage and accuracy.
[0004] Therefore, how to improve search accuracy while ensuring search efficiency, thereby improving the quality of content generation, is an urgent problem to be solved. Summary of the Invention
[0005] To address the aforementioned problems, embodiments of this application provide a content generation method, apparatus, and electronic device based on retrieval, capable of adapting to various fields and efficiently generating accurate and reliable retrieval results, thereby generating high-quality content. Specifically, embodiments of this application disclose the following technical solutions: The first aspect of this application provides a content generation method based on retrieval. The method includes: determining at least one first candidate text block corresponding to the unanswered question from multiple preset text blocks based on a user-inputted unanswered question; wherein the multiple preset text blocks are obtained by a preset model dividing preset text according to preset rules; determining a first contribution degree corresponding to each first candidate text block based on the at least one first candidate text block and the unanswered question; querying a text block clustering tree based on the first contribution degree and the first candidate text block to obtain clustering label information corresponding to the first candidate text block; wherein the text block clustering tree is constructed from multiple preset text blocks based on the clustering label information, and the clustering label information is obtained by a preset model based on preset text; determining at least one second candidate text block from multiple preset text blocks based on the first contribution degree and the clustering label information corresponding to the first candidate text block; determining target content based on the first candidate text block and / or at least one second candidate text block, and instructing a preset model to generate an answer corresponding to the unanswered question based on the target content.
[0006] In some embodiments, determining at least one second candidate text block from a plurality of preset text blocks based on the first contribution of the first candidate text block and the clustering label information corresponding to the first candidate text block includes: determining a first candidate clustering label based on the clustering label information corresponding to the first candidate text block when the first contribution of the first candidate text block is within a first preset range; wherein the first candidate clustering label is other clustering label information besides the clustering label information corresponding to the first candidate text block; and determining at least one second candidate text block from a plurality of preset text blocks based on the first candidate clustering label.
[0007] In some embodiments, determining at least one second candidate text block from a plurality of preset text blocks based on the first contribution of the first candidate text block and the clustering label information corresponding to the first candidate text block includes: determining a first candidate clustering label based on the clustering label information corresponding to the first candidate text block when the first contribution of the first candidate text block is within a second preset range; wherein the first candidate clustering label is the clustering label information corresponding to the first candidate text block; determining at least one second candidate text block from a plurality of preset text blocks based on the first candidate clustering label; wherein the second candidate text block is different from the first candidate text block.
[0008] In some embodiments, the text block clustering tree includes a first clustering tree and a second clustering tree. Determining the first candidate clustering label based on the clustering label information corresponding to the first candidate text block includes: querying the first clustering tree and the second clustering tree respectively based on the clustering label information of the first candidate text block to obtain the first clustering label corresponding to the first candidate text block in the first clustering tree and the second clustering label corresponding to the first candidate text block in the second clustering tree; wherein, the first candidate clustering label includes the first clustering label and the second clustering label.
[0009] In some embodiments, determining at least one second candidate text block from a plurality of preset text blocks based on a first candidate clustering label includes: determining at least one first preset text block with the highest contribution corresponding to the first clustering label from the plurality of preset text blocks based on the contribution of the plurality of preset text blocks; determining at least one second preset text block with the highest contribution corresponding to the second clustering label from the plurality of preset text blocks based on the contribution of the plurality of preset text blocks; and determining the preset text block with the highest contribution among the at least one first preset text block and the at least one second preset text block as the second candidate text block.
[0010] In some embodiments, determining at least one first candidate text block corresponding to the unanswered question from multiple preset text blocks based on the unanswered question includes: extracting question keywords from the unanswered question based on the unanswered question; determining a first candidate text block from multiple preset text blocks based on the matching degree between the question keywords and multiple preset text blocks; wherein the first candidate text block is the preset text block with the highest matching degree with the question keywords among multiple preset text blocks.
[0011] In some embodiments, determining target content based on at least one first candidate text block and / or at least one second candidate text block includes: determining a second contribution of the second candidate text block based on the second candidate text block and the question to be answered; and determining target content based on the first candidate text block and / or the second candidate text block if the second contribution of the second candidate text block is within a third preset range.
[0012] In some embodiments, the text block clustering tree is constructed from the plurality of preset text blocks based on clustering label information, including: obtaining the directory information and text block labels of each preset text block; wherein, the directory information is used to indicate the directory in the preset text, and the text block labels are used to indicate the labels defined by the preset model for the preset text blocks; constructing a first clustering tree based on the preset text blocks and the directory information corresponding to the preset text blocks; wherein, the directory parent node of the preset text block in the first clustering tree is composed of the directory information corresponding to the preset text block; constructing a second clustering tree based on the preset text blocks and the text block labels corresponding to the preset text blocks; wherein, the label parent node of the preset text block in the second clustering tree is composed of the text block labels corresponding to the preset text blocks.
[0013] In some embodiments, constructing a first clustering tree based on preset text blocks and their corresponding directory information includes: determining the directory information of the preset text blocks as the directory parent node of the preset text blocks; and, if the number of preset text blocks corresponding to the directory parent node exceeds a first threshold, generating a directory parent node based on the semantic similarity between the preset text blocks exceeding the first threshold; or, if the preset text blocks do not have directory information, determining the directory information of the preset text blocks based on the semantic similarity between multiple preset text blocks without directory information, and generating a directory parent node based on the directory information; wherein, the directory parent node corresponds to multiple preset child nodes, and the preset child nodes are composed of corresponding preset text blocks; and constructing a first clustering tree based on the preset child nodes and the directory parent node.
[0014] In some embodiments, constructing a second clustering tree based on preset text blocks and their corresponding text block labels includes: classifying multiple text block labels based on the semantic similarity between the text block labels corresponding to multiple preset text blocks to obtain multiple text block label clusters; generating label categories according to multiple text block labels in each text block label cluster using a preset pattern; wherein preset text blocks corresponding to text block labels belonging to the same text block label cluster correspond to the same label category; generating a label parent node based on each label category and its corresponding text block label; generating a new label parent node based on the text block labels corresponding to the preset text blocks that exceed the second threshold when the number of preset text blocks corresponding to the label parent node exceeds a second threshold; wherein the label parent node corresponds to multiple preset child nodes, and each preset child node is composed of a corresponding preset text block; and constructing a second clustering tree based on the preset child nodes and the label parent node.
[0015] A second aspect of this application provides a content generation apparatus based on retrieval, comprising: a first determining module, a second determining module, a third determining module, a fourth determining module, and a fifth determining module. The system comprises the following modules: a first determining module, configured to receive a user-input question and, based on the question, determine at least one first candidate text block corresponding to the question from multiple preset text blocks; wherein the multiple preset text blocks are obtained by a preset model dividing preset text according to preset rules; a second determining module, configured to determine a first contribution degree corresponding to each first candidate text block based on at least one first candidate text block and the question; a third determining module, configured to query a text block clustering tree based on the first contribution degree and the first candidate text block to obtain clustering label information corresponding to the first candidate text block; wherein the text block clustering tree is constructed by multiple preset text blocks based on the clustering label information, and the clustering label information is obtained by a preset model based on preset text; a fourth determining module, configured to determine at least one second candidate text block from multiple preset text blocks based on the first contribution degree and the clustering label information corresponding to the first candidate text block; and a fifth determining module, configured to determine target content based on the first candidate text block and / or at least one second candidate text block, and instruct a preset model to generate an answer to the question based on the target content.
[0016] A third aspect of this application provides an electronic device, including: a processor and a memory, wherein the memory is used to store computer-executable instructions; and the processor is used to read the instructions from the memory and execute the instructions to implement the retrieval-based content generation method described in the first aspect above.
[0017] A fourth aspect of this application provides a computer-readable storage medium storing computer program instructions. When a computer reads the instructions, it executes the retrieval-based content generation method described in the first aspect above.
[0018] A fifth aspect of this application provides a computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions that, when executed by a computer, cause the computer to perform the retrieval-based content generation method described in the first aspect.
[0019] The sixth aspect of this application provides a computer program that, when executed by a processor, can implement the retrieval-based content generation method described in the first aspect above.
[0020] The content generation method based on retrieval provided in this application receives an unanswered question input by a user, and determines at least one first candidate text block corresponding to the unanswered question from multiple preset text blocks based on the unanswered question; determines a first contribution degree corresponding to each first candidate text block based on the at least one first candidate text block and the unanswered question; queries a text block clustering tree based on the first contribution degree and the first candidate text block to obtain clustering label information corresponding to the first candidate text block; determines at least one second candidate text block from multiple preset text blocks based on the first contribution degree and the clustering label information corresponding to the first candidate text block; determines target content based on the first candidate text block and / or at least one second candidate text block, and instructs a preset model to generate an answer corresponding to the unanswered question based on the target content.
[0021] The content generation method based on retrieval provided in this application introduces a text block clustering tree structure, realizing the transformation from keyword retrieval to hierarchical semantic retrieval. At the same time, it utilizes a contribution-based retrieval mechanism to achieve dynamic focusing and semantic diffusion in the retrieval process, effectively improving the retrieval accuracy and content generation quality under complex queries, and solving the technical problem of not being able to balance retrieval efficiency and semantic depth. Attached Figure Description
[0022] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 This is a schematic diagram of a content generation system based on retrieval provided in an embodiment of this application; Figure 2 A schematic diagram illustrating a content generation method based on retrieval provided in an embodiment of this application; Figure 3 A schematic diagram of a text block clustering tree provided in an embodiment of this application; Figure 4 A schematic diagram illustrating another content generation method based on retrieval provided in this application embodiment; Figure 5 A schematic diagram illustrating yet another content generation method based on retrieval provided in an embodiment of this application; Figure 6 A schematic diagram illustrating another retrieval-based content generation method provided in an embodiment of this application; Figure 7 A schematic diagram of a content generation device based on retrieval provided in an embodiment of this application; Figure 8 This is a schematic diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0024] To enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, and to make the above-mentioned objectives, features and advantages of the embodiments of the present invention more apparent and understandable, the technical solutions in the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
[0025] RAG (Retrieval-Augmented Generation) is a technical framework that combines information retrieval with text generation. It improves the accuracy, factuality, and relevance of the generated content by first retrieving relevant information from a knowledge base and then inputting the retrieval results as context into an LLM (Large Language Model).
[0026] The RAG workflow consists of three stages: 1) Retrieval: Based on the user's original question, the most relevant text chunks are semantically searched from the preset knowledge base.
[0027] 2) Augmentation: The retrieved text chunks are merged with the original question to construct a new prompt.
[0028] 3) Generation: The prompts obtained during the enhancement process are input into the LLM to generate the final answer. LLM is a natural language processing model based on deep neural networks. Through self-supervised pre-training on massive amounts of text data, it learns the statistical laws and semantic representations of language. Its parameter scale typically reaches billions to hundreds of billions, possessing powerful contextual understanding and text generation capabilities. In practical applications, this model can effectively process multiple retrieved text blocks, understand their semantic relationships and key information, and autoregressively generate coherent, accurate, and structured natural language responses based on user queries, achieving intelligent transformation from scattered information to a complete answer.
[0029] Typically, before RAG executes its workflow, the text within the domain knowledge base needs to be preprocessed based on prior knowledge of that domain. However, different domains require different preprocessing strategies. If the preprocessing strategy is inadequate, it can lead to problems such as decreased retrieval accuracy and chaotic generation logic. This phenomenon means that preprocessing strategies from different domains cannot be shared, resulting in the following issues in related technologies: 1) Developing RAG products in different fields requires reprocessing, which makes the process cumbersome and requires a lot of manpower and time costs.
[0030] 2) The lack of clear prior knowledge in related fields makes it difficult to design targeted preprocessing strategies, leading to inaccurate results. For example, biographical texts are characterized by a narrative structure centered on the individual, progressing chronologically and emphasizing the correspondence between events and time. Text processing in biographical studies focuses on time, key events, life stages, interpersonal relationships, and historical evaluation. In contrast, legal consultation texts are structured around legal provisions, emphasizing a syllogistic structure of facts, law, and judgment. Without sufficient prior knowledge in related fields, it is impossible to develop accurate and targeted strategies, resulting in ineffective responses.
[0031] 3) If specific adaptations are made for each domain, the intelligence of RAG-based development will be reduced, making it impossible to quickly expand to multiple domains, and it will also involve a large number of people and be costly.
[0032] Furthermore, traditional semantic retrieval mechanisms typically employ a flat index structure, relying solely on vector similarity or keyword matching for single-layer retrieval, lacking the ability to mine hierarchical semantic relationships between text blocks. When faced with complex queries, this mechanism is prone to fragmented search results and incomplete semantic coverage, particularly when the query involves multiple related but different semantic dimensions, making it difficult to achieve precise semantic focus and expansion.
[0033] Therefore, how to efficiently generate accurate and reliable search results across various fields is a problem that urgently needs to be solved in related technologies.
[0034] It is evident that the design of the knowledge base's preprocessing and retrieval mechanisms jointly determines the quality of retrieval results, thus affecting the quality of content production. High-quality preprocessing and appropriate retrieval mechanisms ensure that the RAG accurately identifies and matches the user's query intent, efficiently, accurately, and completely finding the most relevant text blocks. This provides rich and semantically complete contextual support, enhancing the information value of the prompts. Furthermore, accurate retrieval results enable the LLM to generate answers based on reliable domain knowledge, effectively avoiding the illusionary output of its own training data, thereby fundamentally improving the professionalism and accuracy of the answers.
[0035] To address the aforementioned technical issues, this application proposes a retrieval-based content generation method, which is applicable to knowledge base preprocessing in any field, thereby ensuring the final retrieval and generation results.
[0036] Figure 1 This is a schematic diagram of a content generation system based on retrieval, provided as an embodiment of this application. For example... Figure 1 As shown, the content generation system 100 based on retrieval includes a question agent 110, an analysis agent 120, a state agent 130, and a decision agent 140.
[0037] The retrieval-based content generation system provided in this application can be deployed on any electronic device.
[0038] In the retrieval-based content generation system provided in this application embodiment, the problem agent 110, analysis agent 120, state agent 130, and decision agent 140 collaboratively complete the retrieval-based content generation method in this application embodiment. Wherein: The Question Agent 110 is used to analyze and process user-input questions and extract question keywords; it is also used to obtain question vectors and generalized question vectors based on user-input questions.
[0039] An Analyze Agent 120 is used to determine the contribution of preset text blocks. For example, it determines the contribution scores of a first candidate text block, a second candidate text block, and the contribution scores of other preset text blocks. Exemplarily, it inputs the question to be answered along with the current preset text block into the LLM and issues a prompt to calculate the contribution score, thereby determining the contribution score of the preset text block to the question to be answered, and then using this contribution score as a basis to determine whether the preset text block can be used as a basis in the answer generation process.
[0040] State Agent 130 is used to record the retrieval path, specifically including the preset text blocks that have been retrieved and the contribution of each of these preset text blocks, as well as the preset text blocks that have not yet been retrieved.
[0041] The decision agent 140 (Think Agent) is used to determine the next task to be executed based on the output of the state agent 130.
[0042] For example, the decision-making agent 140 is able to perform the following six tasks.
[0043] Task 1: Given that the first contribution of the first candidate text block is within a second preset range, determine the first candidate cluster label based on the cluster label information corresponding to the first candidate text block; wherein, the first candidate cluster label is the cluster label information corresponding to the first candidate text block; based on the first candidate cluster label, determine at least one second candidate text block from multiple preset text blocks; wherein, the second candidate text block is different from the first candidate text block.
[0044] Task 2: Given that the first contribution of the first candidate text block is within a first preset range, determine the first candidate cluster label based on the cluster label information corresponding to the first candidate text block; wherein, the first candidate cluster label is other cluster label information besides the cluster label information corresponding to the first candidate text block; based on the first candidate cluster label, determine at least one second candidate text block from multiple preset text blocks.
[0045] Task 3: If the second contribution of the second candidate text block is within the third preset range, the retrieval is successful and the retrieval ends.
[0046] Task 4: If multiple rounds of searching fail to find the best preset text block, the search will end.
[0047] Task 5: The first round of retrieval uses the grep method to determine the first candidate text block.
[0048] Task 6: If the grep method fails to retrieve the first candidate text block, or if the contribution of the first candidate text block obtained in the first round of retrieval is too low, perform retrieval based on the question vector or a generalized question vector.
[0049] In some examples, the execution of the above six tasks is independent of each other.
[0050] For example, each time the Think Agent determines a task to be executed based on the records of the State Agent, executes the task, and sends the newly retrieved chunk to the Analyze Agent for further contribution scoring, before returning it to the State Agent for recording. This process is repeated until the retrieval is successful or fails, thus ending the retrieval process. When the Think Agent executes task five or six, it can use a grep search. Grep searches do not involve calls to the LLM, consume minimal system resources, and can quickly traverse chunks, making them suitable for the first round of retrieval and situations where previous rounds of retrieval are unsatisfactory.
[0051] The process of the four intelligent agents performing tasks described above is only illustrated by way of example. The specific implementation process is further described in detail in steps 210 to 250 below.
[0052] It should be noted that the LLM called by the RAG system generated based on the retrieved content in this application can directly adopt any compliant existing LLM and perform related tasks based on the model capabilities of the existing LLM. Therefore, pre-training of the LLM is not required. For other modules in the RAG system, such as the various Agents mentioned above, and the preset models in the following embodiments, apart from the tasks performed which involve calling the LLM, they do not involve complex machine learning, and therefore pre-training is not required.
[0053] Figure 2 This is a schematic diagram illustrating a content generation method based on retrieval provided in an embodiment of this application. For example... Figure 2 As shown, the content generation method based on retrieval includes steps 210 to 250. Information related to the retrieval process, such as retrieved text blocks, unretrieved text blocks, contribution levels, retrieval paths, and child nodes determined in each round, can all be recorded using a state agent and retrieved from the state agent when needed.
[0054] Step 210: Receive the user's input question to be answered, and based on the question to be answered, determine at least one first candidate text block corresponding to the question to be answered from multiple preset text blocks.
[0055] The user-inputted question is typically in natural language that the user commonly uses. Before obtaining the first candidate text block using the question, the question needs to be parsed. This parsing can be performed by the question agent.
[0056] In some examples, step 210 includes: extracting question keywords from the question to be answered; and determining a first candidate text block from the multiple preset text blocks based on the matching degree between the question keywords and multiple preset text blocks.
[0057] For example, keyword extraction strategies include: retaining nouns, verbs, and other content words; filtering stop words; identifying proper nouns and numerical information; and possibly applying relevant algorithms to weight and rank keywords. This application does not limit these aspects.
[0058] For example, techniques for extracting keywords include NLP (Natural Language Processing) techniques such as word segmentation, part-of-speech tagging, and named entity recognition. This application does not limit these techniques.
[0059] Among them, multiple preset text blocks are obtained by the preset model dividing the preset text according to preset rules.
[0060] In the RAG-related field, a preset text block is a text block in a pre-built knowledge base that stores external knowledge sets, typically including processed documents, data, or information resources. For example, a text block is multiple preset text blocks segmented from the original document (i.e., preset text) according to preset rules. Each preset text block contains complete contextual information and carries a unique identifier.
[0061] For example, the preset model can be a regular expression engine, LLM, traditional NLP tools, Sentence-BERT, and LlamaIndex, etc.
[0062] For example, preset rules can be fixed-length block rules, natural boundary block rules, and semantic block rules.
[0063] For example, multiple preset texts can be obtained individually or in any combination using the following three methods: Method 1: Employs a basic rule engine such as regular expressions to evenly segment long texts by setting a fixed number of characters or tokens (e.g., 512 tokens). Suitable for texts with simple structures and no clear semantic boundaries.
[0064] Method 2: Combining traditional NLP tools with rule engines, this method utilizes NLTK (Natural Language Toolkit) or Stanford CoreNLP (Stanford Core Natural Language Processing) to identify language structures such as sentence boundaries and paragraph segmentation. Simultaneously, it uses regular expressions to match document features such as heading tags and line breaks. For example, it calls `nltk.sent_tokenize` for sentence segmentation or uses regular expression matching to achieve paragraph-level segmentation, effectively preserving the original text structure.
[0065] Method 3: Use Sentence-BERT (Sentence Bidirectional Encoder Representations from Transformers), BERT (Bidirectional Encoder Representations from Transformers), or RoBERTa (Robustly optimized BERT approach) to calculate sentence embedding vectors, evaluate the semantic relevance of adjacent sentences through cosine similarity, and set a threshold to achieve segmentation.
[0066] In some examples, at least one first candidate text block corresponding to the question can be determined from multiple preset text blocks based on the matching degree between the question keywords and these preset text blocks. This step can be implemented using a decision-making agent. The first candidate text block is the preset text block with the highest matching degree to the question keywords among the multiple preset text blocks.
[0067] For example, the first candidate text block can be the text block obtained in the first round of retrieval after the user enters the question to be answered.
[0068] For example, the first round of retrieval uses the grep (Global Regular Expression Print) method to directly traverse all pre-defined text blocks in the knowledge base. After the user inputs a natural language question, the system first parses the question, extracts keywords, and standardizes them. The pre-processed keywords are then converted into a grep search pattern, and the text blocks are read one by one. String matching algorithms such as Boyer-Moore are used to scan for keywords within each block, recording the successfully matched text blocks. The grep output text blocks undergo post-processing, including deduplication, sorting by the number of matching keywords, and extracting contextual information, finally returning the structured search results.
[0069] For example, the first round of retrieval uses the grep method, based on a text block clustering tree. After the user inputs a natural language question, the question is first parsed, keywords are extracted, and the standardized keywords are vectorized to obtain keyword vectors. Then, similarity matching is performed in the text block clustering tree to quickly locate the text blocks most semantically relevant to the question keywords. Finally, the text blocks output by grep undergo post-processing such as deduplication, sorting by matching degree, and extraction of contextual information, and the structured retrieval results are returned to the user or downstream processing modules. The text block clustering tree can be a tree-like index structure built using a hierarchical clustering algorithm on preset text blocks in the knowledge base, where each parent node represents a cluster category and each child node corresponds to a specific text block. In this process, the construction of the text block clustering tree narrows the retrieval scope, improving the efficiency and accuracy of grep retrieval.
[0070] The first round of retrieval typically uses the grep method to obtain a preliminary text block, which can then serve as a reference for subsequent rounds of retrieval.
[0071] In other examples, the first candidate text block can also be a text block obtained in the second round or a subsequent round of retrieval. For example, based on the question to be answered, the target text block of the previous round is determined from multiple preset text blocks, and its corresponding contribution, child nodes, and parent nodes are determined according to the target text block. Based on the contribution and parent nodes, the parent node to be queried in this round is determined; then, based on the parent node in this round, the child nodes in this round and the node value score of the child nodes are determined; finally, based on the value score of the child nodes, the first candidate text block is determined, thereby determining the target content corresponding to the question to be answered. Here, the child node in this round is the child node corresponding to the first candidate text block to be determined in this round in the text block clustering tree.
[0072] Step 220: Based on at least one first candidate text block and the question to be answered, determine the first contribution corresponding to each first candidate text block.
[0073] In some examples, the first contribution of each first candidate text block can be determined based on the user-input question and at least one first candidate text block. This step can be implemented using an analytical agent.
[0074] For example, contribution can represent the degree to which a text block contributes to the question to be answered, and the degree of contribution of each text block to the question to be answered may be different. Contribution can be intuitively represented by a contribution score, which can be obtained through LLM (Limited Language Management). For example, the question to be answered and the first candidate text block are simultaneously input into the LLM. By designing specific prompts, the LLM directly calculates the first contribution score. Example prompt: "Please evaluate the contribution of the following text block to answering the question, with a score range of 0-1." Another example is to use the embedding similarity method to calculate the first contribution score: the question to be answered and the first candidate text block are converted into vectors respectively, the cosine similarity is calculated as the basic contribution, and then the basic contribution is calibrated and adjusted by the LLM to obtain the first contribution score. For example, a comprehensive scoring system can be designed to evaluate contribution from multiple dimensions: relevance (0-1): the degree to which the text block matches the question's topic; information content (0-1): the unique information value provided by the text block; accuracy (0-1): the correctness of the text block's content; and completeness (0-1): the degree to which it supplements the answer to the question. The final contribution is the sum of the value of each item and its respective weight, i.e., relevance × weight 1 + information content × weight 2 + accuracy × weight 3 + completeness × weight 4. The above method is only for illustrative purposes; this application does not limit the specific method or how it is used.
[0075] For example, a higher contribution score indicates that the text block is more effective for the question to be answered. For instance, the first contribution score is usually a value between 0 and 1. When the first contribution score is between 0.9 and 1, the search for the question to be answered ends, and the target content can be directly generated based on the current first candidate text block. The preset model is then instructed to generate the answer to the question to be answered based on the target content. However, when the first contribution score is less than 0.9, the search for the question to be answered continues.
[0076] Step 230: Based on the first contribution and the first candidate text block, query the text block clustering tree to obtain the clustering label information corresponding to the first candidate text block.
[0077] For example, if the first contribution value of the first candidate text block is 0.9-1 (inclusive of left and right values), it indicates that the first candidate text block is close to the ideal answer, and the target content can be directly generated from the first candidate text block. However, if the first contribution value is 0-0.9 (inclusive of left value), it is necessary to continue the next round of retrieval based on the first candidate text block to obtain other candidate text blocks that are closer to the answer, thereby generating the target content.
[0078] For example, the generation of a text chunk clustering tree involves text clustering, which is the process of grouping and classifying multiple text chunks according to clustering rules. This process can discover the correlation between text content without manual annotation. Clustering can optimize retrieval efficiency. The basic process of clustering includes three parts: vectorizing chunks, determining clustering rules, performing clustering, and obtaining clustering results.
[0079] 1) Vectorized chunks: Convert each chunk into an embedding vector; 2) Determine clustering rules, such as K-Means (K-means clustering algorithm) suitable for large-scale data, hierarchical clustering methods that can generate tree-like structures, and DBSCAN (Density-Based Spatial Clustering of Applications with Noise) suitable for small-scale data.
[0080] 3) Perform clustering and obtain clustering results: Perform clustering processing on multiple chunks according to the selected clustering algorithm, such as determining the number of clusters, the number of chunks within a cluster, and the chunks contained in each cluster; and assign clustering labels to each cluster.
[0081] Building upon the clustering process, to further enhance the structure of knowledge organization and query efficiency, the clustering results can be transformed into a hierarchical tree-like index structure. Therefore, a text block clustering tree can be generated based on the aforementioned clustering results.
[0082] For example, the clustering query tree adopts a three-level tree structure. The root node corresponds to the preset text; the parent node is the cluster label in the clustering result (such as directory information and / or label category), and a text chunk can correspond to multiple parent nodes; the child nodes are the specific chunks belonging to each cluster label.
[0083] The process of transforming the clustering results into a tree in this step establishes a clear hierarchy between discrete labels and chunks, forming a navigable knowledge map that supports subsequent multi-granularity retrieval.
[0084] Figure 3 This is a schematic diagram of a text block clustering tree provided in an embodiment of this application. Figure 3As shown, in the text block clustering tree, each preset text block corresponds to a child node. For example, the first candidate text block corresponds to the first child node A1. The parent node represents the clustering label information of the preset text block, used to identify the clustering category of the preset text block. For example, a certain clustering label of the first candidate text block corresponds to the first parent nodes B1 and / or B2. The root node C1 corresponds to the preset text. Due to different clustering methods for preset text blocks, the affiliation of child nodes is also different. Each child node belongs to at least one parent node; that is, it may belong to only a single parent node or it may belong to multiple different parent nodes simultaneously.
[0085] In some examples, cluster label information is obtained by a preset model based on preset text blocks, and then multiple preset text blocks are used to construct a complete text block clustering tree based on the cluster label information.
[0086] For example, clustering label information may include directory information and label categories, which are obtained by a preset model based on preset text blocks. The preset model may be an LLM, an information extraction model, a document structure analysis model, etc.
[0087] Figure 4 This is a schematic diagram illustrating another content generation method based on retrieval provided in an embodiment of this application. For example... Figure 4 As shown, in some examples, the text block clustering tree in step 230 is constructed by the multiple preset text blocks based on clustering label information, specifically including steps 410 to 430.
[0088] Step 410: Obtain the directory information and text block labels for each preset text block.
[0089] The directory information is used to indicate the directory of the preset text block in the preset text, and the text block label is used to indicate the label defined by the preset model for the preset text block.
[0090] For example, a directory structure is pre-stored in the knowledge base, from which the directory information of the text containing the preset text block can be extracted, and the directory information can be used as the directory tag of the preset text block.
[0091] For example, after the preset text in the knowledge base is divided into blocks, multiple preset text blocks are obtained. Each block is treated as an independent annotation unit. The preset question and triple information of each block are extracted by LLM. The triple information includes entity words, summaries and text block labels.
[0092] Among them, the preset questions indicate the questions that users may ask about this chunk. The annotation of the preset questions helps to build a question-and-answer capability profile of the text chunk, supports the retrieval strategy based on question-and-answer matching, and improves the recall rate of user queries.
[0093] Entity words refer to named entities or key terms that appear in a text block and have specific semantic and referential meanings. Examples include personal names, place names, times, technical terms, and numerical information.
[0094] The summary indicates the content outline corresponding to the chunk, which can provide a high-level semantic representation for the retrieval system and support fast matching based on semantic similarity.
[0095] Among them, the text block label indicates the keywords or category identifiers of the multi-dimensional classification corresponding to the chunk, such as topic tags, style tags, scene tags, etc.
[0096] For example, a chunk might read, "Xiaoming officially entered College A in October 1896. This process was not smooth sailing; he experienced two applications, one failure, and a year of remedial study. During this time, Xiaohong's family provided him with encouragement and help." The entity words in this chunk include Xiaoming, October 1896, and College A. The summary of this chunk could be "Xiaoming's experience of entering university" or "Xiaoming's university admission situation." The pre-set questions for this chunk could include "In which year did Xiaoming enter university?", "Which university did Xiaoming enter?", and "What was the process of Xiaoming entering university?". The text block tags for this chunk could be the core clues or keywords of the chunk's content, such as College A and Xiaohong; or they could be a summary of the content type of the chunk, such as studying or education.
[0097] Step 420: Construct a first clustering tree based on the preset text block and the directory information corresponding to the preset text block; wherein, the directory parent node of the preset text block in the first clustering tree is composed of the directory information corresponding to the preset text block.
[0098] In some examples, the first cluster tree can be a directory cluster tree.
[0099] For example, step 420 includes: determining the directory information of the preset text block as the directory parent node of the preset text block; and, if the number of preset text blocks corresponding to the directory parent node exceeds a first threshold, generating the directory parent node based on the semantic similarity between the preset text blocks exceeding the first threshold; or, if the preset text block does not have directory information, determining the directory information of the preset text block based on the semantic similarity between multiple preset text blocks without directory information, and generating the directory parent node based on the directory information; wherein, the directory parent node corresponds to multiple preset child nodes, and the preset child nodes are composed of corresponding preset text blocks; and constructing a first clustering tree based on the preset child nodes and the directory parent node.
[0100] Each directory parent node corresponds to multiple different preset text blocks, and there is a limit to the number of preset text blocks under the same directory parent node. Therefore, for preset text blocks exceeding the limit, the directory parent node needs to be regenerated and the directory clusters need to be re-divided. In addition, some preset text blocks contain preset texts without directory information. Therefore, for these preset text blocks, directory information needs to be generated and directory clusters need to be divided.
[0101] For example, for a preset text block that needs to be re-divided into directory clusters and the directory information regenerated, clustering can be performed based on semantic similarity.
[0102] Specifically, the semantic similarity between any two preset text blocks is determined from the two dimensions of entity words and summary of preset text blocks. When the semantic similarity between any two preset text blocks reaches the preset condition, it means that the two preset text blocks are similar; then the two preset text blocks are divided into the same directory cluster and correspond to the same directory parent node.
[0103] For example, firstly, LLM is used to determine the similarity score of entity words between two preset text blocks. Then, the summaries of the preset text blocks are converted into embedding vectors, and the similarity score of the summaries of the two preset text blocks is determined by calculating the similarity of the embedding vectors (e.g., calculating the cosine similarity of the embedding vectors of the two preset text blocks). Finally, the similarity scores of entity words and the summary similarity scores are weighted or combined to determine whether the two preset text blocks are similar.
[0104] Specifically, directory information can be generated by LLM. At the same time, since the preset text blocks in the same directory cluster may be constantly changing, the corresponding directory information can also be dynamically updated according to the preset text blocks contained in the same directory cluster.
[0105] For example, the complete content or triple information of a pre-defined text block reclassified into the same directory cluster is input into the LLM, along with explicit generation instructions, such as requiring concise and accurate tags, tag lengths, and expression standards. The LLM analyzes the semantic information of the content based on the input and generation instructions, and outputs the directory information corresponding to that directory cluster. The generated new directory information is dynamically updated in the knowledge base's directory structure, assigning the newly divided text blocks to this new directory information. If subsequent analysis reveals highly similar semantics among text blocks under different directory information, the system will also call a large language model to determine whether directory information needs to be merged, further optimizing the rationality and accuracy of the directory structure. This process achieves automated generation and dynamic maintenance of directory information, enabling the knowledge base's organizational structure to intelligently update as content increases.
[0106] The directory clustering method generates directory information that is a direct semantic summary of a single text block or a small range of similar text blocks, characterized by fine granularity and precise positioning. In diverse domain scenarios, the first cluster tree constructed based on directory information clearly defines the relationships between semantically similar predefined text blocks, thus enabling efficient and accurate retrieval and generation of professional content.
[0107] Step 430: Construct a second clustering tree based on the preset text block and the text block label corresponding to the preset text block; wherein, the parent node of the preset text block label in the second clustering tree is composed of the text block label corresponding to the preset text block.
[0108] In some examples, the second cluster tree can be a community cluster tree.
[0109] For example, step 430 includes: classifying multiple text block labels based on the semantic similarity between text block labels corresponding to multiple preset text blocks to obtain multiple text block label clusters; generating label categories according to multiple text block labels in each text block label cluster using a preset pattern; wherein, preset text blocks corresponding to text block labels belonging to the same text block label cluster correspond to the same label category; generating a label parent node based on each label category and the text block labels corresponding to the label category; if the number of preset text blocks corresponding to the label parent node exceeds a second threshold, generating a new label parent node based on the text block labels corresponding to the preset text blocks exceeding the second threshold; wherein, the label parent node corresponds to multiple preset child nodes, and the preset child nodes are composed of corresponding preset text blocks; and constructing a second clustering tree based on the preset child nodes and the label parent nodes.
[0110] For example, chunks are clustered based on their text block tags, and chunks whose semantic information similarity of text block tags reaches a preset condition are assigned to the same community cluster. Then, a new community tag is generated for the community cluster based on the text block tags corresponding to the chunks in the same community cluster using LLM.
[0111] Specifically, the text block labels of each chunk are vectorized to obtain the semantic vector of each label; based on these semantic vectors, the semantic similarity between the text block labels of different chunks is calculated, and the chunks corresponding to the text block labels with high semantic similarity are divided into the same community cluster.
[0112] Specifically, text block tags belonging to the same community cluster are input into the LLM (Local Management Module), with explicit generation instructions provided, such as requirements for generating concise and accurate tags, tag length, and expression standards. The LLM analyzes the semantic information of the content based on the input and generation instructions, and outputs the community tags corresponding to that community cluster. Then, all text blocks originally corresponding to the text block tags in that community cluster are remapped to the newly generated community tags, completing the hierarchical optimization and semantic integration of the directory structure.
[0113] Each community tag corresponds to multiple different chunks, and there is a limit to the number of chunks under the same community tag. Therefore, for chunks exceeding the limit, community tags need to be regenerated and community clusters redefined. The processing method for this part of the chunks is the same as the method of clustering chunks based on text block tags described above.
[0114] The community clustering text clustering method generates community tags that are high-level summaries generated by clustering and integrating multiple semantically similar directory tags. It has the advantages of broad coverage and clear structure, and can reveal the inherent relationship between content in different fields, forming a macro framework of knowledge system.
[0115] For example, the first threshold and the second threshold are typically integers between 10 and 50, such as both the first threshold and the second threshold being 10, or the first threshold being 10 and the second threshold being 20. This application does not limit this.
[0116] The two text clustering methods involved in steps 420 and 430 above can be performed independently, without any specific order. In practice, depending on the actual scenario, one method can be chosen to perform clustering and obtain a single clustering label, or both methods can be used to obtain two different clustering labels. Using both labels simultaneously enables the construction of a multi-layered knowledge organization structure. Directory labels ensure accurate characterization of professional content across diverse domains, preserving precision at the detail level, while community labels achieve cross-domain knowledge integration and systematic classification. This systematic classification of cross-domain knowledge facilitates both in-depth exploration and overall understanding of the knowledge base, significantly improving the efficiency of information retrieval and the level of intelligent knowledge management.
[0117] Step 220, text clustering, groups and categorizes a large number of text blocks according to rules. In practical applications, RAG can utilize the clustering results to first locate cluster labels relevant to the query, and then perform precise matching within the clusters corresponding to those labels, thereby significantly improving retrieval speed and accuracy. Simultaneously, text clustering can automatically identify the internal structure of the knowledge base, revealing hidden topic distributions and knowledge relationships. More importantly, it organizes originally scattered and disordered text blocks into clear topic clusters, providing structured support for building an efficient retrieval enhancement generation system, making the management of text blocks in the knowledge base more systematic and intelligent.
[0118] Step 240: Based on the first contribution degree corresponding to the first candidate text block and the clustering label information corresponding to the first candidate text block, determine at least one second candidate text block from multiple preset text blocks.
[0119] The purpose of determining the first contribution and cluster label information is to narrow down the scope of the next round of retrieval and identify the second candidate text from that scope. This step requires the collaborative participation of at least an analytical agent and a decision-making agent. For example, the process of calculating the first and second contributions can be mainly implemented using the analytical agent, while the judgment and execution of the jump task based on the first and / or second contributions is mainly implemented using the decision-making agent. That is, the decision-making agent can decide how to jump based on the first and / or second contributions calculated by the analytical agent, thereby determining the second candidate text block.
[0120] In some examples, step 240 includes: determining a first candidate cluster label based on the cluster label information corresponding to the first candidate text block, given that the first contribution of the first candidate text block is within a first preset range; and determining at least one second candidate text block from the plurality of preset text blocks based on the first candidate cluster label.
[0121] The first candidate clustering label is any clustering label other than the clustering label corresponding to the first candidate text block.
[0122] For example, the first preset range can be 0-0.6 (inclusive). For instance, if the first contribution is 0.4, it falls within the first preset range. In this case, the clustering label information in the text block clustering tree, excluding the clustering label information corresponding to the first candidate text block, is used as the range for the next round of retrieval, and at least one second candidate text block is determined from this range. If the first contribution is 0.4, it indicates that the first candidate clustering label corresponding to the first candidate text block is not the most ideal range. Therefore, a more ideal retrieval range can be determined by searching other clustering label information, thereby determining a more matching second candidate text block under other clustering label information.
[0123] In some examples, step 240 includes: if the first contribution of the first candidate text block is within a second preset range, determining a first candidate cluster label based on the cluster label information corresponding to the first candidate text block; and determining at least one second candidate text block from multiple preset text blocks based on the first candidate cluster label. The first candidate cluster label is the cluster label information corresponding to the first candidate text block.
[0124] For example, the second preset range can be 0.6-0.9 (inclusive). If the first contribution of the first candidate text block falls within the second preset range, the next round of searching needs to be conducted within the preset text blocks corresponding to the first candidate cluster label, i.e., continuing the search within the current range. For instance, if the first contribution is 0.8, it falls within the second preset range, indicating that although the first candidate text block is not the closest to the answer, its corresponding first candidate cluster label is relatively ideal and can be used again in the next search. In this case, the first candidate cluster label is used as the cluster label for the next round of searching to provide the scope for the next round of searching. Furthermore, to avoid duplicate searches, deduplication should be performed in the next round of searching, excluding the first candidate text block.
[0125] It should be noted that the right-hand value of the first preset range is less than or equal to the left-hand value of the second preset range, and the two do not overlap. For example, the first preset range and the second preset range can also be 0-0.5 (inclusive of the left-hand value) and 0.5-0.9 (inclusive of the left-hand value), and 0-0.7 (inclusive of the left-hand value) and 0.7-0.9 (inclusive of the left-hand value), etc.
[0126] In some examples, determining at least one second candidate text block from multiple preset text blocks based on a first candidate cluster label includes: querying a first clustering tree and a second clustering tree respectively based on the cluster label information of the first candidate text block to obtain a first cluster label corresponding to the first candidate text block in the first clustering tree and a second cluster label corresponding to the first candidate text block in the second clustering tree; wherein, the first candidate cluster label includes a first cluster label and a second cluster label.
[0127] For example, the first candidate text block has a first cluster label in the first clustering tree and a second cluster label in the second clustering tree. This step requires obtaining the corresponding second candidate text block in each of the two text block clustering trees.
[0128] For example, the first cluster tree is a directory cluster tree, and the second cluster tree is a community cluster tree. The first cluster label is the directory information, and the second cluster label is the label category. Based on the first candidate text block, the corresponding directory information and label category are determined in the directory cluster tree and community cluster tree, respectively.
[0129] Figure 5This is a schematic diagram illustrating yet another content generation method based on retrieval provided in an embodiment of this application. For example... Figure 5 As shown, in some examples, determining at least one second candidate text block from multiple preset text blocks based on the first candidate clustering label further includes steps 510 to 530.
[0130] For example, determining the first candidate cluster label is equivalent to determining the scope of the second round of retrieval. Within this scope, the second candidate text block is further determined from multiple preset text blocks based on the contribution of the preset text blocks corresponding to the first candidate cluster label.
[0131] Step 510: Based on the contribution of multiple preset text blocks, determine at least one first preset text block with the highest contribution corresponding to the first cluster label among the multiple preset text blocks.
[0132] Step 520: Based on the contribution of multiple preset text blocks, determine at least one second preset text block with the highest contribution corresponding to the second cluster label among the multiple preset text blocks.
[0133] For example, the contribution of each preset text block can be calculated using LLM or other methods. For instance, by simultaneously inputting the question to be answered and a preset text block into an LLM, the contribution score calculated by the LLM can be obtained. For specific calculation methods, please refer to the relevant content in step 220 of the aforementioned example regarding the acquisition of the first contribution score.
[0134] For example, the contribution of each preset text block corresponding to the first candidate cluster label to the question to be answered is calculated and recorded, and the contribution of each preset text block corresponding to the second candidate cluster label to the question to be answered is calculated and recorded.
[0135] Step 530: The preset text block with the highest contribution among at least one first preset text block and at least one second preset text block is determined as the second candidate text block.
[0136] In some examples, the contribution of each preset text block is sorted or other maximum value algorithms are used to obtain the preset text block with the maximum contribution under the first cluster label and the preset text block with the maximum contribution under the second cluster label, and the preset text block with the maximum contribution is determined as the second candidate text block from these two preset text blocks.
[0137] In some examples, each preset text block corresponding to the first candidate cluster label and its contribution, and each preset text block corresponding to the second candidate cluster label and its contribution, are sorted, or other maximum value algorithms are used to obtain the preset text block with the largest contribution under the two cluster labels as the second candidate text block.
[0138] In some examples, multiple preset text blocks with the highest contribution can be selected as second candidate text blocks from at least one first preset text block and at least one second preset text block. This application does not limit this.
[0139] Steps 510 and 520 do not have a fixed order and can be executed simultaneously.
[0140] The content generation method based on retrieval provided in this application first locates cluster tags related to the query using clustering results, and then performs precise matching within the clusters corresponding to the cluster tags. This avoids full database scanning, significantly improving retrieval speed. Furthermore, it selects the optimal text block within the cluster tag range based on contribution ranking, achieving efficient location of relevant text blocks while ensuring the accuracy of retrieval results. Through the extraction and organization of multi-dimensional information such as directory information, text block tags, entity words, and summaries, a rich semantic representation is provided for the retrieval system. The annotation of pre-set questions constructs a question-answering capability profile for the text block, supporting a question-answer matching-based retrieval strategy and improving the recall rate of user queries.
[0141] Step 250: Determine the target content based on the first candidate text block and / or at least one second candidate text block, and instruct the preset model to generate the answer to the question to be answered based on the target content.
[0142] For example, the target content can be the contextual information needed for a pre-defined model to generate an answer. The pre-defined model can be a large language model, a model based on an encoder-decoder architecture such as LSTM (Long Short-Term Memory) or GRU (Gated Recurrent Unit), etc. The answer to the question to be answered is content that can be directly presented to the user to answer the question.
[0143] In some examples, step 250 includes determining a second contribution of the second candidate text block based on the second candidate text block and the question to be answered; and determining the target content based on the first candidate text block and / or the second candidate text block if the second contribution of the second candidate text block is within a third preset range.
[0144] In some examples, the left-hand value of the third preset range is greater than or equal to the right-hand value of the second preset range, and the two do not overlap.
[0145] For example, if the contribution of the second candidate text block is within a third preset range, such as 0.9-1, the search has matched the best preset text block and the search for the question to be answered ends. At this time, the target content can be determined based on the first candidate text block and / or at least one second candidate text block, and the preset model can be instructed to generate the answer to the question to be answered based on the target content.
[0146] For example, the target content can be contextual information.
[0147] For example, the first and second candidate text blocks are first concatenated to form complete contextual information, while ensuring that the concatenated target content does not exceed the input length limit of the preset model. During the concatenation process, duplicate content is removed to ensure the logical coherence of the target content and avoid information fragmentation. Then, the question to be answered and the target content are input into the preset model (such as a large language model, a model with an encoder-decoder architecture based on LSTM or GRU, etc.). The preset model understands and infers based on the domain knowledge in the target content to generate an answer to the question to be answered.
[0148] In some examples, if the contribution of the second candidate text block is within the first or second preset range, the current search does not match the best preset text block. The search for the question to be answered should continue, and at least one more search should be performed until the best preset text block is matched.
[0149] For example, if the contribution of the third candidate text block obtained in the third round is greater than the maximum value of the second preset range, the retrieval in this round has matched the best preset text block, and the retrieval for the question to be answered ends. At this time, the target content can be determined based on the first candidate text block and / or at least one second candidate text block and / or at least one third candidate text block, and the preset model can be instructed to generate the answer to the question to be answered based on the target content.
[0150] For example, if multiple rounds of retrieval are performed (i.e., the upper limit of the retrieval rounds or the preset text blocks is reached) and the best preset text block is still not matched, the embedding of the unanswered question and the generalized question embedding can be obtained based on the unanswered question. The next round of retrieval can then be performed based on the question vector or the generalized question vector, combined with the candidate preset text blocks obtained in the previous round and their contribution. Here, the generalized question refers to other questions with the same purpose but different expressions, generalized from the unanswered question.
[0151] For example, if the grep method fails to retrieve the first candidate text block, or if the contribution of the first candidate text block obtained in the first round of retrieval is too low, retrieval can also be performed based on the question vector or a generalized question vector.
[0152] For example, firstly, the question to be answered is embedded and encoded, converting it into a fixed-dimensional vector representation to obtain the question vector. Simultaneously, a generalized version of the original question (e.g., extracting the core intent, expanding synonyms, etc.) is generated, and this generalized question is also embedded and encoded to obtain a generalized question vector. Next, the embedding vectors of the original and generalized questions are compared with the embedding vectors of preset text blocks in the knowledge base to calculate their similarity (usually using cosine similarity or dot product similarity), resulting in two independent similarity score sequences. Then, the two similarity score sequences are weighted and fused. Common strategies include equal-weighted addition, dynamic weight adjustment based on question complexity, or using a maximum value strategy to retain the highest similarity score. Finally, the candidate text blocks are sorted in descending order based on their similarity scores, and the top-ranked text blocks are selected as the first round of search results.
[0153] For example, firstly, a question vector and a generalized question vector are obtained based on the question to be answered. Then, the question vector and the generalized question vector are queried in the first clustering tree to determine the most matching first candidate text block, and based on the first candidate text block, a second candidate text block is determined. Simultaneously, the question vector and the generalized question vector are queried in the second clustering tree to determine the most matching first candidate text block, and based on the first candidate text block and the second clustering query tree, a second candidate text block is determined. This process essentially replaces the question keywords in the aforementioned embodiments with question vectors or generalized question vectors; its execution logic and essence remain unchanged. Therefore, the relevant content of steps 210 to 240 in the aforementioned method embodiments can be referred to.
[0154] This process fully utilizes the precise semantics of the original question and the extended semantics of the generalized question, effectively improving the recall and accuracy of the retrieval.
[0155] In some examples, candidate text blocks corresponding to the question to be answered can be determined based on the question vector or a generalized question vector. When the contribution of the candidate text block reaches the ideal threshold of 0.9-1, it can be indicated that the candidate text block is close to the ideal answer. At this time, the candidate text block can directly generate the target content, and then generate the answer to the question to be answered.
[0156] The content generation method based on retrieval provided in this application selects the most relevant text blocks as context based on contribution scores, ensuring that the information provided to the LLM has high informational value. The multi-round retrieval mechanism automatically performs supplementary retrieval when the first round results are unsatisfactory, ensuring that the final generated prompts are both accurate and complete, effectively improving the value of the prompts. Simultaneously, through precise retrieval based on reliable domain knowledge, accurate contextual support is provided to the LLM, effectively avoiding the illusionary output of its own training data. The contribution threshold judgment mechanism ensures that only high-quality text blocks are used for content generation, fundamentally improving the professionalism and accuracy of the answers.
[0157] The content generation method based on retrieval provided in this application constructs a hierarchical clustering tree structure through automated clustering processing, enabling knowledge base preprocessing and dynamic catalog maintenance, and adapting to the characteristics and changes of knowledge in different domains. During the retrieval process, the system first locates cluster tags related to the query using clustering results, and then performs precise matching within the clusters corresponding to those tags, avoiding a full database scan and significantly improving retrieval speed. Simultaneously, the contribution-based retrieval mechanism can select the optimal text block within the cluster tag range, achieving efficient location of relevant text blocks and ensuring the accuracy of the retrieval results.
[0158] Figure 6 This is a schematic diagram illustrating another content generation method based on retrieval provided in an embodiment of this application. Exemplarily, taking a user's actual retrieval process as an example, combined with... Figure 6 This paper describes the content generation method based on retrieval for the collaborative implementation of the above-mentioned multi-agent system.
[0159] Step 601: The Question Agent (Question Agent 510) converts the question to be answered into question keywords; and sends the question keywords to the Analyze Agent.
[0160] For example, upon receiving a user's input question to be answered, the Question Agent parses the question to be answered, converting it into question keywords and / or generalized questions and / or question vectors; and sends the question keywords and / or generalized questions and / or question vectors to the Analyze Agent, so that the Analyze Agent can score the contribution based on the question keywords.
[0161] Step 602: The Analyze Agent (analysis agent 520) sends the question keywords to the State Agent.
[0162] For example, since the initial stage has not yet undergone retrieval and no Chunk is yet to be scored for contribution, the Analyze Agent will not perform a specific contribution score this time.
[0163] Step 603: The State Agent (State Agent 530) recognizes that there is no contribution score in the content sent by the Analyze Agent, records all Chunk contribution scores as empty, marks the searched paths as 0, and the unsearched Chunks as all Chunks. Based on the fact that all Chunk contribution scores are recorded as empty, the searched paths are marked as 0, and the unsearched Chunks are all Chunks, the first state information is determined; the first state information is sent to the Think Agent.
[0164] For example, since the Analyze Agent has not yet been scored in the initial stage, all Chunk contribution scores and retrieved paths do not exist, and all Chunks are unretrieved Chunks.
[0165] Step 604: The Think Agent (decision agent 540) performs a first round of retrieval based on the first state information to determine the first round of chunks; and sends the first round of chunks to the Analyze Agent.
[0166] For example, at this point, the State Agent has already retrieved 0 paths. Based on this, the Think Agent can determine that this is the first retrieval, and therefore executes task five. Specifically, a grep search is performed based on the question keywords in step 601. Here, it is set that 10 relevant chunks retrieved by grep are used as the first round of chunks.
[0167] Step 605: The Analyze Agent (analysis agent 520) scores the contribution of each chunk in the first round of chunks and obtains the contribution score for each chunk in the first round of chunks; the contribution score is then sent to the State Agent.
[0168] Step 606: The State Agent (State Agent 530) records the contribution scores of the first round of Chunks, the corresponding search paths, and the unsearched Chunks, and determines the second state information; the second state information is sent to the Think Agent.
[0169] Step 607: The Think Agent (decision agent 540) performs a second round of retrieval based on the second state information sent by the State Agent to determine the second round chunk; and sends the second round chunk to the Analyze Agent.
[0170] For example, Think Agent uses each of the 10 chunks in the first round as the starting point for retrieval, determines whether to perform action one or action two, and forms a retrieval path between a chunk in the first round and each chunk obtained after performing the second round of retrieval based on that chunk.
[0171] For example, in the first round of Chunk search, if Chunk1's contribution score reaches the high relevance range but not the fully relevant range, and if its contribution score is within the second preset range, then action one is executed: jump to other Chunks in the directory information / tag category (directory parent node / tag parent node) where Chunk1 is located for retrieval. In the first round of Chunk search, if Chunk3's contribution score reaches the low relevance range, and if Chunk3's contribution score is within the first preset range, then action two is executed: jump to other directory information / tag categories (directory parent node / tag parent node) for retrieval.
[0172] Following this pattern, each of the 10 Chunks in the first round will trigger an action, which will lead to the retrieval of a new Chunk, resulting in a total of 10 new Chunks, which constitute the second round of Chunks.
[0173] Step 608: The Analyze Agent (analysis agent 520) scores the contribution of each chunk in the second round of chunks and obtains the contribution score of the second round of chunks; then it sends the contribution score of the second round of chunks to the State Agent.
[0174] Step 609: The State Agent (State Agent 530) records the contribution scores of the second-round chunks, the corresponding search paths, and the unsearched chunks, and determines the third state information; it then sends the third state information to the Think Agent. The third state information includes the second-round chunks and the correspondence between each chunk and its contribution score, the current search path, and the unsearched chunks.
[0175] Step 610: The Think Agent (decision agent 540) performs a third round of retrieval based on the third state information to determine the third round chunk.
[0176] For example, Think Agent further searches each of the 10 Chunks in the second round, determines whether to perform action one or action two, and obtains 10 new Chunks according to the rules in step 607 above, which are the third round Chunks.
[0177] For example, the search path is explained below: Suppose a text is a biography of Zhang San. After the aforementioned clustering process of the directory / community, we obtain the directory clustering tree and the community clustering tree. Taking the directory clustering tree as an example, it corresponds to five directory information (childhood experience, school experience, early work experience, mid-career experience, and late-life experience). Each directory information includes four chunks.
[0178] Childhood experiences: Chunk1, Chunk2, Chunk3, Chunk4 Educational background: Chunk5, Chunk6, Chunk7, Chunk8 Early work experience: Chunk9, Chunk10, Chunk11, Chunk12 Mid-career experience: Chunk13, Chunk14, Chunk15, Chunk16 Late-life experiences: Chunk17, Chunk18, Chunk19, Chunk20 The user entered the question "What are the most significant events in Zhang San's life?" In the search process, the grep query first retrieved Chunk3, Chunk6, Chunk10, and Chunk13. These four Chunks were then assigned contribution scores of 0.5, 0.7, 0.7, and 0.8 respectively.
[0179] Taking Chunk6 as an example, based on its contribution score, the Think Agent should perform Task 1, continuing to search for other Chunks within the Educational Background tag. At this point, it should jump to the other three Chunks within the Educational Background tag based on their contribution scores. The contribution scores of Chunk5, Chunk7, and Chunk8 are obtained through the Analyze Agent. After comparison, Chunk8 has the highest Analyze Agent score, so it jumps from Chunk6 to Chunk8. The aforementioned steps continue to be performed for Chunk8.
[0180] Chunk8 has a contribution score of 0.5. Based on this score, the Think Agent should execute Task Two: continue searching for other Chunks under other directory information (directory parent nodes). At this point, based on the Chunks corresponding to the four directory information categories—childhood experiences, early work experiences, mid-career experiences, and later life experiences—select Chunk12 with the highest contribution score and redirect from Chunk8 to Chunk12. Continue executing the aforementioned steps for Chunk12.
[0181] The above operations are executed iteratively. The corresponding action is selected and executed according to the contribution score of the Chunk after each jump, and the target to jump to is determined according to the contribution score. When the retrieval is successful, the Chunks retrieved in sequence include Chunk6, Chunk8, Chunk9, Chunk12, and Chunk15. The above Chunks form a retrieval route: Chunk6—Chunk8—Chunk9—Chunk12—Chunk15.
[0182] Similarly, using Chunk3, Chunk10, and Chunk13 as the starting points for the search will yield three other search paths.
[0183] For example, the iterative execution of the Analyze Agent—State Agent—ThinkAgent—Analyze Agent loop in steps 601 to 610 above continues until the Think Agent triggers task three or task four. If task four is triggered, since the above retrieval is only performed using keywords, in the event of a failed retrieval, action six is executed again, iteratively executing steps 601 to 607 with the original question embedding and the generalized question embedding. During the re-retrieval process, chunks with excessively low contribution scores or retrieval paths with unsatisfactory returns during keyword retrieval can be ignored, i.e., repeated jumps or retrievals are not performed.
[0184] After the above steps, one or more target chunks are obtained, and the target chunks are sent to LLM to generate answers.
[0185] The specific implementation methods for the four intelligent agents to perform tasks are only illustrated by way of example. The specific implementation process has been described in detail in steps 210 to 250 of the aforementioned embodiments. For relevant content, please refer to the aforementioned embodiments.
[0186] It should be noted that the LLM called by the RAG system in this application can directly adopt any compliant existing LLM and perform related tasks based on the model capabilities of the existing LLM. Therefore, pre-training of the LLM is not required. For other modules in the RAG system, such as the various Agents mentioned above, the tasks they perform do not involve complex machine learning other than calling the LLM, so pre-training is not necessary.
[0187] Figure 7 This is a schematic diagram of a content generation device based on retrieval, provided as an embodiment of this application. Figure 7As shown, the content generation device 700 based on retrieval includes: a first determining module 710, a second determining module 720, a third determining module 730, a fourth determining module 740, and a fifth determining module 750. Wherein: The first determining module 710 is configured to: receive a question to be answered by a user, and determine at least one first candidate text block corresponding to the question to be answered from multiple preset text blocks based on the question to be answered; wherein the multiple preset text blocks are obtained by a preset model dividing preset text according to preset rules.
[0188] The second determining module 720 is configured to: determine the first contribution degree corresponding to each first candidate text block based on at least one first candidate text block and the question to be answered.
[0189] The third determining module 730 is configured to: query the text block clustering tree based on the first contribution degree and the first candidate text block, and obtain the clustering label information corresponding to the first candidate text block; wherein, the text block clustering tree is constructed by multiple preset text blocks based on the clustering label information, and the clustering label information is obtained by a preset model based on preset text.
[0190] The fourth determining module 740 is configured to: determine at least one second candidate text block from multiple preset text blocks based on the first contribution degree corresponding to the first candidate text block and the clustering label information corresponding to the first candidate text block.
[0191] The fifth determining module 750 is configured to: determine the target content based on the first candidate text block and / or at least one second candidate text block, and instruct the preset model to generate the answer to the question to be answered based on the target content.
[0192] In some embodiments, the fourth determining module 740 is configured to: determine a first candidate cluster label based on the cluster label information corresponding to the first candidate text block when the first contribution of the first candidate text block is within a first preset range; wherein the first candidate cluster label is other cluster label information besides the cluster label information corresponding to the first candidate text block; and determine at least one second candidate text block from multiple preset text blocks based on the first candidate cluster label.
[0193] In some embodiments, the fourth determining module 740 is configured to: determine a first candidate cluster label based on the cluster label information corresponding to the first candidate text block when the first contribution of the first candidate text block is within a second preset range; wherein the first candidate cluster label is the cluster label information corresponding to the first candidate text block; and determine at least one second candidate text block from a plurality of preset text blocks based on the first candidate cluster label; wherein the second candidate text block is different from the first candidate text block.
[0194] In some embodiments, the fourth determining module 740 is configured to: query the first clustering tree and the second clustering tree respectively based on the clustering label information of the first candidate text block, and obtain the first clustering label corresponding to the first candidate text block in the first clustering tree and the second clustering label corresponding to the first candidate text block in the second clustering tree respectively; wherein, the first candidate clustering label includes the first clustering label and the second clustering label.
[0195] In some embodiments, the fourth determining module 740 is configured to: determine at least one first preset text block with the highest contribution corresponding to the first cluster label among the multiple preset text blocks based on the contribution of the multiple preset text blocks; determine at least one second preset text block with the highest contribution corresponding to the second cluster label among the multiple preset text blocks based on the contribution of the multiple preset text blocks; and determine the preset text block with the highest contribution among the at least one first preset text block and the at least one second preset text block as the second candidate text block.
[0196] In some embodiments, the first determining module 710 is configured to: extract question keywords from the question to be answered based on the question to be answered; determine a first candidate text block from the multiple preset text blocks based on the matching degree between the question keywords and multiple preset text blocks; wherein the first candidate text block is the preset text block with the highest matching degree with the question keywords among the multiple preset text blocks.
[0197] In some embodiments, the fifth determining module 750 is configured to: determine target content based on at least one second candidate text block and / or at least one second candidate text block, including: determining the second contribution of the second candidate text block based on the second candidate text block and the question to be answered; and determining the target content based on the first candidate text block and / or the second candidate text block if the second contribution of the second candidate text block is within a third preset range.
[0198] In some embodiments, the third determining module 730 is configured to: obtain directory information and text block labels for each preset text block; wherein the directory information is used to indicate the directory in the preset text, and the text block labels are used to indicate the labels defined by the preset model for the preset text block; construct a first clustering tree based on the preset text block and the directory information corresponding to the preset text block; wherein the directory parent node of the preset text block in the first clustering tree includes the directory information corresponding to the preset text block; construct a second clustering tree based on the preset text block and the text block labels corresponding to the preset text block; wherein the label parent node of the preset text block in the second clustering tree includes the text block labels corresponding to the preset text block.
[0199] In some embodiments, the third determining module 730 is configured to: determine the directory information of a preset text block as the directory parent node of the preset text block; and, if the number of preset text blocks corresponding to the directory parent node exceeds a first threshold, generate a directory parent node based on the semantic similarity between the preset text blocks exceeding the first threshold; or, if the preset text block does not have directory information, determine the directory information of the preset text block based on the semantic similarity between multiple preset text blocks without directory information, and generate a directory parent node based on the directory information; wherein, the directory parent node corresponds to multiple preset child nodes, and the preset child nodes are composed of corresponding preset text blocks; and construct a first clustering tree based on the preset child nodes and the directory parent node.
[0200] In some embodiments, the third determining module 730 is configured to: classify multiple text block labels based on the semantic similarity between text block labels corresponding to multiple preset text blocks to obtain multiple text block label clusters; generate label categories according to multiple text block labels in each text block label cluster using a preset pattern; wherein, preset text blocks corresponding to text block labels belonging to the same text block label cluster correspond to the same label category; generate a label parent node based on each label category and the text block labels corresponding to the label category; if the number of preset text blocks corresponding to the label parent node exceeds a second threshold, generate a new label parent node based on the text block labels corresponding to the preset text blocks exceeding the second threshold; wherein, the label parent node corresponds to multiple preset child nodes, and the preset child nodes are composed of corresponding preset text blocks; and construct a second clustering tree based on the preset child nodes and the label parent nodes.
[0201] Figure 8 This is a schematic diagram of an electronic device provided in an embodiment of this application. In some embodiments, the electronic device includes one or more processors and a memory. The memory is configured to store one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the retrieval-based content generation method in the above embodiments.
[0202] like Figure 8 As shown, the electronic device 1000 includes a processor 1001 and a memory 1002. Exemplarily, the electronic device 1000 may further include a communication interface 1003 and a communication bus 1004. The processor 1001, memory 1002, and communication interface 1003 communicate with each other via the communication bus 1004. The communication interface 1003 is used to communicate with other network elements such as clients or other servers.
[0203] In some embodiments, the processor 1001 is used to execute program 1005, specifically performing the relevant steps in the above-described embodiments of the retrieval-based content generation method. Specifically, program 1005 may include program code, which includes computer-executable instructions.
[0204] For example, processor 1001 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application. Electronic device 1000 may include one or more processors, which may be processors of the same type, such as one or more CPUs; or they may be processors of different types, such as one or more CPUs and one or more ASICs.
[0205] In some embodiments, memory 1002 is used to store program 1005. Memory 1002 may include high-speed RAM memory and may also include non-volatile memory (NVM), such as at least one disk storage device. Specifically, program 1005 may be invoked by processor 1001 to cause electronic device 1000 to perform operations of a retrieval-based content generation method.
[0206] This application provides a computer-readable storage medium storing at least one executable instruction. When the executable instruction is executed on an electronic device 1000, the electronic device 1000 performs the content generation method based on retrieval described in the above embodiment.
[0207] Specifically, the executable instructions can be used to cause the electronic device 1000 to perform operations based on the content generation method.
[0208] For example, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.
[0209] In some embodiments, this application provides a computer program product including a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions that, when executed by a computer, cause the computer to perform the retrieval-based content generation method described in any of the above embodiments.
[0210] In some embodiments, this application also provides a computer program that, when executed by a processor, can implement the retrieval-based content generation method described in any of the above embodiments.
[0211] The beneficial effects that the retrieval-based content generation apparatus, electronic device, computer-readable storage medium, computer program product, and computer program provided in this application embodiment can achieve are similar to the beneficial effects of the retrieval-based content generation method provided above, and will not be repeated here.
[0212] It should be noted that in this application, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.
[0213] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the apparatus embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0214] 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).
[0215] For the purposes of this specification, "computer-readable medium" can mean 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.
[0216] More specific examples of computer-readable media (a non-exhaustive list) include the following: electrical connections having one or more wires (electronic devices), portable computer disks (magnetic devices), 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).
[0217] Furthermore, the computer-readable medium can even be paper or other suitable media on which the program can be printed, because 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 computer memory. It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof.
[0218] In the above embodiments, multiple steps or methods can be implemented using 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.
[0219] The embodiments described above do not constitute a limitation on the scope of protection of this application.
Claims
1. A content generation method based on retrieval, characterized in that, The method includes: The system receives an unanswered question input by a user, and based on the unanswered question, determines at least one first candidate text block corresponding to the unanswered question from multiple preset text blocks; wherein, the multiple preset text blocks are obtained by a preset model dividing preset text according to preset rules; Based on the at least one first candidate text block and the question to be answered, determine the first contribution degree corresponding to each first candidate text block; Based on the first contribution value corresponding to the first candidate text block and the first candidate text block, the text block clustering tree is queried to obtain the clustering label information corresponding to the first candidate text block; wherein, the text block clustering tree is constructed by the plurality of preset text blocks according to the clustering label information, and the clustering label information is obtained by the preset model based on the preset text blocks; the clustering tree adopts a three-level tree structure, the root node is the preset text, the parent node is the clustering label in the clustering result, and the child node is the specific text block belonging to each clustering label; Based on the first contribution degree corresponding to the first candidate text block and the clustering label information corresponding to the first candidate text block, at least one second candidate text block is determined from a plurality of preset text blocks; wherein, if the first contribution degree of the first candidate text block is within a first preset range, the second candidate text block is determined based on other clustering label information besides the clustering label information corresponding to the first candidate text block; if the first contribution degree of the first candidate text block is within a second preset range, the second candidate text block is determined based on the clustering label information corresponding to the first candidate text block; The target content is determined based on the first candidate text block and / or at least one second candidate text block, and a preset model is instructed to generate an answer to the question to be answered based on the target content.
2. The method according to claim 1, characterized in that, The step of determining at least one second candidate text block from multiple preset text blocks based on the first contribution value corresponding to the first candidate text block and the clustering label information corresponding to the first candidate text block includes: If the first contribution of the first candidate text block is within the first preset range, a first candidate cluster label is determined based on the cluster label information corresponding to the first candidate text block; wherein, the first candidate cluster label is other cluster label information besides the cluster label information corresponding to the first candidate text block; Based on the first candidate clustering label, at least one second candidate text block is determined from the plurality of preset text blocks.
3. The method according to claim 1, characterized in that, The step of determining at least one second candidate text block from multiple preset text blocks based on the first contribution value corresponding to the first candidate text block and the clustering label information corresponding to the first candidate text block includes: If the first contribution of the first candidate text block is within the second preset range, a first candidate cluster label is determined based on the cluster label information corresponding to the first candidate text block; wherein, the first candidate cluster label is the cluster label information corresponding to the first candidate text block; Based on the first candidate clustering label, at least one second candidate text block is determined from a plurality of preset text blocks; wherein the second candidate text block is different from the first candidate text block.
4. The method according to claim 2 or 3, characterized in that, The text block clustering tree includes a first clustering tree and a second clustering tree. The step of determining the first candidate clustering label based on the clustering label information corresponding to the first candidate text block includes: Based on the clustering label information of the first candidate text block, the first clustering tree and the second clustering tree are queried respectively to obtain the first clustering label of the first candidate text block in the first clustering tree and the second clustering label of the first candidate text block in the second clustering tree; wherein, the first candidate clustering label includes the first clustering label and the second clustering label.
5. The method according to claim 4, characterized in that, The step of determining at least one second candidate text block from multiple preset text blocks based on the first candidate clustering label includes: Based on the contribution of multiple preset text blocks, at least one first preset text block with the highest contribution corresponding to the first clustering label is determined among the multiple preset text blocks; Based on the contribution of multiple preset text blocks, at least one second preset text block with the highest contribution corresponding to the second clustering label is determined among the multiple preset text blocks; The preset text block with the highest contribution among the at least one first preset text block and the at least one second preset text block is determined as the second candidate text block.
6. The method according to claim 1, characterized in that, The step of determining at least one first candidate text block corresponding to the unanswered question from multiple preset text blocks, based on the unanswered question, includes: Based on the question to be answered, extract the question keywords from the question to be answered; Based on the matching degree between the question keyword and the plurality of preset text blocks, a first candidate text block is determined from the plurality of preset text blocks; wherein, the first candidate text block is the preset text block with the highest matching degree with the question keyword among the plurality of preset text blocks.
7. The method according to claim 5, characterized in that, The step of determining the target content based on the first candidate text block and / or the at least one second candidate text block includes: Based on the second candidate text block and the question to be answered, the second contribution of the second candidate text block is determined; If the second contribution of the second candidate text block is within a third preset range, the target content is determined based on the first candidate text block and / or the second candidate text block.
8. The method according to claim 1, characterized in that, The text block clustering tree is constructed from the plurality of preset text blocks based on clustering label information, including: Obtain the directory information and text block tags for each of the preset text blocks; wherein, the directory information is used to indicate the directory of the preset text block in the preset text, and the text block tags are used to indicate the tags defined by the preset model for the preset text block; Based on the preset text block and the directory information corresponding to the preset text block, a first clustering tree is constructed; wherein, the directory parent node of the preset text block in the first clustering tree is composed of the directory information corresponding to the preset text block; A second clustering tree is constructed based on the preset text block and the text block label corresponding to the preset text block; wherein, the parent node of the preset text block in the second clustering tree is composed of the text block label corresponding to the preset text block.
9. The method according to claim 8, characterized in that, The step of constructing a first clustering tree based on the preset text block and the directory information corresponding to the preset text block includes: The directory information of the preset text block is determined as the directory parent node of the preset text block; and, If the number of preset text blocks corresponding to the directory parent node exceeds a first threshold, a directory parent node is generated based on the semantic similarity between the preset text blocks that exceed the first threshold; or, if the preset text block does not have directory information, the directory information of the preset text block is determined based on the semantic similarity between multiple preset text blocks that do not have directory information, and a directory parent node is generated based on the directory information; wherein, the directory parent node corresponds to multiple preset child nodes, and the preset child nodes are composed of the corresponding preset text blocks; The first clustering tree is constructed based on the preset child nodes and the directory parent nodes.
10. The method according to claim 8, characterized in that, The step of constructing a second clustering tree based on the preset text block and the text block label corresponding to the preset text block includes: Based on the semantic similarity between the text block tags corresponding to the multiple preset text blocks, the multiple text block tags are classified to obtain multiple text block tag clusters; Based on multiple text block tags in each text block tag cluster, a tag category is generated using a preset pattern; wherein, the preset text blocks corresponding to text block tags belonging to the same text block tag cluster correspond to the same tag category; Generate a tag parent node based on each tag category and the text block tag corresponding to the tag category; If the number of preset text blocks corresponding to the parent node of the tag exceeds a second threshold, a new parent node of the tag is generated based on the text block tags corresponding to the preset text blocks that exceed the second threshold; wherein, the parent node of the tag corresponds to multiple preset child nodes, and the preset child nodes are composed of the corresponding preset text blocks; The second clustering tree is constructed based on the preset child nodes and the label parent nodes.
11. A content generation device based on retrieval, characterized in that, include: The first determining module is configured to: receive a question input by a user and, based on the question, determine at least one first candidate text block corresponding to the question from a plurality of preset text blocks; wherein, the plurality of preset text blocks are obtained by a preset model dividing preset text according to preset rules; The second determining module is configured to: determine the first contribution degree corresponding to each first candidate text block based on the at least one first candidate text block and the question to be answered; The third determining module is configured to: query the text block clustering tree based on the first contribution value corresponding to the first candidate text block and the first candidate text block to obtain the clustering label information corresponding to the first candidate text block; wherein, the text block clustering tree is constructed by the plurality of preset text blocks according to the clustering label information, and the clustering label information is obtained by the preset model according to the preset text; the clustering tree adopts a three-level tree structure, the root node is the preset text, the parent node is the clustering label in the clustering result, and the child nodes are the specific text blocks belonging to each clustering label; The fourth determining module is configured to: determine at least one second candidate text block from a plurality of preset text blocks based on the first contribution degree corresponding to the first candidate text block and the clustering label information corresponding to the first candidate text block; wherein, if the first contribution degree of the first candidate text block is within a first preset range, the second candidate text block is determined based on other clustering label information besides the clustering label information corresponding to the first candidate text block; if the first contribution degree of the first candidate text block is within a second preset range, the second candidate text block is determined based on the clustering label information corresponding to the first candidate text block; The fifth determining module is configured to: determine target content based on the first candidate text block and / or the at least one second candidate text block, and instruct a preset model to generate an answer to the question to be answered based on the target content.
12. An electronic device, characterized in that, include: One or more processors; and The memory is configured to store one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the content generation method based on retrieval according to any one of claims 1-10.
13. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the content generation method based on retrieval according to any one of claims 1-10.
Citation Information
Patent Citations
Question answering method and device based on retrieval enhancement generation, equipment and storage medium
CN121388142A
Large model retrieval enhancement generation method based on document density soft clustering
CN121880559A