Question and answer processing method, computer program product, device and medium

By constructing a hierarchical vector database and performing matching calculations for target categories and document segments, the problem of low retrieval quality in the professional field of existing question-and-answer processing models is solved, achieving more accurate and reliable answering results.

CN119066179BActive Publication Date: 2025-02-28INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411515080.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-29
Publication Date
2025-02-28
Estimated Expiration
2044-10-29

AI Technical Summary

Technical Problem

The search quality of existing question-and-answer processing models in the professional field is not high, resulting in inaccurate or incomplete answers, and low recall searches lead to missing some information.

Method used

By constructing a hierarchical vector database, the target category and document slicing segments matched by the preset rules are determined according to the preset rules, the similarity calculation is performed to select the target document slicing segments, the target search results are constructed and the processing model is input to output the answer.

Benefits of technology

It improves the relevance and accuracy of the search results, and enhances the accuracy and reliability of model answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000_ABST
    Figure 00000000_0000_ABST
Patent Text Reader

Abstract

The present application provides a question-answer processing method, a computer program product, a device and a medium, including: in response to detecting that question text data is input into a processing model, determining a target first category matching the question text data according to a first preset rule in a first vector database; determining a target second category matching the question text data and a plurality of pending document segmentation segments according to a second preset rule, the target first category and index information in the first vector database; performing similarity calculation on the question text data and the plurality of pending document segmentation segments to select a first target document segmentation segment; constructing a target retrieval result according to the first target document segmentation segment and the question text data, and inputting the target retrieval result into the processing model to output an answer matching the question text data. By constructing a hierarchical vector database, the relevance of the retrieved text segment to the question is improved, and the accuracy and reliability of the model answer are further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a question-answering processing method, a computer program product, a device, and a medium. Background Art

[0002] Models used for question-answering processing are usually pre-trained on large-scale datasets to master general knowledge, so that the desired relevant knowledge can be acquired through conversations with the trained models.

[0003] The current existing models use external knowledge bases to enhance their retrieval capabilities in professional fields; however, the retrieval quality is not high, and low recall retrieval will lead to missing some information, resulting in inaccurate or incomplete answers generated by the model to questions.

[0004] Therefore, there is an urgent need for a method to solve the above problems by improving the retrieval quality and thus enhancing the model's answering effect. Summary of the invention

[0005] Based on this, it is necessary to provide a question and answer processing method, computer program product, device and medium to address the above technical issues.

[0006] In a first aspect, the present application provides a question-answering processing method, the method comprising:

[0007] In response to detecting that there is question text data input into the processing model, determining a target first category matching the question text data according to a first preset rule in a first vector database;

[0008] Determine a target second category and a plurality of pending document segmentation segments that match the question text data according to a second preset rule, the target first category, and the index information in the first vector database;

[0009] Performing similarity calculation on the question text data and the plurality of pending document segmentation segments to select a first target document segmentation segment;

[0010] A target retrieval result is constructed according to the first target document segmentation fragments and the question text data, and the target retrieval result is input into a processing model to output an answer matching the question text data.

[0011] In some embodiments, the method further includes updating the target search result, and the updating method includes:

[0012] In response to detecting that there is question text data input into the processing model, obtaining a first vector matching the question text data;

[0013] Searching a second vector database for a target vector that matches the first vector;

[0014] Determining a second target document segmentation segment matching the second vector according to a correspondence between the document segmentation segment and the second vector;

[0015] Generating a third target document segmentation segment after screening the first target document segmentation segment and the second target document segmentation segment;

[0016] The target retrieval result is updated according to the third target document segmentation segment and the question text data. The method also includes a method for constructing a first vector database:

[0017] Performing a first classification process on the original documents according to basic features of the plurality of original documents included in the original document set so as to classify the original documents in the original document set into a plurality of first categories;

[0018] Obtaining a document summary of each original document matched by the first category;

[0019] performing a second classification process on the document summaries of the original documents in the first category to classify each of the original documents in the first category into a plurality of second categories;

[0020] Segmenting each original document in the second category to generate a plurality of first document segment segments;

[0021] A first vector database is constructed according to the first document segmentation segments.

[0022] In some embodiments, the method further includes a method for constructing a second vector database:

[0023] Acquire all original documents contained in the original document set and segment the original documents to generate a plurality of second document segment segments;

[0024] Generating candidate questions for matching the second document segment segments;

[0025] The candidate question is vectorized to generate the second vector, and a second vector database is constructed according to the second vector.

[0026] In some embodiments, after constructing a first vector database according to the first document segmentation segments, the method includes:

[0027] Recording a first mapping relationship between the first category and the second category;

[0028] Recording a second mapping relationship between the second category and the first document segmentation segment;

[0029] Index information of the first vector database is generated according to the first mapping relationship and the second mapping relationship.

[0030] In some embodiments, performing a first classification process on the original documents according to basic features of the plurality of original documents included in the original document set to classify the original documents in the original document set into a plurality of first categories includes:

[0031] Acquire basic information of a plurality of original documents included in the original document set and extract basic features from the basic information;

[0032] Basic features of a plurality of original documents contained in an original document set are input into a classification model to output a plurality of first categories matching the original document set.

[0033] In some embodiments, performing a second classification process on the document summaries of the original documents in the first category to classify each original document in the first category into a plurality of second categories includes:

[0034] Vectorizing the document summary of each first category match to generate a summary vector;

[0035] A second classification process is performed on each summary vector matched by the first category according to a clustering algorithm to classify each document summary matched by the first category into a plurality of second categories.

[0036] In some embodiments, when performing a second classification process on each summary vector matching the first category according to a clustering algorithm to classify each document summary matching the first category into multiple second categories, a method for determining the number of second categories under the first category includes:

[0037] Selecting and calculating whether any two summary vectors matched by the first category are orthogonal;

[0038] If there are two orthogonal summary vectors, the intersection of the two summary vectors is defined as the initialization center point;

[0039] Repeat the above step of obtaining the initialization center point until all summary vectors matching the first category are traversed;

[0040] The number of second categories under the first category is determined according to the number of the initialization center points.

[0041] In some embodiments, determining the target first category matching the question text data in the first vector database according to a first preset rule includes:

[0042] Extracting question features from the question text data, and inputting the question features into a classification model to output a target first category; or,

[0043] Obtaining keywords and pre-annotated domain information of the question text data;

[0044] The target first category matching the question text data is determined by matching the keywords of the question text data with the keywords of the original document matching each first category, matching the domain information of the question text data with the domain information of the original document matching each first category, and calculating the similarity between the question text data and the title of the original document matching each first category.

[0045] In some embodiments, determining the target second category and a plurality of pending document segmentation segments matching the question text data according to the second preset rule, the target first category, and the index information in the first vector database includes:

[0046] According to the index information, confirm a plurality of pending second categories corresponding to the target first category;

[0047] Calculate the Euclidean distance between the first vector corresponding to the question text data and the average vector value of the undetermined second category;

[0048] It is determined that the undetermined second category corresponding to the minimum Euclidean distance is the target second category and the first document segmentation segment included in the target second category is the undetermined document segmentation segment.

[0049] In some embodiments, the performing similarity calculation on the question text data and the plurality of pending document segmentation segments to select a first target document segmentation segment includes:

[0050] Acquire a text vector matching the to-be-determined document segment from the first vector database;

[0051] Calculating the similarity between the first vector and the text vector;

[0052] A preset number of target text vectors are selected according to the calculated ranking of similarities, and the pending document segmentation segments corresponding to the target text vectors are determined as first target document segmentation segments.

[0053] In some embodiments, constructing the target retrieval result based on the first target document segmentation fragments and the question text data includes: according to a preset prompt word template, converting the first target document segmentation fragments and the question into a retrieval format matching the prompt word template to construct the target retrieval result.

[0054] In some embodiments, updating the target retrieval result based on the third target document segment and the question text data includes: according to a preset prompt word template, converting the third target document segment and the question into a retrieval format matching the prompt word template to update the target retrieval result.

[0055] In a second aspect, the present application provides a question-answering processing system, the system comprising:

[0056] A first retrieval module is used to determine a target first category matching the question text data according to a first preset rule in a first vector database in response to detecting that there is question text data input into the processing model;

[0057] A second retrieval module is used to determine a target second category and a plurality of pending document segmentation segments that match the question text data according to a second preset rule, the target first category and the index information in the first vector database;

[0058] A third retrieval module is used to perform similarity calculation on the question text data and the plurality of pending document segmentation segments to select a first target document segmentation segment;

[0059] The answer generation module is used to construct a target retrieval result based on the first target document segmentation fragments and the question text data, and input the target retrieval result into a processing model to output an answer matching the question text data.

[0060] In a third aspect, the present application provides a computer program, which, when executed by a processor, implements the steps of the following method:

[0061] In response to detecting that there is question text data input into the processing model, determining a target first category matching the question text data according to a first preset rule in a first vector database;

[0062] Determine a target second category and a plurality of pending document segmentation segments that match the question text data according to a second preset rule, the target first category, and the index information in the first vector database;

[0063] Performing similarity calculation on the question text data and the plurality of pending document segmentation segments to select a first target document segmentation segment;

[0064] A target retrieval result is constructed according to the first target document segmentation fragments and the question text data, and the target retrieval result is input into a processing model to output an answer matching the question text data.

[0065] In a fourth aspect, the present application provides an electronic device, the electronic device comprising:

[0066] one or more processors;

[0067] and a memory associated with one or more processors, the memory being used to store program instructions, which, when read and executed by the one or more processors, perform the following operations:

[0068] In response to detecting that there is question text data input into the processing model, determining a target first category matching the question text data according to a first preset rule in a first vector database;

[0069] Determine a target second category and a plurality of pending document segmentation segments that match the question text data according to a second preset rule, the target first category, and the index information in the first vector database;

[0070] Performing similarity calculation on the question text data and the plurality of pending document segmentation segments to select a first target document segmentation segment;

[0071] A target retrieval result is constructed according to the first target document segmentation fragments and the question text data, and the target retrieval result is input into a processing model to output an answer matching the question text data.

[0072] In a fifth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program enables a computer to perform the following operations:

[0073] In response to detecting that there is question text data input into the processing model, determining a target first category matching the question text data according to a first preset rule in a first vector database;

[0074] Determine a target second category and a plurality of pending document segmentation segments that match the question text data according to a second preset rule, the target first category, and the index information in the first vector database;

[0075] Performing similarity calculation on the question text data and the plurality of pending document segmentation segments to select a first target document segmentation segment;

[0076] A target retrieval result is constructed according to the first target document segmentation fragments and the question text data, and the target retrieval result is input into a processing model to output an answer matching the question text data.

[0077] The beneficial effects achieved by this application are:

[0078] The present application provides a question-answer processing method, including: in response to detecting that there is question text data input into a processing model, determining a target first category matching the question text data in a first vector database according to a first preset rule; determining a target second category matching the question text data and a plurality of pending document segmentation segments according to a second preset rule, the target first category, and index information in the first vector database; performing similarity calculation on the question text data and the plurality of pending document segmentation segments to select a first target document segmentation segment; constructing a target retrieval result according to the first target document segmentation segment and the question text data, and inputting the target retrieval result into a processing model to output an answer matching the question text data. By constructing a hierarchical vector database and performing category segmentation in a multi-level database, more accurate relevant documents can be matched when performing question retrieval, so that the retrieved text segment has a better correlation with the question, thereby improving the accuracy and reliability of the model answer. BRIEF DESCRIPTION OF THE DRAWINGS

[0079] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work, among which:

[0080] Figure 1 It is a flowchart of a question-and-answer processing method provided in an embodiment of the present application;

[0081] Figure 2 is a schematic diagram of a method for constructing a first vector database provided in an embodiment of the present application;

[0082] Figure 3 It is a schematic diagram of a target search result updating method provided in an embodiment of the present application;

[0083] Figure 4 This is a question and answer processing system architecture diagram provided in an embodiment of the present application;

[0084] Figure 5 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0085] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0086] It should be understood that in the description of the present application, unless the context clearly requires otherwise, words such as "include", "comprises", and the like in the entire specification and claims should be interpreted as having an inclusive meaning rather than an exclusive or exhaustive meaning; that is, the meaning of "including but not limited to".

[0087] It should also be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, "plurality" means two or more.

[0088] It should be noted that the terms "S1", "S2", etc. are only used for the purpose of describing the steps, and do not specifically refer to the order or sequence, nor are they used to limit the present application. They are only for the convenience of describing the method of the present application, and cannot be understood as indicating the order of the steps. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in this field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by the present application.

[0089] like Figure 1 The flowchart of the question-answering processing method shown in the figure, the embodiment of the present application provides a question-answering processing method, specifically using the method disclosed in the embodiment of the present application to answer the input question, including the following contents:

[0090] S1. In response to detecting that question text data is input into a processing model, a target first category matching the question text data is determined in a first vector database according to a first preset rule.

[0091] The above-mentioned processing model can be a trained large language model (LLM, Large Language Model). The large language model enables the machine to better understand and generate human natural language text through natural language processing technology based on deep learning. By using a large language model as a processing model, this application can communicate with the processing model to obtain the content and answers you want to know. It is understandable that the above-mentioned processing model is not limited to a large language model, but also includes any other model that can achieve output matching answers for question text data through learning.

[0092] In the present application, the above question text data can be a question or a text identifier used for query; the above question text data can be directly input by the user or converted from other methods (such as language input).

[0093] It is understandable that in order to enhance the retrieval effect, when the question text data input is detected, in some implementation scenarios, the question text data can be enhanced, the question text data can be supplemented, expanded and enhanced, and the comprehensiveness and availability of the answer finally generated by the processing model can be further improved. Specifically, the keywords of the question text data can be extracted to obtain multiple pending keywords, and the keyword information can be obtained after filtering the pending keywords, and only a part of the keywords ranked high in the question text data can be retained as keyword information; specifically, if there are keywords of professional noun type in the question text data, it is necessary to explain the professional noun, wherein the professional noun explanation content can be obtained through the existing professional noun knowledge base. For keywords with English abbreviations in the question text data, it is necessary to complete the English abbreviation of the keyword. If the question text data does not involve professional nouns or English abbreviations, the corresponding enhancement processing can be directly performed. Then, according to the professional noun explanation content and / or the noun full name content, the question text data is enhanced: according to the professional noun explanation content, the noun full name content and the target supplementary keywords, the question text data is enhanced to obtain the enhanced question text data. Among them, the target supplementary keywords are determined based on the preset knowledge keyword database and the various keyword information in the question text data; the above-mentioned preset knowledge keyword database is constructed based on sample keyword information and sample supplementary keywords corresponding to the sample keyword information, and the sample supplementary keywords at least include principle-type keywords, explanation-type keywords and sample-type keywords.

[0094] In a specific implementation scenario, the above-mentioned determination of the target first category matching the question text data according to the first preset rule in the first vector database includes: extracting the question features of the question text data, and inputting the question features into the classification model to output the target first category. Alternatively, obtaining the question text data keywords and pre-annotated domain information; determining the target first category matching the question text data by matching the keywords of the question with the keywords of the original document matching each first category, matching the domain information of the question with the domain information of the original document matching each first category, and calculating the similarity between the title of the question and the original document matching each first category. Wherein, the domain information can be prompted by the processing model when the user inputs the question text data to annotate it by himself; or it can be automatically generated by calling the annotation model to automatically generate the domain information matching the input question text data by training a deep learning-based annotation model in advance, and the training process of the annotation model is no longer expanded in this application. When searching for the input question text data, firstly perform a preliminary search in the mounted first vector database according to the first preset rule, perform a preliminary search based on the question features extracted from the question text data and the basic features contained in the original document, narrow the scope of the later need for fine search, speed up the overall search efficiency, and thus improve the answer speed of the processing model.

[0095] Among them, the classification model is the classification model used to determine the first category corresponding to the original document when the first vector database is constructed, and it can be a model for classifying documents based on deep learning; at this time, by extracting the problem feature of the question text data, the problem feature is a feature vector generated after vectorizing the words, words or sentences with substantial meaning in the input question. By inputting the problem feature into the trained classification model, the first classification corresponding to the problem feature can be output. The training process of the classification model is no longer expanded in this application.

[0096] When the first vector database is constructed, a plurality of first categories are generated after the original documents are subjected to the first classification processing based on the classification model. It can be understood that the original documents under each category are identical or similar in domain information, and there is a high repetition rate of keywords contained in the text and title between each original document. By matching the keywords of the question text data with the keywords contained in the original documents corresponding to each category, the original documents with a high degree of matching with the question text data can be screened out; by matching the domain information of the question text data with the domain information contained in the original document, the original documents with a high degree of matching with the question text data can also be screened out; by calculating the similarity between the question text data and the title of the original document, the original text with a high degree of matching with the question text data can also be screened out according to the similarity ranking; through the three matching methods, the original documents with a high degree of matching with the question text data are finally screened out, and the question text data is further determined. Among them, it is worth noting that the above three matching methods have no order limit in the execution order, and can be executed in a certain order or simultaneously. Secondly, in order to improve the retrieval efficiency, when performing the first classification processing based on the classification model, the keyword set with high repetition corresponding to each first category can be recorded, and the title can be enhanced to obtain an enhanced title that can represent the first category (that is, to achieve the integration of the same or similar titles), and the domain information can be enhanced to obtain domain information that can represent the first category (that is, to achieve the integration of the same or similar titles); when mapping the question data text to the first category, keyword matching can be directly performed according to the keyword set corresponding to each first category and the keywords contained in the question text data, matching can be performed according to the enhanced domain information corresponding to each first category and the enhanced domain information contained in the question text data, and similarity calculation can be performed according to the enhanced title corresponding to each first category and the question text data, so as to directly determine the target first category with the highest matching degree with the question text data.

[0097] S2. Determine a target second category and a plurality of pending document segmentation segments that match the question text data according to a second preset rule, the target first category, and index information in the first vector database.

[0098] In order to facilitate hierarchical retrieval, the present application also proposes recording a first mapping relationship between a first category and a second category when constructing a first vector database; recording a second mapping relationship between a second category and a first document segment; and generating index information of the first vector database based on the first mapping relationship and the second mapping relationship. It is understandable that the above index information can be stored in a designated storage space in the first vector database, or it can be stored separately and provide a query interface to facilitate processing model calls. Based on the pre-establishment of the first vector database, the present application records classification information and generates index information, so as to facilitate the rapid positioning of the document range that needs to be further retrieved after determining the first category, thereby speeding up the retrieval speed.

[0099] In a specific implementation scenario, the target second category and multiple pending document segmentation segments that match the question text data are determined according to the second preset rule, the target first category, and the index information in the first vector database, including: confirming multiple pending second categories corresponding to the target first category according to the index information; calculating the Euclidean distance between the first vector corresponding to the question text data and the average vector value of the pending second category; determining the pending second category corresponding to the smallest Euclidean distance as the target second category, and the document segmentation segments contained in the target second category as the pending document segmentation segments. It can be understood that the first vector database is obtained based on the center point determined by the clustering algorithm when determining the second category, wherein the calculation method of the Euclidean distance is a conventional technical means in the field, and this application will not be repeated here. After confirming the target first category that matches the question text data, this application calculates again which second category under the first category the question text data belongs to, and determines the target second category with the smallest Euclidean distance by calculating the Euclidean distance, thereby improving the accuracy of the second category confirmation, improving the retrieval accuracy, and further narrowing the calculation range to achieve an improvement in retrieval efficiency. It is understandable that in some implementation scenarios where the requirements for retrieval accuracy are low and the requirements for retrieval comprehensiveness are high, the undetermined second category corresponding to the calculated Euclidean distance less than a preset threshold can be determined as the target second category.

[0100] S3. Calculate similarity between the question text data and multiple pending document segment segments to select a first target document segment segment.

[0101] Specifically, the above-mentioned similarity calculation of the problem text data and multiple pending document segmentation segments to select the first target document segmentation segment includes: obtaining a text vector matching the pending document segmentation segment from a first vector database; calculating the similarity between the first vector and the text vector; selecting a preset number of target text vectors according to the ranking of the calculated similarity, and determining the pending document segmentation segment corresponding to the target text vector as the first target document segmentation segment. The similarity calculation of the above-mentioned first vector and the text vector can be determined by calculating the cosine similarity between the two vectors, and the larger the cosine similarity, the higher the similarity; or by calculating the Euclidean distance between the two vectors, and the smaller the Euclidean distance, the higher the similarity; it can also be achieved by calculating the Manhattan distance between the two vectors, and the smaller the Manhattan distance, the higher the similarity, and it can also be achieved by calculating the Chebyshev distance, Minkowski distance, etc. between the two vectors. Among them, the above-mentioned preset number is set by those skilled in the art according to the actual scene requirements and retrieval requirements, such as being set to 5 or 10, etc., and this application does not limit this.

[0102] S4. Construct a target retrieval result based on the first target document segmentation segments and the question text data, and input the target retrieval result into a processing model to output an answer that matches the question text data.

[0103] The above-mentioned method of constructing the target search result based on the first target document segment and the question text data includes: according to a preset prompt word template, converting the first target document segment and the question into a search format matching the prompt word template to construct the target search result. Specifically, in the prompt word template, use <question> question< / question> , <content> Target search results< / content> This format tells the model where the question is and where the search results are, and then lets the model answer the question based on the content.

[0104] By building a hierarchical database and using a hierarchical retrieval strategy when searching for relevant documents for user feedback, the search is continuously refined and deepened layer by layer, so that the search results that are more relevant to the questions are finally retrieved, thereby improving the availability and accuracy of the search results.

[0105] In some implementation scenarios where the question text data is enhanced, the above step S4 is adaptively changed to construct a target retrieval result based on the first target document segmentation fragments and the enhanced question text data, and the target retrieval result is input into the processing model to output an answer that matches the question text data; please refer to the previous text for the specific content.

[0106] Figure 2 A schematic diagram of a method for constructing a first vector database provided in the present application. Based on the above embodiment, the specific method for constructing the first vector database disclosed in the present application includes the following contents:

[0107] According to the basic features of multiple original documents contained in the original document set, the original documents are first classified into multiple first categories, wherein the original document set includes one or more of the enterprise's private data or Internet data; the document summary of each original document matching the first category is obtained, wherein the extraction of the document summary can be generated using a large language model or by training other learning models, which will not be described in detail in this application; the document summary of the original document in the first category is second classified to classify the original documents in each first category into multiple second categories; the original document in each second category is segmented to generate multiple first document segmented segments; and a first vector database is constructed based on the first document segmented segments. After obtaining the first document segmented segments, the first document segmented segments can be vectorized using a vectorization model, and a first vector database can be constructed based on the vectorized first document segmented segments; the vectorization model can also be integrated in the first vector database, and the first document segmented segments can be directly stored in the first vector database, and then the first vector database can automatically realize the vectorization of the first document segmented segments. It is understandable that a suitable vectorization model, such as a word embedding model, is selected according to task requirements and data characteristics; the first document segment is input into the vectorization model to convert the first document segment into a vector representation. Similarly, the acquisition of basic features disclosed in the present application is also achieved through a vectorization model.

[0108] Specifically, the original documents are first classified according to the basic features of the original documents in the original document set to classify the original documents in the original document set into multiple first categories, including: obtaining basic information of the original documents in the original document set, the basic information including but not limited to keywords, titles and pre-marked domain information; extracting basic features from the basic information; inputting the basic features of the original documents in the original document set into a pre-trained classification model to output multiple first categories matching the original document set. The original documents are initially divided according to the keywords, titles and domain information of the documents through the trained classification model; when the input question text data is retrieved, the first category can be confirmed through simple technical means, which speeds up the retrieval speed while narrowing the subsequent retrieval scope.

[0109] Among them, the classification model can be a model based on deep learning, and the model is trained by extracting basic features from the original document and pre-annotated domain information, and finally a classification model of the document is obtained to classify the document. The basic feature is a feature vector after vectorization based on words, sentences or paragraphs with substantial meaning in the original document. The specific classification model can be based on the FastText model, TextCNN model, TextRNN model training, or it can be based on other models that can be used for text classification. This application does not limit the specific model selected. It is worth noting that the classification model used in the first category for determining the matching of the problem text data disclosed in the above embodiment is the same as the classification model used to construct the first vector database. Among them, the domain information is the information that the technicians in this field pre-annotate the original document, such as documents in the hardware field, whose domain classification can include principle design, layout and wiring, BISO, BMC, etc., which are domain information; as mentioned above, it can also be achieved by training the annotation model.

[0110] Specifically, the above-mentioned second classification processing of the document summaries of the original documents in the first category to classify the original documents in each first category into multiple second categories includes: vectorizing each document summary matching the first category to generate a summary vector; performing a second classification processing on each summary vector matching the first category according to the clustering algorithm to classify each document summary matching the first category into multiple second categories. It can be determined that at this time, based on the second category to which the document summary belongs, the second category to which the original document matching the document summary belongs can be determined. Among them, the vectorization of the document summary can be implemented using a vectorization model as described above, and this application will not repeat it here. Among them, the above-mentioned clustering algorithm is a k-means clustering algorithm, and in some implementation scenarios it can also be other types of clustering algorithms, such as a hierarchical clustering algorithm, a segmentation clustering algorithm, etc., and adaptive processing is performed. The k-means clustering algorithm is used to cluster multiple documents belonging to the first category, thereby achieving subdivision of small categories. Therefore, when performing question retrieval, smaller subdivided categories can be retrieved, which improves the reliability and relevance of the retrieved documents to a certain extent, making the basis of the large model more accurate and reliable when answering questions, and thus making the answers obtained more accurate and reliable.

[0111] It can be understood that the k-means clustering algorithm requires the number of cluster categories to be pre-set, where the number of cluster categories in the original document contained in each first category is the number of second categories. Specifically, the number of categories is determined by the following method: select and calculate whether any two summary vectors are orthogonal in the summary vectors matching the first category; if there are two orthogonal summary vectors, define the intersection of the two summary vectors as the initialization center point; repeat the above steps of obtaining the initialization center point until the summary vectors matching the first category are traversed; according to the number of initialization center points, determine the number of second categories under the first category. That is, in order to avoid too much human intervention, we map the document summary to the vector space, traverse all feature vectors, calculate whether each two feature vectors are orthogonal, if so, set it as an initialization center point, repeat the work until all initialization center points are selected, recorded as K, and finally divided into K categories, that is, the number of second categories under the first category is determined by performing the second classification process on the original documents contained in each first category.

[0112] Based on the above embodiments, Figure 3 As shown in the schematic diagram of a disclosed target search result updating method, the present application also discloses a target search result updating method, which specifically includes the following contents:

[0113] X1. In response to detecting that question text data is input into the processing model, a first vector matching the question text data is obtained.

[0114] Specifically, the first vector is obtained by inputting the question text data into a vectorization model for conversion, and a suitable vectorization model, such as a word embedding model, is selected according to task requirements and data characteristics. Similarly, the candidate questions are subsequently vectorized to generate a second vector, which is obtained by inputting the candidate questions into a vectorization model for conversion.

[0115] X2. Search the second vector database for a second vector that matches the first vector.

[0116] Among them, the method for constructing the second vector database includes: obtaining all original documents contained in the original document set and segmenting the original documents to generate multiple second document segment segments; generating alternative questions matching the second document segment segments; vectorizing the alternative questions to generate second vectors, and constructing a second vector database based on the second vectors. By converting the document data into possible questions in advance and constructing a second vector database based on the questions, retrieval is performed from the question level, enriching the retrieval level, and thus improving the retrieval accuracy. Among them, in the specific implementation scenario, a large language model can be used to generate alternative questions matching the second document segment segments, or a deep learning-based model can be pre-trained to achieve this, which is not limited in this application.

[0117] X3. Determine a second target document segment that matches the second vector based on the correspondence between the document segment and the second vector.

[0118] It is understandable that, since the second vector is generated by vectorizing the document segmentation segments, there is a one-to-one correspondence between the document segmentation segments and the second vector. The number of the determined second target document segmentation segments meets the preset number mentioned above.

[0119] X4. Generate a third target document segment after screening the first target document segment and the second target document segment.

[0120] Among them, the method for confirming the first target document segment is the same as steps S1-S3 disclosed in the aforementioned embodiment, and will not be repeated in this application.

[0121] Specifically, the generation of the third target document segment after screening the first target document segment and the second target document segment can be performed by eliminating the similarity values ​​from high to low, removing the duplicates and obtaining the document segment that meets the quantity requirement, specifically: ranking the first target document segment and the second target document segment according to the calculated similarity value between the text vector corresponding to the first target document segment and the first vector, and the calculated similarity value between the second vector corresponding to the second target document segment and the first vector, wherein only one of the repeated document segment in the first target document segment and the second target document segment is retained. Since the similarity standard is the same, the similarity calculation method used in this application is consistent, so the document segment that meets the preset number can be selected as the third target document segment according to the ranking; wherein the setting of the preset number has been explained in the previous text and will not be repeated here.

[0122] Furthermore, in order to improve the accuracy and pertinence of the target retrieval results finally constructed, the present application also proposes to add a retrieval re-ranking model, sort the obtained multiple first target document segmentation fragments and second target document segmentation fragments based on the preset retrieval re-ranking model and question text data, and according to the sorting results, the document segmentation fragments corresponding to the top N results are used as the third target document segmentation fragments, where N is a number value determined by technical personnel in this field according to the actual scenario and retrieval requirements. Among them, the retrieval re-ranking model used can be selected according to the situation. For example, in the present application, the bge-reranker-large retrieval re-ranking model can be selected, and the present application does not limit it here.

[0123] X5. Update the target retrieval results based on the third target document segmentation fragments and question text data.

[0124] Specifically, according to the preset prompt word template, the third target document segmentation fragment and the question are converted into a retrieval format matching the prompt word template to construct a new target retrieval result. For example, in the prompt word template, use <question> question< / question> , <content> Target search results< / content> This format tells the model where the question is and where the search results are, and then lets the model answer the question based on the content.

[0125] In the above embodiment, the present application constructs a hierarchical database and searches for relevant documents for user questions. While using a hierarchical retrieval strategy to continuously refine the retrieval, it constructs a second vector database using relevant questions generated based on documents, and then uses question-to-question vector matching to improve the accuracy of the retrieval. Finally, the two retrieval results are merged, thereby improving the accuracy and usability of the model in answering professional field questions to a certain extent.

[0126] Based on the above embodiments, Figure 4 As shown in the system architecture diagram, the present application embodiment also provides a question-answering processing system, including:

[0127] A first retrieval module 410 is used to determine a target first category matching the question text data according to a first preset rule in a first vector database in response to detecting that there is question text data input into the processing model;

[0128] A second retrieval module 420 is used to determine a target second category and a plurality of pending document segmentation segments that match the question text data according to a second preset rule, the target first category and the index information in the first vector database;

[0129] A third retrieval module 430 is used to perform similarity calculation on the question text data and the plurality of pending document segmentation segments to select a first target document segmentation segment;

[0130] The answer generation module 440 is used to construct a target retrieval result according to the first target document segmentation segment and the question text data, and input the target retrieval result into a processing model to output an answer matching the question text data.

[0131] In some implementation scenarios, the above system also includes a question retrieval module (not shown in the figure), which is used to obtain a first vector matching the question text data in response to detecting that question text data is input into the processing model; search for a target vector matching the first vector in a second vector database; determine a second target document segment matching the second vector based on the correspondence between the document segment and the second vector; the third retrieval module 430 is also used to generate a third target document segment after screening the first target document segment and the second target document segment; the answer generation module 440 is also used to update the target retrieval result based on the third target document segment and the question text data.

[0132] In some implementation scenarios, the above system includes a data preparation module (not shown in the figure), which is used to construct a first vector database: perform a first classification processing on the original documents according to basic features of multiple original documents included in the original document set to classify the original documents in the original document set into multiple first categories; obtain a document summary of each original document matching the first category; perform a second classification processing on the document summary of the original documents in the first category to classify the original documents in each first category into multiple second categories; segment the original documents in each second category to generate multiple first document segment segments; and construct a first vector database based on the first document segment segments.

[0133] In some implementation scenarios, the data preparation module is also used to construct a method for constructing a second vector database: obtaining all original documents contained in the original document set and segmenting the original documents to generate multiple second document segment segments; generating alternative questions matching the second document segment segments; vectorizing the alternative questions to generate the second vector, and constructing a second vector database based on the second vector.

[0134] In some implementation scenarios, the data preparation module is also used to record a first mapping relationship between the first category and the second category; record a second mapping relationship between the second category and the first document segment; and generate index information of the first vector database based on the first mapping relationship and the second mapping relationship.

[0135] In some implementation scenarios, the data preparation module is also used to obtain basic information of multiple original documents contained in the original document set and extract basic features from the basic information; and input the basic features of the multiple original documents contained in the original document set into a classification model to output multiple first categories matching the original document set.

[0136] In some implementation scenarios, the data preparation module is further used to vectorize the document summary of each first category match to generate a summary vector; and perform a second classification process on the summary vector of each first category match according to a clustering algorithm to classify each document summary of the first category match into multiple second categories.

[0137] In some implementation scenarios, the data preparation module is further used to execute: selecting and calculating whether any two summary vectors are orthogonal from the summary vectors matching the first category; if there are two orthogonal summary vectors, defining the intersection of the two summary vectors as the initialization center point; repeating the above steps of obtaining the initialization center point until all summary vectors matching the first category are traversed; and determining the number of second categories under the first category based on the number of the initialization center points.

[0138] In some implementation scenarios, the first retrieval module 410 is used to extract question features of the question text data, and input the question features into a classification model to output a target first category; or, obtain keywords and pre-annotated domain information of the question text data; determine the target first category matching the question text data by matching the keywords of the question text data with the keywords of the original document matching each first category, matching the domain information of the question text data with the domain information of the original document matching each first category, and calculating the similarity between the question text data and the title of the original document matching each first category.

[0139] In some implementation scenarios, the second retrieval module 420 is used to confirm multiple pending second categories corresponding to the target first category based on the index information; calculate the Euclidean distance between the first vector corresponding to the question text data and the average vector value of the pending second category; determine that the pending second category corresponding to the smallest Euclidean distance is the target second category and the first document segmentation segment contained in the target second category is the pending document segmentation segment.

[0140] In some implementation scenarios, the third retrieval module 430 is used to obtain a text vector matching the pending document segment from the first vector database; calculate the similarity between the first vector and the text vector; select a preset number of target text vectors based on the ranking of the calculated similarities, and determine that the pending document segment corresponding to the target text vector is the first target document segment.

[0141] In some implementation scenarios, the answer generation module 440 is used to convert the first target document segmentation segments and questions into a retrieval format matching the prompt word template according to a preset prompt word template to construct the target retrieval result.

[0142] In some implementation scenarios, the answer generation module 440 is used to convert the third target document segmentation segments and questions into a retrieval format matching the prompt word template according to a preset prompt word template to update the target retrieval result.

[0143] On the basis of the above embodiments, the embodiments of the present application further provide a computer program, which implements the steps of the following method when the computer program is executed by a processor:

[0144] In response to detecting that there is question text data input into the processing model, determining a target first category matching the question text data according to a first preset rule in a first vector database;

[0145] Determine a target second category and a plurality of pending document segmentation segments that match the question text data according to a second preset rule, the target first category, and the index information in the first vector database;

[0146] Performing similarity calculation on the question text data and the plurality of pending document segmentation segments to select a first target document segmentation segment;

[0147] A target retrieval result is constructed according to the first target document segmentation fragments and the question text data, and the target retrieval result is input into a processing model to output an answer matching the question text data.

[0148] Corresponding to all the above embodiments, an embodiment of the present application provides an electronic device, including: one or more processors; and a memory associated with the one or more processors, the memory is used to store program instructions, and when the program instructions are read and executed by the one or more processors, the following operations are performed:

[0149] In response to detecting that there is question text data input into the processing model, determining a target first category matching the question text data according to a first preset rule in a first vector database;

[0150] Determine a target second category and a plurality of pending document segmentation segments that match the question text data according to a second preset rule, the target first category, and the index information in the first vector database;

[0151] Performing similarity calculation on the question text data and the plurality of pending document segmentation segments to select a first target document segmentation segment;

[0152] A target retrieval result is constructed according to the first target document segmentation fragments and the question text data, and the target retrieval result is input into a processing model to output an answer matching the question text data.

[0153] in, Figure 5The architecture of the electronic device is shown as an example, which may include a processor 510, a video display adapter 511, a disk drive 512, an input / output interface 513, a network interface 514, and a memory 520. The processor 510, the video display adapter 511, the disk drive 512, the input / output interface 513, the network interface 514, and the memory 520 may be communicatively connected via a bus 530.

[0154] Among them, the processor 510 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more circuits, etc., to execute relevant programs to implement the technical solution provided in this application.

[0155] The memory 520 can be implemented in the form of ROM (Read Only Memory, programmable memory), RAM (Random Access Memory, random access memory), static storage device, dynamic storage device, etc. The memory 520 can store an operating system 521 for controlling the execution of the electronic device 500, and a basic input and output system (BIOS) 522 for controlling the low-level operations of the electronic device 500. In addition, a web browser 523, a data storage management system 524, and an icon font processing system 525, etc. can also be stored. The above-mentioned icon font processing system 525 can be an application program that specifically implements the operations of the aforementioned steps in the embodiment of the present application. In short, when the technical solution provided in the present application is implemented by software or firmware, the relevant program code is stored in the memory 520 and is called and executed by the processor 510.

[0156] The input / output interface 513 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.

[0157] The network interface 514 is used to connect to a communication module (not shown) to achieve communication interaction between the device and other devices. The communication module can achieve communication through a wired method (such as USB, network cable, etc.) or a wireless method (such as mobile network, WIFI, Bluetooth, etc.).

[0158] The bus 530 comprises a pathway for transmitting information between the various components of the device (eg, the processor 510 , the video display adapter 511 , the disk drive 512 , the input / output interface 513 , the network interface 514 , and the memory 520 ).

[0159] In addition, the electronic device 500 can also obtain information on specific collection conditions from the virtual resource object collection condition information database for use in condition judgment, etc.

[0160] It should be noted that, although the above device only shows a processor 510, a video display adapter 511, a disk drive 512, an input / output interface 513, a network interface 514, a memory 520, a bus 530, etc., in the specific implementation process, the device may also include other components necessary for normal execution. In addition, it can be understood by those skilled in the art that the above device may also only include components necessary for implementing the solution of the present application, and does not necessarily include all the components shown in the figure.

[0161] It can be seen from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution of the present application can essentially or in other words, the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a disk, an optical disk, etc., including several instructions for enabling a computer device (which can be a personal computer, a cloud service end, or a network device, etc.) to execute the methods of various embodiments of the present application or certain parts of the embodiments.

[0162] Corresponding to all the above embodiments, the embodiments of the present application further provide a computer-readable storage medium storing a computer program, which enables a computer to perform the following operations:

[0163] In response to detecting that there is question text data input into the processing model, determining a target first category matching the question text data according to a first preset rule in a first vector database;

[0164] Determine a target second category and a plurality of pending document segmentation segments that match the question text data according to a second preset rule, the target first category, and the index information in the first vector database;

[0165] Performing similarity calculation on the question text data and the plurality of pending document segmentation segments to select a first target document segmentation segment;

[0166] A target retrieval result is constructed according to the first target document segmentation fragments and the question text data, and the target retrieval result is input into a processing model to output an answer matching the question text data.

[0167] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, in which the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0168] The above are only preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims

1. A question-answering processing method, characterized in that: The method comprises: In response to detecting that there is question text data input into the processing model, determining a target first category matching the question text data according to a first preset rule in a first vector database; Determine a target second category and a plurality of pending document segmentation segments that match the question text data according to a second preset rule, the target first category, and the index information in the first vector database; Performing similarity calculation on the question text data and the plurality of pending document segmentation segments to select a first target document segmentation segment; Constructing a target retrieval result according to the target document segmentation fragments and the question text data, and inputting the target retrieval result into a processing model to output an answer matching the question text data; The method for constructing the first vector database includes: Performing a first classification process on the original documents according to basic features of the plurality of original documents included in the original document set so as to classify the original documents in the original document set into a plurality of first categories; Obtaining a document summary of each original document matched by the first category; performing a second classification process on the document summaries of the original documents in the first category to classify each of the original documents in the first category into a plurality of second categories; Segmenting each original document in the second category to generate a plurality of first document segment segments; A first vector database is constructed according to the first document segmentation segments.

2. The method according to claim 1, characterized in that The method further includes updating the target search result, and the updating method includes: In response to detecting that there is question text data input into the processing model, obtaining a first vector matching the question text data; Searching a second vector database for a target vector that matches the first vector; Determining a second target document segmentation segment matching the second vector according to a correspondence between the document segmentation segment and the second vector; Generating a third target document segmentation segment after screening the first target document segmentation segment and the second target document segmentation segment; The target retrieval result is updated according to the third target document segmentation segment and the question text data.

3. The method according to claim 2, characterized in that The method also includes a method for constructing a second vector database: Acquire all original documents contained in the original document set and segment the original documents to generate a plurality of second document segment segments; Generating candidate questions for matching the second document segment segments; The candidate question is vectorized to generate the second vector, and a second vector database is constructed according to the second vector.

4. The method according to claim 1, characterized in that: After constructing a first vector database according to the first document segmentation segments, the method includes: Recording a first mapping relationship between the first category and the second category; Recording a second mapping relationship between the second category and the first document segmentation segment; Generate index information of the first vector database according to the first mapping relationship and the second mapping relationship.

5. The method according to claim 1, characterized in that The performing a first classification process on the original documents according to basic features of the plurality of original documents included in the original document set to classify the original documents in the original document set into a plurality of first categories includes: Acquire basic information of a plurality of original documents included in the original document set and extract basic features from the basic information; Basic features of a plurality of original documents contained in an original document set are input into a classification model to output a plurality of first categories matching the original document set.

6. The method according to claim 1, characterized in that The performing a second classification process on the document summaries of the original documents in the first category to classify each original document in the first category into a plurality of second categories includes: Vectorizing the document summary of each first category match to generate a summary vector; A second classification process is performed on each summary vector matched by the first category according to a clustering algorithm to classify each document summary matched by the first category into a plurality of second categories.

7. The method according to claim 6, characterized in that When performing a second classification process on each summary vector matching the first category according to a clustering algorithm to classify each document summary matching the first category into a plurality of second categories, a method for determining the number of second categories under the first category includes: Selecting and calculating whether any two summary vectors are orthogonal from the summary vectors matched in the first category; If there are two orthogonal summary vectors, the intersection of the two summary vectors is defined as the initialization center point; Repeat the step of obtaining the initialization center point until all summary vectors matching the first category are traversed; The number of second categories under the first category is determined according to the number of the initialization center points.

8. The method according to any one of claims 5 to 7, characterized in that: Determining the first target category matching the question text data according to the first preset rule in the first vector database includes: Extracting question features from the question text data, and inputting the question features into a classification model to output a target first category; or, Obtaining keywords and pre-annotated domain information of the question text data; The target first category matching the question text data is determined by matching the keywords of the question text data with the keywords of the original document matching each first category, matching the domain information of the question text data with the domain information of the original document matching each first category, and calculating the similarity between the question text data and the title of the original document matching each first category.

9. The method according to claim 8, characterized in that The step of determining the target second category and a plurality of pending document segmentation segments matching the question text data according to the second preset rule, the target first category, and the index information in the first vector database includes: According to the index information, confirm a plurality of pending second categories corresponding to the target first category; Calculate the Euclidean distance between the first vector corresponding to the question text data and the average vector value of the undetermined second category; It is determined that the undetermined second category corresponding to the minimum Euclidean distance is the target second category and the first document segmentation segment included in the target second category is the undetermined document segmentation segment.

10. The method according to claim 9, characterized in that The performing similarity calculation on the question text data and the plurality of pending document segmentation segments to select a first target document segmentation segment comprises: Acquire a text vector matching the to-be-determined document segment from the first vector database; Calculating the similarity between the first vector and the text vector; A preset number of target text vectors are selected according to the calculated ranking of similarities, and the pending document segmentation segments corresponding to the target text vectors are determined as first target document segmentation segments.

11. The method according to claim 3, characterized in that The step of constructing a target retrieval result based on the first target document segment and the question text data includes: according to a preset prompt word template, converting the first target document segment and the question into a retrieval format matching the prompt word template to construct the target retrieval result.

12. The method according to claim 11, characterized in that The updating of the target retrieval result according to the third target document segment and the question text data includes: according to a preset prompt word template, converting the third target document segment and the question into a retrieval format matching the prompt word template to update the target retrieval result.

13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 12 are implemented.

14. An electronic device, characterized in that: The electronic device comprises: one or more processors; And a memory associated with the one or more processors, the memory is used to store program instructions, and when the program instructions are read and executed by the one or more processors, the method according to any one of claims 1-12 is executed.

15. A computer-readable storage medium, characterized in that: The computer program stores a computer program, wherein the computer program enables a computer to execute the method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Question answering method and device based on knowledge base, computer equipment and storage medium

    CN117688151A

  • Question and answer processing method, system and equipment based on large language model and medium

    CN118377888A