Question and answer method, device and equipment based on large model

Through the embedding model, the document topics and text fragments similar to the question text are filtered out, which solves the problems of low direct retrieval efficiency and low accuracy of documents in the prior art, and achieves a more efficient and accurate question-and-answer process.

CN119441395APending Publication Date: 2025-02-14CHINA TELECOM NETWORK SECURITY TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411412272.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-10
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

The prior art searches for documents directly, and is difficult and inefficient. Due to the large content of the document, the retrieved documents may not be the documents required to reply to the question text, resulting in low accuracy of the big model question and answer.

Method used

Determine the target feature vector of the question text to be replied by the embedding model, and filter out the target topics and text fragments similar to the question text based on the feature vectors and the feature vectors of each topic of each document and the feature vectors of the body fragments in advance, and enter Generate reply text into the big model.

Benefits of technology

Reduces the difficulty of search, improves the search efficiency, and improves the accuracy of big model Q&A.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119441395A_ABST
    Figure CN119441395A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data processing, in particular to a question and answer method, device and equipment based on a large model. In the embodiment of the invention, the electronic equipment stores the document in the forms of themes and text segments, and stores a first feature vector corresponding to each theme, a second feature vector corresponding to each text segment and a corresponding relationship between the themes and the text segments. On the basis, during question answering, the electronic equipment can firstly screen each target theme similar to the question text, and then screen each target text fragment similar to the question text from the text fragments corresponding to each target theme, so that a large model generates the reply text according to each target text fragment, the retrieval difficulty is reduced, and the retrieval efficiency is improved. The efficiency is improved, and the accuracy of large model questions and answers is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a question-answering method, device and equipment based on a large model. Background Art

[0002] With the development of technology, large models are widely used in various fields. In order to cope with the problems of high computing power investment in large model training and rapid updating of relevant knowledge, large model question and answer based on knowledge base retrieval enhancement has emerged.

[0003] However, in many professional fields, knowledge is not stored in the form of question-answer pairs, but in the form of various documents. At the same time, it is difficult to directly convert these documents into high-quality question-answer pairs, so the only way is to directly retrieve the documents. That is, the electronic device retrieves the document corresponding to the question text based on the content corresponding to each document stored in the knowledge base, and then inputs the document and the question text into the large model, so that the large model generates a reply text. Direct retrieval of documents is difficult and inefficient. Since the documents contain a lot of content, the retrieved documents may not be the documents required to reply to the question text, which leads to low accuracy of large model question answering. Summary of the invention

[0004] The present application provides a question-answering method, apparatus and device based on a large model, which is used to solve the problem that the prior art directly retrieves documents, which is difficult and inefficient to retrieve, and because the documents contain a lot of content, the retrieved documents may not be the documents required to reply to the question text, which leads to the low accuracy of large model question answering.

[0005] In a first aspect, an embodiment of the present application provides a question-answering method based on a large model, the method comprising:

[0006] Determine a target feature vector of the question text to be answered according to the embedding model, and determine a first preset number of target topics in each topic that are similar to the question text according to a first feature vector of each topic of each document saved in advance and the target feature vector;

[0007] Determining a second preset number of target text segments similar to the question text in each text segment according to the pre-saved second feature vector of each text segment corresponding to each target topic and the target feature vector;

[0008] The second preset number of target text segments, preset prompt words and the question text are input into the large model, and the large model output reply text is obtained.

[0009] In a second aspect, an embodiment of the present application further provides a question-answering device based on a large model, the device comprising:

[0010] A processing module is used to determine a target feature vector of the question text to be answered according to the embedding model, and determine a first preset number of target topics similar to the question text in each topic according to a pre-saved first feature vector of each topic of each document and the target feature vector; and determine a second preset number of target text segments similar to the question text in each text segment according to a pre-saved second feature vector of each text segment corresponding to each target topic and the target feature vector;

[0011] The question-answering module is used to input the second preset number of target text segments, preset prompt words and the question text into the large model, and obtain the reply text output by the large model.

[0012] In a third aspect, an embodiment of the present application further provides an electronic device, comprising at least a processor and a memory, wherein the processor is used to implement the steps of any of the above-mentioned large model-based question-answering methods when executing a computer program stored in the memory.

[0013] In an embodiment of the present application, the electronic device determines the target feature vector of the question text to be answered according to the embedded model, and determines the first preset number of target topics similar to the question text in each topic according to the first feature vector and the target feature vector of each topic of each document saved in advance; determines the second preset number of target text segments similar to the question text in each text segment according to the second feature vector and the target feature vector of each text segment corresponding to each target topic saved in advance; inputs the second preset number of target text segments, the preset prompt words and the question text into the large model, and obtains the large model output reply text. In an embodiment of the present application, the electronic device stores the document in the form of topics and text segments, and saves the first feature vector corresponding to each topic, the second feature vector corresponding to each text segment, and the corresponding relationship between the topic and the text segment. Based on this, when performing question and answer, the electronic device can first screen each target topic similar to the question text, and then screen each target text segment similar to the question text from the text segment corresponding to each target topic, so that the large model generates a reply text according to each target text segment, which reduces the difficulty of retrieval, improves the efficiency, and improves the accuracy of large model question and answer. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0015] Figure 1 A schematic diagram of the question-answering process based on a large model provided for related technologies;

[0016] Figure 2 A schematic diagram of a question-answering process based on a large model provided in an embodiment of the present application;

[0017] Figure 3 A schematic diagram of a vector database provided in an embodiment of the present application;

[0018] Figure 4 A schematic diagram of a question-and-answer architecture provided for an embodiment of the present application;

[0019] Figure 5 A schematic diagram of the structure of a question-answering device based on a large model provided in an embodiment of the present application;

[0020] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0021] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.

[0022] The terms "first" and "second" in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive protection. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. "Multiple" in the present application can mean at least two, for example, two, three or more, and the embodiments of the present application are not limited.

[0023] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description. It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, which should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.

[0024] In the related art, however, in many professional fields, knowledge is not stored in the form of question-answer pairs, but in the form of various documents. At the same time, it is difficult to directly convert these documents into high-quality question-answer pairs, so the only way is to directly retrieve the documents. That is, the electronic device retrieves the document corresponding to the question text based on the content corresponding to each document stored in the knowledge base, and then inputs the document and the question text into the large model together, so that the large model generates a reply text. Direct retrieval of documents is difficult and inefficient. Since the documents contain a lot of content, the retrieved documents may not be the documents required to reply to the question text, which leads to low accuracy of large model question and answer.

[0025] Figure 1 A schematic diagram of the question-answering process based on a large model provided for related technologies, such as Figure 1As shown, the process includes: the electronic device uses an embedding model to determine the corpus text vector corresponding to the original corpus, and saves the corpus text vector into a vector database; the electronic device uses the embedding model to determine the question text vector corresponding to the received question, and retrieves the topK texts similar to the question text vector from the vector database; the electronic device uses a prompt word project to process the topK texts and questions, and inputs the processed data into a large language model (LLM) to obtain the answer corresponding to the question.

[0026] Based on this, the embodiment of the present application provides a question-answering method, device and equipment based on a large model. In the embodiment of the present application, the electronic device determines the target feature vector of the question text to be answered according to the embedded model, and determines the first preset number of target topics similar to the question text in each topic according to the first feature vector and target feature vector of each topic of each document saved in advance; determines the second preset number of target text segments similar to the question text in each text segment according to the second feature vector and target feature vector of each text segment corresponding to each target topic saved in advance; inputs the second preset number of target text segments, the preset prompt words and the question text into the large model, and obtains the reply text output by the large model.

[0027] Embodiment 1:

[0028] Figure 2 A schematic diagram of a question-answering process based on a large model provided in an embodiment of the present application, the process includes:

[0029] S201: Determine a target feature vector of the question text to be answered based on the embedding model, and determine a first preset number of target topics in each topic that are similar to the question text based on a first feature vector of each topic of each document saved in advance and the target feature vector.

[0030] A large model-based question-answering method provided in an embodiment of the present application is applied to an electronic device, which may be a server, a PC, etc.

[0031] In an embodiment of the present application, an electronic device receives an input question text, and replies to the question text to generate a reply text corresponding to the question text. Among them, there are many ways for the electronic device to receive the question text, which may be receiving the input text information or voice information through a front-end web page, APP, etc., or receiving the input text information or voice information through other general external devices. If the information received by the electronic device is text information, the text information is determined as the question text; if the information received by the electronic device is voice information, the voice information is converted into text information, and the converted text information is determined as the question text.

[0032] In an embodiment of the present application, an embedding model is pre-configured in the electronic device, and the embedding model adopts embedding technology, wherein the embedding technology is a method of mapping high-dimensional discrete data to a low-dimensional continuous vector space. In the field of natural language processing, it usually refers to a method of mapping a piece of discrete text data into a piece of continuous vector. This mapping retains the semantic relationship between the data.

[0033] Based on this, after receiving the question text, the electronic device can map the question text into a vector through the embedding model. Specifically, the electronic device inputs the question text into the embedding model, and the embedding model embeds the question text to determine and output the target feature vector corresponding to the question text.

[0034] In addition, the electronic device also stores each document, each topic corresponding to each document, and a first feature vector corresponding to each topic. Among them, a document can correspond to one or more topics. In order to make the generated answer more accurate, in the embodiment of the present application, a document corresponds to multiple topics.

[0035] Based on this, the electronic device can determine a first preset number of target topics in each topic that are similar to the question text based on the first feature vector corresponding to each topic of each saved document and the target feature vector corresponding to the question text.

[0036] Specifically, a similarity algorithm is pre-configured in the electronic device. The electronic device can determine the similarity between the target feature vector and each first target feature according to the similarity algorithm. The electronic device sorts each similarity in descending order of value, and determines the topics corresponding to the first preset number of similarities that are ranked high as the target topics.

[0037] The first preset number may be one, or two or more, and is not limited here.

[0038] S202: Determine a second preset number of target text segments similar to the question text in each text segment based on the pre-saved second feature vector of each text segment corresponding to each target topic and the target feature vector.

[0039] In the embodiment of the present application, for a document, one or more topics corresponding to the document are stored in the electronic device, and the text segments corresponding to each topic are also stored in the electronic device. In order to make the data used by the large model to generate the reply text more accurate, in the embodiment of the present application, if there is only one topic corresponding to a document, then each text segment corresponding to the topic is combined to form the document; if there are multiple topics corresponding to a document, then the text segments corresponding to each topic may overlap or not overlap, and the text segments corresponding to each topic are combined to form the document.

[0040] In an embodiment of the present application, the electronic device also pre-stores a second feature vector corresponding to each text segment determined by using an embedding model. After determining the first preset number of target topics, the electronic device determines the second feature vector of the text segment corresponding to the target topic for each target topic; the electronic device determines the similarity between the target feature vector of the question text and the second feature vector, and sorts each similarity in descending order, and determines the text segments corresponding to the second preset number of similarities that are ranked first as the target text segments required for question answering.

[0041] In the embodiment of the present application, the electronic device can store the first feature vector corresponding to each topic and the second feature vector corresponding to each text segment in a hierarchical storage manner. That is, the electronic device stores the first feature vector corresponding to each topic in a vector database, and stores the second feature vector corresponding to each text segment in another vector database, and the electronic device also stores the corresponding relationship between the topic and the text segment.

[0042] Specifically, the electronic device searches for a first preset number of target first feature vectors similar to the target feature vector of the question text in a vector database storing first feature vectors, and determines the topics corresponding to the first preset number of target first feature vectors as the target topics. The electronic device then determines each text segment corresponding to the target topic based on the correspondence between the saved topics and the text segments. The electronic device searches for each second feature vector of each text segment corresponding to the target topic from a vector database storing second feature vectors, and determines a second preset number of target second feature vectors similar to the target feature vector of the question text, and determines the text segments corresponding to the second preset number of target second feature vectors as the target text segments.

[0043] Figure 3 A schematic diagram of a vector database provided in an embodiment of the present application, such as the Figure 3 As shown, the first feature vector corresponding to the topic is stored in vector database A, and the second feature vector corresponding to the text segment is stored in vector database B.

[0044] S203: Input the second preset number of target text segments, preset prompt words and the question text into the large model, and obtain the large model output reply text.

[0045] In an embodiment of the present application, the electronic device may use a large model to determine the reply text corresponding to the question text based on a second preset number of target text segments.

[0046] Specifically, a prompt word template is pre-stored in the electronic device, and the prompt word template includes a first field for writing a text segment, a second field for writing a question text, and a prompt word for prompting the large model to ask and answer questions. After the electronic device determines a second preset number of target text segments, the electronic device can splice the second preset number of text segments, write the spliced ​​text segments into the first field of the prompt word template, and write the question text into the second field of the prompt word template. The electronic device inputs the written prompt word template into the large model, so that the large model determines and outputs the reply text corresponding to the question text according to the prompt word and the spliced ​​text segment.

[0047] In an embodiment of the present application, the electronic device stores the document in the form of topics and text segments, and saves the first feature vector corresponding to each topic, the second feature vector corresponding to each text segment, and the correspondence between the topic and the text segment. Based on this, when conducting question and answer, the electronic device can first screen each target topic similar to the question text, and then screen each target text segment similar to the question text from the text segment corresponding to each target topic, so that the large model generates a reply text according to each target text segment, which reduces the difficulty of retrieval, improves efficiency, and improves the accuracy of large model question and answer.

[0048] Embodiment 2:

[0049] In order to reduce the difficulty of retrieval, improve retrieval efficiency, and improve the accuracy of large model question answering, based on the above embodiment, in the embodiment of the present application, the process of determining each topic of each document includes:

[0050] For each document, obtain the saved target document type of the document and the correspondence between each document type and the title format saved in advance; determine the target format corresponding to the title in the target document type based on the correspondence; determine each title in the target document whose format is the target format, and determine each title as each subject corresponding to the document.

[0051] In an embodiment of the present application, when the electronic device determines each topic of each document, the electronic device can extract the topic of the document based on methods such as word matching and deep learning.

[0052] Specifically, a document may contain a title, and the electronic device may determine the title contained in the document as the subject of the document. Since the title formats contained in documents of different document types are different, in order to enable the electronic device to accurately determine the subject of documents of each document type, in an embodiment of the present application, the electronic device is pre-configured with a correspondence between each document type and the title format.

[0053] Based on this, when the electronic device determines the document subject corresponding to each document, the electronic device may first determine the target document type corresponding to the document, and then determine the target format corresponding to the target document type based on the saved correspondence between each document type and the title format. According to the target format, the electronic device searches for each title in the document in the target format, and determines each title as each subject corresponding to the document.

[0054] In the embodiment of the present application, in the pre-configured correspondence between each document type and title format, one document type may correspond to one or more title formats, which is not limited here. Moreover, one document may contain multiple titles of one target format, which is not limited here either.

[0055] In addition, in an embodiment of the present application, before determining the subject corresponding to each document, the electronic device may also pre-process the collected documents in professional fields, including text cleaning, format conversion, etc., to facilitate subsequent processing and analysis, so as to ensure the integrity and accuracy of the document information and provide high-quality input for subsequent vector conversion and retrieval.

[0056] Embodiment 3:

[0057] In order to reduce the difficulty of retrieval, improve retrieval efficiency, and improve the accuracy of large model question answering, based on the above embodiments, in the embodiment of the present application, the process of determining each text segment corresponding to each topic includes:

[0058] For each topic, determine the first text position of the topic in the document; if there are other topics in the document whose corresponding other text positions are after the first text position, determine the characters between the first text position and the other text positions as the text corresponding to the topic; use a preset character length to segment the text to obtain each text segment corresponding to the topic.

[0059] In an embodiment of the present application, after the electronic device determines each topic corresponding to each document based on the correspondence between the document type and the title format, the electronic device can determine the text segment corresponding to each topic based on the first text position of each topic in the document.

[0060] Specifically, in an embodiment of the present application, for each topic, the electronic device determines the first text position of the topic in the document; if there are other topics in the document whose corresponding other text positions are after the first text position, the characters located between the first text position and the other text positions are determined as the text corresponding to the topic; the text is segmented using a preset character length to obtain each text segment corresponding to the topic.

[0061] If the number of other topics corresponding to the other text positions after the first text position in the document is two or more, the electronic device determines the target other text position closest to the first text position, and determines the characters between the first text position and the target other text position as the text corresponding to the topic. Then, the text is segmented using a preset character length to obtain each text segment corresponding to the topic.

[0062] For example, if the first text position of the subject in the document is the third paragraph, and the other text positions of other subjects in the document are the sixth paragraph, the tenth paragraph, and the twentieth paragraph, respectively, the electronic device determines that the characters between the third paragraph and the sixth paragraph are the text corresponding to the subject. The electronic device segments the text according to the preset character length to obtain each text segment corresponding to the subject.

[0063] It should be noted that in an embodiment of the present application, when the electronic device segments the text using a preset character length, the lengths of all text segments except the last text segment in the segmentation order are the preset character length, and the length of the last text segment is less than or equal to the preset character length.

[0064] In order to reduce the difficulty of retrieval, improve retrieval efficiency, and improve the accuracy of large model question answering, on the basis of the above embodiments, in the embodiment of the present application, if the other topic does not exist in the document, the method further includes:

[0065] The characters after the first text position are determined as the text corresponding to the topic; and a subsequent process of segmenting the text using a preset character length to obtain each text segment corresponding to the topic is performed.

[0066] In an embodiment of the present application, if there is no other topic in the document with a corresponding other text position after the first text position, the electronic device determines all characters after the first text position as the text corresponding to the topic. The electronic device uses a preset character length to segment the text to obtain each text segment corresponding to the topic.

[0067] For example, if the first text position of the topic in the document is the 30th paragraph, and there is no other topic in the document with a corresponding other text position after the first text position, the electronic device determines that the characters between the 30th paragraph and the last character of the document are the text corresponding to the topic. The electronic device segments the text according to the preset character length to obtain each text segment corresponding to the topic.

[0068] Embodiment 4:

[0069] In order to reduce the difficulty of retrieval, improve retrieval efficiency, and improve the accuracy of large model question answering, based on the above embodiments, in the embodiment of the present application, the process of determining each topic of each document includes:

[0070] For each of the documents, the document is divided into sub-documents of a preset length; each of the sub-documents is input into other large models for summarizing document topics, and each document topic corresponding to each sub-document output by the other large models is obtained; each document topic is determined as each topic of the document.

[0071] In an embodiment of the present application, the electronic device may also determine the subject contained in each document by deep learning. The deep learning method is applicable to any scenario. If the electronic device cannot determine the target format corresponding to the target document type of the document based on the correspondence between the document type and the title format, the electronic device may determine the subject contained in the document based on deep learning.

[0072] Specifically, in an embodiment of the present application, for each document, the electronic device divides the document into sub-documents of a preset length; each sub-document is input into other large models for summarizing the document topic, and each document topic corresponding to each sub-document output by the other large models is obtained; and each document topic is determined as each topic of the document.

[0073] The length of each sub-document is greater than the length of the main text segment, that is, the preset length is greater than the preset character length.

[0074] Embodiment 5:

[0075] In order to reduce the difficulty of retrieval, improve retrieval efficiency, and improve the accuracy of large model question answering, on the basis of the above embodiments, in the embodiment of the present application, the method further includes:

[0076] Save the correspondence between each sub-document and each document topic;

[0077] The process of determining each text segment corresponding to each topic includes:

[0078] For each topic, the target sub-document corresponding to the topic is determined according to the corresponding relationship; the target sub-document is segmented according to a preset character length to obtain each text segment corresponding to the topic.

[0079] In an embodiment of the present application, when the electronic device determines each topic of a document based on a deep learning method, the electronic device saves the correspondence between each sub-document obtained by segmentation and each document topic. Based on the correspondence, the electronic device determines the sub-document corresponding to each topic as the text corresponding to the topic.

[0080] Specifically, for each topic, the electronic device determines the target sub-document corresponding to the topic according to the correspondence between each sub-document and each document topic saved, and segments the target sub-document according to a preset character length to obtain each text segment corresponding to the topic.

[0081] Embodiment 6:

[0082] In order to reduce the difficulty of retrieval, improve retrieval efficiency, and improve the accuracy of large model question answering, on the basis of the above embodiments, in the embodiment of the present application, the second preset number of target text segments similar to the question text in each text segment is determined, including:

[0083] For each target topic, according to a preset similarity algorithm, determine the similarity between the second feature vector of each text segment corresponding to the target topic and the target feature vector;

[0084] Sort each similarity according to the numerical value of each similarity, and select a second preset number of target similarities with the highest similarity from the sorting results;

[0085] The text segments corresponding to the second preset number of target similarities are determined as target text segments.

[0086] In the embodiment of the present application, when the electronic device determines the second preset number of target text segments similar to the question text in each text segment, for each target topic, the electronic device determines the similarity between the second feature vector of each text segment corresponding to the target topic and the target feature vector according to a preset similarity algorithm. The preset similarity algorithm may be a cosine similarity algorithm, a Euclidean distance algorithm, an inner product, etc., which is not limited here.

[0087] The electronic device sorts each similarity according to the numerical value of each similarity, and selects a second preset number of target similarities with the highest similarities from the sorting results; and determines the text segments corresponding to the second preset number of target similarities as the target text segments.

[0088] In order to reduce the difficulty of retrieval, improve retrieval efficiency, and improve the accuracy of large model question answering, based on the above embodiments, in the embodiment of the present application, before determining the similarity between the second feature vector of each text segment corresponding to the target topic and the target feature vector according to a preset similarity algorithm, the method also includes:

[0089] determining target characters in the question text that are common to the target topic;

[0090] Deleting the target character from the question text, and determining other feature vectors of the question text after deleting the target character according to the embedding model;

[0091] The target feature vector is updated using the other feature vectors.

[0092] In the embodiment of the present application, there is no specific limit on the length of the topic. A longer topic contains more information, which may lead to information annihilation and reduce the accuracy of the retrieval of the text. Based on this, in order to improve the accuracy of the text retrieval, the electronic device can delete the part of the question text that overlaps with the target topic before retrieval.

[0093] Specifically, the electronic device determines the target characters in the question text that are common to the target topic, deletes the target characters from the question text, and determines other feature vectors of the question text after deleting the target characters based on the embedding model. The electronic device updates the target feature vector using the other feature vectors, and retrieves a second preset number of target text segments similar to the question text from each text segment corresponding to the target topic based on the updated other feature vectors.

[0094] The embodiment of the present application proposes a large-model question-answering method based on topic enhancement, which aims to solve the retrieval problem of the existing large-model question-answering system when processing non-question-answer form knowledge. The method converts and stores the hierarchical vectors of the subject and the text in the document construction stage, and first performs a topic search when the question is input, then deletes the subject of the question, and finally searches in the text vector library, thereby improving the accuracy and efficiency of the search. The method of the embodiment of the present application includes modules such as knowledge document preprocessing, topic extraction, topic retrieval, and text vector library retrieval.

[0095] The present application embodiment mainly makes improvements in two aspects:

[0096] 1. When the database is first constructed, vector conversion and storage are performed hierarchically in the form of topic + text (the methods of topic extraction include but are not limited to various methods based on word matching, machine learning, and large models). This structure not only optimizes the organization of information, but also allows the key information of the document to be expressed more accurately through targeted vector conversion. In the retrieval process, this method significantly improves retrieval efficiency and accuracy, because the rapid location of the topic and the precise matching of the text can quickly find the required information and hand it over to the large model for processing, improving the user experience.

[0097] Second, when the question text is input, the question text is first searched for the topic. After the topic is retrieved, the topic content is deleted from the original question text, and then the search is performed in the text vector library. This strategy first quickly locates the relevant scope of the user's query through topic search, and then deletes the topic of the input question text on this basis, and then performs an accurate match of the text vector. This strategy not only speeds up the search speed, but also reduces the interference of topic information on the question search results through topic deletion.

[0098] Figure 4 A schematic diagram of a question-and-answer architecture provided by an embodiment of the present application, such as the Figure 4 As shown, the architecture includes a knowledge document preprocessing module, a topic extraction module, a vector conversion storage module, a topic retrieval module, a text vector retrieval module and a result integration and output module.

[0099] The specific question-and-answer process includes:

[0100] (1) Knowledge document segmentation preprocessing module: The collected documents (original corpus) are segmented and preprocessed, including text cleaning, format conversion, etc., to facilitate subsequent processing and analysis. The key to this module is to ensure the integrity and accuracy of document information and provide high-quality input for subsequent vector conversion and retrieval.

[0101] (2) Topic extraction module: Use topic extraction technology, such as word matching, deep learning, etc. to extract the topic of the document. This step is the core of the entire question-answering system, which directly affects the accuracy and relevance of the retrieval.

[0102] There are two specific methods for topic extraction:

[0103] The first type is that the document contains relatively obvious titles and subtitles, which can be directly extracted as the subject text;

[0104] The second type is that the document does not contain obvious title information. The document can be input into the big model, and the big model can be used to summarize the topic and summarize the topic text.

[0105] Through the first two modules, the topic and corresponding text content are extracted from the document, laying the foundation for hierarchical vector conversion.

[0106] (3) Vector conversion storage module: The preprocessed document content is classified according to the topic and text, and converted into vector form using an embedding model (such as m3e, bge, etc.) and stored in the knowledge base. The topic vector captures the core concept of the document, while the text vector contains more detailed information. This module uses an embedding model to ensure that the vectorization process can accurately reflect the semantic information of the document, providing support for efficient retrieval.

[0107] The functions are generally achieved through the three modules (1), (2) and (3): the document content after preprocessing and extracting themes is classified according to themes and texts, and converted into vector form and stored in the knowledge base.

[0108] (4) Topic retrieval module: When a user enters a question, since the question text is generally short and less clear, the topic extraction method similar to that of documents is not adopted. Instead, the question is directly converted into a vector through the embedding model and then searched in the topic vector database (vector database A). The most relevant topic to the question is quickly located, which provides guidance for the next step of text retrieval.

[0109] (5) Text vector retrieval module: Based on the results of the topic retrieval, this module further searches the text vector library (vector database B) corresponding to the retrieved topic, and deletes the part of the input question that overlaps with the topic before searching (if the information in the topic part is too long, it is very likely to cause information annihilation, reducing the retrieval accuracy of the text), and then generates a new text vector for the question after removing the topic through the embedding model, and uses the new text vector to search in the text vector library corresponding to the topic.

[0110] The above hierarchical retrieval mechanism effectively reduces the number of fragments that need to be retrieved, and the algorithm complexity is reduced from O(M*N) to O(M+N), where M represents the number of topics and N represents the number of text fragments corresponding to the topics, thereby improving the efficiency of retrieval.

[0111] (6) Result integration and output module: Integrate the top K ranked text segments retrieved from the text vector library corresponding to the topic and use them as context input to the large model to generate answers to the questions.

[0112] Embodiment 7:

[0113] In the embodiment of the present application, a question-answering method based on a large model provided in the embodiment of the present application is introduced with a specific scenario:

[0114] The question-answering method based on a big model provided in the embodiment of the present application can be applied in a telecommunications customer service scenario. Instead of establishing a question-answer pair, the original telecommunications package webpage is directly used to answer user questions with the help of a big model:

[0115] (1) Clean and convert the collected telecom package web pages to extract complete documents without the need to establish question-answer pairs, thereby improving efficiency and saving manpower. Question-answer pairs may result in incomplete information coverage.

[0116] (2) Use topic extraction technology to extract the theme of each telecom package webpage. Due to the special scenario of telecom packages, the title of the webpage can be directly used as the theme. In the case of no clear theme, machine learning and deep learning methods such as LLM summary generation can be used to generate it;

[0117] (3) The topics and text segments are converted into vectors through the embedding model and stored in two vector databases A and B;

[0118] (4) When inputting user questions, since user questions are generally short, we do not use the topic extraction method similar to documents. Instead, we convert the questions into vectors through the same embedding model and search them in the topic vector database. For example, “How to apply for the worry-free package” can be mapped to the topic “worry-free card”.

[0119] (5) After finding the corresponding topic, search the text vector library corresponding to the topic in vector database B. The specific form is: first delete the part related to the topic from the input question (i.e. convert the original sentence "how to apply for the worry-free package" to "how to apply for the package"), and then convert the processed question ("how to apply for the package") into a vector through the same embedding model and search in the text vector library corresponding to the topic. This search can eliminate the influence of the worry-free card subject on the search and focus more on how to apply for this information;

[0120] The above hierarchical retrieval mechanism effectively reduces the number of fragments that need to be retrieved, and the algorithm complexity is reduced from O(M*N) to O(M+N), where M represents the number of topics and N represents the number of text fragments corresponding to the topic, thus improving the efficiency of retrieval.

[0121] (6) The top K retrieved text fragments are then used as context and input into the large model through prompt to generate the corresponding answer.

[0122] Embodiment 8:

[0123] Based on the above embodiments, Figure 5 A schematic diagram of the structure of a question-answering device based on a large model provided in an embodiment of the present application, the device comprising:

[0124] Processing module 501 is used to determine the target feature vector of the question text to be answered according to the embedding model, and determine a first preset number of target topics similar to the question text in each topic according to the first feature vector of each topic of each document saved in advance and the target feature vector; determine a second preset number of target text segments similar to the question text in each text segment according to the second feature vector of each text segment corresponding to each target topic saved in advance and the target feature vector;

[0125] The question-answering module 502 is used to input the second preset number of target text segments, preset prompt words and the question text into the large model, and obtain the reply text output by the large model.

[0126] In a possible implementation, the processing module 501 is specifically used to obtain, for each document, a saved target document type of the document and a pre-saved correspondence between each document type and a title format; determine, based on the correspondence, a target format corresponding to the title in the target document type; determine each title in the target document that is formatted in the target format, and determine each title as each subject corresponding to the document.

[0127] In a possible implementation, the processing module 501 is specifically used to determine, for each topic, the first text position of the topic in the document; if there are other topics in the document whose corresponding other text positions are after the first text position, the characters located between the first text position and the other text positions are determined as the text corresponding to the topic; and the text is segmented using a preset character length to obtain each text segment corresponding to the topic.

[0128] In a possible implementation, the processing module 501 is specifically used to determine the characters located after the first text position as the text corresponding to the topic if the other topic does not exist in the document; and execute the subsequent process of segmenting the text using a preset character length to obtain each text segment corresponding to the topic.

[0129] In a possible implementation, the processing module 501 is specifically used to divide each document into sub-documents of a preset length; input each sub-document into other large models for summarizing document topics, and obtain each document topic corresponding to each sub-document output by the other large models; and determine each document topic as each topic of the document.

[0130] In a possible implementation, the processing module 501 is further used to save the corresponding relationship between each sub-document and each document topic;

[0131] The processing module 501 is specifically used to determine, for each topic, a target sub-document corresponding to the topic according to the corresponding relationship; and segment the target sub-document according to a preset character length to obtain each text segment corresponding to the topic.

[0132] In a possible implementation, the processing module 501 is specifically used to determine, for each target topic, according to a preset similarity algorithm, the similarity between the second feature vector of each text segment corresponding to the target topic and the target feature vector; sort each similarity according to the numerical value of each similarity, and select a second preset number of target similarities with the highest similarity from the sorting results; and determine the text segments corresponding to the second preset number of target similarities as the target text segments.

[0133] In a possible implementation, the processing module 501 is also used to determine the target characters in the question text that are common with the target topic; delete the target characters from the question text, and determine other feature vectors of the question text after deleting the target characters based on the embedding model; and use the other feature vectors to update the target feature vector.

[0134] Embodiment 9:

[0135] Based on the above embodiments, the present application also provides an electronic device, Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 6As shown, it includes: a processor 601, a communication interface 602, a memory 603 and a communication bus 604, wherein the processor 601, the communication interface 602, and the memory 603 communicate with each other through the communication bus 604;

[0136] The memory 603 stores a computer program. When the program is executed by the processor 601, the processor 601 performs the following steps:

[0137] Determine a target feature vector of the question text to be answered according to the embedding model, and determine a first preset number of target topics in each topic that are similar to the question text according to a first feature vector of each topic of each document saved in advance and the target feature vector;

[0138] Determining a second preset number of target text segments similar to the question text in each text segment according to the pre-saved second feature vector of each text segment corresponding to each target topic and the target feature vector;

[0139] The second preset number of target text segments, preset prompt words and the question text are input into the large model, and the large model output reply text is obtained.

[0140] In a possible implementation, the process of determining each topic of each document includes:

[0141] For each document, obtain the saved target document type of the document and the correspondence between each document type and the title format saved in advance; determine the target format corresponding to the title in the target document type based on the correspondence; determine each title in the target document whose format is the target format, and determine each title as each subject corresponding to the document.

[0142] In a possible implementation, the process of determining each text segment corresponding to each topic includes:

[0143] For each topic, determine the first text position of the topic in the document; if there are other topics in the document whose corresponding other text positions are after the first text position, determine the characters between the first text position and the other text positions as the text corresponding to the topic; use a preset character length to segment the text to obtain each text segment corresponding to the topic.

[0144] In a possible implementation manner, if the other topic does not exist in the document, the method further includes:

[0145] The characters after the first text position are determined as the text corresponding to the topic; and a subsequent process of segmenting the text using a preset character length to obtain each text segment corresponding to the topic is performed.

[0146] In a possible implementation, the process of determining each topic of each document includes:

[0147] For each of the documents, the document is divided into sub-documents of a preset length; each of the sub-documents is input into other large models for summarizing document topics, and each document topic corresponding to each sub-document output by the other large models is obtained; each document topic is determined as each topic of the document.

[0148] In a possible implementation, the method further includes:

[0149] Save the correspondence between each sub-document and each document topic;

[0150] The process of determining each text segment corresponding to each topic includes:

[0151] For each topic, the target sub-document corresponding to the topic is determined according to the corresponding relationship; the target sub-document is segmented according to a preset character length to obtain each text segment corresponding to the topic.

[0152] In a possible implementation manner, determining a second preset number of target text segments in each text segment that are similar to the question text includes:

[0153] For each target topic, according to a preset similarity algorithm, determine the similarity between the second feature vector of each text segment corresponding to the target topic and the target feature vector;

[0154] Sort each similarity according to the numerical value of each similarity, and select a second preset number of target similarities with the highest similarity from the sorting results;

[0155] The text segments corresponding to the second preset number of target similarities are determined as target text segments.

[0156] In a possible implementation, before determining the similarity between the second feature vector of each text segment corresponding to the target topic and the target feature vector according to a preset similarity algorithm, the method further includes:

[0157] determining target characters in the question text that are common to the target topic;

[0158] Deleting the target character from the question text, and determining other feature vectors of the question text after deleting the target character according to the embedding model;

[0159] The target feature vector is updated using the other feature vectors.

[0160] Since the principle of solving the problem by the above electronic device is similar to the question-answering method based on the large model, the implementation of the above electronic device can refer to the embodiment of the method, and the repeated parts will not be repeated.

[0161] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface 602 is used for communication between the above electronic device and other devices. The memory may include a random access memory (RAM) and may also include a non-volatile memory (NVM), such as at least one disk storage. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0162] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; it can also be a digital signal processing processor (Digital Signal Processing, DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.

[0163] Embodiment 10:

[0164] On the basis of the above embodiments, an embodiment of the present invention further provides a computer-readable storage medium, in which a computer program executable by a processor is stored. When the program runs on the processor, the processor implements the following steps when executing:

[0165] Determine a target feature vector of the question text to be answered according to the embedding model, and determine a first preset number of target topics in each topic that are similar to the question text according to a first feature vector of each topic of each document saved in advance and the target feature vector;

[0166] Determining a second preset number of target text segments similar to the question text in each text segment according to the pre-saved second feature vector of each text segment corresponding to each target topic and the target feature vector;

[0167] The second preset number of target text segments, preset prompt words and the question text are input into the large model, and the large model output reply text is obtained.

[0168] In a possible implementation, the process of determining each topic of each document includes:

[0169] For each document, obtain the saved target document type of the document and the correspondence between each document type and the title format saved in advance; determine the target format corresponding to the title in the target document type based on the correspondence; determine each title in the target document whose format is the target format, and determine each title as each subject corresponding to the document.

[0170] In a possible implementation, the process of determining each text segment corresponding to each topic includes:

[0171] For each topic, determine the first text position of the topic in the document; if there are other topics in the document whose corresponding other text positions are after the first text position, determine the characters between the first text position and the other text positions as the text corresponding to the topic; use a preset character length to segment the text to obtain each text segment corresponding to the topic.

[0172] In a possible implementation manner, if the other topic does not exist in the document, the method further includes:

[0173] The characters after the first text position are determined as the text corresponding to the topic; and a subsequent process of segmenting the text using a preset character length to obtain each text segment corresponding to the topic is performed.

[0174] In a possible implementation, the process of determining each topic of each document includes:

[0175] For each of the documents, the document is divided into sub-documents of a preset length; each of the sub-documents is input into other large models for summarizing document topics, and each document topic corresponding to each sub-document output by the other large models is obtained; each document topic is determined as each topic of the document.

[0176] In a possible implementation, the method further includes:

[0177] Save the correspondence between each sub-document and each document topic;

[0178] The process of determining each text segment corresponding to each topic includes:

[0179] For each topic, the target sub-document corresponding to the topic is determined according to the corresponding relationship; the target sub-document is segmented according to a preset character length to obtain each text segment corresponding to the topic.

[0180] In a possible implementation manner, determining a second preset number of target text segments in each text segment that are similar to the question text includes:

[0181] For each target topic, according to a preset similarity algorithm, determine the similarity between the second feature vector of each text segment corresponding to the target topic and the target feature vector;

[0182] Sort each similarity according to the numerical value of each similarity, and select a second preset number of target similarities with the highest similarity from the sorting results;

[0183] The text segments corresponding to the second preset number of target similarities are determined as target text segments.

[0184] In a possible implementation, before determining the similarity between the second feature vector of each text segment corresponding to the target topic and the target feature vector according to a preset similarity algorithm, the method further includes:

[0185] determining target characters in the question text that are common to the target topic;

[0186] Deleting the target character from the question text, and determining other feature vectors of the question text after deleting the target character according to the embedding model;

[0187] The target feature vector is updated using the other feature vectors.

[0188] Since the principle of solving the problem by the above-mentioned computer program product is similar to the question-answering method based on the large model, the implementation of the above-mentioned computer program product can refer to the implementation of the method, and the repeated parts will not be repeated.

[0189] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0190] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0191] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0192] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0193] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A question-answering method based on a large model, characterized in that: The method comprises: Determine a target feature vector of the question text to be answered according to the embedding model, and determine a first preset number of target topics in each topic that are similar to the question text according to a first feature vector of each topic of each document saved in advance and the target feature vector; Determining a second preset number of target text segments similar to the question text in each text segment according to the pre-saved second feature vector of each text segment corresponding to each target topic and the target feature vector; The second preset number of target text segments, preset prompt words and the question text are input into the large model, and the large model output reply text is obtained.

2. The method according to claim 1, characterized in that The process of determining each topic of each document includes: For each document, obtain the saved target document type of the document and the correspondence between each document type and the title format saved in advance; determine the target format corresponding to the title in the target document type based on the correspondence; determine each title in the target document whose format is the target format, and determine each title as each subject corresponding to the document.

3. The method according to claim 2, characterized in that The process of determining each text segment corresponding to each topic includes: For each topic, determine the first text position of the topic in the document; if there are other topics in the document whose corresponding other text positions are after the first text position, determine the characters between the first text position and the other text positions as the text corresponding to the topic; use a preset character length to segment the text to obtain each text segment corresponding to the topic.

4. The method according to claim 3, characterized in that: If the other topic does not exist in the document, the method further includes: The characters after the first text position are determined as the text corresponding to the topic; and a subsequent process of segmenting the text using a preset character length to obtain each text segment corresponding to the topic is performed.

5. The method according to claim 1 or 2, characterized in that: The process of determining each topic of each document includes: For each of the documents, the document is divided into sub-documents of a preset length; each of the sub-documents is input into other large models for summarizing document topics, and each document topic corresponding to each sub-document output by the other large models is obtained; each document topic is determined as each topic of the document.

6. The method according to claim 5, characterized in that The method further comprises: Save the correspondence between each sub-document and each document topic; The process of determining each text segment corresponding to each topic includes: For each topic, the target sub-document corresponding to the topic is determined according to the corresponding relationship; the target sub-document is segmented according to a preset character length to obtain each text segment corresponding to the topic.

7. The method according to claim 1, characterized in that The determining of a second preset number of target text segments in each text segment that are similar to the question text comprises: For each target topic, according to a preset similarity algorithm, determine the similarity between the second feature vector of each text segment corresponding to the target topic and the target feature vector; Sort each similarity according to the numerical value of each similarity, and select a second preset number of target similarities with the highest similarity from the sorting results; The text segments corresponding to the second preset number of target similarities are determined as target text segments.

8. The method according to claim 7, characterized in that Before determining the similarity between the second feature vector of each text segment corresponding to the target topic and the target feature vector according to a preset similarity algorithm, the method further includes: determining target characters in the question text that are common to the target topic; Deleting the target character from the question text, and determining other feature vectors of the question text after deleting the target character according to the embedding model; The target feature vector is updated using the other feature vectors.

9. A question-answering device based on a large model, characterized in that: The device comprises: A processing module is used to determine a target feature vector of the question text to be answered according to the embedding model, and determine a first preset number of target topics similar to the question text in each topic according to a pre-saved first feature vector of each topic of each document and the target feature vector; and determine a second preset number of target text segments similar to the question text in each text segment according to a pre-saved second feature vector of each text segment corresponding to each target topic and the target feature vector; The question-answering module is used to input the second preset number of target text segments, preset prompt words and the question text into the large model, and obtain the reply text output by the large model.

10. An electronic device, characterized in that: The electronic device comprises at least a processor and a memory, and the processor is used to implement the steps of the large model-based question-answering method as claimed in any one of claims 1 to 8 when executing a computer program stored in the memory.