Method and device for generating answer data, computer device, readable storage medium and program product

By identifying query keywords in a pre-set question-and-answer knowledge base and using a vector library for querying, the problem of low efficiency in existing knowledge-based question-and-answer technologies is solved, achieving accurate querying and efficient generation of answer data.

CN122388089APending Publication Date: 2026-07-14CLP JINXIN SOFTWARE (SHANGHAI CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CLP JINXIN SOFTWARE (SHANGHAI CO LTD
Filing Date
2026-04-13
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

Existing large-scale question answering methods based on retrieval enhancement technology require slicing and vectorizing all files in the knowledge base, resulting in low efficiency in knowledge question answering.

Method used

By identifying query keywords in the query request, searching in a preset question-and-answer knowledge base, determining the target retrieval data, and searching in a preset vector library, the retrieval results are processed using a preset question-and-answer model to generate answer data, thereby achieving precise querying and step-by-step accurate retrieval.

Benefits of technology

It improves the accuracy and efficiency of generating answer data. By determining the search results within a specified range, it achieves precise querying of query requests, thereby enhancing the accuracy and efficiency of question and answer.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122388089A_ABST
    Figure CN122388089A_ABST
Patent Text Reader

Abstract

The application relates to a method and device for generating answering data, computer equipment, a readable storage medium and a program product. The method comprises the following steps: responding to a query request, and identifying a query keyword in the query request; based on the query keyword, querying a preset question and answer knowledge base to determine target retrieval data corresponding to the query request; based on the target retrieval data, querying a preset vector library in the preset question and answer knowledge base to obtain a retrieval result corresponding to the query request; and based on a preset question and answer model, processing the retrieval result to obtain answering data corresponding to the query request. The method can improve the efficiency of knowledge question and answer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to a method, apparatus, computer device, readable storage medium, and program product for generating response data. Background Technology

[0002] Large-scale model question answering improves the quality and accuracy of responses by utilizing large language models and knowledge bases. Currently, retrieval augmentation (RAG) techniques are commonly used to extract knowledge from external knowledge bases, further enhancing the accuracy and reliability of the responses.

[0003] In related technologies, large-scale question-answering strategies based on retrieval enhancement technology require slicing all files in the knowledge base, vectorizing each slice, storing the vectorized slices directly, and comprehensively retrieving relevant information from the knowledge base when a question-answering request is received, resulting in low efficiency of knowledge-based question answering. Summary of the Invention

[0004] Therefore, it is necessary to provide a method, apparatus, computer device, readable storage medium, and program product for generating answer data that can improve the efficiency of knowledge-based question answering, in response to the above-mentioned technical problems.

[0005] Firstly, this application provides a method for generating response data, including:

[0006] Responding to a query request, and identifying the query keywords in the query request;

[0007] Based on the query keywords, a query is performed in a preset question-and-answer knowledge base to determine the target retrieval data corresponding to the query request;

[0008] Based on the target retrieval data, a query is performed in the preset vector library of the preset question-and-answer knowledge base to obtain the retrieval results corresponding to the query request. Based on the preset question-and-answer model, the retrieval results are processed to obtain the answer data corresponding to the query request.

[0009] In one embodiment, the query keywords include file name data, and the step of querying a preset question-and-answer knowledge base based on the query keywords to determine the target retrieval data corresponding to the query request includes:

[0010] In a pre-defined question-and-answer knowledge base, the target file identifier corresponding to the file name data is determined based on the correspondence between file identifiers and file names.

[0011] Based on the target file identifier, the target retrieval data corresponding to the query request is determined.

[0012] In one embodiment, the query keywords further include chapter name data, and determining the target retrieval data corresponding to the query request based on the target file identifier includes:

[0013] Determine the target file structure tree corresponding to the target file identifier;

[0014] In the target file structure tree, the target index range corresponding to the chapter name data is identified, and the target index range and the target file identifier are determined as the target retrieval data corresponding to the query request.

[0015] In one embodiment, the step of querying a preset vector library in the preset question-and-answer knowledge base based on the target retrieval data to determine the retrieval result corresponding to the query request includes:

[0016] Based on the target index data and the query request's question data, construct the retrieval parameters;

[0017] Based on the search parameters, target segmented text vectors that meet the preset matching conditions are selected from the preset vector library in the preset question-and-answer knowledge base, and each target segmented text vector is determined as the search result corresponding to the query request.

[0018] In one embodiment, the method further includes:

[0019] The text data in each file is divided into blocks to obtain multiple initial segmented text data;

[0020] The metadata of each initial segmented text data is identified, and the metadata of each initial segmented text data is vectorized to obtain each segmented text vector. Each segmented text vector is then stored in the preset vector library. The metadata includes one or more of the following: file identifier, index value, chapter path, file name, and file type of the initial segmented text data.

[0021] In one embodiment, the method further includes:

[0022] For each file identifier, based on the index value of each initial segmented text data in each chapter name data, the index range corresponding to each chapter name data is determined, and a file structure tree corresponding to the file identifier is constructed based on each index range.

[0023] Secondly, this application also provides an answer data generation apparatus, comprising:

[0024] An identification module is used to respond to a query request and identify the query keywords in the query request;

[0025] The processing module is used to process the query keywords in a preset question-and-answer knowledge base to obtain the target retrieval data corresponding to the query request;

[0026] The answer module is used to query the preset vector library in the preset question-and-answer knowledge base based on the target retrieval data to obtain the retrieval results corresponding to the query request, and to process the retrieval results based on the preset question-and-answer model to obtain the answer data corresponding to the query request.

[0027] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0028] Responding to a query request, and identifying the query keywords in the query request;

[0029] Based on the query keywords, a query is performed in a preset question-and-answer knowledge base to determine the target retrieval data corresponding to the query request;

[0030] Based on the target retrieval data, a query is performed in the preset vector library of the preset question-and-answer knowledge base to obtain the retrieval results corresponding to the query request. Based on the preset question-and-answer model, the retrieval results are processed to obtain the answer data corresponding to the query request.

[0031] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:

[0032] Responding to a query request, and identifying the query keywords in the query request;

[0033] Based on the query keywords, a query is performed in a preset question-and-answer knowledge base to determine the target retrieval data corresponding to the query request;

[0034] Based on the target retrieval data, a query is performed in the preset vector library of the preset question-and-answer knowledge base to obtain the retrieval results corresponding to the query request. Based on the preset question-and-answer model, the retrieval results are processed to obtain the answer data corresponding to the query request.

[0035] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:

[0036] Responding to a query request, and identifying the query keywords in the query request;

[0037] Based on the query keywords, a query is performed in a preset question-and-answer knowledge base to determine the target retrieval data corresponding to the query request;

[0038] Based on the target retrieval data, a query is performed in the preset vector library of the preset question-and-answer knowledge base to obtain the retrieval results corresponding to the query request. Based on the preset question-and-answer model, the retrieval results are processed to obtain the answer data corresponding to the query request.

[0039] The aforementioned answer data generation method, apparatus, computer equipment, readable storage medium, and program product, by responding to a query request and identifying query keywords in the query request; based on the query keywords, performing a query in a preset question-and-answer knowledge base to determine the target retrieval data corresponding to the query request; based on the target retrieval data, performing a query in a preset vector library within the preset question-and-answer knowledge base to obtain the retrieval results corresponding to the query request; and processing the retrieval results based on a preset question-and-answer model to obtain the answer data corresponding to the query request, can achieve the following: by identifying query keywords in the query request and determining the target retrieval data in the preset question-and-answer knowledge base based on the query keywords, it can achieve the following: by defining and determining the retrieval scope of the query request in the preset question-and-answer knowledge base, and by performing a further query in the preset vector library within the preset question-and-answer knowledge base based on the target retrieval data to determine the retrieval results, and by generating answer data based on the retrieval results, it achieves precise querying of the query request, improves the accuracy of the generated answer data, improves the efficiency of generating answer data by determining the retrieval results within a specified range, and further improves the accuracy and efficiency of question and answer by enabling the preset question-and-answer model to perform precise retrieval operations in a step-by-step manner through a complete retrieval process. Attached Figure Description

[0040] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0041] Figure 1 This is a flowchart illustrating a method for generating response data in one embodiment;

[0042] Figure 2 This is a flowchart illustrating a method for generating a preset vector library in one embodiment;

[0043] Figure 3 This is a schematic diagram of a response data generation method in one embodiment;

[0044] Figure 4This is a structural block diagram of a response data generation device in one embodiment;

[0045] Figure 5 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0046] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0047] In one exemplary embodiment, such as Figure 1 As shown, a method for generating answer data is provided. This embodiment illustrates the application of this method to a terminal. It is understood that this method can also be applied to a server, and further to a system including both a terminal and a server, and is implemented through interaction between the terminal and the server. In this embodiment, the method includes the following steps:

[0048] Step 101: Respond to the query request and identify the query keywords in the query request.

[0049] Among them, a query request is a request initiated by the user to query a question; the query request carries the query question data; and the query keywords refer to the keywords that match a specified index range in the preset question and answer knowledge base.

[0050] Specifically, when the terminal receives a query request from the user, it preprocesses the query question in the query request to obtain multiple query terms. Based on a preset question-answering model and preset intent analysis prompts, it processes the multiple query terms to obtain the user intent type. The user intent type is used to clarify the specified search scope in the query question. For example, the user intent type can represent searching for the content in a file, or searching for a specific chapter in a file, or searching for a specific chapter. Based on the user intent type, the multiple query terms are filtered to obtain query keywords. The preset intent analysis prompts can identify the query keywords in the query question and clarify the user intent type.

[0051] Optionally, the preprocessing of query question data may include: text cleaning the query question data to obtain cleaned question data, and word segmentation of the cleaned question data to obtain multiple query terms.

[0052] Step 102: Based on the query keywords, perform a query in the preset question and answer knowledge base to determine the target retrieval data corresponding to the query request.

[0053] The preset question-and-answer knowledge base includes at least the stored files, a file list, and a file structure tree; optionally, the file list includes at least one of the following: the file identifier of each file and the identifier of the original file from which it originates; the target retrieval data refers to the retrieval range that matches the query request and is found in the preset question-and-answer knowledge base.

[0054] Specifically, the terminal can search for target data matching the query keywords in a preset question-and-answer knowledge base based on a preset question-and-answer model, preset range search suggestions, and query keywords. The preset range search suggestions can be determined based on the query keywords and are used to invoke the corresponding search tool to retrieve the search range matching the query request from the preset question-and-answer knowledge base.

[0055] Step 103: Based on the target retrieval data, perform a query in the preset vector library in the preset question-and-answer knowledge base to obtain the retrieval results corresponding to the query request, and process the retrieval results based on the preset question-and-answer model to obtain the answer data corresponding to the query request.

[0056] The preset question-and-answer knowledge base also includes a preset vector library, which stores segmented text vectors. These segmented text vectors are the vectorized, segmented text data of each file. Search results refer to the file knowledge data corresponding to the query request found within the search scope specified by the target search data. The preset question-and-answer model can be a large language model, used to generate natural language answers based on the search results and query request. Answer data is the data corresponding to the question data in the query request; this answer data can be natural language text.

[0057] Specifically, the terminal can perform a query in a preset vector library within a preset question-and-answer knowledge base based on a preset question-and-answer model, preset search execution prompts, and target search data to obtain the search results corresponding to the query request. The preset search execution prompts can be prompts that call a search tool to perform a search in the preset question-and-answer knowledge base based on the target search data. The terminal can process the search results based on the preset question-and-answer model to obtain the answer data corresponding to the query request.

[0058] Optionally, the answer data may also carry the source of the search results, such as the file name, chapter name, etc., where the search results are located.

[0059] The aforementioned answer data generation method, by identifying query keywords in the query request and determining target retrieval data in a preset question-and-answer knowledge base based on these keywords, enables the segmentation and determination of the retrieval scope of the query request within the preset question-and-answer knowledge base. It also allows for further searching within a preset vector library of the preset question-and-answer knowledge base based on the target retrieval data to determine the retrieval results, and generates answer data based on these results. This achieves precise querying of the query request, improves the accuracy of the generated answer data, and enhances the efficiency of answer data generation by determining the retrieval results within a specified range. Furthermore, the complete retrieval process enables the preset question-and-answer model to perform precise step-by-step retrieval operations, further improving the accuracy and efficiency of question and answer processing.

[0060] In an exemplary embodiment, the query keywords include file name data. The specific implementation process of step 102, "based on the query keywords, perform a query in a preset question-and-answer knowledge base to determine the target retrieval data corresponding to the query request," may include:

[0061] In the pre-defined question-and-answer knowledge base, the target file identifier corresponding to the file name data is determined based on the correspondence between file identifier and file name; based on the target file identifier, the target retrieval data corresponding to the query request is determined.

[0062] The file list can include the correspondence between file identifiers and file names.

[0063] Specifically, the terminal can obtain prompt words through a preset question-and-answer model and a preset file list, invoke a file list retrieval tool in a preset tool layer, and use this file list retrieval tool to query the file list from a preset question-and-answer knowledge base. The terminal then inputs this file list into the preset question-and-answer model, determines the target file identifier corresponding to the file name data in the correspondence between file identifiers and file names, and determines the target retrieval data corresponding to the query request based on the file identifier. Optionally, the preset file list retrieval prompt words can be used when file name data is received or when the query request includes the need to understand the full picture of the knowledge base, thus invoking the file list retrieval tool.

[0064] Optionally, if the query keywords only include file name data, the terminal identifies the target file as the target retrieval data. Optionally, the target retrieval data may also include file name, file size, file type, and vectorization status. Additionally, if the query keywords include chapter name data, further searching is required in a preset question-and-answer knowledge base based on that chapter name data, which will be described in detail in subsequent embodiments and will not be repeated here.

[0065] In this embodiment, the target search data is obtained by searching the file name data in a preset knowledge base, which enables file-level and chapter-level retrieval, thereby improving the accuracy of question and answer.

[0066] In an exemplary embodiment, the query keywords also include chapter name data, and the specific implementation process of the step "determine the target retrieval data corresponding to the query request based on the target file identifier" may include:

[0067] Determine the target file structure tree corresponding to the target file identifier; in the target file structure tree, identify the target index range corresponding to the chapter name data, and determine the target index range and the target file identifier as the target retrieval data corresponding to the query request.

[0068] The target file structure tree includes at least a root node and multi-level chapter nodes. For example, multi-level chapter nodes can include first-level chapter nodes and second-level chapter nodes. The root node includes a file identifier; first-level chapter nodes include multiple chapter names and their corresponding index ranges; second-level chapter nodes include multiple sub-chapter names and their corresponding index ranges; chapter name data can be first-level or second-level chapter names, and can include chapter titles or the specific names of chapters. The target index range is determined by the minimum and maximum index values ​​of each segmented text data in the chapter name data. The index value of a segmented text data is its number in the file, used to identify the sequential data of that segmented text data within the file. The target file structure tree can also be a directory structure tree, which can include directories at each level and each header node indicating the corresponding chunk index range.

[0069] Specifically, the terminal can invoke a file directory retrieval tool in a preset tool layer using a preset question-and-answer model, preset file structure parsing prompts, and chapter name data. This tool then queries the preset question-and-answer knowledge base for the initial file structure tree corresponding to the target file identifier, and queries the preset vector library for the target segmented file data corresponding to the initial file structure tree. The terminal combines the initial file data with the index ranges of each target segmented file data to obtain the target file structure tree. Based on the preset question-and-answer model, preset file structure parsing prompts, and chapter name data, the terminal identifies the target index range corresponding to the chapter name data from the target file structure tree. Finally, the terminal determines the target index range and the target file identifier as the target index data corresponding to the query request. The preset file structure parsing prompts may include invoking the file directory retrieval tool to obtain the file structure tree when the query request includes chapter name data, and may also include obtaining the target index range corresponding to the chapter name data from the target parsing tree. Optionally, the target segmented text data may include chunks and index values.

[0070] Optionally, the terminal can pre-store the target file structure tree corresponding to each file in a preset question-and-answer knowledge base. That is, the terminal can directly obtain the file directory tool from the preset question-and-answer knowledge base to query the target file structure tree corresponding to the target file identifier.

[0071] In another embodiment, the query keywords only include chapter name data. The terminal can parse the prompt words using a preset question-and-answer model and a preset file structure, call the file directory retrieval tool of the preset tool layer, and use the file directory retrieval tool to query the target file structure tree corresponding to each target file identifier from the preset question-and-answer knowledge base. Based on the preset question-and-answer model, the preset file structure parsing prompt words, and the chapter name data, the terminal identifies the target index range corresponding to the chapter name data from the target file structure tree; and determines the target index range and the target file identifier as the target index data corresponding to the query request.

[0072] In this embodiment, by obtaining the target file structure tree and identifying the corresponding target index range, precise unlocking at the chapter level is achieved. The preset question-and-answer model is guided by prompt words to divide the retrieval range into steps and match the query request, thereby improving the accuracy and efficiency of question and answer.

[0073] In an exemplary embodiment, the specific implementation process of step 103, "based on the target retrieval data, querying in the preset vector library of the preset question-and-answer knowledge base to determine the retrieval results corresponding to the query request," may include:

[0074] Based on the target index data and the question data of the query request, retrieval parameters are constructed; based on the retrieval parameters, target segmented text vectors that meet the preset matching conditions are selected from the preset vector library in the preset question and answer knowledge base, and each target segmented text vector is determined as the retrieval result corresponding to the query request.

[0075] Here, "question data" refers to the question data raised by the user in the query request. "Retrieval parameters" are used to determine the retrieval scope corresponding to the retrieval request in the preset question-and-answer knowledge base. Optionally, retrieval parameters are used to limit the search to a specified file or to a specific chunk index range, and can be a single integer or a range of [start, end]. "Preset matching conditions" refer to the matching value between the question data and each segmented text vector within the target index data being greater than a preset matching threshold. The retrieval results can include the segmented text data of each target segmented text vector, the index value corresponding to the segmented text data, and the chapter path to which it belongs.

[0076] Specifically, after identifying the target file identifier and target index data, the terminal calls a preset hybrid indexing tool through a preset question-and-answer model and preset search execution prompts. The preset hybrid indexing tool constructs search parameters from the target index data and the question data of the query request. Based on the search parameters, it selects each target segmented text vector that meets the preset matching conditions from the preset vector library in the preset question-and-answer knowledge base. Based on each target segmented text vector, it determines the search results corresponding to the query request.

[0077] Optionally, the target index data includes target file identifiers and target retrieval data. The terminal can determine the index range in the preset vector library of the preset question-and-answer knowledge base using the target file identifiers and target retrieval data. It can also use a preset hybrid indexing tool to segment the question data into multiple segmented question data. Each segmented question data is then vectorized to obtain multiple segmented question vectors. These multiple segmented question vectors and segmented question data are then used for a hybrid retrieval within the index range to obtain the matching value between each segmented question data and each segmented text vector within the index range. The segmented text vectors corresponding to matching values ​​greater than a preset matching threshold are identified as target segmented text vectors that meet preset matching conditions. The terminal can then format these target segmented text vectors using a preset tool layer to obtain formatted segmented text vectors. These formatted segmented text vectors are then used as retrieval results and input into the preset question-and-answer model to obtain the answer data corresponding to the query request. It should be understood that the formatting process is used to adapt the data format to the preset question-and-answer model and can be converted using a fixed reference information template.

[0078] In one example, the matching value can include keyword matching values ​​and similarity values. The terminal can calculate the keyword matching value between each segmented question data and each segmented text data, and calculate the similarity value between each segmented question vector and each segmented text vector. Based on a preset weight value, the keyword matching value and the corresponding similarity value are weighted and summed to obtain the matching value. Optionally, the terminal can sort the matching values ​​in ascending or descending order, filter the maximum preset number of matching values, and determine the segmented text vector corresponding to the preset number of matching values, which is the target segmented text vector that meets the preset matching conditions. In addition, the search parameters can also include a preset weight value, which is predetermined by a preset hybrid indexing tool and can be determined according to different application scenarios. This preset weight value can be used to control the weight ratio of semantic search and keyword search.

[0079] In this embodiment, by constructing search parameters, determining the search scope in a preset question-and-answer knowledge base based on the search parameters, performing precise filtering within the search scope, and returning search results, precise retrieval and precise answers to query requests are achieved, improving the accuracy and efficiency of the answers.

[0080] In one exemplary embodiment, the answer data generation method further includes:

[0081] The text data in each file is divided into blocks to obtain multiple initial segmented text data; the metadata of each initial segmented text data is identified, and each initial segmented text data and its metadata are vectorized to obtain segmented text vectors, which are then stored in a preset vector library.

[0082] Metadata consists of the file to which the initial segmented text data belongs, its specific index value, and the specific chapter path of the file; metadata includes one or more of the following: file identifier, index value, chapter path, file name, and file type of the initial segmented text data.

[0083] Specifically, such as Figure 2 As shown, for each file, the terminal can preprocess each initial file to obtain the file, and then perform chunking processing on the text data in the preprocessed file to obtain multiple initial segmented text data for the file, as well as identify the metadata of each initial segmented text data in the file. Each initial segmented text data and its metadata are then vectorized to obtain segmented text vectors, which are stored in a preset vector library. In one example, the metadata of each segmented text vector can be the processed file ID ("file_id":processed_file.id), the chunk file index ("chunk_index":file_chunk_index), the chapter path ("header_path": ">".join(headers)), the filename ("filename":original_file.filename), and the file type ("mime_type":original_file.mime_type). Optionally, each initial segmented text data can be encoded to obtain its index value.

[0084] In this embodiment, by adding metadata to the initial segmented text data, the segmented text data is enhanced, and the source of each segmented text data is traced to facilitate the construction of a tree structure, thereby enabling accurate retrieval of question-and-answer data.

[0085] In one exemplary embodiment, the answer data generation method further includes:

[0086] For each file identifier, based on the index value of each initial segmented text data in each chapter name data, determine the index range corresponding to each chapter name data, and construct the file structure tree corresponding to the file identifier based on each index range.

[0087] The index value refers to the global index position of the initial segmented text data in the file.

[0088] Specifically, for each file identifier, the index value of each initial segmented text data in each chapter name data is determined, and the minimum and maximum index values ​​of each chapter name data are determined as the index range corresponding to that chapter name data. Based on each index range, a file structure tree corresponding to the file identifier is constructed. The file structure tree may include a root node and multi-level chapter nodes, as well as the index range of each chapter node.

[0089] In this embodiment, a file structure tree is constructed by using the index range corresponding to each chapter name data, which enables chapter-level retrieval and achieves precise retrieval.

[0090] In one embodiment, the answer data generation method further includes:

[0091] Based on the preset question-answering model and preset optimized prompts, the relevance and completeness of the search results are evaluated to obtain the evaluation results. Based on the evaluation results, the corresponding adjustment strategy is determined, and step 102 is re-executed based on the adjustment strategy.

[0092] Specifically, the terminal can perform a topic consistency check on the search results to obtain a topic consistency check result. This result is used to determine whether the content of the search results is semantically relevant to the user's query; and to remove semantically irrelevant, mismatched keywords, and redundant information segments. It can also perform a completeness check on the search results to obtain a completeness check result. This result is obtained by matching the data of each question with the search results, and indicates whether key information is missing or whether all the key points of the question are covered. The topic consistency check result and the completeness check result are used as evaluation results. Based on the correspondence between the evaluation results and adjustment strategies, the corresponding adjustment strategy is determined. The adjustment strategy can be to adjust query parameters and / or broaden the search scope. Query parameters can include adjusting the weighting ratio of keywords and semantics in mixed searches; broadening the search scope can include increasing the number of chunk searches and lowering the preset matching threshold.

[0093] Optionally, preset optimization suggestions can be used to assess the relevance and completeness of search results, and to adjust query parameters or broaden the search scope based on the results.

[0094] In this embodiment, by verifying the search results, more comprehensive and relevant knowledge fragments are obtained, thereby improving the accuracy of the generated answer data.

[0095] In one embodiment, such as Figure 3 As shown, Figure 3 This is a diagram illustrating the data generation method for responses. The data generation method for responses may include the following steps:

[0096] Step 301: The user sends a query request to the preset question-answering model, and the query request carries the query question data.

[0097] Step 302: Analyze the user intent type of the query question data through the preset question-answering model and preset intent analysis prompts, and extract query keywords. Query keywords include file name data (file name) and chapter name data (chapter name).

[0098] Step 303: Obtain prompt words through the preset question-and-answer model and preset file list, and call the get_file_list tool of the preset tool layer (MCP tool layer).

[0099] Step 304: Use the file list acquisition tool to query the file list from the preset question and answer knowledge base.

[0100] Step 305: Input the file list into the preset question-answering model. The file list includes its own file identifier (file_id) and the file identifier to which it belongs (source_file_id).

[0101] Step 306: In the correspondence between the file identifier and the file name, determine the target file identifier (target file ID) corresponding to the file name data.

[0102] Step 307: Parse the prompt words and chapter name data using the preset question-and-answer model and preset file structure, and call the preset tool layer's get_file_headers tool.

[0103] Step 308: Use the file directory acquisition tool to query the initial file structure tree corresponding to the target file identifier from the preset question and answer knowledge base.

[0104] Step 309: Query the target segmented file data corresponding to the initial file structure tree in the preset vector library.

[0105] Step 310: Combine the index ranges of the initial file data and the target split file data to obtain the target file structure tree.

[0106] Step 311: Based on the preset question-answering model and preset file structure parsing prompt words and chapter name data, identify the target index range (chunk index range of the target chapter) corresponding to the chapter name data from the target file structure tree.

[0107] Step 312: After identifying the target file identifier and the target index range, the preset hybrid index (hybrid_search) tool is invoked through the preset question-answering model and preset search execution prompts.

[0108] Step 313: Using a preset hybrid indexing tool, construct retrieval parameters from the target file identifier, target index range, and query request question data. These index parameters are used to filter the file identifier and index range.

[0109] Step 314: Based on the search parameters, select the target segmented text vectors that meet the preset matching conditions from the preset vector library in the preset question and answer knowledge base. Based on each target segmented text vector, determine the initial search results corresponding to the query request. The initial search results include the segmented text data (content), the index value (chunk_id) corresponding to the segmented text data, and the chapter path (header_path).

[0110] Step 315: Format the initial search results to obtain the final search results.

[0111] Step 316: Use the search result as input value and input it into the preset question-answering model to obtain the answer data corresponding to the query request, and send the answer data (final answer) to the user terminal.

[0112] It should be understood that steps 302 to 306 are steps for identifying the file ID, and are executed only when the file name is identified in the query request; steps 307 to 311 are the process of identifying the index range, and are executed only when the chapter name is identified in the query request.

[0113] In this embodiment, precise retrieval at the file and chapter levels is achieved through a vector library-based precise retrieval method. Enhanced metadata information and a robust toolchain guide the large language model to perform step-by-step precise retrieval operations, thereby improving the accuracy and efficiency of RAG question answering.

[0114] In one example, the user's question is: "How do I configure the database connection in the 'Product User Manual.pdf'?". The process of precise file-level retrieval may include the following steps:

[0115] The `get_file_list` tool is called to retrieve a list of files, returning the following files: "Product User Manual.pdf" (file_id: manual_001), "API Reference Document.pdf" (file_id: api_001), and "Troubleshooting Guide.pdf" (file_id: guide_001). The target file ID is identified as `manual_001`. `hybrid_search` is called, setting `file_id=manual_001`. Search parameters can be `query: "How to configure database connection", `file_id: "manual_001"`, and `top_k: 10`. The search results are 8 results (all from the target file).

[0116] The first result, [Source File ID: manual_001] <Intelligent Similarity>: 0.92; <Source>: Chapter 4 > Database Configuration > 4.1 Connection Settings; <Content>: Database connection configuration requires setting the host address, port number, username, and password.

[0117] The second result, [Source File ID: manual_001] <Intelligent Similarity>: 0.89; <Source>: Chapter 4 > Database Configuration > 4.2 Connection Pool Configuration; <Content>: Connection pool parameters include maximum number of connections, timeout, etc.

[0118] The third result, [Source File ID: manual_001] <Smart Similarity>: 0.87; <Source>: Chapter 4 > Database Configuration > 4.3 Advanced Configuration; <Content>: Advanced configuration includes SSL encryption, character set settings, etc.

[0119] The other five results all come from Chapter 4 of the same article and will not be cited here.

[0120] In this embodiment, all search results are derived from the target file "Product User Manual.pdf", narrowing the search scope from 5,000 chunks to approximately 200 chunks (a single file); the relevance rate is 100% (8 / 8); the search time is reduced by approximately 70% (from 5,000 chunks to 200 chunks); users do not need to manually filter and can directly obtain the content of the target file, thereby improving the accuracy and efficiency of the search.

[0121] In one example, the user's question is, "In Chapter 3 of the 'Technical Architecture Document.pdf,' how does the system handle concurrent requests?". A chapter-level precise retrieval process can include the following steps:

[0122] The `get_file_list` tool is used to identify the target file `arch_001`, and the `get_file_headers` tool is used to obtain the target file's structure tree. The chunk index range of the target chapter "Chapter 3" is identified as [90, 156]. `hybrid_search` is called, setting `file_id=arch_001` and `chunk_index=[90, 156]`. The search parameters include: `query: "How does the system handle concurrent requests?", `file_id: "arch_001"`, `chunk_index: [90, 156]`, and `top_k: 10`. The search results are 6 results (all from Chapter 3).

[0123] First search result: [Source file ID: arch_001] <Intelligent similarity>: 0.94; <Source>: Chapter 3 > Architecture Design > 3.2 Concurrent Processing; <Content>: The system adopts a multi-threaded architecture to handle concurrent requests, managed through a thread pool...

[0124] Second search result: [Source file ID: arch_001] <Smart similarity>: 0.91; <Source>: Chapter 3 > Architecture Design > 3.2 Concurrent Processing; <Content>: Concurrent requests are distributed to multiple server nodes through a load balancer...

[0125] The third search result: [Source File ID: arch_001] <Intelligent Similarity>: 0.89; <Source>: Chapter 3 > Architecture Design > 3.2 Concurrent Processing; <Content>: Each server node uses a thread pool to process requests, and the thread pool size is configurable...

[0126] Fourth search result: [Source file ID: arch_001] <Intelligent similarity>: 0.87; <Source>: Chapter 3 > Architecture Design > 3.1 Overall Architecture; <Content>: The overall architecture design considers high-concurrency scenarios and supports horizontal scaling...

[0127] The fifth search result: [Source File ID: arch_001] <Intelligent Similarity>: 0.85; <Source>: Chapter 3 > Architecture Design > 3.2 Concurrent Processing; <Content>: The request queue adopts a priority queue, and important requests are processed first...

[0128] The sixth search result: [Source File ID: arch_001] <Intelligent Similarity>: 0.83; <Source>: Chapter 3 > Architecture Design > 3.2 Concurrency Processing; <Content>: Concurrency control uses a semaphore mechanism to prevent resource contention...

[0129] In this embodiment, all results are from the target chapter "Chapter 3". The search scope is narrowed from 1000 chunks to 67 chunks (the chunk range of Chapter 3). The relevant result percentage is 100% (6 / 6). The search time is reduced by about 93% (from 1000 chunks to 67 chunks). The results are more focused and directly answer the user's questions about "Chapter 3", avoiding interfering information from other chapters.

[0130] In one example, given the user question "What are the request parameters for the user authentication interface in the API documentation.pdf?", the document knowledge base retrieval process could include the following steps:

[0131] The `get_file_list` function identifies the target file `api_doc_001`; the `hybrid_search` function sets `file_id` to `api_doc_001`; the search parameters include: `query: "request parameters of the user authentication interface", `file_id: "api_doc_001", and `top_k: 10`; the search results include the following 8 results (all from the target file):

[0132] First search result: [Source File ID: api_doc_001] <Smart Similarity>: 0.93; <Source>: Chapter 2 > Authentication Interface > 2.1 User Authentication; <Content>: The request parameters for the user authentication interface include: username (required, string type), password (required, string type)...

[0133] Second search result: [Source file ID: api_doc_001] <Smart similarity>: 0.90; <Source>: Chapter 2 > Authentication Interface > 2.1 User Authentication; <Content>: Request parameters are in JSON format, example: {"username":"user@example.com", "password": "****"}...

[0134] The third search result: [Source File ID: api_doc_001] <Smart Similarity>: 0.88; <Source>: Chapter 2 > Authentication Interface > 2.1 User Authentication; <Content>: Optional parameters include remember_me (boolean, default false)...

[0135] Fourth search result: [Source file ID: api_doc_001] <Intelligent similarity>: 0.86; <Source>: Chapter 2 > Authentication Interface > 2.2 Parameter Description; <Content>: username parameter requirements: length 3-50 characters, supports email format...

[0136] Fifth search result: [Source file ID: api_doc_001] <Intelligent similarity>: 0.84; <Source>: Chapter 2 > Authentication Interface > 2.2 Parameter Description; <Content>: password parameter requirements: 8-128 characters in length, containing uppercase and lowercase letters and numbers...

[0137] It should be understood that the other three results all come from the same file, and Chapter 2 will not be exemplified here.

[0138] In this embodiment, all results are derived from the target file "API Documentation.pdf". The search scope has been narrowed from 3,000 chunks to approximately 150 chunks (a single file). The relevant result rate is 100% (8 / 8), the search time is reduced by approximately 95% (from 3,000 chunks to 150 chunks), the results are more accurate, directly answer the user's questions about the specific file, and avoid interference from other documents.

[0139] As shown in Table 1, the comparison between the use of precise search and the use of precise search in this embodiment is made from multiple dimensions (proportion of relevant results at the document level, proportion of relevant results at the chapter level, search scope (document level), search scope (chapter level), search time (document level), search time (chapter level), user screening workload, answer accuracy, and user experience). This embodiment generates answer data by using precise search, which has a significant improvement effect.

[0140] Table 1

[0141]

[0142] It should be understood that the above examples are for illustrative purposes only and do not constitute specific limitations.

[0143] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0144] Based on the same inventive concept, this application also provides an answer data generation apparatus for implementing the answer data generation method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more answer data generation apparatus embodiments provided below can be found in the limitations of the answer data generation method described above, and will not be repeated here.

[0145] In one exemplary embodiment, such as Figure 4 As shown, an answer data generation device 40 is provided, including: a recognition module 41, a processing module 42, and an answer module 43, wherein:

[0146] The identification module 41 is used to respond to a query request and identify the query keywords in the query request;

[0147] Processing module 42 is used to process the query keywords in a preset question-and-answer knowledge base to obtain the target retrieval data corresponding to the query request;

[0148] The answer module 43 is used to query the preset vector library in the preset question-and-answer knowledge base based on the target retrieval data to obtain the retrieval results corresponding to the query request, and to process the retrieval results based on the preset question-and-answer model to obtain the answer data corresponding to the query request.

[0149] In one embodiment, the query keywords include file name data, and the processing module 42 is used to determine the target file identifier corresponding to the file name data based on the correspondence between file identifiers and file names in a preset question and answer knowledge base;

[0150] Based on the target file identifier, the target retrieval data corresponding to the query request is determined.

[0151] In one embodiment, the query keywords also include chapter name data, and the processing module 42 is used to determine the target file structure tree corresponding to the target file identifier;

[0152] In the target file structure tree, the target index range corresponding to the chapter name data is identified, and the target index range and the target file identifier are determined as the target retrieval data corresponding to the query request.

[0153] In one embodiment, the answer module 43 is used to construct retrieval parameters based on the target index data and the question data of the query request;

[0154] Based on the search parameters, target segmented text vectors that meet the preset matching conditions are selected from the preset vector library in the preset question-and-answer knowledge base, and each target segmented text vector is determined as the search result corresponding to the query request.

[0155] In one embodiment, the response data generation apparatus further includes:

[0156] The chunking module is used to divide the text data in each file into chunks to obtain multiple initial chunked text data.

[0157] The vectorization module is used to identify the metadata of each of the initial segmented text data, and to perform vectorization processing on each of the initial segmented text data and the metadata of each of the initial segmented text data to obtain each segmented text vector, and to store each of the segmented text vectors in the preset vector library. The metadata includes one or more of the following: file identifier, index value, chapter path, file name and file type of the initial segmented text data.

[0158] In one embodiment, the response data generation apparatus further includes:

[0159] The construction module is used to determine the index range corresponding to each chapter name data for each file identifier based on the index value of each initial segmented text data in each chapter name data, and to construct the file structure tree corresponding to the file identifier based on each index range.

[0160] Each module in the aforementioned answer data generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0161] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 5As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a method for generating response data. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0162] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0163] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.

[0164] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0165] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0166] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0167] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0168] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0169] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for generating response data, characterized in that, The method includes: Responding to a query request, and identifying the query keywords in the query request; Based on the query keywords, a query is performed in a preset question-and-answer knowledge base to determine the target retrieval data corresponding to the query request; Based on the target retrieval data, a query is performed in the preset vector library of the preset question-and-answer knowledge base to obtain the retrieval results corresponding to the query request. Based on the preset question-and-answer model, the retrieval results are processed to obtain the answer data corresponding to the query request.

2. The method according to claim 1, characterized in that, The query keywords include file name data. The step of querying a preset question-and-answer knowledge base based on the query keywords to determine the target retrieval data corresponding to the query request includes: In a pre-defined question-and-answer knowledge base, the target file identifier corresponding to the file name data is determined based on the correspondence between file identifiers and file names. Based on the target file identifier, the target retrieval data corresponding to the query request is determined.

3. The method according to claim 2, characterized in that, The query keywords also include chapter name data. The step of determining the target retrieval data corresponding to the query request based on the target file identifier includes: Determine the target file structure tree corresponding to the target file identifier; In the target file structure tree, the target index range corresponding to the chapter name data is identified, and the target index range and the target file identifier are determined as the target retrieval data corresponding to the query request.

4. The method according to claim 1, characterized in that, The step of querying a preset vector library in the preset question-and-answer knowledge base based on the target retrieval data to determine the retrieval results corresponding to the query request includes: Based on the target index data and the query request's question data, construct the retrieval parameters; Based on the search parameters, target segmented text vectors that meet the preset matching conditions are selected from the preset vector library in the preset question-and-answer knowledge base, and each target segmented text vector is determined as the search result corresponding to the query request.

5. The method according to claim 1, characterized in that, The method further includes: The text data in each file is divided into blocks to obtain multiple initial segmented text data; The metadata of each initial segmented text data is identified, and the metadata of each initial segmented text data is vectorized to obtain each segmented text vector. Each segmented text vector is then stored in the preset vector library. The metadata includes one or more of the following: file identifier, index value, chapter path, file name, and file type of the initial segmented text data.

6. The method according to claim 3, characterized in that, The method further includes: For each file identifier, based on the index value of each initial segmented text data in each chapter name data, the index range corresponding to each chapter name data is determined, and a file structure tree corresponding to the file identifier is constructed based on each index range.

7. A response data generation device, characterized in that, The device includes: An identification module is used to respond to a query request and identify the query keywords in the query request; The processing module is used to process the query keywords in a preset question-and-answer knowledge base to obtain the target retrieval data corresponding to the query request; The answer module is used to query the preset vector library in the preset question-and-answer knowledge base based on the target retrieval data to obtain the retrieval results corresponding to the query request, and to process the retrieval results based on the preset question-and-answer model to obtain the answer data corresponding to the query request.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.