CN117828041A - Method, device, equipment and medium for generating reply corpus based on large model - Google Patents

Method, device, equipment and medium for generating reply corpus based on large model Download PDF

Info

Publication number
CN117828041A
CN117828041A CN202311630585.0A CN202311630585A CN117828041A CN 117828041 A CN117828041 A CN 117828041A CN 202311630585 A CN202311630585 A CN 202311630585A CN 117828041 A CN117828041 A CN 117828041A
Authority
CN
China
Prior art keywords
statement
large model
template
target
prompting
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
CN202311630585.0A
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.)
Hisense Group Holding Co Ltd
Original Assignee
Hisense Group Holding 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 Hisense Group Holding Co Ltd filed Critical Hisense Group Holding Co Ltd
Priority to CN202311630585.0A priority Critical patent/CN117828041A/en
Publication of CN117828041A publication Critical patent/CN117828041A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • G06F40/35Discourse or dialogue representation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Mathematical Physics (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present disclosure relates to the field of natural language processing technologies, and in particular, to a method, an apparatus, a device, and a medium for generating a reply corpus based on a large model. In the embodiment of the application, the electronic device adds the missing first slot information to the target SQL statement of the problem statement according to the SQL statement template corresponding to the target intention of the problem statement; generating a complete question sentence according to the supplemented and completed target SQL sentence, and determining a first answer according to the target SQL sentence; and generating a reply corpus through a large model according to the updated question sentences and the first answer, so that the accuracy, reliability, robustness and generalization of the reply corpus generation are improved.

Description

Method, device, equipment and medium for generating reply corpus based on large model
Technical Field
The present disclosure relates to the field of natural language processing technologies, and in particular, to a method, an apparatus, a device, and a medium for generating a reply corpus based on a large model.
Background
In the question-and-answer scenario, since the fields of the database are fixed, this results in the format of each intended structured query language (Structured Query Language, SQL) statement being fixed as well.
In the practical application process, the problem sentences are affected by the personalized habits of users, and the problem sentences are strong in generalization and often lack of slot position information. In order to accurately reply, in the prior art, missing slot information is obtained in a prompting mode, the obtained slot information is added into a problem sentence, so that the problem sentence is complete, an SQL sentence is obtained based on the complete problem sentence, and a reply corpus is generated.
However, due to the flexibility of question sentences, adding missing slot information to question sentences easily causes deviation or even error between the added questions and the actual meaning of users, and further causes low accuracy of the generated reply corpus.
Disclosure of Invention
The application provides a method, a device, equipment and a medium for generating reply corpus based on a large model, which are used for solving the problems that in the prior art, the added problem is easily caused to deviate or even be wrong with the actual meaning of a user by adding missing slot position information to a problem statement, and the generated reply corpus is poor in effect and low in accuracy.
In a first aspect, an embodiment of the present application provides a method for generating a reply corpus based on a large model, where the method includes:
Inputting a problem statement to be replied into a large model, and acquiring a target intention and a target SQL statement of the problem statement output by the large model;
if the first supplementary slot information is received, acquiring a pre-stored SQL statement template corresponding to the target intention, and adding the first slot information into the target SQL statement according to the position information of the first slot information in the SQL statement template;
determining a first answer corresponding to the question statement according to the added target SQL statement, and updating the question statement according to the added target SQL statement;
and inputting the updated question sentences and the first answers into the large model to obtain a first reply corpus output by the large model.
In a second aspect, an embodiment of the present application further provides a corpus generating device based on a large model, where the device includes:
the processing module is used for inputting the problem statement to be replied into the large model and acquiring the target intention and the target SQL statement of the problem statement output by the large model;
the supplementing module is used for acquiring a pre-stored SQL statement template corresponding to the target intention if the supplementing first slot information is received, and adding the first slot information into the target SQL statement according to the position information of the first slot information in the SQL statement template;
The processing module is further used for determining a first answer corresponding to the question statement according to the added target SQL statement, and updating the question statement according to the added target SQL statement;
and the generation module is used for inputting the updated question sentences and the first answers into the large model to acquire a first reply corpus output by the large model.
In a third aspect, an embodiment of the present application provides an electronic device, where the electronic device includes a processor, where the processor is configured to implement, when executing a computer program stored in a memory, the steps of any one of the large model-based corpus generating methods described above.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium storing a computer program, which when executed by a processor, implements the steps of a large model-based corpus generation method as described in any one of the above.
In the embodiment of the application, the electronic equipment inputs a problem statement to be replied into a large model, and obtains a target intention and a target SQL statement of the problem statement output by the large model; if the first supplementary slot information is received, acquiring a pre-stored SQL statement template corresponding to the target intention, and adding the first slot information into the target SQL statement according to the position information of the first slot information in the SQL statement template; determining a first answer corresponding to the question statement according to the added target SQL statement, and updating the question statement according to the added target SQL statement; and inputting the updated question sentences and the first answers into the large model to obtain a first reply corpus output by the large model. That is, in the embodiment of the present application, the electronic device is an SQL statement template corresponding to the target intention of the question statement, and adds the missing first slot information to the target SQL statement of the question statement; generating a complete question sentence according to the supplemented and completed target SQL sentence, and determining a first answer according to the target SQL sentence; and generating a reply corpus through a large model according to the updated question sentences and the first answer, so that the accuracy, reliability, robustness and generalization of the reply corpus generation are improved.
Drawings
In order to more clearly illustrate the technical solutions of the present application, the drawings that are needed in the description of the embodiments will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic diagram of a large model-based corpus reply generation process according to an embodiment of the present application;
fig. 2 is a flowchart of generating a reply corpus according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a question answering device according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the present application more apparent, the present application will be described in further detail below with reference to the accompanying drawings, wherein it is apparent that the described embodiments are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
The existing reply corpus generation method is mainly based on a rule template generation method, namely, a template is set according to the intention of a question sentence, the template comprises the position of each piece of slot information and the position of an answer of the question sentence in the template, and the electronic equipment can obtain the reply corpus only by filling the slot information carried in the question sentence and the answer of the question sentence into the template. The template for recovering the corpus is fixed and poor in adaptability, a special template needs to be formulated for supporting according to special conditions, and otherwise, the generated corpus recovering effect is not good.
For example, the query rank reply corpus template is: the ranking of "/x (time)/x (location)/x (index) in"/x (location range) is the "th x (ranking)". The question sentence of the normal question index is "what rank the sum value produced in the Qingdao city of 2022 is in Shandong province", and for the question sentence, the reply corpus generated based on the reply corpus template is: "the rank of the sum of production in the Qingdao city of 2022 in Shandong province is first". However, when the question statement is: when "what rank the sum of production values is in the Shandong province" in the Qingdao city of 2021-2022, the reply corpus determined by the electronic device is: "the rank of the sum of production values in the Qingdao city of 2021 in Shandong province is first, and the rank of the sum of production values in the Qingdao city of 2022 in Shandong province is first".
That is, for the complex problem, the reply corpus generated by the electronic device according to the reply corpus template is simply listed, when the time or place information is more, the generated reply corpus is too long, and the key information cannot be omitted. The corpus to be generated is as follows: "Tsingtao city production total value ranks first in 2021 and 2022 in Shandong province. The sum of production in the Qingdao city of "or" 2021 and 2022 is first ranked in Shandong province. ". In addition, there are cases where the reply corpus is imperfect when there is no information in the sentence, such as: the region of 2021 is used for producing the region with the top three ranks, the region is lack of a place range in the sentence, when the Qingdao city needs to be supplemented, the supplementation in the original sentence is difficult, the supplementation is needed to be customized where, and the workload is large.
Based on the above, in order to improve accuracy of reply corpus generation, the embodiment of the application provides a reply corpus generation method, device, equipment and medium based on a large model.
In the embodiment of the application, the electronic equipment inputs a problem statement to be replied into a large model, and obtains a target intention and a target SQL statement of the problem statement output by the large model; if the first supplementary slot information is received, acquiring a pre-stored SQL statement template corresponding to the target intention, and adding the first slot information into the target SQL statement according to the position information of the first slot information in the SQL statement template; determining a first answer corresponding to the question statement according to the added target SQL statement, and updating the question statement according to the added target SQL statement; and inputting the updated question sentences and the first answers into the large model to obtain a first reply corpus output by the large model.
It should be noted that, in the embodiment of the present application, a "large model" may be understood as a model based on a converter (transducer) architecture; the "large model" may also be understood as a machine learning model with a huge parameter scale and complexity, e.g., a neural network model with millions to billions of parameters or billions of parameters; the "large model" may also be understood as a deep learning model trained on large-scale training data by semi (weakly) supervised, fully supervised, self-supervised or unsupervised techniques. In the embodiment of the application, the large model can process a plurality of different tasks, training is generally performed based on training data of a certain target task field when the large model is trained, and the large model obtained through training can be migrated to other task fields similar to the target task field for use under the general condition. The existing large model shows generalization capability beyond understanding in terms of semantic understanding, and can achieve good generalization effect under the condition of low labeling and even zero labeling.
Fig. 1 is a schematic diagram of a large model-based corpus generating process according to an embodiment of the present application, where the process includes:
S101: inputting the problem statement to be replied into a large model, and acquiring the target intention and the target SQL statement of the problem statement output by the large model.
The reply corpus generation method based on the large model is applied to electronic equipment, and the electronic equipment can be a PC or a server.
The embodiment of the application improves the generation process of the reply corpus, the existing reply corpus needs to set a reply corpus template according to intention, and the groove information extracted from the problem sentences and the answers of the problem sentences are filled into the reply corpus template to obtain the reply corpus. The method has the advantages that the template is fixed, the flexibility is poor when abnormal conditions occur, and the generated reply corpus is not humanized enough. Based on this, in the embodiment of the application, the reply corpus template is not adopted, but the question sentence is converted into the SQL sentence, and then the reply corpus is obtained according to the SQL sentence.
In the embodiment of the application, the electronic device determines a problem statement to be replied, and determines a target intention and a target SQL statement corresponding to the problem statement through a big model.
Specifically, in the embodiment of the application, the electronic device may collect voice information, convert the voice information into text, and use the text as a question sentence; the electronic equipment can also receive the input question text and determine the question text as a question sentence; the electronic device may also receive a reply corpus generation request sent by other devices, and obtain a problem statement from the reply corpus generation request. In addition, the electronic device may obtain the problem statement in other manners, which is not limited herein.
After the electronic device determines the problem statement, the electronic device inputs the problem statement into a large model, and the large model analyzes the problem statement, determines and outputs a target intention and a target SQL statement of the problem statement. The target SQL statement is used for inquiring answers corresponding to the question text in the structural database.
S102: if the first supplementary slot information is received, acquiring a pre-stored SQL statement template corresponding to the target intention, and adding the first slot information into the target SQL statement according to the position information of the first slot information in the SQL statement template.
In the question-answer scenario, the fields in the structural database are fixed, and the format of the corresponding SQL statement for each intention is also fixed. Under the influence of the flexibility of the problem statement, when the problem statement supplements the missing first slot information, it is very important that the first slot information is supplemented at which position in the problem statement can enable the problem statement to be more complete and smooth, and the supplemented unsmooth and even errors directly influence the accuracy of the intention understanding of the problem statement and the effect of generating a reply corpus.
Based on this, in the embodiment of the present application, the electronic device stores each intended SQL statement template, where each SQL statement template includes necessary slot information required for determining an answer corresponding to a question statement of the intended question and location information of each necessary slot information in the SQL statement template.
Specifically, in the embodiment of the present application, the electronic device obtains an intent list corresponding to the structural database, that is, the structural database may be used to provide an answer to an intent in the intent list. For each intent in the intent list, the electronic device receives input of an SQL statement template corresponding to the intent.
After the electronic equipment determines the target intention and the target SQL statement of the problem statement and receives the first supplementary slot information, the electronic equipment acquires a pre-stored SQL statement template corresponding to the target intention according to the target intention. And the electronic equipment adds the first slot information into the target SQL statement according to the position information of the first slot information in the SQL statement template.
Specifically, in the embodiment of the application, the electronic device identifies target necessary slot information corresponding to the first slot information in the necessary slot information included in the SQL statement template, determines the position information of the target necessary slot information in the SQL statement template as the position information of the first slot information in the target SQL statement, and adds the first slot information into the target SQL statement.
S103: determining a first answer corresponding to the question statement according to the added target SQL statement, and updating the question statement according to the added target SQL statement; and inputting the updated question sentences and the first answers into the large model to obtain a first reply corpus output by the large model.
In the embodiment of the application, the content generation capability of the large model is used for replying the corpus problem, and meanwhile, the reverse capability database-to-text (Structured Query Language to Text, sql2 text) from the text-to-database (Text to Structured Query Language, text2 sql) is used, so that the integrity and fluency of the original sentence are supplemented, and the text for supplementing the complete problem is synthesized with the first answer, so that the generated first replying corpus is more friendly and accurate.
Specifically, in the embodiment of the application, the electronic device updates the question statement according to the SQL2text technology and the added target SQL statement. And the electronic equipment determines a first answer corresponding to the question statement according to the added target SQL statement. The electronic device fuses the updated question sentences and the first answers according to the large model to obtain a first reply corpus.
That is, in the embodiment of the present application, the electronic device is an SQL statement template corresponding to the target intention of the question statement, and adds the missing first slot information to the target SQL statement of the question statement; generating a complete question sentence according to the supplemented and completed target SQL sentence, and determining a first answer according to the target SQL sentence; and generating a reply corpus through a large model according to the updated question sentences and the first answers, so that the accuracy of generating the reply corpus is improved.
In order to improve accuracy of generating the reply corpus, in the embodiment of the present application, inputting the problem statement to be replied to the large model includes:
acquiring a first prompt template which is preconfigured and used for prompting a large model to classify intention; the first prompting template comprises a first field of a problem statement to be written and a first prompting word for prompting the big model to classify intention;
writing the problem statement into a first field of the first prompt template, inputting the written first prompt template into the large model, enabling the large model to determine a target intention corresponding to the problem statement according to the first prompt word, and generating an SQL statement according to a second prompt template which is stored in advance and corresponds to the target intention and used for prompting the large model to generate the SQL statement, and generating the target SQL statement; the second prompt template comprises table structure information of a database.
In the embodiment of the application, a first prompt template for prompting the big model to classify the intention and a second prompt template corresponding to each intention and used for prompting the big model to generate an SQL sentence are pre-stored in the electronic equipment. The electronic device can write the problem statement into the first prompt template, and input the first prompt template written with the problem statement into the large model, so that the large model determines the target intention corresponding to the problem statement, calls the second prompt template corresponding to the target intention, and determines the target SQL statement corresponding to the problem statement.
The first prompting template at least comprises a first field of a to-be-written problem statement and a first prompting word for prompting the big model to classify the intention. The second prompting template comprises prompting words for prompting the big model to generate SQL sentences and definition of a database table structure, and can also comprise other requirements for generating the SQL sentences.
Specifically, in the embodiment of the application, the electronic device acquires a first prompt template which is preconfigured and used for prompting the large model to classify the intention; the first prompting template comprises a first field of a problem statement to be written and a first prompting word used for prompting the big model to classify intention. The electronic equipment writes the problem statement into a first field of the first prompt template, and inputs the written first prompt template into the large model, and the large model determines the target intention corresponding to the problem statement. The large model acquires a second prompt template corresponding to the stored target intention, and determines a target SQL statement corresponding to the problem statement according to the second prompt template. The second prompt template contains table structure information of the database.
It should be noted that, in the embodiment of the present application, in the application of the large model, table structure information of the database and the problem statement are input to the large model in a manner of a prompt word, the large model generates a target SQL statement corresponding to the problem statement, and different prompt word templates are set in the large model for problem statements with different intentions.
For example, in the embodiment of the present application, the first prompt word used for prompting the large model to perform intent classification in the first prompt template may be "when the user queries a specific value of a certain index, identify an intent to search for an index value, and call the index value prompt template; when a user queries the top few small places in the big places, the top few intents are identified, and the top few prompt templates are called. The large model can identify the intention of the problem statement according to the first prompt word, and determine the target intention corresponding to the problem statement, and can recall a second prompt template according to the first prompt, namely, different second prompt templates for prompting the large model to generate the target SQL statement are called according to different intentions.
For example, the second hint template corresponding to the query intent may be:
"you are MySQL generation tools that need to provide customers with MySQL statements that can be directly executed, which are generated according to the following table structure definition and examples.
The following is a definition of the database table structure:
table name #: index_info, index information lookup table, fields are as follows:
index_name, string, index name
index_value, int, index value
provice, string, province, fixed value: shandong province
The enumerated values of city, enum, city include Qingdao, jinan, zibo, jujube, east, tobacco stand, weifang, jining, taian, weihai, japanese, linyi, texas, chat, coast, and joze
year, enum, year in terms of year statistics, expressed in integers, enumerated values contain 2021,2022,2023
Month, enum, expressed in terms of months by integers, enumerated values contain 1,2,3,4,5,6,7,8,9,10,11,12
Other requirements for generating SQL:
examples: "
Wherein, "you are MySQL generation tools, which need to provide MySQL statements that can be directly executed to clients, generate MySQL statements" as the first hint words according to the following table structure definition and examples.
In order to improve accuracy of reply corpus generation, in the embodiment of the present application, after obtaining the target intent and the target SQL statement of the problem statement output by the large model, the method further includes:
Acquiring a pre-stored SQL statement template corresponding to the target intention, wherein the SQL statement template carries necessary slot information for replying a problem statement of the target intention and position information of each necessary slot information;
acquiring second slot information contained in the target SQL statement;
determining whether first slot position information which is missing exists or not according to the necessary slot position information and the second slot position information;
if the first slot position information exists, generating and outputting prompt information for prompting the deletion of the first slot position information, and receiving the input first slot position information.
In the embodiment of the application, an SQL sentence template corresponding to each intention is stored in the electronic equipment, and after the electronic equipment receives the target intention and the target SQL sentence output by the big model, the electronic equipment acquires the pre-stored SQL sentence template corresponding to the target intention and determines whether the problem sentence is complete according to the SQL sentence template.
Specifically, in the embodiment of the present application, after the electronic device obtains the target intent and the target SQL statement of the problem statement output by the large model, the electronic device obtains the SQL statement template corresponding to the target intent stored in advance. The electronic device obtains necessary slot information contained in the SQL statement template and obtains second slot information contained in the target SQL statement.
The electronic equipment determines whether first slot position information which is missing exists according to the necessary slot position information and the second slot position information; if the first slot information is available, generating and outputting prompt information for prompting the missing of the first slot information, and receiving the input first slot information.
For example, the question sentence is "what the rank of the total value produced in Qingdao city" and the target SQL sentence output by the large model is: "SELECT FROM (SELECT RANK () OVER (ORDER BY index value DESC) as ranks FROM index _info WHERE index name name= 'region production total value' AND city is not null) t WHERE t.city= 'island city'", the target to which the question statement corresponds is intended to rank the comparisons. The electronic device obtains the pre-stored SQL sentence template corresponding to the target intention, and the target SQL sentence lacks necessary slot information province (provice), year (year) and month (month), so that the electronic device determines that the problem sentence is incomplete, province, year and month are lacking, and the electronic device outputs prompt information for prompting the deletion of the first slot information province, year and the month.
In order to improve accuracy of reply corpus generation, in the embodiment of the present application, based on the above embodiments, determining, according to the added target SQL statement, a first answer corresponding to the question statement includes:
Searching an answer corresponding to the target SQL statement in a pre-stored database according to the target SQL statement;
and determining the answer as a first answer corresponding to the question sentence.
In the embodiment of the application, a database is stored in an electronic device, and after the electronic device obtains a target SQL sentence output by a large model, the electronic device searches an answer corresponding to the target SQL in the pre-stored database and determines the answer as a first answer corresponding to a question sentence.
In order to improve accuracy of reply corpus generation, based on the above embodiments, in the embodiments of the present application, updating the question sentence according to the added target SQL sentence includes:
acquiring a third pre-configured prompt template for prompting the big model to generate a problem statement based on the SQL statement; the third prompting template comprises a second field of the SQL sentence and a third prompting word for prompting the big model to generate a problem sentence based on the SQL sentence;
writing the SQL statement-based generated problem statement into a second field of the third prompt template, and inputting the written third prompt template into the large model;
And determining the output of the large model as an updated target sentence.
Because the SQL sentence template corresponding to each intention is fixed, and the problem sentences of the user are flexible, the addition of missing slot information in the original problem sentences is difficult, such as: "what the ranking of the total value produced in Qingdao city is," the addition range is "Henan province," the time is "2021", and the possible results after the addition are as follows:
1. rank of total value of production in Qingdao city of Henan province in 2021;
2. the urban Qingdao region of the Henan province 2021 ranks what is the total value produced.
The question sentence obtained by adding the slot information is deviated from the actual meaning of the user and even is wrong.
However, the position of the missing slot information in the SQL sentence template is fixed, and the slot information which needs to be supplemented is directly supplemented to the corresponding position without errors. The electronic equipment can update the problem statement based on the supplemented SQL statement to obtain a problem statement with complete slot information supplementation.
Specifically, in the embodiment of the application, a third prompting template for prompting the big model to generate a problem statement based on the SQL statement is stored in the electronic device; the third prompting template comprises a second field of the SQL sentence and a third prompting word for prompting the big model to generate a problem sentence based on the SQL sentence. The electronic equipment writes the problem statement generated based on the SQL statement into a second field of the third prompt template, and inputs the written third prompt template into the large model; the output of the large model is determined as the updated target statement.
Wherein, in the embodiment of the application, the third prompting template may be "
You are a text generation tool that needs to convert MySQL statements into user question text, which is generated from the following table structure definitions and examples.
The following is a definition of the database table structure:
table name #: index_info, index information lookup table, fields are as follows:
index_name, string, index name
index_value, int, index value
provice, string, province, fixed value: shandong province
The enumerated values of city, enum, city include Qingdao, jinan, zibo, jujube, east, tobacco stand, weifang, jining, taian, weihai, japanese, linyi, texas, chat, coast, and joze
year, enum, year in terms of year statistics, expressed in integers, enumerated values contain 2021,2022,2023
Month, enum, expressed in terms of months by integers, enumerated values contain 1,2,3,4,5,6,7,8,9,10,11,12
Other requirements for generating text:
in order to improve accuracy of reply corpus generation, based on the foregoing embodiments, in the embodiment of the present application, inputting the updated question sentence and the first answer into the large model includes:
Acquiring a fourth prompting template which is preconfigured and used for prompting the large model to generate a reply corpus; the fourth prompting template comprises a third field of a problem statement to be written, a fourth field of a reply statement to be written and a fourth prompting word for prompting the large model to generate a reply corpus;
writing the updated problem statement into a third field of the fourth prompting template, and writing the first reply statement into a fourth field of the fourth prompting template;
and inputting a fourth prompt template for writing completion into the large model.
In this embodiment of the present application, after determining an updated question sentence and a first answer, the electronic device adds the updated question sentence and the first answer to the fourth prompt template, and inputs the added fourth prompt template to the large model.
Specifically, in the embodiment of the present application, the electronic device writes the updated problem statement into the third field of the fourth alert template, writes the first reply statement into the fourth field of the fourth alert template, and inputs the written fourth alert template into the big model. And the large model fuses the updated problem statement and the first reply statement together according to a fourth prompt word contained in the fourth prompt template to obtain a first reply corpus.
In order to improve accuracy of generating the reply corpus, based on the foregoing embodiments, in this embodiment of the present application, if there is no missing first slot information, the method further includes:
determining a second answer corresponding to the question statement according to the target SQL statement;
and inputting the question sentences and the second answers into the large model to obtain a second reply corpus output by the large model.
In the embodiment of the application, if the electronic device determines that the missing first slot information does not exist in the question sentence, that is, the electronic device determines that the question sentence is complete, the electronic device determines a second answer corresponding to the question sentence according to a target SQL sentence corresponding to the question sentence output by the large model.
The electronic equipment inputs the question sentence and the second answer into the large model, and obtains a second reply corpus output by the large model.
In this embodiment of the present application, the electronic device may fuse the question sentence and the second answer according to the large model to obtain the second reply corpus, so that the obtained second reply corpus is simple and accurate.
It should be noted that, in the embodiment of the present application, the process that the electronic device inputs the question sentence and the second answer into the large model and obtains the second reply corpus output by the large model is consistent with the process that the updated question sentence and the first answer of the electronic device are input into the large model and obtain the second reply corpus output by the large model in the above embodiment, and will not be described herein.
Fig. 2 is a flowchart of generating a reply corpus according to an embodiment of the present application, where, as shown in fig. 2, the process includes:
s201: acquiring a first prompt template which is preconfigured and used for prompting a large model to classify intention; the first prompting template comprises a first field to be written into a problem statement and a first prompting word for prompting the big model to classify the intention.
S202: writing the problem statement into a first field of a first prompt template, inputting the written first prompt template into a large model, enabling the large model to determine a target intention corresponding to the problem statement according to a first prompt word, and generating an SQL statement according to a second prompt template which is corresponding to a pre-stored target intention and used for prompting the large model to generate the SQL statement.
S203: acquiring a pre-stored SQL statement template corresponding to the target intention, wherein the SQL statement template carries necessary slot information for replying a problem statement of the target intention and position information of each necessary slot information; and obtaining second slot information contained in the target SQL statement.
S204: judging whether first slot position information which is missing exists or not according to the necessary slot position information and the second slot position information; if so, S205 is executed, and if not, S209 is executed.
S205: and generating and outputting prompt information for prompting the missing of the first slot position information, and receiving the input first slot position information.
S206: if the first slot information is received, acquiring a pre-stored SQL statement template corresponding to the target intention, and adding the first slot information into the target SQL statement according to the position information of the first slot information in the SQL statement template.
S207: and determining a first answer corresponding to the question statement according to the added target SQL statement, and updating the question statement according to the added target SQL statement.
S208: and inputting the updated question sentences and the first answers into the large model to obtain a first reply corpus output by the large model.
S209: and determining a second answer corresponding to the question statement according to the target SQL statement.
S210: and inputting the question sentences and the second answers into the large model to obtain a second reply corpus output by the large model.
Based on the foregoing embodiments, fig. 3 is a schematic structural diagram of a large model-based corpus generating device according to an embodiment of the present application, where the device includes:
the processing module 301 is configured to input a problem statement to be replied to a large model, and obtain a target intention and a target SQL statement of the problem statement output by the large model;
The supplementing module 302 is configured to obtain a pre-stored SQL statement template corresponding to the target intention if the first slot information is received, and add the first slot information to the target SQL statement according to the position information of the first slot information in the SQL statement template;
the processing module 301 is further configured to determine a first answer corresponding to the question sentence according to the added target SQL sentence, and update the question sentence according to the added target SQL sentence;
and the generating module 303 is configured to input the updated question sentence and the first answer into the large model, and obtain a first reply corpus output by the large model.
In a possible implementation manner, the processing module 301 is specifically configured to obtain a first prompting template configured in advance for prompting the large model to perform intent classification; the first prompting template comprises a first field of a problem statement to be written and a first prompting word for prompting the big model to classify intention; writing the problem statement into a first field of the first prompt template, inputting the written first prompt template into the large model, enabling the large model to determine a target intention corresponding to the problem statement according to the first prompt word, and generating an SQL statement according to a second prompt template which is stored in advance and corresponds to the target intention and used for prompting the large model to generate the SQL statement; the second prompting template comprises table structure information of a database and second prompting words for prompting the large model to generate SQL sentences.
In a possible implementation manner, the processing module 301 is further configured to obtain a pre-stored SQL statement template corresponding to the target intention, where the SQL statement template carries necessary slot information for replying to a problem statement of the target intention and location information of each necessary slot information; acquiring second slot information contained in the target SQL statement; determining whether first slot position information which is missing exists or not according to the necessary slot position information and the second slot position information; if the first slot position information exists, generating and outputting prompt information for prompting the deletion of the first slot position information, and receiving the input first slot position information.
In a possible implementation manner, the processing module 301 is specifically configured to determine, if there is no missing first slot information, a second answer corresponding to the question statement according to the target SQL statement;
the generating module 303 is further configured to input the question sentence and the second answer into the large model, and obtain a second reply corpus output by the large model.
In a possible implementation manner, the processing module 301 is specifically configured to search, in a pre-stored database, an answer corresponding to the target SQL statement according to the target SQL statement; and determining the answer as a first answer corresponding to the question sentence.
In a possible implementation manner, the processing module 301 is specifically configured to obtain a third pre-configured prompting template for prompting the big model to generate a question sentence based on the SQL sentence; the third prompting template comprises a second field of the SQL sentence and a third prompting word for prompting the big model to generate a problem sentence based on the SQL sentence; writing the SQL statement-based generated problem statement into a second field of the third prompt template, and inputting the written third prompt template into the large model;
and determining the output of the large model as an updated target sentence.
In a possible implementation manner, the generating module 303 is specifically configured to obtain a fourth prompting template configured in advance for prompting the large model to generate a reply corpus; the fourth prompting template comprises a third field of a problem statement to be written, a fourth field of a reply statement to be written and a fourth prompting word for prompting the large model to generate a reply corpus; writing the updated problem statement into a third field of the fourth prompting template, and writing the first reply statement into a fourth field of the fourth prompting template; and inputting a fourth prompt template for writing completion into the large model.
On the basis of the foregoing embodiments, the embodiment of the present application further provides an electronic device, and fig. 4 is a schematic structural diagram of the electronic device provided in the embodiment of the present application, as shown in fig. 4, including: the processor 401, the communication interface 402, the memory 403 and the communication bus 404, wherein the processor 401, the communication interface 402 and the memory 403 complete communication with each other through the communication bus 404;
the memory 403 has stored therein a computer program which, when executed by the processor 401, causes the processor 401 to perform the steps of the large model-based corpus generation method as provided in the above embodiments.
Because the principle of solving the problem of the electronic device is similar to that of the large-model-based corpus restoration generation method, implementation of the electronic device can refer to an embodiment of the method, and repeated parts are not repeated.
The communication bus mentioned above for the electronic devices may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus. The communication interface 402 is used for communication between the electronic device and other devices. The Memory may include random access Memory (Random Access Memory, RAM) or may include Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; but also digital instruction processors (Digital Signal Processing, DSP), application specific integrated circuits, field programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
On the basis of the above embodiments, the embodiments of the present invention further provide a computer readable storage medium, in which a computer program executable by a processor is stored, where the program when executed on the processor causes the processor to implement the steps of the large model-based reply corpus generation method provided in the above embodiments.
Since the principle of solving the problem by the above-mentioned computer readable storage medium is similar to that of the reply corpus generation method based on the large model, the implementation of the above-mentioned computer readable storage medium can refer to the embodiment of the method, and the repetition is not repeated.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various modifications and variations can be made in the present application without departing from the spirit or scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims and the equivalents thereof, the present application is intended to cover such modifications and variations.

Claims (10)

1. The method for generating the reply corpus based on the large model is characterized by comprising the following steps:
inputting a problem statement to be replied into a large model, and acquiring a target intention and a target SQL statement of the problem statement output by the large model;
if the first supplementary slot information is received, acquiring a pre-stored SQL statement template corresponding to the target intention, and adding the first slot information into the target SQL statement according to the position information of the first slot information in the SQL statement template;
Determining a first answer corresponding to the question statement according to the added target SQL statement, and updating the question statement according to the added target SQL statement;
and inputting the updated question sentences and the first answers into the large model to obtain a first reply corpus output by the large model.
2. The method of claim 1, wherein the inputting the question statement to be replied to into the large model comprises:
acquiring a first prompt template which is preconfigured and used for prompting a large model to classify intention; the first prompting template comprises a first field of a problem statement to be written and a first prompting word for prompting the big model to classify intention;
writing the problem statement into a first field of the first prompt template, inputting the written first prompt template into the large model, enabling the large model to determine a target intention corresponding to the problem statement according to the first prompt word, and generating an SQL statement according to a second prompt template which is stored in advance and corresponds to the target intention and used for prompting the large model to generate the SQL statement; the second prompting template comprises table structure information of a database and second prompting words for prompting the large model to generate SQL sentences.
3. The method of claim 1, wherein after the obtaining the target intent and target SQL statement of the question statement output by the large model, the method further comprises:
acquiring a pre-stored SQL statement template corresponding to the target intention, wherein the SQL statement template carries necessary slot information for replying a problem statement of the target intention and position information of each necessary slot information;
acquiring second slot information contained in the target SQL statement;
determining whether first slot position information which is missing exists or not according to the necessary slot position information and the second slot position information;
if the first slot position information exists, generating and outputting prompt information for prompting the deletion of the first slot position information, and receiving the input first slot position information.
4. The method of claim 3, wherein if there is no missing first slot information, the method further comprises:
determining a second answer corresponding to the question statement according to the target SQL statement;
and inputting the question sentences and the second answers into the large model to obtain a second reply corpus output by the large model.
5. The method of claim 1, wherein determining the first answer corresponding to the question statement according to the added completed target SQL statement comprises:
searching an answer corresponding to the target SQL statement in a pre-stored database according to the target SQL statement;
and determining the answer as a first answer corresponding to the question sentence.
6. The method of claim 1, wherein updating the question statement according to the added completed target SQL statement comprises:
acquiring a third pre-configured prompt template for prompting the big model to generate a problem statement based on the SQL statement; the third prompting template comprises a second field of the SQL sentence and a third prompting word for prompting the big model to generate a problem sentence based on the SQL sentence;
writing the SQL statement-based generated problem statement into a second field of the third prompt template, and inputting the written third prompt template into the large model;
and determining the output of the large model as an updated target sentence.
7. The method of claim 1, wherein the entering the updated question statement and the first answer into the large model comprises:
Acquiring a fourth prompting template which is preconfigured and used for prompting the large model to generate a reply corpus; the fourth prompting template comprises a third field of a problem statement to be written, a fourth field of a reply statement to be written and a fourth prompting word for prompting the large model to generate a reply corpus;
writing the updated problem statement into a third field of the fourth prompting template, and writing the first reply statement into a fourth field of the fourth prompting template;
and inputting a fourth prompt template for writing completion into the large model.
8. A large model-based reply corpus generation device, the device comprising:
the processing module is used for inputting the problem statement to be replied into the large model and acquiring the target intention and the target SQL statement of the problem statement output by the large model;
the supplementing module is used for acquiring a pre-stored SQL statement template corresponding to the target intention if the supplementing first slot information is received, and adding the first slot information into the target SQL statement according to the position information of the first slot information in the SQL statement template;
The processing module is further used for determining a first answer corresponding to the question statement according to the added target SQL statement, and updating the question statement according to the added target SQL statement;
and the generation module is used for inputting the updated question sentences and the first answers into the large model to acquire a first reply corpus output by the large model.
9. An electronic device comprising a processor for implementing the steps of the large model-based corpus generation method according to any of claims 1-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 large model-based corpus generation method according to any of claims 1-7.
CN202311630585.0A 2023-11-30 2023-11-30 Method, device, equipment and medium for generating reply corpus based on large model Pending CN117828041A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311630585.0A CN117828041A (en) 2023-11-30 2023-11-30 Method, device, equipment and medium for generating reply corpus based on large model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311630585.0A CN117828041A (en) 2023-11-30 2023-11-30 Method, device, equipment and medium for generating reply corpus based on large model

Publications (1)

Publication Number Publication Date
CN117828041A true CN117828041A (en) 2024-04-05

Family

ID=90519925

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311630585.0A Pending CN117828041A (en) 2023-11-30 2023-11-30 Method, device, equipment and medium for generating reply corpus based on large model

Country Status (1)

Country Link
CN (1) CN117828041A (en)

Similar Documents

Publication Publication Date Title
CN106649742B (en) Database maintenance method and device
CN107210035B (en) Generation of language understanding systems and methods
CN111708869B (en) Processing method and device for man-machine conversation
CN109325040B (en) FAQ question-answer library generalization method, device and equipment
US20160117405A1 (en) Information Processing Method and Apparatus
CN110929094A (en) Video title processing method and device
CN111553138B (en) Auxiliary writing method and device for standardizing content structure document
CN107798123A (en) Knowledge base and its foundation, modification, intelligent answer method, apparatus and equipment
CN116775906A (en) Knowledge graph construction method, system, computer equipment and storage medium
CN117033667A (en) Knowledge graph construction method and device, storage medium and electronic equipment
CN110610698A (en) Voice labeling method and device
US10678514B2 (en) Method and device for generating code assistance information
CN118170894A (en) Knowledge graph question-answering method, knowledge graph question-answering device and storage medium
CN117194646A (en) Question and answer method and device and electronic equipment
CN117112593A (en) SQL sentence generation method, medium and computer device
CN117332282A (en) Knowledge graph-based event matching method and device
CN109492086B (en) Answer output method and device, electronic equipment and storage medium
CN117828041A (en) Method, device, equipment and medium for generating reply corpus based on large model
CN115964465A (en) Intelligent question and answer method and device and electronic equipment
CN112988986B (en) Man-machine interaction method, device and equipment
CN110147358A (en) The building method and construction system of automatic question answering knowledge base
CN117149985B (en) Question and answer method, device, equipment and medium based on large model
US20230195723A1 (en) Estimation apparatus, learning apparatus, estimation method, learning method and program
CN114925179A (en) Information query method, device, storage medium and terminal
CN118070925B (en) Model training method, device, electronic equipment, storage medium and program product

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