CN117688160A - Question-answer pair construction method and device, electronic equipment and storage medium - Google Patents

Question-answer pair construction method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117688160A
CN117688160A CN202311829388.1A CN202311829388A CN117688160A CN 117688160 A CN117688160 A CN 117688160A CN 202311829388 A CN202311829388 A CN 202311829388A CN 117688160 A CN117688160 A CN 117688160A
Authority
CN
China
Prior art keywords
question
answer
text
prompt
answer pair
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311829388.1A
Other languages
Chinese (zh)
Inventor
李锐
郭思敏
梅林海
刘权
王士进
刘聪
胡国平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
iFlytek Co Ltd
Original Assignee
iFlytek Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by iFlytek Co Ltd filed Critical iFlytek Co Ltd
Priority to CN202311829388.1A priority Critical patent/CN117688160A/en
Publication of CN117688160A publication Critical patent/CN117688160A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a question-answer pair construction method, a question-answer pair construction device, electronic equipment and a storage medium, wherein the method comprises the following steps: acquiring knowledge points and the type of the questions to be asked; constructing a prompt based on knowledge points and question request texts of the question types, wherein the question request texts are used for describing requirements of questions aiming at the knowledge points under the question types; based on the prompt, a question-answer pair is generated, the questions in the question-answer pair belong to the question types, and the answers in the question-answer pair are based on knowledge points. The method, the device, the electronic equipment and the storage medium provided by the invention construct the prompt based on the knowledge points and the question request text of the question type, generate the question-answer pair based on the prompt, and serve as the question-answer pair corresponding to the knowledge points for training a question-answer model, thereby ensuring the high efficiency and low cost of constructing the question-answer pair, further ensuring the quality of the question-answer pair and being beneficial to improving the quality of the question-answer model.

Description

Question-answer pair construction method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of natural language processing technologies, and in particular, to a method and apparatus for constructing question-answer pairs, an electronic device, and a storage medium.
Background
In an intelligent customer service scene, aiming at a user question, knowledge points matched with the user question are required to be determined through a knowledge retrieval model, so that the user question is answered.
The knowledge retrieval model needs to be obtained by training a training party by applying question data and corresponding answers which are provided for specific products of specific companies as training data. The training data are rare, and the time cost and the expense cost for data collection are high due to the limitation of the field professionals.
Disclosure of Invention
The invention provides a question-answer pair construction method, a question-answer pair construction device, electronic equipment and a storage medium, which are used for solving the defect that the question-answer pair in the subdivision field in the prior art is difficult to acquire data.
The invention provides a question-answer pair construction method, which comprises the following steps:
acquiring knowledge points and the type of the questions to be asked;
constructing a prompt based on the knowledge points and question request texts of the question types, wherein the question request texts are used for describing the requirements of questions aiming at the knowledge points under the question types;
and generating a question-answer pair based on the prompt, wherein the questions in the question-answer pair belong to the question type, and the answers in the question-answer pair are based on the knowledge points.
According to the question-answer pair construction method provided by the invention, the construction of the prompt on the basis of the knowledge points and the question request text of the question type comprises the following steps:
and constructing the prompt based on at least one of a background setting text, a task issuing text, an output control text, an example text and a task confirmation text, and the knowledge points and the question request text of the question type.
According to the method for constructing the question-answer pair provided by the invention, the question-answer pair is generated based on the prompt, and the method comprises the following steps:
inputting the prompt into a large language model to obtain an output text of the large language model;
and dividing the question-answer pairs from the output text based on the dividing rule corresponding to the prompt.
According to the question-answer pair construction method provided by the invention, the prompt comprises an abnormal output form when the question-answer pair is abnormal;
the step of dividing the question-answer pair from the output text based on the division rule corresponding to the prompt comprises the following steps:
and dividing the question-answer pairs from the output text based on the division rule corresponding to the abnormal output form.
According to the question-answer pair construction method provided by the invention, the knowledge points are contained in the task confirmation text.
According to the question-answer pair construction method provided by the invention, the example text comprises the example questions belonging to the question type.
According to the question-answer pair construction method provided by the invention, the knowledge points are obtained based on hierarchical title division in the product document.
The invention also provides a question-answer pair construction device, which comprises:
the acquisition unit is used for acquiring knowledge points and the types of questions to be asked;
the prompt unit is used for constructing a prompt based on the knowledge points and the question request text of the question type, wherein the question request text is used for describing the requirement of asking for the knowledge points under the question type;
and the generating unit is used for generating question-answer pairs based on the prompt, wherein the questions in the question-answer pairs belong to the question types, and the answers in the question-answer pairs are based on the knowledge points.
The invention also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor realizes the question-answer pair construction method according to any one of the above when executing the program.
The present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a question-answer pair construction method as described in any one of the above.
The invention also provides a computer program product comprising a computer program which when executed by a processor implements a question-answer pair construction method as described in any one of the above.
According to the question-answer pair construction method, the question-answer pair construction device, the electronic equipment and the storage medium, the prompt is constructed based on the knowledge points and the question-answer requirement text of the question type, the question-answer pair is generated based on the prompt and used for training the question-answer model, the high efficiency and low cost of the construction of the question-answer pair are guaranteed, the application of the question-answer requirement text in the prompt is further guaranteed, the quality of the question-answer pair is further guaranteed, and the quality of the question-answer model is improved.
Drawings
In order to more clearly illustrate the invention or the technical solutions of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are some embodiments of the invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a question-answer pair construction method provided by the invention;
FIG. 2 is a second flow chart of the method for constructing question-answer pairs provided by the invention;
FIG. 3 is a schematic diagram of a construction device of question-answer pairs provided by the invention;
fig. 4 is a schematic structural diagram of an electronic device provided by the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In an intelligent customer service scene, aiming at a user question, knowledge points matched with the user question are required to be determined through a knowledge retrieval model, so that the user question is answered. For example, in the intelligent customer service scenario of an insurance company, a user question is usually developed for an insurance product pushed by the insurance company, so when developing a knowledge retrieval model, question-answer data related to the insurance product pushed by the insurance company needs to be used as training data.
The training data are very rare, limited by the field expertise. At present, in order to acquire training data, a common mode is to manually construct questions or mine user question data in an online interaction system, and then manually mark knowledge points capable of answering the user questions, so that the construction of question-answer pairs is realized.
The manual construction problem requires high labor cost and consumes long time; the data of the on-line interactive system is extremely large, so that the data at the on-line interactive system is mined, higher labor cost and time cost are also required, and the quality of the data obtained by mining cannot be guaranteed.
Aiming at the problems, the embodiment of the invention provides a question-answer pair construction method. FIG. 1 is a schematic flow chart of a method for constructing question-answer pairs, as shown in FIG. 1, the method includes:
step 110, obtain knowledge points, and the type of question to be asked.
The knowledge points herein, i.e. the knowledge points required for constructing question-answer pairs, may specifically be knowledge points on which the answers in the question-answer pairs are expected to be constructed. For a certain product in a certain field or a certain company, the knowledge points may be extracted from a knowledge base in a certain field or may be extracted from a product specification of a certain product, which is not particularly limited in the embodiment of the present invention. It will be appreciated that the knowledge points may be one or more, and for each knowledge point, question-answer pairs corresponding to the knowledge point may be generated.
The question type, i.e., the type to which the question in the question-answer pair is expected to be constructed. It will be appreciated that for a certain field or a certain product of a certain company, user questions may be generalized into a plurality of common question types, so that questions closer to practical applications can be generated when a subsequent question-answer pair is constructed. Also, the type of questions to be asked may be different in different fields or for different products.
Taking the insurance product customer service field as an example, common problem types can include four types of "query term content", "generalized theory", "query knowledge point details", and "context description". Where "query term content" refers to content that directly queries for insurance product terms, an exemplary question may be "what is XX insurance assurance content? "; "generalized speaking" refers to a way of asking questions that do not directly relate to a product, and an exemplary question may be "do a luminaire become worn, can claim? "; "query knowledge point details" refers to a detailed question of knowledge points of insurance products, and an exemplary question may be "is XX insurance claim asthma? "; "context description" refers to a problem that the user posed after describing his own context, an exemplary problem may be "I'm own healthy, but My insurance buys a drug for a certain illness to the family, which affects claims? ".
And step 120, constructing a prompt based on the knowledge points and question requirement texts of the question types, wherein the question requirement texts are used for describing requirements of questions aiming at the knowledge points under the question types.
Specifically, after determining the knowledge points and question types for constructing question-answer pairs, a prompt may be constructed based on both. The prompt is taken as a prompt input by a large language model, and the prompt can comprise knowledge points and question type question requirement texts, and can also comprise a requirement description facing the large language model, wherein the requirement description is used for explaining the requirement of generating question and answer pairs based on the knowledge points and the question requirement texts.
The question request text is set for a question type, that is, different question types correspond to different question request texts, and specific requirements of questions for knowledge points under the question type generated can be described in the question request text for the question type. For example, for the question type of "inquiring knowledge point details", the question request text may be "start with the detail topic, mine specific information in the document, including specific conditions such as date, task, place, event, etc., and then form a specific question", so that when a large language model generates a question, the question request text may start with the detail topic, mine specific information to form a question "inquiring knowledge point details"; for another example, for the question type of "context description," the question requirement text may be "not only question and direct facts, but also include inferred or predicted behavior. Bearing in mind that the actual situation and possible scenarios should be considered in advance to generate questions "that are insight and various hypothetical situations, requiring that large language models be able to generate questions that include a hypothetical situation that complies with the" context description "when generating the questions.
In addition, the question request text may further include a question request common to each question type, for example, the question request text may include the following contents for each question type:
"ensure that the generated question must be specific, unambiguous, and that the offered insurance clause can answer, the question is very definite;
ensuring that each question generated has its product name;
the mouth kiss questioning of insurance clients is ensured, so that the requirements of Chinese mouth language characteristics are met, daily dialogue scenes are attached, and repeated sentence patterns are avoided;
each problem is independent, and no reference and inheritance relationships occur;
after the question-answer pair is extracted, the question is reviewed, so that the question is clear, and an accurate answer can be found in the document. If you do not answer the question in I'm provided document, then ' no answer ' "is written in the answer.
And 130, generating a question-answer pair based on the prompt, wherein the questions in the question-answer pair belong to the question type, and the answers in the question-answer pair are based on the knowledge points.
Specifically, after obtaining the prompt containing the knowledge points and the question request text, the prompt can be input into a large language model to generate and output question-answer pairs through the large language model.
The large language model (Large Language Model, LLM) refers to a natural language processing model, such as a star fire cognition large model, which uses a large-scale corpus to perform self-supervision learning in the pre-training process, with a huge number of parameters. In specific applications, the pre-trained large language model may be directly applied to generate the question-answer pair, or the pre-trained large language model may be applied to generate the question-answer pair after the sample question-answer pair is subjected to supervised fine tuning, which is not particularly limited in the embodiment of the present invention.
Because the prompt carries knowledge points and question request texts set for the question types, the large language model can apply the knowledge points and the question request texts in the prompt when generating question and answer, thereby determining that the questions in the generated question and answer pair can meet the requirements described by the question request texts, the questions in the generated question and answer pair belong to the question types, and the answers in the generated question and answer pair are based on the knowledge points.
According to the method provided by the embodiment of the invention, the prompt is constructed based on the knowledge points and the question request text of the question type, and the question-answer pair is generated based on the prompt and used for training the question-answer model, so that the construction efficiency and low cost of the question-answer pair are ensured, the application of the question request text in the prompt is further ensured, the quality of the question-answer pair is further ensured, and the quality of the question-answer model is improved.
Based on the above embodiment, step 120 includes:
and constructing the prompt based on at least one of a background setting text, a task issuing text, an output control text, an example text and a task confirmation text, and the knowledge points and the question request text of the question type.
Specifically, in constructing the prompt, the prompt may be applied to at least one of a background setting text, a task issuing text, an output control text, an example text, and a task confirmation text, in addition to a question request text applied to a knowledge point and a question type.
The background setting text is used for describing background setting of the prompt, and characters required to be substituted by the large language model are usually provided in the background setting text, for example, in the field of customer service of insurance products, the background setting text can be "you are common users consulting insurance related problems," you do not know basic information and insurance general knowledge of the insurance, and a question of related information needs to be asked. By carrying the background setting text in the prompt, the large language model can be immersed in the role provided by the background setting text when the question and answer pair is generated, the feeling of being in the scene is provided, and the generation effect of the question and answer pair can be improved.
The task issuing text is used for describing the task for generating the question-answer pair so as to realize task issuing aiming at the large-scale language model. For example, in the field of insurance product clients, the task issuing text may be "please generate 5 question-answer pairs containing questions and answers according to the insurance clause text provided by me".
The output control text is used to describe a particular form of output for which the large language model is desired, so that the large language model can be output based on the output form described by the output control text. For example, in the field of insurance product customer service, the output control text may be "each question-answer correspondence is written on two lines independently, first a question, and the beginning indicates a 'question' + sequence number, the next line is an answer, and the beginning indicates a 'answer' + sequence number".
Example text is used to provide text that is an example of the output of a large language model as an output reference for the large language model. For example, in the area of insurance product customer service, an example text may be presented in the form:
"I would give you 3 samples, and reference sample pair generated question-answer pairs for the final text.
Sample 1:
insurance clause: product description of XX insurance: description of investment account case: robust revenue investment account: asset configuration scope: liquidity asset: mainly comprises cash, money market fund, bank demand deposit and bank notice deposit
Problems: what are the liquidity assets within my XX insurance products?
Answer: the liquidity assets are cash, money market funds, bank demand deposit and bank notice deposit
Sample 2: … …; sample 3: … …).
The task confirmation text is used for describing tasks to be executed by the large language model and prompting information to be confirmed when the large language model executes the tasks. For example, in the field of insurance product customer service, the task validation text may be "please now perform the task, generate 5 questions and answers according to the given insurance clause, remit again, ensure that the generated questions must be answerable by the provided insurance clause, ensure that each generated question has its product name of insurance: the insurance clause text is as follows: … …).
In the embodiment of the invention, when the prompt is generated, besides the knowledge points and the question request text, at least one of a background setting text, a task issuing text, an output control text, an example text and a task confirmation text can be applied, so that the generated prompt can prompt the knowledge points of the large-scale language model, which are required to be applied when the question and answer pair are generated, and the specific requirements when the questions are generated, and can help the large-scale language model to substitute roles, define tasks, give out output forms, provide output references and clearly execute the tasks to ensure the information required to be confirmed, thereby further improving the reliability of generating the question and answer pair based on the large-scale language model and ensuring the generation quality of the question and answer pair.
Based on any of the above embodiments, step 130 includes:
inputting the prompt into a large language model to obtain an output text of the large language model;
and dividing the question-answer pairs from the output text based on the dividing rule corresponding to the prompt.
Specifically, after the prompt is obtained, the prompt is input into a large language model, question-answer pairs are generated for the prompt by the large language model, and output text including the generated question-answer pairs is output.
Considering that the output text of the large language model may contain a plurality of question-answer pairs, and the output text may also contain an abnormality, for example, the case that the question generated by the large language model cannot be answered based on knowledge points. Therefore, after the output text is obtained, it is also necessary to divide the output text so as to obtain the question-answer pairs contained in the output text.
Here, the segmentation of the output text may be achieved by a segmentation rule, where the segmentation rule corresponds to the prompt, and further, the segmentation rule corresponds to the description of the output format in the prompt. For example, in the prompt, the output control text "each question-answer pair is independently written on two lines, first a question, and the beginning indicates a 'question' + sequence number, the next line is an answer, and in the case where the beginning indicates a 'answer' + sequence number", the corresponding division rule may be to perform character matching on each line head, determine whether the line head is a "question" or a "answer", and form two lines of text into a question-answer pair based on the sequence numbers after the "question" and the "answer".
According to the method provided by the embodiment of the invention, the output text of the large language model is segmented based on the segmentation rule corresponding to the prompt so as to obtain the question-answer pair, so that the automatic question-answer pair cleaning is realized, and the construction efficiency of the question-answer pair is improved.
Based on any of the above embodiments, the prompt includes an abnormal output form when the question-answer pair is abnormal.
Specifically, the prompt may include an output form of the generated question-answer pair when there is an abnormality, which is referred to herein as an abnormal output form. In order to enable the large language model to output according to an abnormal output form when the generated question-answer pair is abnormal, the description of the question-answer pair with the abnormality and the description of the abnormal output form can be written into prompt.
For example, "if a question you generate cannot answer in a document i provide," a prompt may be written to the answer that "cannot answer'" where the document is a knowledge point, "a question generated cannot answer in a document i provide" means that a question generated by a large language model cannot answer on the basis of the knowledge point, i.e., a description of the presence of an abnormality for the generated question-answer. "write 'no answer'" in answer, i.e., abnormal output form, is used to constrain the form of output text in such abnormal situations.
Accordingly, in step 130, the segmenting the question-answer pair from the output text based on the segmentation rule corresponding to the prompt includes:
and dividing the question-answer pairs from the output text based on the division rule corresponding to the abnormal output form.
Specifically, for the abnormal output form carried in the prompt, a corresponding segmentation rule can be set, so that the abnormal output form in the output text can be identified in the process of segmenting the question-answer pairs from the output text, the normal question-answer pairs in the output text are distinguished from the text in the abnormal output form, and the situation that the text in the abnormal output form in the output text is mistakenly identified as the question-answer pairs is avoided.
Under the situation, based on the segmentation rules corresponding to the abnormal output form, the text under the normal question-answer pair and the text under the abnormal output form can be distinguished from the output text, and respectively segmented, wherein the normal question-answer pair is directly used as training data of the question-answer model, and the text under the abnormal output form is manually processed and then used as training data of the question-answer model;
or, based on the segmentation rule corresponding to the abnormal output form, the text in the abnormal output form and the normal question-answer pair can be distinguished from the output text, and the normal question-answer pair is segmented from the output text and used as training data of the question-answer model, which is not particularly limited in the embodiment of the invention.
According to the method provided by the embodiment of the invention, the question-answer pairs are segmented from the output text based on the segmentation rules corresponding to the abnormal output form, namely, the data cleaning is realized while the question-answer pairs are acquired, and the acquisition efficiency of the question-answer pairs is effectively improved.
Based on any of the above embodiments, the knowledge points are included in the task validation script.
Specifically, in the generating process of the prompt, knowledge points can be contained in the task confirmation text, so that the task confirmation text brings out knowledge points which need to be applied in the generating of the question-answer pair by the large language model in the process of describing the question-answer pair to be executed by the large language model, and the large language model can better understand the execution logic of the question-answer pair generating task, and thus the question-answer pair generating task can be better executed.
For example, in the field of insurance product customer service, the task validation text may carry knowledge points in the form of:
"now please perform the task, generate 5 questions and answers according to the given insurance clause, remind again, ensure that the generated questions must be answerable by the provided insurance clause, ensure that each generated question has its product name of insurance:
the insurance clause text is as follows: … …).
It will be appreciated that the "insurance clause text" therein is as follows: the "following" is the knowledge point in the form of the insurance clause text.
Based on any of the above embodiments, the example text includes an example question belonging to the question type.
Specifically, examples of which the large language model can refer to are generally included in the example text, for example, in a question-answer pair generation task provided by an embodiment of the present invention, examples of which are example question-answer pairs that are close to a question-answer that is expected to be generated.
On the basis, in order to ensure that the question-answer pair generated by the large-scale language model can be more close to expectations, namely, the generated question-answer pair questions belong to the question types, and the answers are based on the knowledge points, the example question-answer pair which is more close to the expectations can be selected from the example text, and the concrete is that the example question in the example question-answer pair is the question which belongs to the question types, so that the large-scale language model can obtain more accurate and more close to the question types of the example questions when outputting references based on the example text in the prompt, and the quality of the generated question-answer pair is improved.
Based on any of the above embodiments, the knowledge points are partitioned based on hierarchical titles in the product document.
Specifically, in order to implement the question-answer model training, knowledge points that may be involved when the user asks based on the question-answer model in a specific scenario need to be determined first. Considering that the knowledge points collected manually may be missed and the knowledge points collected manually may be biased towards subjectivity, the knowledge point extraction is performed based on the product document in the embodiment of the invention.
Here, the product document, that is, the relevant document of the product for which the question-answer model is aimed, may be specifically an introduction document of the product or may be a contract document of the product, which is not specifically limited in the embodiment of the present invention. Considering that the content is divided in the product document usually in the form of a hierarchical title, the hierarchical title can be used as a basis for dividing the knowledge points from the product document, so as to achieve knowledge point acquisition for the product.
Further, the title of the smallest hierarchy in the hierarchy titles can be used as a division granularity, and the text segment under the title of the smallest hierarchy can be used as a knowledge point.
According to the method provided by the embodiment of the invention, the knowledge points are divided by using the hierarchical titles in the product document, so that the comprehensiveness of knowledge point acquisition is ensured, and the knowledge point acquisition efficiency is improved.
Based on any of the above embodiments, fig. 2 is a second schematic flow chart of the method for constructing a question-answer pair provided by the present invention, and as shown in fig. 2, the question-answer pair construction may include the following steps:
first, a knowledge point is determined:
for any industry, documents of products in the industry can be divided according to hierarchical titles, so that knowledge points can be obtained. It is understood that the knowledge points here are text segments in the document.
Secondly, constructing a prompt:
for each knowledge point, a prompt corresponding to the knowledge point can be constructed based on a preset template. Here, the corresponding templates may be different for different fields. The template for generating the prompt may be understood as a splicing template of at least one of a background setting text, a task issuing text, an output control text, an example text, a task confirmation text, and a question request text of a knowledge point and a question type.
For example, the hint thus formed may be:
"you are an ordinary user consulting the insurance related problem, you do not know the basic information and insurance knowledge of the insurance, and need to ask for related information. Please generate 5 question-answer pairs containing questions and answers according to the insurance clause text provided by me.
Each question-answer pair is written on two rows independently, first a question, and the beginning indicates a 'question' + sequence number, the next row is an answer, and the beginning indicates a 'answer' + sequence number.
When generating question-answer pairs, please follow the following requirements:
ensuring that the generated questions must be specific, unambiguous, questions that the offered insurance clauses can answer are well defined.
Ensure that each question generated has its product name.
-ensuring that the insurance customer is asked with a kiss, taking care of conforming to the Chinese spoken language features, conforming to the daily dialogue scene, avoiding the use of repeated sentence patterns;
each question is independent, no references and inheritance relationships occur;
after extracting the question-answer pair, review your question, ensure that the question is clear and an accurate answer can be found in the document. If the question you generate cannot answer in the document I offer, then 'no answer' is written in the answer.
I would give you 3 examples, reference examples to generate question-answer pairs for the final text.
Sample 1:
insurance clause: product description of XX insurance: description of investment account case: robust revenue investment account: asset configuration scope: liquidity asset: mainly comprises cash, money market fund, bank demand deposit and bank notice deposit
Problems: what are the liquidity assets within my XX insurance products?
Answer: the liquidity assets are cash, money market funds, bank demand deposit and bank notice deposit
Sample 2: … …; sample 3: … …
Now please perform the task, generate 5 questions and answers according to the given insurance clause, remind again, ensure that the generated questions must be answerable by the provided insurance clause, ensure that each generated question has its insurance product name: the insurance clause text is as follows: … …'
For each knowledge point, different question types can be oriented, and prompt corresponding to the different question types is generated, wherein the prompt is used for prompting a large language model to ask the knowledge point with which question type, and then an answer pair is generated.
Next, a large model is executed:
the constructed prompt can be input into a large model, namely, a large language model, and the output text of the large language model is obtained by running the large language model.
Subsequently, the question-answer pairs are parsed:
after the output text is obtained, the question-answer pairs in the output text can be obtained by selecting the corresponding regular expression and analyzing according to the definition of the output format in the prompt.
Further, considering that a question-answer pair generated by a large language model has an abnormality, for example, that a generated question cannot be answered based on a knowledge point, such a case is constrained with an abnormal output form in a prompt, for example, a word of "no answer" is output. Therefore, the word eyes of 'unable answer' can be searched from the question-answer pairs obtained by analysis, so that abnormal question-answer pairs are screened out, and data cleaning is realized.
Finally, constructing a training set:
question-answer pairs obtained after the analysis and the cleaning are completed, namely positive examples of the training set. In addition, the negative examples of the training set can be constructed by mixing questions and answers in different question-answer pairs, so that the training set containing both positive examples and negative examples is obtained, and the training set can be used for training a question-answer model. In addition, because the question-answer pair generated by the method is directly associated with the knowledge points carried in the prompt, the corresponding relation between the questions and the knowledge points can be obtained based on the question-answer pair, the questions and the knowledge points with the corresponding relation can be used as positive examples of the training set, the questions and the knowledge points without the corresponding relation are mixed to construct negative examples of the training set, and therefore the training set containing both the positive examples and the negative examples is obtained, and the training set can be used for training a knowledge retrieval model.
Based on any of the above embodiments, fig. 3 is a schematic structural diagram of a device for constructing question-answer pairs provided by the present invention, as shown in fig. 3, where the device includes:
an obtaining unit 310, configured to obtain knowledge points and types of questions to be asked;
a prompt unit 320, configured to construct a prompt based on the knowledge point and a question request text of the question type, where the question request text is used to describe a requirement for asking for the knowledge point under the question type;
and a generating unit 330, configured to generate a question-answer pair based on the prompt, where a question in the question-answer pair belongs to the question type, and an answer in the question-answer pair is based on the knowledge point.
The device provided by the embodiment of the invention constructs the prompt based on the knowledge points and the question request text of the question type, generates the question-answer pair based on the prompt, and is used for training the question-answer model as the question-answer pair corresponding to the knowledge points, thereby ensuring the high efficiency and low cost of the construction of the question-answer pair, further ensuring the quality of the question-answer pair by applying the question request text in the prompt, and being beneficial to improving the quality of the question-answer model.
Based on any of the above embodiments, the prompt unit is specifically configured to:
and constructing the prompt based on at least one of a background setting text, a task issuing text, an output control text, an example text and a task confirmation text, and the knowledge points and the question request text of the question type.
Based on any of the above embodiments, the generating unit is specifically configured to:
inputting the prompt into a large language model to obtain an output text of the large language model;
and dividing the question-answer pairs from the output text based on the dividing rule corresponding to the prompt.
Based on any one of the above embodiments, the prompt includes an abnormal output form when the answer pair is abnormal;
the generating unit is specifically configured to:
and dividing the question-answer pairs from the output text based on the division rule corresponding to the abnormal output form.
Based on any of the above embodiments, the knowledge points are included in the task validation script.
Based on any of the above embodiments, the example text includes an example question belonging to the question type.
Based on any of the above embodiments, the knowledge points are partitioned based on hierarchical titles in the product document.
Fig. 4 illustrates a physical schematic diagram of an electronic device, as shown in fig. 4, which may include: processor 410, communication interface (Communications Interface) 420, memory 430 and communication bus 440, wherein processor 410, communication interface 420 and memory 430 communicate with each other via communication bus 440. Processor 410 may call logic instructions in memory 430 to perform a problem pair construction method comprising: acquiring knowledge points and the type of the questions to be asked; constructing a prompt based on the knowledge points and question request texts of the question types, wherein the question request texts are used for describing the requirements of questions aiming at the knowledge points under the question types; and generating a question-answer pair based on the prompt, wherein the questions in the question-answer pair belong to the question type, and the answers in the question-answer pair are based on the knowledge points.
Further, the logic instructions in the memory 430 described above may be implemented in the form of software functional units and may be stored in a computer-readable storage medium when sold or used as a stand-alone product. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product, where the computer program product includes a computer program, where the computer program can be stored on a non-transitory computer readable storage medium, and when the computer program is executed by a processor, the computer can execute a problem pair construction method provided by the above methods, and the method includes: acquiring knowledge points and the type of the questions to be asked; constructing a prompt based on the knowledge points and question request texts of the question types, wherein the question request texts are used for describing the requirements of questions aiming at the knowledge points under the question types; and generating a question-answer pair based on the prompt, wherein the questions in the question-answer pair belong to the question type, and the answers in the question-answer pair are based on the knowledge points.
In yet another aspect, the present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, is implemented to perform the problem pair construction method provided by the above methods, the method comprising: acquiring knowledge points and the type of the questions to be asked; constructing a prompt based on the knowledge points and question request texts of the question types, wherein the question request texts are used for describing the requirements of questions aiming at the knowledge points under the question types; and generating a question-answer pair based on the prompt, wherein the questions in the question-answer pair belong to the question type, and the answers in the question-answer pair are based on the knowledge points.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. The method for constructing the question-answer pair is characterized by comprising the following steps of:
acquiring knowledge points and the type of the questions to be asked;
constructing a prompt based on the knowledge points and question request texts of the question types, wherein the question request texts are used for describing the requirements of questions aiming at the knowledge points under the question types;
and generating a question-answer pair based on the prompt, wherein the questions in the question-answer pair belong to the question type, and the answers in the question-answer pair are based on the knowledge points.
2. The question-answer pair construction method according to claim 1, wherein the constructing a prompt based on the knowledge points and question request text of the question type includes:
and constructing the prompt based on at least one of a background setting text, a task issuing text, an output control text, an example text and a task confirmation text, and the knowledge points and the question request text of the question type.
3. The method for constructing question-answer pairs according to claim 1 or 2, wherein the generating of question-answer pairs based on the prompt includes:
inputting the prompt into a large language model to obtain an output text of the large language model;
and dividing the question-answer pairs from the output text based on the dividing rule corresponding to the prompt.
4. A method of constructing a question-answer pair according to claim 3, wherein the prompt includes an abnormal output form when the question-answer pair is abnormal;
the step of dividing the question-answer pair from the output text based on the division rule corresponding to the prompt comprises the following steps:
and dividing the question-answer pairs from the output text based on the division rule corresponding to the abnormal output form.
5. The question-answer pair construction method according to claim 2, characterized in that the knowledge points are contained in the task confirmation text.
6. The question-answer pair construction method according to claim 2, wherein the example text includes an example question belonging to the question type.
7. The method of claim 1 or 2, wherein the knowledge points are partitioned based on hierarchical titles in the product document.
8. A question-answer pair construction device, comprising:
the acquisition unit is used for acquiring knowledge points and the types of questions to be asked;
the prompt unit is used for constructing a prompt based on the knowledge points and the question request text of the question type, wherein the question request text is used for describing the requirement of asking for the knowledge points under the question type;
and the generating unit is used for generating question-answer pairs based on the prompt, wherein the questions in the question-answer pairs belong to the question types, and the answers in the question-answer pairs are based on the knowledge points.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the question-answer pair construction method of any one of claims 1 to 7 when the program is executed by the processor.
10. A non-transitory computer readable storage medium having stored thereon a computer program, wherein the computer program when executed by a processor implements the question-answer pair construction method of any one of claims 1 to 7.
CN202311829388.1A 2023-12-26 2023-12-26 Question-answer pair construction method and device, electronic equipment and storage medium Pending CN117688160A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311829388.1A CN117688160A (en) 2023-12-26 2023-12-26 Question-answer pair construction method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311829388.1A CN117688160A (en) 2023-12-26 2023-12-26 Question-answer pair construction method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117688160A true CN117688160A (en) 2024-03-12

Family

ID=90130182

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311829388.1A Pending CN117688160A (en) 2023-12-26 2023-12-26 Question-answer pair construction method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117688160A (en)

Similar Documents

Publication Publication Date Title
EP3144822A1 (en) Tagging text snippets
CN112070138B (en) Construction method of multi-label mixed classification model, news classification method and system
CN113268610B (en) Intent jump method, device, equipment and storage medium based on knowledge graph
US20160283876A1 (en) System and method for providing automomous contextual information life cycle management
CN111930914A (en) Question generation method and device, electronic equipment and computer-readable storage medium
CN112347226A (en) Document knowledge extraction method and device, computer equipment and readable storage medium
Alhassan et al. A novel framework for Arabic dialect chatbot using machine learning
CN117033571A (en) Knowledge question-answering system construction method and system
CN112434501A (en) Work order intelligent generation method and device, electronic equipment and medium
CN111831810A (en) Intelligent question and answer method, device, equipment and storage medium
CN116010569A (en) Online answering method, system, electronic equipment and storage medium
CN117520503A (en) Financial customer service dialogue generation method, device, equipment and medium based on LLM model
CN116798428A (en) Large language intelligent model system based on private domain management
CN112328812B (en) Domain knowledge extraction method and system based on self-adjusting parameters and electronic equipment
CN117688160A (en) Question-answer pair construction method and device, electronic equipment and storage medium
CN110851572A (en) Session labeling method and device, storage medium and electronic equipment
US20210350088A1 (en) Systems and methods for digital document generation using natural language interaction
CN114118937A (en) Information recommendation method and device based on task, electronic equipment and storage medium
CN113870998A (en) Interrogation method, device, electronic equipment and storage medium
Srinivasan Chatbot application for tourism using natural language tool kit
CN113868419B (en) Text classification method, device, equipment and medium based on artificial intelligence
CN117522485B (en) Advertisement recommendation method, device, equipment and computer readable storage medium
Alhassan et al. Research Article A Novel Framework for Arabic Dialect Chatbot Using Machine Learning
CN113886553A (en) Text generation method, device, equipment and storage medium
CN117827804A (en) Thread generation method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination