Question and answer data generation method and device based on large model, equipment and medium

By determining the target document segment that matches the question to be answered in the intelligent question answering system, and generating the reply information in the large model, using keywords and topic similarity verification, the problem of insufficient accuracy of the reply information generated by the intelligent question answering system is solved. Greater accuracy and professionalism achieved.

CN118551002APending Publication Date: 2024-08-27HISENSE GRP HLDG CO LTD

Patent Information

Application Number
CN202410538009.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-30
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

Existing intelligent question answering systems lack accuracy when generating response information to questions to be answered. Especially when facing highly professional or time-sensitive questions, limited model learning knowledge leads to incorrect or inaccurate generated response information.

Method used

By determining the target document segment that matches the question to be answered among the pre-saved document segments, the question to be answered, the target document segment and the prompt text are input into the large model to generate reply information, and the keywords in the reply information are matched with the subject of the target document segment. When the similarity is greater than the threshold, the reply information is determined to be the target answer, achieving double guarantee.

Benefits of technology

It improves the accuracy of question and answer data generation, ensures the professionalism and accuracy of response information, and generates more accurate answers by carefully collecting relevant documents and utilizing the powerful analysis capabilities of large language models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118551002A
    Figure CN118551002A
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, in particular to a question and answer data generation method and device based on a large model, equipment and a medium. Determining a target document segment matched with the to-be-answered question in pre-stored document segments, and inputting the to-be-answered question, the target document segment and the first prompt text into a first large model according to a preset format, so that the first large model analyzes the target document segment according to the first prompt text, and the to-be-answered question is answered according to the content recorded in the target document segment. And determining reply information of the to-be-replied question, so that the first large model performs more professional reply on the to-be-replied question based on the target document segment. And verification is carried out based on the similarity between the keyword in the reply information and the theme of the target document segment, so that the accuracy of generating the reply information of the to-be-replied question is further improved, and dual assurance of question and answer data generation is realized.
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 method, device, equipment and medium for generating question and answer data based on a large model. Background Art

[0002] With the development of artificial intelligence, the application of intelligent question and answer is becoming more and more extensive, the requirements for intelligent question and answer are becoming higher and higher, and the questions asked by users are becoming more professional.

[0003] Therefore, how to accurately generate answer information for questions to be answered becomes an urgent problem to be solved. Summary of the invention

[0004] The embodiments of the present application provide a method, apparatus, device and medium for generating question and answer data based on a large model, so as to improve the accuracy of generating answer information for questions to be answered.

[0005] In a first aspect, the present application provides a method for generating question-answer data based on a large model, the method comprising:

[0006] Determine a target document segment that matches the question to be answered from among the pre-saved document segments;

[0007] Inputting the unanswered question, the target document segment and the first prompt text into the first large model in a preset format to obtain answer information, wherein the first prompt text is used to prompt the first large model to output the answer information of the unanswered question based on the analysis of the target document segment;

[0008] Determining keywords in the reply information and the subject of the target document segment;

[0009] When the similarity between the keyword and the topic is greater than a first preset threshold, the reply information is determined to be a target answer to the question to be answered.

[0010] In a second aspect, the present application provides a device for generating question and answer data based on a large model, the device comprising:

[0011] A determination module, used for determining a target document segment matching the question to be answered from among the pre-saved document segments;

[0012] A generation module, used for inputting the question to be answered, the target document segment and the first prompt text into the first large model according to a preset format to obtain answer information, wherein the first prompt text is used to prompt the first large model to output the answer information of the question to be answered based on the analysis of the target document segment;

[0013] The determination module is also used to determine the keywords in the reply information and the subject of the target document segment; when the similarity between the keywords and the subject is greater than a first preset threshold, the reply information is determined to be the target answer to the question to be answered.

[0014] In a third aspect, the present application also provides an electronic device, comprising a processor, wherein the processor is used to implement the steps of any of the above-mentioned methods for generating question and answer data based on a large model when executing a computer program stored in a memory.

[0015] In a fourth aspect, the present application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the above-mentioned methods for generating question and answer data based on a large model.

[0016] In the embodiment of the present application, a target document segment matching the question to be answered is determined in the pre-saved document segment, and the question to be answered, the target document segment and the first prompt text are input into the first large model according to a preset format, so that the first large model analyzes the target document segment according to the first prompt text, thereby determining the answer information of the question to be answered according to the content recorded in the target document segment, and when the similarity between the keywords in the answer information and the subject of the target document segment is greater than a first preset threshold, the answer information output by the first large model is determined to be the target answer to the question to be answered. In other words, the target document segment matching the question to be answered is determined so that the first large model can give a more professional answer to the question to be answered based on the target document segment, and then the answer information is verified based on the similarity to further improve the accuracy of generating the answer information of the question to be answered, thereby achieving a double guarantee for the generation of question and answer data. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] 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.

[0018] Figure 1 A schematic diagram of a process of generating question and answer data based on a large model provided in an embodiment of the present application;

[0019] Figure 2 A schematic diagram of determining reply information provided in an embodiment of the present application;

[0020] Figure 3 A schematic diagram of a large model-based question-answer data generation process provided in an embodiment of the present application;

[0021] Figure 4 A schematic diagram of question and answer data generation provided in an embodiment of the present application;

[0022] Figure 5 A schematic diagram of the structure of a large model-based question and answer data generation device provided in an embodiment of the present application;

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

[0024] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the embodiment of the present application will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiment is only a part of the embodiment of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field belong to the scope of protection of this application.

[0025] The embodiments of the present application provide a method, apparatus, device and medium for generating question and answer data based on a large model. In the method, a target document segment matching the question to be answered in a pre-saved document segment is determined; the question to be answered, the target document segment and a first prompt text are input into the first large model in a preset format to obtain answer information, wherein the first prompt text is used to prompt the first large model to output the answer information of the question to be answered based on the analysis of the target document segment; keywords in the answer information and the subject of the target document segment are determined; and when the similarity between the keywords and the subject is greater than a first preset threshold, the answer information is determined to be the target answer to the question to be answered.

[0026] Figure 1 A flowchart of a large model-based question-answer data generation process provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the process includes the following steps:

[0027] S101: Determine a target document segment that matches the question to be answered in pre-saved document segments.

[0028] The large model-based question and answer data generation method provided in the present application is applied to an electronic device, which may be a PC, a mobile terminal, a server, etc.

[0029] In the field of question-answering technology, for some highly professional or time-sensitive questions, in the process of using the model for question-answering, it is likely that due to the limited knowledge learned by the model, erroneous or inaccurate answer information will be generated. Since the developers of the fields involved in intelligent question-answering are known in advance, in the embodiment of the present application, in order to accurately determine the answer information of the questions to be answered, the relevant documents of the fields involved can be collected and saved in advance. In order to facilitate the subsequent determination of the target document segment that matches the questions to be answered, in the embodiment of the present application, after any document is collected, the document can be pre-processed, such as format conversion, data cleaning, data extraction, etc. Format conversion can be understood as converting all documents into a unified format. Specifically, the documents collected are generally in PDF and doc formats, and the format conversion program can be used to complete the conversion of the document format, and the format can be uniformly converted into txt format. Data cleaning can be understood as deleting some useless parts of the document, such as deleting the cover of the document, disclaimer, etc. Data extraction can be understood as extracting relevant information in the document to facilitate the subsequent generation of answer information for questions to be answered. For example, feature extraction is performed on the document, such as determining the feature matrix of the document, and then when generating the reply information, the similarity comparison of the feature matrix is ​​performed.

[0030] In an embodiment of the present application, after acquiring any document, in order to facilitate processing by an electronic device, the document in text form may be converted into a vector matrix, that is, the document may be encoded to obtain a vector matrix format that can be understood by the electronic device.

[0031] Since each document is relatively long, in order to facilitate subsequent search for target document segments that match the question to be answered, each document can be segmented to obtain multiple document segments and save them.

[0032] In a possible implementation, any document may be segmented according to a fixed size. In an embodiment of the present application, the number of words included in each document segment may be predefined, and when the document is segmented, the document may be segmented according to the number.

[0033] In a possible implementation, when a document is segmented according to a predetermined number of characters, in order to ensure that the semantic context is not lost between document segments, in an embodiment of the present application, there may be partial overlap between adjacent document segments. That is, the first few characters of a document segment may be the last few characters of the adjacent previous document segment.

[0034] Splitting a document according to a predetermined number of characters can greatly reduce the amount of calculation of an electronic device, and does not require the use of any natural language processing (NLP) library, and is easy to use.

[0035] In one possible implementation, any document can be segmented using an open source library function. For example, the Natural Language Toolkit (NLTK) of the Python library is used for segmentation. NLTK is used to process human language data, and it provides a sentence tagger that can segment documents into sentences to help create more meaningful document segments. For another example, the spaCy library can be used for segmentation. spaCy is a powerful Python library for NLP tasks that provides a complex sentence segmentation function that can effectively segment documents into separate sentences, thereby better preserving the semantic information of the context in the generated document segments.

[0036] In a possible implementation, the document may be segmented according to sentences. For example, the document is segmented once each time a period appears.

[0037] In a possible implementation, the document may be segmented according to natural segments, that is, each natural segment in any document is regarded as a document segment.

[0038] When generating question-and-answer data based on a large model, a target document segment that matches the question to be answered can be determined in a pre-saved document segment. The question to be answered can be input by a user of an electronic device or sent to the electronic device by other electronic devices, and the embodiments of the present application are not limited to this. Exemplarily, the question to be answered can be "What are the principles for determining the degree of disability caused by human injuries?" The target document segment that matches the question to be answered can be one or more.

[0039] When determining the target document segment that matches the question to be answered, a search may be performed based on similarity. For example, the target document segment may be retrieved using methods such as Euclidean distance, Manhattan distance, and cosine similarity. Exemplarily, the similarity between the question to be answered and each saved document segment may be calculated, and the document segment with a similarity greater than a preset similarity threshold may be determined as the target document segment. Keywords in the question to be answered may also be extracted, and the document segments containing the keywords in the saved document segments may all be determined as the target document segments.

[0040] S102: Input the question to be answered, the target document segment and the first prompt text into the first large model according to a preset format to obtain answer information, wherein the first prompt text is used to prompt the first large model to output answer information of the question to be answered based on the analysis of the target document segment.

[0041] After the target document segment is determined, in order to determine the answer information of the question to be answered based on the determined target document segment, in an embodiment of the present application, the question to be answered, the target document segment and the first prompt text can be input into the first large model according to a preset format to obtain the answer information. Among them, the first prompt text is used to prompt the first large model to output the answer information of the question to be answered based on the analysis of the target document segment. That is to say, based on its own powerful language analysis ability, after receiving the input question to be answered, the target document segment and the first prompt text, the first large model performs corresponding processing operations on the target document segment according to the processing content required in the first prompt text, thereby outputting the answer information of the question to be answered.

[0042] In the embodiment of the present application, the "big model" can be understood as a model based on the transformer architecture; the "big model" can also be understood as a machine learning model with a huge parameter scale and complexity, for example, a neural network model with millions to billions of parameters or tens of billions of parameters; the "big model" can also be understood as a deep learning model trained on large-scale training data through semi-(weak) supervision, full supervision, self-supervision or unsupervised techniques. In the embodiment of the present application, the "big model" can handle a variety of different tasks. When training the "big model", it is generally trained based on the training data of a certain target task field. The "big model" obtained by training can generally be migrated to other task fields similar to the target task field for use. In the embodiment of the present application, the first big model can be any big language model, that is, any big language model with language analysis capabilities can be used as the first big model, such as the Wenxinyiyan model.

[0043] S103: Determine the keywords in the reply information and the subject of the target document segment.

[0044] Although large models have powerful language analysis capabilities, they often have problems with inaccurate analysis. For example, the question to be answered asks about content A, while the output answer information is about content B. Therefore, in order to improve the accuracy of question and answer data generation, in an embodiment of the present application, after obtaining the answer information, the correlation between the answer information and the question to be answered can be verified. In an embodiment of the present application, the keywords in the answer information and the subject of the target document segment can be determined. Exemplarily, a pre-trained extraction model can be used to extract the keywords in the answer information and the subject of the target document segment, respectively.

[0045] S104: When the similarity between the keyword and the topic is greater than a first preset threshold, determining that the reply information is a target answer to the question to be answered.

[0046] After determining the keywords in the reply information and the subject of the target document segment, the similarity between the keywords and the subject can be determined. When the similarity is greater than a first preset threshold, the reply information output by the first large model is determined to be the target answer to the question to be answered.

[0047] Since the determined target document segment can be one or more, the determined topic may also be one or more. In an embodiment of the present application, when the determined target document segment is one, the similarity between the keyword and the topic of the target document segment can be directly determined. When the determined target document segment is multiple, the similarity between the keyword and each topic can be determined separately, and then the average similarity is determined based on each similarity, and then based on the size relationship between the average similarity and the first preset threshold, it is determined whether the reply information is the target answer to the question to be answered. When the determined target document segment is multiple, the topic of each target document segment can also be spliced ​​in sequence, and then the features of the spliced ​​topics are extracted to obtain the topic feature vector, and then the similarity between the keyword feature vector and the topic feature vector is determined, and then based on the size relationship between the similarity and the first preset threshold, it is determined whether the reply information is the target answer to the question to be answered.

[0048] The embodiment of the present application makes full use of the role of the large language model to generate answers based on all carefully collected relevant documents and questions to be answered, thereby improving the accuracy of question and answer data generation.

[0049] In the embodiment of the present application, a target document segment matching the question to be answered is determined in the pre-saved document segment, and the question to be answered, the target document segment and the first prompt text are input into the first large model according to a preset format, so that the first large model analyzes the target document segment according to the first prompt text, thereby determining the answer information of the question to be answered according to the content recorded in the target document segment, and when the similarity between the keywords in the answer information and the subject of the target document segment is greater than a first preset threshold, the answer information output by the first large model is determined to be the target answer to the question to be answered. In other words, the target document segment matching the question to be answered is determined so that the first large model can give a more professional answer to the question to be answered based on the target document segment, and then the answer information is verified based on the similarity to further improve the accuracy of generating the answer information of the question to be answered, thereby achieving a double guarantee for the generation of question and answer data.

[0050] In order to further improve the accuracy of question-answer data generation, based on the above embodiment, in the embodiment of the present application, after determining the target document segment that matches the question to be answered in the pre-saved document segment, and before inputting the question to be answered, the target document segment and the first prompt text into the first large model according to a preset format, the method further includes:

[0051] If the similarity between the target document segment and the question to be answered is greater than a second preset threshold, then continue to execute the subsequent step of inputting the question to be answered, the target document segment and the first prompt text into the first large model according to a preset format;

[0052] If the similarity between the target document segment and the question to be answered is not greater than the second preset threshold, the target document segment is deleted, and a target document segment matching the question to be answered is determined based on a preset reselection strategy.

[0053] If an incorrect target document segment is input to the first large model, the first large model will not be able to output the correct answer information. Therefore, in order to further improve the accuracy of question and answer data generation, in an embodiment of the present application, after determining the target document segment that matches the question to be answered, before inputting the target document segment into the first large model, the similarity between the target document segment and the question to be answered can also be determined, thereby determining whether to determine the answer information based on the target document segment based on the relationship between the similarity and the second preset threshold. It should be noted that if the target document segment that matches the question to be answered in the pre-saved document segment is determined based on the similarity, then when determining the similarity between the target document segment and the question to be answered, the similarity determination method used should be different from the method used to determine the target document segment that matches the question to be answered.

[0054] If it is determined that the similarity between the target document segment and the question to be answered is greater than the second preset threshold, it means that the determined target document segment is relatively accurate, and the subsequent steps of inputting the question to be answered, the target document segment and the first prompt text into the first large model according to the preset format can be continued.

[0055] If it is determined that the similarity between the target document segment and the question to be answered is not greater than the second preset threshold, it means that the determined target document segment is not very accurate and cannot pass the secondary verification. Therefore, the determined target document segment can be deleted, and the target document segment matching the question to be answered can be determined based on the preset reselection strategy. For example, the target document segment to be deleted and the question to be answered are input into the large model, and the large model selects the target document segment most relevant to the question to be answered.

[0056] When there are multiple target document segments determined, these target document segments may have different relevance to the user's query. Some target document segments may be very relevant, while other target document segments may be only slightly relevant or even irrelevant. In an embodiment of the present application, the target document segments whose similarity is not greater than the second preset threshold can be deleted, and the remaining target document segments can be retained. In other words, the reselection strategy at this time is to determine the remaining target document segments greater than the second preset threshold as the target document segments that match the question to be answered.

[0057] In order to further improve the accuracy of question and answer data generation, based on the above embodiments, in the embodiment of the present application, the target document segment matching the question to be answered based on the preset reselection strategy includes:

[0058] Determine, based on the re-ranking model, a target document segment in the pre-saved document segments that matches the question to be answered; or,

[0059] The Internet is searched for a target document segment matching the question to be answered.

[0060] In a possible implementation, when determining the target document segment that matches the question to be answered based on a preset reselection strategy, the target document segment that matches the question to be answered in the pre-saved document segment can be determined based on the reranking model. The reranking model can fully consider the interaction characteristics between the target document segment and the question to be answered to more accurately evaluate their relevance. The reranking model improves the result of semantic sorting by reranking the candidate document list according to the semantic matching degree with the question to be answered. The principle is to calculate the relevance score between the user's question and each given candidate document, and return a list of documents sorted from high to low by relevance. The documents in the document list are the target document segments. Common reranking models include: Cohere's rerank model, bge-re-ranker model, etc.

[0061] In a possible implementation, the target document segment matching the question to be answered is searched on the Internet. If the similarity between the target document segment and the question to be answered is not greater than the second preset threshold, it means that the pre-saved document segment may not involve the content of the question to be answered. Therefore, in the embodiment of the present application, when determining the target document segment matching the question to be answered based on the preset reselection strategy, the target document segment matching the question to be answered can be searched on the Internet.

[0062] Specifically, the relevant target document segments may be directly searched based on the question to be answered, or keywords of the question to be answered may be extracted and the target document segments corresponding to the keywords may be searched on the Internet.

[0063] In order to further improve the accuracy of question and answer data generation, based on the above embodiments, in the embodiment of the present application, after obtaining the reply information and before determining the keywords in the reply information, the method further includes:

[0064] Inputting the unanswered question, the answer information and the second prompt text into the second large model according to a preset format to obtain polished answer information, wherein the second prompt text is used to prompt the second large model to polish the answer information according to the unanswered question;

[0065] The polishing reply information is updated to the reply information.

[0066] Since some target document segments include relatively large amounts of content, and there may be multiple target document segments determined to match the questions to be answered, there may be more redundant information in the reply information made by the first largest model based on more reference document segments. Therefore, in order to obtain accurate reply information and improve the accuracy of question and answer data generation, in an embodiment of the present application, after obtaining the reply information output by the first largest model, before determining the keywords in the reply information, the reply information may also be polished to obtain more accurate and refined reply information.

[0067] In an embodiment of the present application, the second largest model can be used to polish the reply information output by the first largest model. The second largest model can be any language model, which can be the same as the first largest model or different from the first largest model. In an embodiment of the present application, the question to be answered, the reply information and the second prompt text can be input into the second largest model according to a preset format to obtain the polished reply information. The second prompt text is used to prompt the second largest model to polish the reply information according to the question to be answered. Polishing can be understood as appropriate rewriting of the reply information to make the reply information more fluent and reasonable, and can also be understood as abbreviation of the reply information, refining the reply information without changing the semantics, etc.

[0068] After obtaining the polishing reply information output by the second largest model, the polishing reply information can be updated to reply information, and subsequent processing can be performed based on the updated reply information.

[0069] The process of determining the reply information is described below with reference to a specific embodiment. Figure 2 A schematic diagram of determining reply information provided in an embodiment of the present application is as follows: Figure 2As shown, a question to be answered is received. The question to be answered can be query information input by a user, for example, the user requires the generation of an answer to the question "What is the principle for determining the degree of disability caused by human injury?" A retriever is used to retrieve K document segments related to "the principle for determining the degree of disability caused by human injury", and the document segment is a target document segment. An evaluator is used to evaluate the relevance score between the question to be answered and each target document segment, and the relevance score can be determined based on the similarity. Specifically, a Euclidean distance similarity calculation method can be used. Euclidean distance is a commonly used distance definition, which refers to the real distance between two points in an n-dimensional space. Euclidean distance is the most commonly used distance calculation formula, which measures the absolute distance between each point in a multidimensional space. When the data is dense and continuous, this is a good calculation method. When Euclidean distance is used to represent similarity, the following formula is generally used for conversion: the smaller the distance, the greater the similarity. The relevance score of the document is obtained by Euclidean distance calculation, and the smaller the Euclidean distance, the higher the relevance score. In an embodiment of the present application, the corresponding relationship between the Euclidean distance and the relevance score can be pre-configured, and the relevance score can be determined by the corresponding relationship after the Euclidean distance is determined. If the relevance score is higher than the threshold, the corresponding target document segment is determined to be relevant, and then the question to be answered, the target document segment and the first prompt text are input into the first large model to obtain the answer information. The answer information is polished using the second large model to obtain the polished answer information, which can be used as the answer to the question to be answered. If the relevance score after evaluation is lower than the threshold, the corresponding target document segment is determined to be irrelevant, and these document segments are discarded.

[0070] In order to further improve the accuracy of question and answer data generation, based on the above embodiments, in the embodiment of the present application, determining the keywords in the reply information includes:

[0071] The reply information and the third prompt text are input into the third largest model according to a preset format to obtain the keywords, and the third prompt text is used to prompt the third largest model to extract the keywords included in the reply information.

[0072] In an embodiment of the present application, when determining the keywords in the reply information, a large model can be used for determination. Specifically, the reply information and the third prompt text can be input into the third large model according to a preset format to obtain the keywords. The third large model can be any large language model, and the third large model can be the same as the first large model and the second large model, or different, and the embodiment of the present application does not limit this. The third prompt text is input into the third large model to prompt the third large model to extract the keywords included in the reply information.

[0073] In order to further improve the accuracy of question-answer data generation, based on the above embodiments, in the embodiment of the present application, determining the subject of the target document segment includes:

[0074] Based on the topic extraction model, the topic of the target document segment is determined.

[0075] In an embodiment of the present application, when determining the theme of a target document segment, the theme of the target document can be determined based on a theme extraction model. The theme extraction model can be any model with theme extraction capability, and the embodiment of the present application does not limit this. Exemplarily, the theme extraction model can be a Latent Dirichlet Allocation (LDA) model. How to extract document themes based on an LDA model is a prior art, and the embodiment of the present application will not repeat the process of extracting the theme of a target document segment by LDA.

[0076] In order to further improve the accuracy of question and answer data generation, based on the above embodiments, in the embodiment of the present application, the question to be answered, the target document segment and the first prompt text are input into the first large model according to a preset format to obtain the answer information, including:

[0077] If the number of characters included in the target document segment is greater than a preset word count threshold, the target document segment is divided into a plurality of sub-document segments, and the number of characters included in any sub-document segment is not greater than the preset word count threshold;

[0078] For each sub-document segment, input the question to be answered, the sub-document segment and the first prompt text into the first large model to obtain candidate answer information;

[0079] The candidate answer information corresponding to each sub-document segment is fused using the first large model to obtain the answer information.

[0080] Since the input length of the large model is limited, in order to further improve the accuracy of question and answer data generation, in the embodiment of the present application, when the question to be answered, the target document segment and the first prompt text are input into the first large model according to the preset format and the answer information is obtained, it can be determined whether the number of characters included in the target document exceeds the limit of the preset word count threshold. In other words, before the target document segment is input into the first large model, it is determined whether the input data of the first large model exceeds the word count limit.

[0081] If it is determined that the number of characters included in the target document segment input into the first large model is greater than the preset word count threshold, it can be determined that the input data of the first large model is too long, and the target document segment can be segmented into multiple sub-document segments, and the number of characters included in any sub-document segment is not greater than the preset word count threshold. Specifically, a segmentation word count can be pre-configured, and the segmentation word count is less than the preset word count threshold. When it is determined that the target document segment needs to be segmented, the target document segment can be segmented according to the segmentation word count.

[0082] When each sub-document segment is obtained by segmentation, the question to be answered, the sub-document segment and the first prompt text can be input into the first large model for each sub-document segment to obtain candidate answer information. In other words, each sub-document segment is analyzed using the first large model to determine candidate answer information based on the content recorded in each sub-document segment.

[0083] After obtaining each candidate answer information, each candidate answer information can be merged to determine the answer information of the question to be answered. In the embodiment of the present application, the first large model can be used to merge the candidate answer information corresponding to each sub-document segment to obtain the answer information.

[0084] Specifically, the prompt text and each candidate answer information can be input into the first large model, so that the first large model analyzes the candidate answers based on the prompt text to obtain the answer information. The prompt text can be "Please analyze the semantics of the following paragraphs of text, and merge the paragraphs of text according to the analysis results, and output a coherent answer information."

[0085] It should be noted that the present application does not limit the prompt text input into the large model in the above embodiments, and technicians in this field can configure appropriate prompt text as needed.

[0086] In the process of fine-tuning a large model, a high-quality data set plays a vital role. A high-quality data set can provide the model with rich and comprehensive information, which helps the model to better understand and learn the characteristics and laws of the data. It can reduce the risk of overfitting of the model and improve the generalization ability of the model, so that the model can be more stable and reliable in practical applications. Therefore, when fine-tuning a large model, selecting and preparing a high-quality data set is a crucial step, which can directly affect the performance and effect of the model. In the fine-tuning process of the knowledge question and answer model, if the knowledge question and answer data set is all manually labeled and generated, it will take a huge amount of manpower and material resources. In general, traditional data annotation and text enhancement methods have the problems of low efficiency and low accuracy, and it is difficult to meet the growing data processing needs. Using a large model for data generation and verification can effectively overcome the limitations of traditional methods and improve the quality and efficiency of data processing. The question and answer data generation method based on a large model described in the above embodiments of the present application can be applied to the generation of a training data set for the model. Using a large model to generate a knowledge question and answer data set, there is no need to train the model separately, and the data scale can be quickly expanded to obtain high-quality knowledge question and answer generalization corpus. This method can automatically generate a large number of high-quality question-answer pairs by leveraging the powerful language understanding and generation capabilities of large models, and can also save a lot of training time and resource costs.

[0087] The following is an example of a process for generating question and answer data based on a large model. Figure 3 A schematic diagram of a large model-based question-answer data generation process provided in an embodiment of the present application, the process includes the following steps:

[0088] S301: Receive questions to be answered.

[0089] S302: Retrieve a target document segment matching the question to be answered in the document library.

[0090] S303: Input the question to be answered, the target document segment and the first prompt text into the first large model according to a preset format to obtain answer information.

[0091] S304: Use the first large model to determine keywords in the reply information.

[0092] S305: Call the LDA model to determine the topic of the target document segment.

[0093] S306: Determine the similarity between the keyword and the topic.

[0094] S307: Determine whether the similarity is greater than a first preset threshold, if so, execute S308; if not, execute S309.

[0095] S308: Determine the reply information as the target answer to the question to be answered, and output it according to the set format.

[0096] After the target answer to the question to be answered is determined, the question-target answer pair can be formatted to form a fine-tuning dataset for fine-tuning the model.

[0097] S309: Output the reply information, receive the modified reply information, and execute S308.

[0098] When it is determined that the similarity is not greater than the first preset threshold, the reply information is output so that relevant staff can modify the reply information.

[0099] The method for generating question and answer data based on a large model provided in the embodiment of the present application makes the large model more practical and credible in practical applications. Figure 4 A schematic diagram of question and answer data generation provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, if you directly ask the big model "How do you evaluate the fact that Li Jun, CEO of your AA company, was suddenly fired and then reinstated in just a few days?" Due to the limitations of the pre-training data and the lack of knowledge of recent events, the big model indicates that it cannot answer. Based on the big model-based question and answer data generation method provided in the embodiment of the present application, this gap can be solved by retrieving the latest document excerpts from the Internet. That is to say, after obtaining the question to be answered of the user's inquiry, the Internet is searched for the target document segment that matches the question to be answered. For example, some bloggers' commentary articles or news articles on the question to be answered on the Internet are retrieved. Subsequently, the commentary article can be used as the target document segment, and the question to be answered, the target document segment and the first prompt text are combined and input into the first big model, so that the big model determines the reply information based on the received target document segment. In the embodiment of the present application, a series of news articles related to the inquiry are obtained. These articles, together with the original question, are then merged into a rich prompt, allowing the first big model to synthesize a well-founded response. Retrieving relevant information from a broad document database and then using that information to guide the generation process greatly improves the accuracy and relevance of the content, effectively alleviates the hallucination problem, increases the speed of knowledge updating, and enhances the traceability of content generation.

[0100] Based on the same inventive concept, the embodiment of the present application also provides a question-answer data generation device based on a large model, Figure 5 A schematic diagram of the structure of a large model-based question-answer data generation device provided in an embodiment of the present application, the device comprising:

[0101] A determination module 501 is used to determine a target document segment that matches the question to be answered in the pre-saved document segments;

[0102] A generating module 502, configured to input the question to be answered, the target document segment and the first prompt text into the first large model in a preset format to obtain answer information, wherein the first prompt text is used to prompt the first large model to output answer information of the question to be answered based on the analysis of the target document segment;

[0103] The determination module 501 is also used to determine the keywords in the reply information and the subject of the target document segment; when the similarity between the keywords and the subject is greater than a first preset threshold, the reply information is determined to be the target answer to the question to be answered.

[0104] In a possible implementation, the generating module 502 is specifically configured to continue to execute the subsequent step of inputting the question to be answered, the target document segment and the first prompt text into the first large model according to a preset format if the similarity between the target document segment and the question to be answered is greater than a second preset threshold;

[0105] The determination module 501 is specifically used to delete the target document segment if the similarity between the target document segment and the question to be answered is not greater than the second preset threshold, and determine the target document segment matching the question to be answered based on a preset reselection strategy.

[0106] In a possible implementation, the determination module 501 is specifically used to determine the target document segment that matches the question to be answered in the pre-saved document segments based on the re-ranking model; or, to search the Internet for the target document segment that matches the question to be answered.

[0107] In a possible implementation, the generation module 502 is also used to input the question to be answered, the answer information and the second prompt text into the second large model according to a preset format to obtain polished answer information, and the second prompt text is used to prompt the second large model to polish the answer information according to the question to be answered; and update the polished answer information to the answer information.

[0108] In a possible implementation, the determination module 501 is specifically used to input the reply information and the third prompt text into the third largest model according to a preset format to obtain the keywords, and the third prompt text is used to prompt the third largest model to extract the keywords included in the reply information.

[0109] In a possible implementation, the determination module 501 is specifically configured to determine the topic of the target document segment based on a topic extraction model.

[0110] In one possible implementation, the generation module 502 is specifically used to divide the target document segment into multiple sub-document segments if the number of characters included in the target document segment is greater than a preset word count threshold, and the number of characters included in any sub-document segment is not greater than the preset word count threshold; for each sub-document segment, input the question to be answered, the sub-document segment and the first prompt text into the first large model to obtain candidate answer information; and use the first large model to merge the candidate answer information corresponding to each sub-document segment to obtain the answer information.

[0111] Based on the same inventive concept, an embodiment of the present application further 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 6 As 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;

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

[0113] Determine a target document segment that matches the question to be answered from among the pre-saved document segments;

[0114] Inputting the unanswered question, the target document segment and the first prompt text into the first large model in a preset format to obtain answer information, wherein the first prompt text is used to prompt the first large model to output the answer information of the unanswered question based on the analysis of the target document segment;

[0115] Determining keywords in the reply information and the subject of the target document segment;

[0116] When the similarity between the keyword and the topic is greater than a first preset threshold, the reply information is determined to be a target answer to the question to be answered.

[0117] In a possible implementation, the processor 601 is further configured to: if the similarity between the target document segment and the question to be answered is greater than a second preset threshold, continue to execute a subsequent step of inputting the question to be answered, the target document segment and the first prompt text into the first large model according to a preset format;

[0118] If the similarity between the target document segment and the question to be answered is not greater than the second preset threshold, the target document segment is deleted, and a target document segment matching the question to be answered is determined based on a preset reselection strategy.

[0119] In a possible implementation manner, the processor 601 is further configured to: determine, based on the reordering model, a target document segment in the pre-saved document segments that matches the question to be answered; or,

[0120] The Internet is searched for a target document segment matching the question to be answered.

[0121] In a possible implementation manner, the processor 601 is further configured to: input the unanswered question, the answer information, and the second prompt text into the second large model according to a preset format to obtain polished answer information, wherein the second prompt text is used to prompt the second large model to polish the answer information according to the unanswered question;

[0122] The polishing reply information is updated to the reply information.

[0123] In a possible implementation, the processor 601 is also used to: input the reply information and the third prompt text into the third largest model according to a preset format to obtain the keywords, and the third prompt text is used to prompt the third largest model to extract the keywords included in the reply information.

[0124] In a possible implementation, the processor 601 is further configured to: determine the topic of the target document segment based on a topic extraction model.

[0125] In a possible implementation, the processor 601 is further configured to: if the number of characters included in the target document segment is greater than a preset word count threshold, divide the target document segment into a plurality of sub-document segments, and the number of characters included in any sub-document segment is not greater than the preset word count threshold;

[0126] For each sub-document segment, input the question to be answered, the sub-document segment and the first prompt text into the first large model to obtain candidate answer information;

[0127] The candidate answer information corresponding to each sub-document segment is fused using the first large model to obtain the answer information.

[0128] 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 can include a random access memory (RAM) and can also include a non-volatile memory (NVM), such as at least one disk storage. Optionally, the memory can also be at least one storage device located away from the aforementioned processor.

[0129] 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.

[0130] 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:

[0131] Determine a target document segment that matches the question to be answered from among the pre-saved document segments;

[0132] Inputting the unanswered question, the target document segment and the first prompt text into the first large model in a preset format to obtain answer information, wherein the first prompt text is used to prompt the first large model to output the answer information of the unanswered question based on the analysis of the target document segment;

[0133] Determining keywords in the reply information and the subject of the target document segment;

[0134] When the similarity between the keyword and the topic is greater than a first preset threshold, the reply information is determined to be a target answer to the question to be answered.

[0135] In a possible implementation, after determining the target document segment that matches the question to be answered in the pre-saved document segment, and before inputting the question to be answered, the target document segment, and the first prompt text into the first large model according to a preset format, the method further includes:

[0136] If the similarity between the target document segment and the question to be answered is greater than a second preset threshold, then continue to execute the subsequent step of inputting the question to be answered, the target document segment and the first prompt text into the first large model according to a preset format;

[0137] If the similarity between the target document segment and the question to be answered is not greater than the second preset threshold, the target document segment is deleted, and a target document segment matching the question to be answered is determined based on a preset reselection strategy.

[0138] In a possible implementation manner, determining the target document segment matching the question to be answered based on a preset reselection strategy includes:

[0139] Determine, based on the re-ranking model, a target document segment in the pre-saved document segments that matches the question to be answered; or,

[0140] The Internet is searched for a target document segment matching the question to be answered.

[0141] In a possible implementation manner, after obtaining the reply information and before determining the keywords in the reply information, the method further includes:

[0142] Inputting the unanswered question, the answer information and the second prompt text into the second large model according to a preset format to obtain polished answer information, wherein the second prompt text is used to prompt the second large model to polish the answer information according to the unanswered question;

[0143] The polishing reply information is updated to the reply information.

[0144] In a possible implementation manner, determining the keywords in the reply information includes:

[0145] The reply information and the third prompt text are input into the third largest model according to a preset format to obtain the keywords, and the third prompt text is used to prompt the third largest model to extract the keywords included in the reply information.

[0146] In a possible implementation, determining the subject of the target document segment includes:

[0147] Based on the topic extraction model, the topic of the target document segment is determined.

[0148] In a possible implementation manner, the step of inputting the question to be answered, the target document segment, and the first prompt text into the first large model in a preset format to obtain answer information includes:

[0149] If the number of characters included in the target document segment is greater than a preset word count threshold, the target document segment is divided into a plurality of sub-document segments, and the number of characters included in any sub-document segment is not greater than the preset word count threshold;

[0150] For each sub-document segment, input the question to be answered, the sub-document segment and the first prompt text into the first large model to obtain candidate answer information;

[0151] The candidate answer information corresponding to each sub-document segment is fused using the first large model to obtain the answer information.

[0152] 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.

[0153] 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.

[0154] 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.

[0155] 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.

[0156] 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 method for generating question-answer data based on a large model, characterized in that: The method comprises: Determine a target document segment that matches the question to be answered from among the pre-saved document segments; Inputting the unanswered question, the target document segment and the first prompt text into the first large model in a preset format to obtain answer information, wherein the first prompt text is used to prompt the first large model to output the answer information of the unanswered question based on the analysis of the target document segment; Determining keywords in the reply information and the subject of the target document segment; When the similarity between the keyword and the topic is greater than a first preset threshold, the reply information is determined to be a target answer to the question to be answered.

2. The method according to claim 1, characterized in that After determining the target document segment that matches the question to be answered in the pre-saved document segment, and before inputting the question to be answered, the target document segment and the first prompt text into the first large model according to a preset format, the method further includes: If the similarity between the target document segment and the question to be answered is greater than a second preset threshold, then continue to execute the subsequent step of inputting the question to be answered, the target document segment and the first prompt text into the first large model according to a preset format; If the similarity between the target document segment and the question to be answered is not greater than the second preset threshold, the target document segment is deleted, and a target document segment matching the question to be answered is determined based on a preset reselection strategy.

3. The method according to claim 2, characterized in that The step of determining the target document segment matching the question to be answered based on a preset reselection strategy includes: Determine, based on the re-ranking model, a target document segment in the pre-saved document segments that matches the question to be answered; or, The Internet is searched for a target document segment matching the question to be answered.

4. The method according to claim 1, characterized in that: After obtaining the reply information and before determining the keywords in the reply information, the method further includes: Inputting the unanswered question, the answer information and the second prompt text into the second large model according to a preset format to obtain polished answer information, wherein the second prompt text is used to prompt the second large model to polish the answer information according to the unanswered question; The polishing reply information is updated to the reply information.

5. The method according to claim 1, characterized in that The determining of the keywords in the reply information includes: The reply information and the third prompt text are input into the third largest model according to a preset format to obtain the keywords, and the third prompt text is used to prompt the third largest model to extract the keywords included in the reply information.

6. The method according to claim 1, characterized in that Determining the subject of the target document segment includes: Based on the topic extraction model, the topic of the target document segment is determined.

7. The method according to claim 1, characterized in that The step of inputting the question to be answered, the target document segment and the first prompt text into the first large model according to a preset format to obtain answer information includes: If the number of characters included in the target document segment is greater than a preset word count threshold, the target document segment is divided into a plurality of sub-document segments, and the number of characters included in any sub-document segment is not greater than the preset word count threshold; For each sub-document segment, input the question to be answered, the sub-document segment and the first prompt text into the first large model to obtain candidate answer information; The candidate answer information corresponding to each sub-document segment is fused using the first large model to obtain the answer information.

8. A device for generating question-answer data based on a large model, characterized in that: The device comprises: A determination module, used for determining a target document segment matching the question to be answered from among the pre-saved document segments; A generation module, used for inputting the question to be answered, the target document segment and the first prompt text into the first large model according to a preset format to obtain answer information, wherein the first prompt text is used to prompt the first large model to output the answer information of the question to be answered based on the analysis of the target document segment; The determination module is also used to determine the keywords in the reply information and the subject of the target document segment; when the similarity between the keywords and the subject is greater than a first preset threshold, the reply information is determined to be the target answer to the question to be answered.

9. An electronic device, characterized in that: The electronic device includes a processor, and the processor is used to implement the steps of the method for generating question and answer data based on a large model as described in any one of claims 1 to 7 when executing a computer program stored in a memory.

10. A computer-readable storage medium, characterized in that: It stores a computer program, which, when executed by a processor, implements the steps of the method for generating question and answer data based on a large model as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Online customer service response system and method

    CN107784051A

  • Information extraction method based on machine reading understanding and related equipment thereof

    CN111814466A

  • Artificial intelligence interaction method and device, electronic equipment and storage medium

    CN117194634A

  • Autonomous intelligent calculation method and system for biomedical data mining and medium

    CN117457226A

  • Intelligent document implementation method and device based on large model, equipment and medium

    CN117573857A

Cited By

  • Training data set generation method and device, equipment, medium and product

    CN120541175A