CN114547274B - Multi-turn question and answer method, device and equipment - Google Patents
Multi-turn question and answer method, device and equipment Download PDFInfo
- Publication number
- CN114547274B CN114547274B CN202210440996.2A CN202210440996A CN114547274B CN 114547274 B CN114547274 B CN 114547274B CN 202210440996 A CN202210440996 A CN 202210440996A CN 114547274 B CN114547274 B CN 114547274B
- Authority
- CN
- China
- Prior art keywords
- information
- dialogue
- dialogue information
- rewritten
- rewriting
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 45
- 238000006243 chemical reaction Methods 0.000 claims description 16
- 238000012545 processing Methods 0.000 claims description 16
- 230000004044 response Effects 0.000 claims description 12
- 230000011218 segmentation Effects 0.000 claims description 8
- 238000003780 insertion Methods 0.000 claims description 2
- 230000037431 insertion Effects 0.000 claims description 2
- 230000003993 interaction Effects 0.000 description 15
- 238000010586 diagram Methods 0.000 description 10
- 230000006870 function Effects 0.000 description 10
- 238000012549 training Methods 0.000 description 10
- 238000004590 computer program Methods 0.000 description 8
- 230000002452 interceptive effect Effects 0.000 description 6
- 230000000694 effects Effects 0.000 description 4
- 230000014509 gene expression Effects 0.000 description 4
- 230000000717 retained effect Effects 0.000 description 4
- 238000004891 communication Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 239000000284 extract Substances 0.000 description 3
- 239000013589 supplement Substances 0.000 description 3
- 238000003062 neural network model Methods 0.000 description 2
- 230000009466 transformation Effects 0.000 description 2
- 230000009471 action Effects 0.000 description 1
- 230000006978 adaptation Effects 0.000 description 1
- 238000007796 conventional method Methods 0.000 description 1
- 238000012937 correction Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000003058 natural language processing Methods 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 238000012216 screening Methods 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/33—Querying
- G06F16/332—Query formulation
- G06F16/3329—Natural language query formulation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/33—Querying
- G06F16/3331—Query processing
- G06F16/334—Query execution
- G06F16/3344—Query execution using natural language analysis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/10—Text processing
- G06F40/12—Use of codes for handling textual entities
- G06F40/151—Transformation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/205—Parsing
- G06F40/216—Parsing using statistical methods
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Artificial Intelligence (AREA)
- Computational Linguistics (AREA)
- General Physics & Mathematics (AREA)
- Audiology, Speech & Language Pathology (AREA)
- General Health & Medical Sciences (AREA)
- Health & Medical Sciences (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Mathematical Physics (AREA)
- Probability & Statistics with Applications (AREA)
- Human Computer Interaction (AREA)
- Machine Translation (AREA)
Abstract
Description
技术领域technical field
本申请涉及计算机技术领域,尤其涉及一种多轮问答的方法、装置及设备。The present application relates to the field of computer technology, and in particular, to a method, apparatus and device for multi-round question and answer.
背景技术Background technique
基于表格数据的人机交互系统(Table QA),是将用户输入的自然语言问题转换成对应的结构化查询语言(Structured Query Language,简称SQL)语句,并在数据库中用于存储表格数据的数据表中找到SQL语句对应的结果反馈给用户的功能。由于表格是日常工作和生活中常见的数据存储结构,Table QA系统有很广泛的应用场景,比如数据的查询、统计与筛选等,可以应用于政务、金融、能源等多种应用领域中。实现Table QA系统的关键技术是将自然语言问题转换成对应的SQL语句,即Text-to-SQL语言转换。The human-computer interaction system (Table QA) based on tabular data is to convert the natural language questions input by users into corresponding Structured Query Language (SQL) statements, and store tabular data in the database. The function of finding the result corresponding to the SQL statement in the table and feeding it back to the user. Since tables are a common data storage structure in daily work and life, Table QA system has a wide range of application scenarios, such as data query, statistics and screening, etc., and can be applied to various application fields such as government affairs, finance, and energy. The key technology to realize the Table QA system is to convert natural language questions into corresponding SQL statements, that is, Text-to-SQL language conversion.
在实际的应用场景中,用户常常是以多轮问答的方式与系统进行交互,历史多轮问答内容中经常存在冗余的内容,本轮对话中可能省略或用其他内容指代历史对话中已经出现过信息。为了让对话系统具备记忆的能力,通常会通过对话状态跟踪(Dialog StateTracking ,简称DST),来存储对话历史中的一些重要信息,但是 DST 相关的方法常常很复杂,无法应用于在线的人机交互系统。In practical application scenarios, users often interact with the system in the form of multiple rounds of Q&A. There are often redundant content in the historical multiple rounds of Q&A. This round of dialogue may omit or use other content to refer to the historical dialogue. message appeared. In order to enable the dialogue system to have the ability to remember, some important information in the dialogue history is usually stored through dialogue state tracking (Dialog State Tracking, DST for short), but DST-related methods are often complex and cannot be applied to online human-computer interaction. system.
目前的人机交互系统中,通过将本轮对话与历史轮次的历史对话内容全部拼接到一起后输入Text-to-SQL语言转换模型,引入额外的噪声,转换得到的SQL语句不准确,从而导致人机交互系统给出的答复信息质量差、准确性低。In the current human-computer interaction system, the text-to-SQL language conversion model is input by splicing all the historical dialogue content of the current round and the historical rounds, which introduces additional noise, and the converted SQL statement is inaccurate, so As a result, the response information given by the human-computer interaction system is of poor quality and low accuracy.
发明内容SUMMARY OF THE INVENTION
本申请提供一种多轮问答的方法、装置及设备,用以解决目前人机交互系统给出的答复信息质量差、准确性低的问题。The present application provides a method, device and device for multi-round question and answer, which are used to solve the problems of poor quality and low accuracy of answer information given by the current human-computer interaction system.
第一方面,本申请提供一种多轮问答的方法,包括:In a first aspect, the present application provides a method for multiple rounds of question and answer, including:
响应于对话请求,若确定本轮对话之前存在至少一轮历史对话,则获取本轮对话信息和所述至少一轮历史对话的历史对话信息;In response to the dialogue request, if it is determined that there is at least one round of historical dialogue before the current round of dialogue, acquiring the current round of dialogue information and the historical dialogue information of the at least one round of historical dialogue;
将所述本轮对话信息和所述历史对话信息输入上下文改写模型,利用所述上下文改写模型,确定所述本轮对话信息中待改写对象,所述待改写对象对应的改写操作类型,以及所述历史对话信息中用于改写的关键文本;Input the current round of dialogue information and the historical dialogue information into the context rewriting model, and use the context rewriting model to determine the object to be rewritten in the current round of dialogue information, the type of rewriting operation corresponding to the object to be rewritten, and the The key text used for rewriting in the historical dialogue information;
根据所述本轮对话信息中待改写对象和所述待改写对象对应的改写操作类型,使用所述关键文本,对所述本轮对话信息进行改写,生成候选对话信息;According to the object to be rewritten in the current round of dialogue information and the rewriting operation type corresponding to the object to be rewritten, use the key text to rewrite the current round of dialogue information to generate candidate dialogue information;
根据所述候选对话信息的质量信息,将其中一个候选对话信息作为本轮对话信息改写后的目标对话信息;According to the quality information of the candidate dialogue information, one of the candidate dialogue information is used as the target dialogue information after the current round of dialogue information is rewritten;
获取所述目标对话信息对应的答复信息,并反馈所述答复信息。Acquire reply information corresponding to the target dialogue information, and feed back the reply information.
第二方面,本申请提供一种多轮问答的装置,包括:In a second aspect, the present application provides a multi-round question and answer device, comprising:
信息获取模块,用于响应于对话请求,若确定本轮对话之前存在至少一轮历史对话,则获取本轮对话信息和所述至少一轮历史对话的历史对话信息;an information acquisition module, configured to, in response to the dialogue request, acquire the dialogue information of the current round and the historical dialogue information of the at least one round of historical dialogue if it is determined that there is at least one round of historical dialogue before the current round of dialogue;
改写预测模块,用于将所述本轮对话信息和所述历史对话信息输入上下文改写模型,利用所述上下文改写模型,确定所述本轮对话信息中待改写对象,所述待改写对象对应的改写操作类型,以及所述历史对话信息中用于改写的关键文本;The rewriting prediction module is used to input the current round of dialogue information and the historical dialogue information into a context rewriting model, and use the context rewriting model to determine the object to be rewritten in the current round of dialogue information, and the corresponding object to be rewritten. The type of rewriting operation, and the key text used for rewriting in the historical dialogue information;
改写模块,用于根据所述本轮对话信息中待改写对象和所述待改写对象对应的改写操作类型,使用所述关键文本,对所述本轮对话信息进行改写,生成候选对话信息;A rewriting module, configured to rewrite the current round of dialogue information by using the key text according to the object to be rewritten and the rewriting operation type corresponding to the object to be rewritten in the current round of dialogue information to generate candidate dialogue information;
选择模块,用于根据所述候选对话信息的质量信息,将其中一个候选对话信息作为本轮对话信息改写后的目标对话信息;a selection module, configured to use one of the candidate dialogue information as the target dialogue information after rewriting the current round of dialogue information according to the quality information of the candidate dialogue information;
答复模块,用于获取所述目标对话信息对应的答复信息,并反馈所述答复信息。A reply module, configured to obtain reply information corresponding to the target dialogue information, and feed back the reply information.
第三方面,本申请提供一种电子设备,包括:处理器,以及与所述处理器通信连接的存储器;In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
所述存储器存储计算机执行指令;the memory stores computer-executable instructions;
所述处理器执行所述存储器存储的计算机执行指令,以实现上述第一方面所述的方法。The processor executes the computer-executable instructions stored in the memory to implement the method described in the first aspect above.
第四方面,本申请提供一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机执行指令,所述计算机执行指令被处理器执行时用于实现上述第一方面所述的方法。In a fourth aspect, the present application provides a computer-readable storage medium, where computer-executable instructions are stored in the computer-readable storage medium, and the computer-executable instructions are used to implement the method described in the first aspect when executed by a processor. .
第五方面,本申请提供一种计算机程序产品,包括计算机程序,该计算机程序被处理器执行时实现上述第一方面所述的方法。In a fifth aspect, the present application provides a computer program product, including a computer program, which implements the method described in the first aspect when the computer program is executed by a processor.
本申请提供的多轮问答的方法、装置及设备,对于发起的新一轮对话(本轮对话),通过获取本轮对话之前存在至少一轮历史对话的历史对话信息,将本轮对话信息和历史对话信息输入上下文改写模型,利用训练好的上下文改写模型,确定本轮对话信息中待改写对象,待改写对象对应的改写操作类型,以及历史对话信息中用于改写的关键文本;根据本轮对话信息中待改写对象和待改写对象对应的改写操作类型,使用关键文本,对本轮对话信息进行改写,生成候选对话信息;根据候选对话信息的质量信息,将质量较优的一个候选对话信息作为本轮对话信息改写后的目标对话信息,能够将本轮对话中省略的关键信息补充完整,并将指代信息替换为所指代的完整内容信息,从而将本轮对话信息改写为高质量的表达,解决多轮问答中指定和省略的问题,基于改写后的目标对话信息获取对应的答复信息,提高了答复信息的质量和准确性。The method, device and device for multi-round question and answer provided by the present application, for a new round of dialogue (this round of dialogue) initiated, by obtaining the historical dialogue information of at least one round of historical dialogues before the current round of dialogue, the current round of dialogue information and The historical dialogue information is input into the context rewriting model, and the trained context rewriting model is used to determine the object to be rewritten in this round of dialogue information, the type of rewriting operation corresponding to the object to be rewritten, and the key text used for rewriting in the historical dialogue information; In the dialogue information, the object to be rewritten and the type of rewriting operation corresponding to the object to be rewritten, use the key text to rewrite the current round of dialogue information to generate candidate dialogue information; according to the quality information of the candidate dialogue information, a candidate dialogue information with better quality As the target dialogue information after the current round of dialogue information is rewritten, it can complete the key information omitted in the current round of dialogue, and replace the reference information with the complete content information referred to, so as to rewrite the current round of dialogue information to high quality It solves the problems specified and omitted in multiple rounds of question and answer, and obtains the corresponding reply information based on the rewritten target dialogue information, which improves the quality and accuracy of the reply information.
附图说明Description of drawings
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本申请的实施例,并与说明书一起用于解释本申请的原理。The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description serve to explain the principles of the application.
图1为本申请提供的一多轮问答内容的示例图;Fig. 1 is an example diagram of a plurality of rounds of question and answer content provided by this application;
图2为本申请所基于的一示例性的网络架构的示意图;2 is a schematic diagram of an exemplary network architecture on which this application is based;
图3 为本申请一示例性实施例提供的一种多轮问答的方法流程图;3 is a flowchart of a method for a multi-round question and answer provided by an exemplary embodiment of the present application;
图4为本申请另一示例性实施例提供的多轮问答的方法流程图;4 is a flowchart of a method for multiple rounds of question and answer provided by another exemplary embodiment of the present application;
图5为本申请一示例性实施例提供的上下文改写模型使用的框架图;FIG. 5 is a framework diagram used by a context rewriting model provided by an exemplary embodiment of the present application;
图6为一示例性实施例提供的基于上下文改写模型的Text-to-SQL语言转换的框架图;6 is a framework diagram of a Text-to-SQL language conversion based on a context rewriting model provided by an exemplary embodiment;
图7为本申请一示例性实施例提供的多轮问答的装置的结构示意图;7 is a schematic structural diagram of an apparatus for multiple rounds of question and answer provided by an exemplary embodiment of the present application;
图8为本申请一示例实施例提供的电子设备的结构示意图。FIG. 8 is a schematic structural diagram of an electronic device provided by an exemplary embodiment of the present application.
通过上述附图,已示出本申请明确的实施例,后文中将有更详细的描述。这些附图和文字描述并不是为了通过任何方式限制本申请构思的范围,而是通过参考特定实施例为本领域技术人员说明本申请的概念。Specific embodiments of the present application have been shown by the above-mentioned drawings, and will be described in more detail hereinafter. These drawings and written descriptions are not intended to limit the scope of the concepts of the present application in any way, but to illustrate the concepts of the present application to those skilled in the art by referring to specific embodiments.
具体实施方式Detailed ways
这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本申请相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本申请的一些方面相一致的装置和方法的例子。Exemplary embodiments will be described in detail herein, examples of which are illustrated in the accompanying drawings. Where the following description refers to the drawings, the same numerals in different drawings refer to the same or similar elements unless otherwise indicated. The implementations described in the illustrative examples below are not intended to represent all implementations consistent with this application. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present application as recited in the appended claims.
首先对本申请所涉及的名词进行解释:First, the terms involved in this application are explained:
数据表:结构化查询语言(SQL)数据库中的数据表,用于存储数据,数据存入数据库的对应数据表后,即完成了待存储数据的永久化,此后可以通过访问查询数据库的数据表,来获取数据的数据内容。Data table: The data table in the Structured Query Language (SQL) database is used to store data. After the data is stored in the corresponding data table of the database, the permanentization of the data to be stored is completed, and then the data table of the database can be queried by accessing , to get the data content of the data.
数据元素:也称作数据表的模式,指数据表中的表名、列名、值等信息。Data element: also known as the schema of the data table, refers to the table name, column name, value and other information in the data table.
Table QA:一种基于表格数据(或表格知识)的人机交互系统,其实现将用户输入的自然语言问题转换为SQL语句,并在数据库中用于存储表格数据的数据表中找到SQL语句对应的结果反馈给用户的功能。如,基于表格数据的问答/对话系统。Table QA: A human-computer interaction system based on table data (or table knowledge), which converts natural language questions input by users into SQL statements, and finds the corresponding SQL statements in the data table used to store table data in the database The function of feeding back the results to the user. For example, a question answering/dialogue system based on tabular data.
Text-to-SQL语言转换模型:是Table QA系统的核心技术,一种语言理解(semantic parsing)的方式,用于将人类的自然语言描述的问题(Text)转换为计算机可执行的SQL语句。利用该模型可以实现人和表格/数据库之间的自由交互,无需用户学习复杂的SQL语法。进一步地,依赖该模型可以实现基于表格/数据库的问答/对话系统。Text-to-SQL language conversion model: It is the core technology of the Table QA system, a method of semantic parsing, which is used to convert questions (Text) described by human natural language into computer-executable SQL statements. With this model, free interaction between people and tables/databases can be achieved without requiring users to learn complex SQL syntax. Further, a table/database-based question answering/dialogue system can be implemented by relying on this model.
token:自然语言处理中文本经分词处理(tokenization)后得到的每一个词(或字)。token: Each word (or word) obtained after the text is tokenized in natural language processing.
此外,术语“第一”、“第二”等仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。在以下各实施例的描述中,“多个”的含义是两个以上,除非另有明确具体的限定。In addition, the terms "first", "second", etc. are used for descriptive purposes only, and should not be construed as indicating or implying relative importance or implying the number of indicated technical features. In the description of the following embodiments, the meaning of "plurality" is two or more, unless otherwise expressly and specifically defined.
本申请提供的多轮问答的方法,可以应用于多种应用领域中的人机交互系统,例如,基于表格数据(表格知识或者数据库)的问答/对话系统。The multi-round question answering method provided in this application can be applied to human-computer interaction systems in various application fields, for example, question answering/dialogue systems based on tabular data (tabular knowledge or database).
在实际的人机交互系统中,用户常常是以多轮问答的方式与系统进行交互,历史多轮问答内容中经常存在冗余的内容,本轮对话中可能省略或用其他内容指代历史对话中已经出现过信息。In the actual human-computer interaction system, users often interact with the system in the form of multiple rounds of question and answer. There are often redundant content in the historical multiple rounds of question and answer content. This round of dialogue may omit or use other content to refer to the historical dialogue. Information has already appeared in .
示例性地,以图1所示的多轮问答内容为例,在该示例中,本轮(第三轮)对话中的“他们”指代基于历史两轮对话的查询到的玩家,也即“身高超过200cm的扑克玩家”,本轮对话完整的问题可以表述为“身高超过200cm的扑克玩家的平均身高是多少”。Exemplarily, taking the multi-round question-and-answer content shown in FIG. 1 as an example, in this example, “they” in the current (third round) dialogue refers to the players queried based on the two rounds of historical dialogues, that is, "Poker players over 200cm tall", the complete question in this round of dialogue can be expressed as "What is the average height of poker players over 200cm tall".
传统的人机交互系统中,会将上述三轮对话内容全部拼接后输入Text-to-SQL语言转换模型,引入大量额外的噪声,转换得到的SQL语句不准确,导致人机交互系统给出的答复信息质量差、准确性低。In the traditional human-computer interaction system, the content of the above three rounds of dialogues are all spliced and input into the Text-to-SQL language conversion model, which introduces a lot of extra noise, and the converted SQL statements are inaccurate, resulting in the error given by the human-computer interaction system. The response information is of poor quality and low accuracy.
针对上述技术问题,本申请提供一种多轮问答的方法,将本轮对话信息和历史对话信息输入上下文改写模型,利用训练好的上下文改写模型,确定本轮对话信息中待改写对象,待改写对象对应的改写操作类型,以及历史对话信息中用于改写的关键文本;根据本轮对话信息中待改写对象和待改写对象对应的改写操作类型,使用关键文本,对本轮对话信息进行改写,生成候选对话信息;根据候选对话信息的质量信息,将质量较优的一个候选对话信息作为本轮对话信息改写后的目标对话信息,能够将本轮对话中省略的关键信息补充完整,并将指代信息替换为所指代的完整内容信息,从而将本轮对话信息改写为高质量的表达,解决多轮中指定和省略的问题,基于改写后的目标对话信息获取对应的答复信息,提高了答复信息的质量和准确性。In view of the above technical problems, the present application provides a method for multiple rounds of question and answer, inputting the current round of dialogue information and historical dialogue information into a context rewriting model, and using the trained context rewriting model to determine the object to be rewritten in the current round of dialogue information, to be rewritten The type of rewriting operation corresponding to the object, and the key text used for rewriting in the historical dialogue information; according to the type of rewriting operation corresponding to the object to be rewritten and the object to be rewritten in the current round of dialogue information, use the key text to rewrite the current round of dialogue information, Generate candidate dialogue information; according to the quality information of the candidate dialogue information, a candidate dialogue information with better quality is used as the target dialogue information after the current round of dialogue information rewrites, which can supplement the key information omitted in the current round of dialogue. The substitute information is replaced with the complete content information referred to, so that the current round of dialogue information is rewritten into a high-quality expression, the problem of specifying and omitting in multiple rounds is solved, and the corresponding reply information is obtained based on the rewritten target dialogue information, which improves the Quality and accuracy of response information.
示例性地,图2为本申请所基于的一示例性的网络架构的示意图,图2所示网络架构具体可包括服务器以及终端。Exemplarily, FIG. 2 is a schematic diagram of an exemplary network architecture on which this application is based, and the network architecture shown in FIG. 2 may specifically include a server and a terminal.
其中,服务器具体可为设置在云端的服务器集群,该服务器上存储有历史对话数据,以及数据库中存储的用于实现人机交互的数据查询的数据,如实现表格问答/对话的表格数据等。该服务器中还存储有上下文改写模型,Text-to-SQL语言转换模型等相关的模型数据,通过服务器中预设运算逻辑,服务器可实现模型训练、多轮问答的人机交互等多种运算功能。Specifically, the server may be a server cluster set up in the cloud, and the server stores historical dialogue data and data stored in the database for realizing human-computer interaction data query, such as table data for realizing form question answering/dialogue, etc. The server also stores related model data such as the context rewriting model, the Text-to-SQL language conversion model, etc. Through the preset computing logic in the server, the server can realize various computing functions such as model training and multi-round question-and-answer human-computer interaction. .
终端具体可为具有网络通信功能、运算功能以及信息显示功能的硬件设备,其包括但不限于智能手机、平板电脑、台式电脑、物联网设备等。Specifically, the terminal may be a hardware device with network communication function, computing function, and information display function, which includes but is not limited to a smart phone, a tablet computer, a desktop computer, an Internet of Things device, and the like.
通过与服务器的通信交互,终端将用户输入的本轮对话信息发送至服务器。服务器获取到用户输入的本轮对话信息之后,如果本轮对话之前还存在本次对话的至少一轮历史对话,则获取至少一轮历史对话的历史对话信息,通过训练好的上下文改写模型,根据历史对话信息对本轮对话信息进行改写,得到改写后的目标对话信息;将目标对话信息输入Text-to-SQL语言转换模型,将目标对话信息转换为对应的SQL语句;根据该SQL语句查询数据表得到答复信息,将答复信息反馈给终端。Through the communication interaction with the server, the terminal sends the current round of dialogue information input by the user to the server. After the server obtains the current dialogue information input by the user, if there is at least one historical dialogue of the current dialogue before the current dialogue, the server acquires the historical dialogue information of at least one historical dialogue, and rewrites the model through the trained context, according to The historical dialogue information rewrites the current round of dialogue information to obtain the rewritten target dialogue information; input the target dialogue information into the Text-to-SQL language conversion model to convert the target dialogue information into the corresponding SQL statement; query data according to the SQL statement The form gets the reply information, and feeds back the reply information to the terminal.
下面以具体地实施例对本申请的技术方案以及本申请的技术方案如何解决上述技术问题进行详细说明。下面这几个具体的实施例可以相互结合,对于相同或相似的概念或过程可能在某些实施例中不再赘述。下面将结合附图,对本申请的实施例进行描述。The technical solutions of the present application and how the technical solutions of the present application solve the above-mentioned technical problems will be described in detail below with specific examples. The following specific embodiments may be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below with reference to the accompanying drawings.
图3 为本申请一示例性实施例提供的一种多轮问答的方法流程图。本实施例提供的多轮问答的方法具体可以应用于前述提及的服务器。如图3所示,该方法具体步骤如下:FIG. 3 is a flowchart of a method for multiple rounds of question and answer provided by an exemplary embodiment of the present application. The method for multiple rounds of question and answer provided in this embodiment can be specifically applied to the aforementioned server. As shown in Figure 3, the specific steps of the method are as follows:
步骤S301、响应于对话请求,若确定本轮对话之前存在至少一轮历史对话,则获取本轮对话信息和至少一轮历史对话的历史对话信息。Step S301 , in response to the dialogue request, if it is determined that there is at least one round of historical dialogue before the current round of dialogue, acquire the current round of dialogue information and the historical dialogue information of at least one round of historical dialogues.
在实际应用中,用户可以在终端上提供的交互页面上输入对话内容,终端会将服务反馈的答复信息通过交互页面展示给用户。用户在终端上输入新一轮的对话内容之后,终端向服务器发送对话请求,该对话请求包含用户输入的本轮对话文本信息,用于请求服务器根据本轮对话文本信息给出答复信息。In practical applications, the user can input the content of the dialogue on the interactive page provided on the terminal, and the terminal will display the reply information fed back by the service to the user through the interactive page. After the user inputs a new round of dialogue content on the terminal, the terminal sends a dialogue request to the server, the dialogue request includes the current dialogue text information input by the user, and is used to request the server to give reply information according to the current dialogue text information.
服务器响应于对话请求提取本轮对话文本信息,并基于存储的历史对话数据,确定本轮对话之前是否存在一轮或多轮历史对话。若确定本轮对话之前存在至少一轮历史对话,则获取至少一轮历史对话的历史对话信息。The server extracts the text information of the current round of dialogues in response to the dialogue request, and determines whether there are one or more rounds of historical dialogues before the current round of dialogues based on the stored historical dialogue data. If it is determined that there is at least one round of historical dialogue before the current round of dialogue, historical dialogue information of at least one round of historical dialogue is acquired.
示例性地,服务器获取的本轮对话信息可以是本轮对话文本信息对应的分词结果,也即对本轮对话文本分词后得到的token序列。Exemplarily, the current round of dialogue information obtained by the server may be the word segmentation result corresponding to the current round of dialogue text information, that is, a token sequence obtained after word segmentation of the current round of dialogue text.
示例性地,本实施例中,对于中文文本的分词是将句子转化为单个字(如单个汉字、单个数字、单个字母)的序列。对于英文文本的分词是将句子转化为单个词(英文单词)的序列。Exemplarily, in this embodiment, word segmentation for Chinese text is a sequence of converting a sentence into a single character (eg, a single Chinese character, a single number, and a single letter). Tokenization for English text is the transformation of a sentence into a sequence of individual words (English words).
例如,对于“他们的平均身高是多少”,对该语句进行分词处理后的token序列为{他,们,的,平,均,身,高,是,多,少}。For example, for "what is their average height", the token sequence after tokenizing the sentence is {he, they, of, average, average, height, height, yes, more, less}.
例如,对于“有多少玩家的身高超过200cm”,对该语句进行分词处理后的token序列为{有,多,少,玩,家,的,身,高,超,过,2,0,0,c,m }For example, for "how many players are taller than 200cm", the token sequence after tokenizing the sentence is {yes, more, less, play, home, at, height, over, over, 2, 0, 0 , c, m }
步骤S302、将本轮对话信息和历史对话信息输入上下文改写模型,利用上下文改写模型,确定本轮对话信息中待改写对象,待改写对象对应的改写操作类型,以及历史对话信息中用于改写的关键文本。Step S302, input the current round of dialogue information and historical dialogue information into the context rewriting model, and use the context rewriting model to determine the object to be rewritten in the current round of dialogue information, the rewriting operation type corresponding to the object to be rewritten, and the historical dialogue information for rewriting. key text.
在获取到本轮对话信息和本次交互的一个或多个轮次的历史对话的历史对话信息之后,将本轮对话信息和历史对话信息输入训练好的上下文改写模型,利用该上下文改写模型来判断本轮对话信息中每一位置上的文本信息是保留、替换还是删除,以及需要在哪个位置前插入历史对话中的关键信息,并且从历史对话信息中提取可能要补入本轮对话信息中的关键信息作为关键文本,用于对本轮对话信息进行改写。After obtaining the current round of dialogue information and the historical dialogue information of one or more rounds of historical dialogues in this interaction, input the current round of dialogue information and historical dialogue information into the trained context rewriting model, and use the context rewriting model to Determine whether the text information at each position in the current round of dialogue information is retained, replaced or deleted, and at which position the key information in the historical dialogue needs to be inserted, and extracting from the historical dialogue information may be added to the current round of dialogue information The key information is used as the key text to rewrite the dialogue information of this round.
本实施例中,上下文改写模型是预先训练好的神经网络模型,用于根据输入的本轮对话信息和历史对话信息,确定本轮对话信息中每一位置对应的改写位置类别及改写操作类型,以及历史对话信息中每一位置对应的候选位置类别,从而进一步可以确定本轮对话信息中待改写对象,待改写对象对应的改写操作类型,以及历史对话信息中用于改写的关键文本。In this embodiment, the context rewriting model is a pre-trained neural network model, which is used to determine the rewriting position category and rewriting operation type corresponding to each position in the current round of dialogue information according to the inputted current round of dialogue information and historical dialogue information, and the candidate position category corresponding to each position in the historical dialogue information, so as to further determine the object to be rewritten in the current round of dialogue information, the type of rewriting operation corresponding to the object to be rewritten, and the key text used for rewriting in the historical dialogue information.
其中,待改写对象可以为待插入位置或者待改写文本。The object to be rewritten may be the position to be inserted or the text to be rewritten.
待插入位置是本轮对话信息中的任一token对应位置,本轮对话信息中每一token对应一个位置。在该待插入位置之前需要插入历史对话中的关键信息。The position to be inserted is the corresponding position of any token in the current round of dialogue information, and each token in the current round of dialogue information corresponds to a position. The key information in the historical dialogue needs to be inserted before the to-be-inserted position.
本轮对话信息中可以包括一个或者多个待改写文本,一个待改写文本包含本轮对话信息中一个或者多个连续的token。历史对话信息中用于改写的关键文本可以为一个或者多个关键文本,每一关键文本包括历史对话信息中的一个或者多个连续的token。The current round of dialogue information may include one or more texts to be rewritten, and one to-be-rewritten text includes one or more consecutive tokens in the current round of dialogue information. The key text used for rewriting in the historical dialogue information may be one or more key texts, and each key text includes one or more consecutive tokens in the historical dialogue information.
示例性地,改写操作类型包括以下至少一种:插入、删除、替换、保持原样。Illustratively, the type of overwrite operation includes at least one of the following: insert, delete, replace, keep as is.
待插入位置对应的改写操作类型为插入,待改写文本对应的改写操作类型可以为删除、替换、保持原样中的任一种。The type of rewriting operation corresponding to the position to be inserted is insert, and the type of rewriting operation corresponding to the text to be rewritten may be any one of deletion, replacement, and keeping as it is.
对于改写操作类型为插入的目标位置,将每一个待插入的目标位置单独处理,可以向该位置插入候选token。For the target position where the rewrite operation type is insertion, each target position to be inserted is processed separately, and a candidate token can be inserted into this position.
步骤S303、根据本轮对话信息中待改写对象和待改写对象对应的改写操作类型,使用关键文本,对本轮对话信息进行改写,生成候选对话信息。Step S303 , according to the object to be rewritten and the rewriting operation type corresponding to the object to be rewritten in the dialogue information of the current round, use the key text to rewrite the dialogue information of the current round to generate candidate dialogue information.
在确定本轮对话信息中待改写对象和待改写对象对应的改写操作类型,以及历史对话信息中用于改写的关键文本之后,自动实现对本轮对话信息改写,生成改写后的候选对话信息。After determining the object to be rewritten in the current round of dialogue information and the type of rewriting operation corresponding to the object to be rewritten, and the key text used for rewriting in the historical dialogue information, the current round of dialogue information is automatically rewritten to generate rewritten candidate dialogue information.
示例性地,本轮对话信息中可以包括一个或者多个待改写文本,历史对话信息中用于改写的关键文本可以为一个或者多个关键文本,可以根据待改写对象对应的改写操作类型,采用枚举的方式给出所有可能的改写方式,生成所有可能的候选对话信息。Exemplarily, the current round of dialogue information may include one or more texts to be rewritten, and the key texts used for rewriting in the historical dialogue information may be one or more key texts, which can be used according to the type of rewriting operation corresponding to the object to be rewritten. The enumeration method gives all possible rewriting methods and generates all possible candidate dialogue information.
在实际的交互系统中,通常对话内容较简单,本轮对话信息中通常包含一个改写操作类型为替换的待改写文本,或者包含一个待插入位置。In an actual interactive system, the content of the dialogue is usually relatively simple, and the current round of dialogue information usually contains a text to be rewritten whose type of rewriting operation is replacement, or a position to be inserted.
示例性地,若本轮对话信息中仅包括一个待插入位置,可以对所有关键文本的顺序进行排列组合,枚举所有可能的排列方式,得到对应的组合文本,将每一组合文本插入本轮对话信息中的待插入位置,得到对应的候选对话信息。Exemplarily, if the current round of dialogue information includes only one position to be inserted, the sequence of all key texts can be arranged and combined, all possible arrangements can be enumerated, the corresponding combined texts can be obtained, and each combined text can be inserted into the current round. The to-be-inserted position in the dialogue information is obtained to obtain the corresponding candidate dialogue information.
示例性地,若本轮对话信息中仅包括一个待改写文本,且待改写文本的改写操作类型为替换,可以对所有关键文本的顺序进行排列组合,枚举所有可能的排列方式,得到对应的组合文本,用每一组合文本替换本轮对话信息中的待改写文本,得到对应的候选对话信息。Exemplarily, if the current round of dialogue information includes only one text to be rewritten, and the rewriting operation type of the text to be rewritten is replacement, the order of all key texts can be arranged and combined, and all possible arrangements can be enumerated to obtain the corresponding Combining text, replacing the text to be rewritten in the current round of dialogue information with each combined text to obtain corresponding candidate dialogue information.
例如,以图1所示的多轮问答内容为例,利用上下文改写模型可以确定:本轮对话信息中的待改写对象为“他们”,对应的改写操作类型为:替换。历史对话信息中的关键文本包括:“身高超过200cm”和“扑克玩家”。通过枚举的方式至少可以生成如下候选对话信息:“扑克玩家身高超过200cm的平均身高是多少”、“身高超过200cm扑克玩家的平均身高是多少”。For example, taking the multi-round question and answer content shown in FIG. 1 as an example, using the context rewriting model, it can be determined that the object to be rewritten in this round of dialogue information is "they", and the corresponding rewriting operation type is: replace. Key text in the historical dialogue information includes: "Over 200cm tall" and "Poker player". Through enumeration, at least the following candidate dialogue information can be generated: "What is the average height of poker players over 200cm tall", "What is the average height of poker players over 200cm tall".
示例性地,若本轮对话信息中包括多个需要使用关键文本的待改写对象(包括待插入位置、改写操作类型为替换的待改写文本),那么每一待改写对应至少一个关键文本,通过枚举所有可能的改写方式,生成每一种改写方式对应的候选对话信息。Exemplarily, if the current round of dialogue information includes multiple objects to be rewritten that need to use key text (including the position to be inserted and the text to be rewritten whose type of rewriting operation is replacement), then each to-be-rewritten corresponds to at least one key text, through Enumerate all possible rewriting methods, and generate candidate dialog information corresponding to each rewriting method.
步骤S304、根据候选对话信息的质量信息,将其中一个候选对话信息作为本轮对话信息改写后的目标对话信息。Step S304 , according to the quality information of the candidate dialogue information, use one of the candidate dialogue information as the target dialogue information after the current round of dialogue information is rewritten.
在对本轮对话信息进行改写得到候选对话信息之后,若候选对话信息有多个,可以根据候选对话信息的质量信息进行排序,将质量较优的一个候选对话信息作为本轮对话信息改写后的目标对话信息。After rewriting the dialogue information of the current round to obtain candidate dialogue information, if there are multiple candidate dialogue information, it can be sorted according to the quality information of the candidate dialogue information, and a candidate dialogue information with better quality is used as the rewritten dialogue information of the current round. Target dialogue information.
另外,若候选对话信息只有一个,将该候选对话信息直接作为本轮对话信息改写后的目标对话信息。In addition, if there is only one candidate dialogue information, the candidate dialogue information is directly used as the target dialogue information after the current round of dialogue information is rewritten.
本轮对话信息改写后的目标对话信息,将本轮对话中省略的关键信息补充完整,并将指代信息替换为所指代的完整内容信息,是高质量的表达文本。The target dialogue information after the current round of dialogue information is rewritten, completes the key information omitted in the current round of dialogue, and replaces the reference information with the complete content information referred to, which is a high-quality expression text.
步骤S305、获取目标对话信息对应的答复信息,并反馈答复信息。Step S305: Acquire reply information corresponding to the target dialogue information, and feed back the reply information.
在确定本轮对话信息改写后的目标对话信息之后,基于目标对话信息生成对应的答复信息,能够获取到对用户本轮对话的高质量的答复。服务器将获取到的答复信息反馈给终端。After determining the target dialog information after the rewritten dialog information of the current round is determined, corresponding reply information is generated based on the target dialog information, and a high-quality reply to the current dialog of the user can be obtained. The server feeds back the obtained reply information to the terminal.
本实施例中,对于发起的新一轮对话(本轮对话),获取本轮对话之前存在至少一轮历史对话的历史对话信息,将本轮对话信息和历史对话信息输入上下文改写模型,利用训练好的上下文改写模型,确定本轮对话信息中待改写对象,待改写对象对应的改写操作类型,以及历史对话信息中用于改写的关键文本;根据本轮对话信息中待改写对象和待改写对象对应的改写操作类型,使用关键文本,对本轮对话信息进行改写,生成候选对话信息;根据候选对话信息的质量信息,将质量较优的一个候选对话信息作为本轮对话信息改写后的目标对话信息,能够将本轮对话中省略的关键信息补充完整,并将指代信息替换为所指代的完整内容信息,从而将本轮对话信息改写为高质量的表达,解决多轮问答中指定和省略的问题,基于改写后的目标对话信息获取对应的答复信息,提高了答复信息的质量和准确性。In this embodiment, for a new round of dialogue (this round of dialogue) initiated, obtain the historical dialogue information of at least one round of historical dialogues before the current round of dialogue, input the current round of dialogue information and historical dialogue information into the context rewriting model, and use the training A good context rewriting model determines the object to be rewritten in this round of dialogue information, the type of rewriting operation corresponding to the object to be rewritten, and the key text used for rewriting in historical dialogue information; according to the object to be rewritten and the object to be rewritten in this round of dialogue information For the corresponding rewriting operation type, use the key text to rewrite the current round of dialogue information to generate candidate dialogue information; according to the quality information of the candidate dialogue information, a candidate dialogue information with better quality is used as the target dialogue after the current round of dialogue information is rewritten. It can supplement the key information omitted in the current round of dialogue, and replace the reference information with the complete content information referred to, so as to rewrite the current round of dialogue information into high-quality expressions and solve the problems specified in multiple rounds of question and answer. For the omitted questions, the corresponding reply information is obtained based on the rewritten target dialogue information, which improves the quality and accuracy of the reply information.
一种可选的实施例中,上下文改写模型用于判断本轮对话信息中每一位置上的文本信息是保留、替换还是删除,以及需要在哪个位置前插入历史对话中的关键信息,并且从历史对话信息中提取可能要补入本轮对话信息中的关键信息作为关键文本,用于对本轮对话信息进行改写。In an optional embodiment, the context rewriting model is used to determine whether the text information at each position in the current round of dialogue information is retained, replaced or deleted, and before which position the key information in the historical dialogue needs to be inserted, and from The key information that may be added to the current round of dialogue information is extracted from the historical dialogue information as key texts to rewrite the current round of dialogue information.
具体地,将本轮对话信息和历史对话信息输入上下文改写模型,通过上下文改写模型进行分类处理,得到包含如下信息的分类结果:Specifically, input the current round of dialogue information and historical dialogue information into the context rewriting model, and perform classification processing through the context rewriting model to obtain a classification result containing the following information:
本轮对话信息中每一位置对应的改写位置类别及改写操作类型,历史对话信息中每一位置对应的候选位置类别,其中,改写位置类别为改写开始位置、改写终止位置、非改写起止位置中的任一种;候选位置类别为候选开始位置、候选终止位置、非候选起止位置中的任一种。The rewriting position category and the rewriting operation type corresponding to each position in the current dialogue information, the candidate position category corresponding to each position in the historical dialogue information, wherein the rewriting position category is the rewriting starting position, the rewriting ending position, and the non-rewriting starting and ending positions. Any of ; the candidate position category is any one of the candidate start position, the candidate end position, and the non-candidate start and end position.
进一步地,根据分类结果,确定本轮对话信息中待改写对象,待改写对象对应的改写操作类型,以及历史对话信息中的关键文本。Further, according to the classification result, the object to be rewritten in the current round of dialogue information, the rewriting operation type corresponding to the object to be rewritten, and the key text in the historical dialogue information are determined.
参见图4,图4为本申请另一示例性实施例提供的多轮问答的方法流程图。如图4所示,该方法具体步骤如下:Referring to FIG. 4 , FIG. 4 is a flowchart of a method for multiple rounds of question and answer provided by another exemplary embodiment of the present application. As shown in Figure 4, the specific steps of the method are as follows:
步骤S401、响应于对话请求,若确定本轮对话之前存在至少一轮历史对话,则获取本轮对话信息和至少一轮历史对话的历史对话信息。Step S401 , in response to the dialogue request, if it is determined that there is at least one round of historical dialogue before the current round of dialogue, acquire the current round of dialogue information and the historical dialogue information of at least one round of historical dialogues.
在实际应用中,用户可以在终端上提供的交互页面上输入对话内容,终端会将服务反馈的答复信息通过交互页面展示给用户。用户在终端上输入新一轮的对话内容之后,终端向服务器发送对话请求,该对话请求包含用户输入的本轮对话文本信息,用于请求服务器根据本轮对话文本信息给出答复信息。In practical applications, the user can input the content of the dialogue on the interactive page provided on the terminal, and the terminal will display the reply information fed back by the service to the user through the interactive page. After the user inputs a new round of dialogue content on the terminal, the terminal sends a dialogue request to the server, the dialogue request includes the current dialogue text information input by the user, and is used to request the server to give reply information according to the current dialogue text information.
服务器响应于对话请求提取本轮对话文本信息,并基于存储的历史对话数据,确定本轮对话之前是否存在一轮或多轮历史对话。若确定本轮对话之前存在至少一轮历史对话,则获取至少一轮历史对话的历史对话信息。The server extracts the text information of the current round of dialogues in response to the dialogue request, and determines whether there are one or more rounds of historical dialogues before the current round of dialogues based on the stored historical dialogue data. If it is determined that there is at least one round of historical dialogue before the current round of dialogue, historical dialogue information of at least one round of historical dialogue is acquired.
示例性地,服务器获取的本轮对话信息可以是本轮对话文本信息对应的分词结果,也即对本轮对话文本分词后得到的token序列。Exemplarily, the current round of dialogue information obtained by the server may be the word segmentation result corresponding to the current round of dialogue text information, that is, a token sequence obtained after word segmentation of the current round of dialogue text.
可选地,该步骤中获取本轮对话文本和至少一轮历史对话的历史对话文本;将本轮对话文本和每一轮历史对话的历史对话文本分别进行分词处理,得到本轮对话文本的token序列和每一轮历史对话的历史对话文本的token序列。Optionally, in this step, the current round of dialogue texts and the historical dialogue texts of at least one round of historical dialogues are obtained; the current round of dialogue texts and the historical dialogue texts of each round of historical dialogues are subjected to word segmentation respectively to obtain the token of the current round of dialogue texts. Sequence and token sequence of historical dialogue text for each round of historical dialogue.
示例性地,本实施例中,对于中文文本的分词是将句子转化为单个字(如单个汉字、单个数字、单个字母)的序列。对于英文文本的分词是将句子转化为单个词(英文单词)的序列。Exemplarily, in this embodiment, word segmentation for Chinese text is a sequence of converting a sentence into a single character (eg, a single Chinese character, a single number, and a single letter). Tokenization for English text is the transformation of a sentence into a sequence of individual words (English words).
例如,对于“他们的平均身高是多少”,对该语句进行分词处理后的token序列为{他,们,的,平,均,身,高,是,多,少}。For example, for "what is their average height", the token sequence after tokenizing the sentence is {he, they, of, average, average, height, height, yes, more, less}.
例如,对于“有多少玩家的身高超过200cm”,对该语句进行分词处理后的token序列为{有,多,少,玩,家,的,身,高,超,过,2,0,0,c,m }For example, for "how many players are taller than 200cm", the token sequence after tokenizing the sentence is {yes, more, less, play, home, at, height, over, over, 2, 0, 0 , c, m }
通过步骤S402-S404,基于上下文改写模型,确定本轮对话信息中待改写的目标token,目标token对应的改写操作类型,以及历史对话信息中用于改写的候选token。Through steps S402-S404, based on the context rewriting model, the target token to be rewritten in the dialogue information of the current round, the rewriting operation type corresponding to the target token, and the candidate token for rewriting in the historical dialogue information are determined.
步骤S402、将本轮对话信息和历史对话信息输入上下文改写模型,通过上下文改写模型进行分类处理,得到包含如下信息的分类结果:本轮对话信息中每一位置对应的改写位置类别及改写操作类型,历史对话信息中每一位置对应的候选位置类别。Step S402, input the current round of dialogue information and historical dialogue information into the context rewriting model, perform classification processing through the context rewriting model, and obtain a classification result containing the following information: the rewriting location category and the rewriting operation type corresponding to each position in the current round of dialogue information , the candidate position category corresponding to each position in the historical dialogue information.
其中,改写位置类别为改写开始位置、改写终止位置、非改写起止位置中的任一种。Here, the rewriting position type is any one of a rewriting start position, a rewriting end position, and a non-rewriting start and end position.
候选位置类别为候选开始位置、候选终止位置、非候选起止位置中的任一种。The candidate position category is any one of a candidate start position, a candidate end position, and a non-candidate start and end position.
本实施例中,上下文改写模型是预先训练好的神经网络模型,用于根据输入的本轮对话信息和历史对话信息,判断本轮对话信息中每一位置上的文本信息是保留、替换还是删除,以及需要在哪个位置前插入历史对话中的关键信息,并且从历史对话信息中提取可能要补入本轮对话信息中的关键信息作为关键文本,用于对本轮对话信息进行改写,从而确定本轮对话信息中每一位置对应的改写位置类别及改写操作类型,以及历史对话信息中每一位置对应的候选位置类别。In this embodiment, the context rewriting model is a pre-trained neural network model, which is used to determine whether the text information at each position in the current round of dialogue information is to be retained, replaced or deleted according to the inputted current round of dialogue information and historical dialogue information , and before which position to insert the key information in the historical dialogue, and extract the key information that may be added to the current round of dialogue information from the historical dialogue information as the key text to rewrite the current round of dialogue information, so as to determine The rewrite location category and rewrite operation type corresponding to each position in the current dialogue information, and the candidate position category corresponding to each position in the historical dialogue information.
可选地,上下文改写模型可以包括骨干网络和分类器,其中骨干网络为Transformer模型,具体可以是BART或T5等。分类器包括如下三个分类器:位置预测分类器、指代预测分类器和替换预测分类器。将本轮对话信息和历史对话信息输入上下文改写模型的骨干网络进行处理,将处理结果输入三个分类器中进行分类处理,得到分类结果。Optionally, the context rewriting model may include a backbone network and a classifier, where the backbone network is a Transformer model, specifically, BART or T5. The classifiers include the following three classifiers: a position prediction classifier, a reference prediction classifier, and a replacement prediction classifier. Input the current round of dialogue information and historical dialogue information into the backbone network of the context rewriting model for processing, and input the processing results into three classifiers for classification processing to obtain the classification results.
其中,位置预测分类器用于确定本轮对话信息中每一位置对应的改写位置类别,指代预测分类器用于确定本轮对话信息中每一位置对应的改写操作类型。基于这两个分类器的分类结果,能够判断本轮对话信息中每一位置上的文本信息是保留、替换、删除、还是在该位置前插入其他文本信息。Wherein, the location prediction classifier is used to determine the rewrite location category corresponding to each location in the current round of dialogue information, and the predictive classifier is used to determine the rewrite operation type corresponding to each location in the current round of dialogue information. Based on the classification results of the two classifiers, it can be determined whether the text information at each position in the current round of dialogue information is retained, replaced, deleted, or inserted before the position.
替换预测分类器用于确定历史对话信息中每一位置对应的候选位置类别,根据该分类器的分类结果可以实现从历史对话信息中提取可能要补入本轮对话信息中的关键信息作为关键文本。The replacement prediction classifier is used to determine the candidate position category corresponding to each position in the historical dialogue information. According to the classification result of the classifier, the key information that may be added to the current round of dialogue information can be extracted from the historical dialogue information as the key text.
示例性地,上下文改写模型中的分类器可以采用多层感知机(MultilayerPerceptron,简称MLP)实现。Exemplarily, the classifier in the context rewriting model may be implemented by using a multi-layer perceptron (Multilayer Perceptron, MLP for short).
示例性地,如图5所示,上下文改写模型可以在Transformer基础上增加三个MLP,每一MLP作为一个分类器,用于确定对应的分类结果。基于图1所示的多轮问答内容,如图5所示,将本轮对话和两轮历史对话的对话信息输入Transformer,Transformer的处理结果输入三个分类器分别输出如图5所示的分类结果。Exemplarily, as shown in FIG. 5 , the context rewriting model may add three MLPs on the basis of the Transformer, and each MLP is used as a classifier to determine the corresponding classification result. Based on the multi-round question and answer content shown in Figure 1, as shown in Figure 5, the dialogue information of the current round of dialogue and two rounds of historical dialogue is input into the Transformer, and the processing results of the Transformer are input into three classifiers to output the classification shown in Figure 5. result.
本实施例中,上下文改写模型是基于训练集训练好的模型。In this embodiment, the context rewriting model is a model trained based on the training set.
示例性地,在进行模型训练之前,首先获取大量的历史数据样本,包括:本轮对话样本、至少一轮历史对话样本和对本轮对话信息改写后的目标对话样本。通过对本轮对话样本、至少一轮历史对话样本和目标对话样本进行解析,可以确定本轮对话样本中每一位置对应的改写位置类别及改写操作类型,以及历史对话样本中每一位置对应的候选位置类别,得到标注数据。另外,也可以通过人工标注的方式获取标注数据。Exemplarily, before performing model training, first obtain a large number of historical data samples, including: current round of dialogue samples, at least one round of historical dialogue samples and target dialogue samples after rewriting the current round of dialogue information. By analyzing the current round of dialogue samples, at least one round of historical dialogue samples and target dialogue samples, it is possible to determine the rewrite location category and rewrite operation type corresponding to each position in this round of dialogue samples, as well as the corresponding rewrite operation type for each position in the historical dialogue samples. The candidate position category is obtained, and the labeled data is obtained. In addition, the annotation data can also be obtained by manual annotation.
训练集包括多条训练数据,每一条训练数据包括本轮对话样本,至少一轮历史对话样本,及标注数据(包括本轮对话样本中每一位置对应的改写位置类别及改写操作类型,以及历史对话样本中每一位置对应的候选位置类别)。The training set includes multiple pieces of training data, each piece of training data includes the current round of dialogue samples, at least one round of historical dialogue samples, and labeled data (including the rewrite location category and rewrite operation type corresponding to each position in the current round of dialogue samples, and historical the candidate position category corresponding to each position in the dialogue sample).
在进行模型训练时,将本轮对话样本和至少一轮历史对话样本输入上下文改写模型,得到上下文改写模型的分类结果,根据上下文改写模型的分类结果与标注数据计算损失,并根据损失优化上下文改写模型的模型参数。经过多轮迭代训练至模型收敛时,确定训练好的上下文改写模型。During model training, input the current round of dialogue samples and at least one round of historical dialogue samples into the context rewriting model to obtain the classification result of the context rewriting model, calculate the loss according to the classification result of the context rewriting model and the labeled data, and optimize the context rewriting according to the loss Model parameters for the model. After multiple rounds of iterative training to the model convergence, determine the trained context to rewrite the model.
可选地,进行模型训练时,可以基于上下文改写模型在测试集上的预测结果,确定改写后的目标对话信息。使用改写后的目标对话信息的困惑度(或句子概率)来衡量上下文改写模型的优劣,困惑度越低(或句子概率越高)说明上下文改写模型越好,能够使得利用训练好的上下文改写模型确定的改写后的目标对话信息的质量更高更流畅。Optionally, during model training, the prediction result of the model on the test set may be rewritten based on the context, and the rewritten target dialogue information may be determined. Use the perplexity degree (or sentence probability) of the rewritten target dialogue information to measure the pros and cons of the context rewriting model. The lower the perplexity degree (or the higher the sentence probability), the better the context rewriting model, which can make use of the trained context rewriting model. The rewritten target dialogue information determined by the model is of higher quality and smoother.
步骤S403、根据分类结果,确定本轮对话信息中待改写对象,待改写对象对应的改写操作类型,以及历史对话信息中的关键文本。Step S403 , according to the classification result, determine the object to be rewritten in the dialogue information of the current round, the rewriting operation type corresponding to the object to be rewritten, and the key text in the historical dialogue information.
其中,待改写对象为待插入位置或待改写文本。改写操作类型包括:插入、删除、替换和保持原样。待插入位置对应的改写操作类型为插入。The object to be rewritten is the position to be inserted or the text to be rewritten. Types of overwrite operations include: insert, delete, replace, and keep-as-is. The rewrite operation type corresponding to the position to be inserted is insert.
在得到分类结果之后,根据分类结果中每一改写开始位置与对应的改写终止位置,确定一个待改写对象。After the classification result is obtained, an object to be rewritten is determined according to each rewriting start position and the corresponding rewriting termination position in the classification result.
根据每一待改写对象所在位置的改写操作类型,确定待改写对象的改写操作类型。The rewriting operation type of the object to be rewritten is determined according to the rewriting operation type of the location of each object to be rewritten.
示例性地,分类结果中改写开始位置和改写终止位置是成对出现的,一个改写开始位置与其后第一个出现的改写终止位置对应。成对出现的改写开始位置和改写终止位置确定一个待改写对象,该待改写对象包括改写开始位置、改写终止位置、以及这两者之间的位置所有这些位置上的文本。成对出现的改写开始位置和改写终止位置,以及这两者之间的位置的改写操作类型均一致,也即是对应的待改写对象的改写操作类型。Exemplarily, in the classification result, the rewriting start position and the rewriting termination position appear in pairs, and one rewriting start position corresponds to the rewriting termination position that occurs first afterward. The overwriting start position and the overwriting end position appearing in pairs determine an object to be overwritten, which includes the text at the overwriting start position, the overwriting end position, and the positions in between. The rewriting start position and the rewriting end position that appear in pairs, and the rewriting operation types of the positions between the two are consistent, that is, the rewriting operation types of the corresponding objects to be rewritten.
示例性地,若改写开始位置和改写终止位置重合,则确定待改写对象对应一个位置。若该位置的改写操作类型为替换、删除、保持原样中的任一种,则该待改写对象为待改写文本,该待改写文本对应的操作类型与该位置的改写操作类型一致。若该位置的改写操作类型为插入,则该待改写对象为待插入位置,该待插入位置对应的操作类型为插入。后续在该待插入位置前面(或后面)插入关键文本。Exemplarily, if the rewriting start position and the rewriting termination position coincide, it is determined that the object to be rewritten corresponds to one position. If the rewriting operation type of the position is any one of replace, delete, and keep as it is, the object to be rewritten is the text to be rewritten, and the operation type corresponding to the text to be rewritten is consistent with the rewriting operation type of the position. If the rewriting operation type of the location is insert, the object to be rewritten is the location to be inserted, and the operation type corresponding to the location to be inserted is insert. Subsequent key text is inserted before (or after) the position to be inserted.
例如,根据如图5中所示的分类结果:本轮对话信息中的改写起始位置为0,改写终止位置为1,确定待改写对象为位置0-1上的文本“他们”,待改写操作类型为替换。For example, according to the classification result shown in Figure 5: the rewriting start position in the current round of dialogue information is 0, and the rewriting end position is 1, and it is determined that the object to be rewritten is the text "they" on the position 0-1, which is to be rewritten. The action type is Replace.
该步骤中,根据分类结果中每一候选开始位置与对应的候选终止位置确定一个关键文本。In this step, a key text is determined according to each candidate start position and corresponding candidate end position in the classification result.
示例性地,分类结果中候选开始位置和候选终止位置是成对出现的,一个候选开始位置与其后第一个出现的候选终止位置对应。成对出现的候选开始位置和候选终止位置确定一个关键文本,该关键文本包括候选开始位置、候选终止位置、以及这两者之间的位置所有这些位置上的文本。Exemplarily, in the classification result, the candidate start position and the candidate end position appear in pairs, and one candidate start position corresponds to the candidate end position that appears first afterward. The paired candidate start position and candidate end position determine a key text that includes the candidate start position, the candidate end position, and the text at all of these positions in between.
例如,根据如图5中所示的分类结果,可以确定轮次一的历史对话信息中的候选起始位置为6,候选终止位置为9,确定关键文本为位置[6-9]上的文本“扑克玩家”;轮次二的历史对话信息中的候选起始位置为6,候选终止位置为14,确定关键文本为位置[6-14]上的文本“身高超过200cm”。For example, according to the classification result shown in Fig. 5, it can be determined that the candidate starting position in the historical dialogue information of round 1 is 6, the candidate ending position is 9, and the key text is determined to be the text on position [6-9] "Poker player"; the candidate starting position in the historical dialogue information of the second round is 6, the candidate ending position is 14, and the key text is determined to be the text "height over 200cm" on position [6-14].
步骤S404、根据本轮对话信息中待改写对象和待改写对象对应的改写操作类型,使用关键文本,对本轮对话信息进行改写,生成候选对话信息。Step S404 , according to the object to be rewritten and the rewriting operation type corresponding to the object to be rewritten in the dialogue information of the current round, use the key text to rewrite the dialogue information of the current round to generate candidate dialogue information.
在确定本轮对话信息中待改写对象和待改写对象对应的改写操作类型,以及历史对话信息中用于改写的关键文本之后,自动实现对本轮对话信息改写,生成改写后的候选对话信息。After determining the object to be rewritten in the current round of dialogue information and the type of rewriting operation corresponding to the object to be rewritten, and the key text used for rewriting in the historical dialogue information, the current round of dialogue information is automatically rewritten to generate rewritten candidate dialogue information.
具体地,若本轮对话信息中存在待插入位置,则将至少一个关键文本插入待插入位置。需要说明的是,待插入位置指示的是在该待插入位置的前面(或者后面)插入关键文本。Specifically, if there is a position to be inserted in the current round of dialogue information, at least one key text is inserted into the position to be inserted. It should be noted that the to-be-inserted position indicates that key text is to be inserted before (or after) the to-be-inserted position.
若本轮对话信息中存在第一待改写文本,第一待改写文本的改写操作类型为替换,则使用至少一个关键文本替换第一待改写文本。If there is the first text to be rewritten in the current round of dialogue information, and the rewriting operation type of the first text to be rewritten is replacement, at least one key text is used to replace the first text to be rewritten.
若本轮对话信息中存在第二待改写文本,第二待改写文本的改写操作类型为删除,则删除本轮对话信息中的第二待改写文本。If the second to-be-rewritten text exists in the current round of dialogue information, and the rewriting operation type of the second to-be-rewritten text is delete, the second to-be-rewritten text in the current round of dialogue information is deleted.
在实际的交互系统中,通常对话内容较简单,本轮对话信息中通常包含一个改写操作类型为替换的待改写文本,或者包含一个待插入位置。In an actual interactive system, the content of the dialogue is usually relatively simple, and the current round of dialogue information usually contains a text to be rewritten whose type of rewriting operation is replacement, or a position to be inserted.
示例性地,若本轮对话信息中仅包括一个待插入位置,可以对所有关键文本的顺序进行排列组合,枚举所有可能的排列方式,得到对应的组合文本,将每一组合文本插入本轮对话信息中的待插入位置,得到对应的候选对话信息。Exemplarily, if the current round of dialogue information includes only one position to be inserted, the sequence of all key texts can be arranged and combined, all possible arrangements can be enumerated, the corresponding combined texts can be obtained, and each combined text can be inserted into the current round. The to-be-inserted position in the dialogue information is obtained to obtain the corresponding candidate dialogue information.
示例性地,若本轮对话信息中仅包括一个待改写文本,且待改写文本的改写操作类型为替换,可以对所有关键文本的顺序进行排列组合,枚举所有可能的排列方式,得到对应的组合文本,用每一组合文本替换本轮对话信息中的待改写文本,得到对应的候选对话信息。Exemplarily, if the current round of dialogue information includes only one text to be rewritten, and the rewriting operation type of the text to be rewritten is replacement, the order of all key texts can be arranged and combined, and all possible arrangements can be enumerated to obtain the corresponding Combining text, replacing the text to be rewritten in the current round of dialogue information with each combined text to obtain corresponding candidate dialogue information.
示例性地,若本轮对话信息中包括多个需要使用关键文本的待改写对象(包括待插入位置、改写操作类型为替换的待改写文本),那么每一待改写对应至少一个关键文本,通过枚举所有可能的改写方式,生成每一种改写方式对应的候选对话信息。Exemplarily, if the current round of dialogue information includes multiple objects to be rewritten that need to use key text (including the position to be inserted and the text to be rewritten whose type of rewriting operation is replacement), then each to-be-rewritten corresponds to at least one key text, through Enumerate all possible rewriting methods, and generate candidate dialog information corresponding to each rewriting method.
例如,以图5所示分类结果为例,所确定的本轮对话信息中的待改写文本为位置0-1上的文本“他们”,待改写操作类型为替换;历史对话信息中的关键文本包括:轮次一中位置[6-9]上的文本“扑克玩家”,轮次二中位置[6-14]上的文本“身高超过200cm”。通过枚举的方式至少可以生成如下候选对话信息:“扑克玩家身高超过200cm的平均身高是多少”、“身高超过200cm扑克玩家的平均身高是多少”。For example, taking the classification result shown in Fig. 5 as an example, the determined text to be rewritten in the current round of dialogue information is the text "they" at position 0-1, and the operation type to be rewritten is replacement; the key text in the historical dialogue information Including: the text "Poker Player" on position [6-9] in Round 1, and the text "Over 200cm tall" on Position [6-14] in Round 2. Through enumeration, at least the following candidate dialogue information can be generated: "What is the average height of poker players over 200cm tall", "What is the average height of poker players over 200cm tall".
步骤S405、根据候选对话信息的质量信息,将其中一个候选对话信息作为本轮对话信息改写后的目标对话信息。Step S405: According to the quality information of the candidate dialogue information, use one of the candidate dialogue information as the target dialogue information after the rewriting of the dialogue information of the current round.
在对本轮对话信息进行改写得到候选对话信息之后,若候选对话信息有多个,可以根据候选对话信息的质量信息进行排序,将质量较优的一个候选对话信息作为本轮对话信息改写后的目标对话信息。After rewriting the dialogue information of the current round to obtain candidate dialogue information, if there are multiple candidate dialogue information, it can be sorted according to the quality information of the candidate dialogue information, and a candidate dialogue information with better quality is used as the rewritten dialogue information of the current round. Target dialogue information.
可选地,获取每一候选对话信息的句子概率,将句子概率最高的候选对话信息作为目标对话信息。Optionally, the sentence probability of each candidate dialogue information is obtained, and the candidate dialogue information with the highest sentence probability is used as the target dialogue information.
示例性地,可以基于n元语法模型计算每一候选对话信息的句子概率,或者可以采用现有的任意一种计算句子概率的方式实现,此处不做具体限定。Exemplarily, the sentence probability of each candidate dialogue information can be calculated based on the n-gram model, or it can be implemented by any existing method of calculating the sentence probability, which is not specifically limited here.
可选地,获取每一候选对话信息的困惑度,将困惑度最低的候选对话信息作为目标对话信息。Optionally, the perplexity degree of each candidate dialogue information is obtained, and the candidate dialogue information with the lowest perplexity degree is used as the target dialogue information.
其中,一个句子W的困惑度可以通过如下方式确定:Among them, the perplexity of a sentence W can be determined as follows:
其中,表示句子W的困惑度,N表示句子W中包含的token的数量,为句子W中包含的N个token,表示句子W的句子概率。 in, represents the perplexity of sentence W, N represents the number of tokens contained in sentence W, is the N tokens contained in the sentence W, represents the sentence probability of sentence W.
可选地,对于得到的目标对话信息,可以进行增加连接词等修正处理,使得改写后的目标对话信息的质量更高、更流畅。Optionally, for the obtained target dialogue information, correction processing such as adding connectives may be performed, so that the rewritten target dialogue information is of higher quality and smoother.
例如,假设目标对话信息为“身高超过200cm扑克玩家的平均身高是多少”,其中,“身高超过200cm”和“扑克玩家”为两个关键文本,在两个关键文本中间增加连接词“的”,得到修正后的“身高超过200cm的扑克玩家的平均身高是多少”。For example, suppose the target dialogue information is "what is the average height of poker players over 200cm tall", where "height over 200cm" and "poker player" are two key texts, and the connecting word "de" is added between the two key texts , to get the revised "What is the average height of a poker player over 200cm tall".
在应用于基于表格数据的问答/或对话场景时,在得到本轮对话信息改写后的目标对话信息之后,通过步骤S406-S408获取目标对话信息对应的答复信息,并反馈答复信息。When applied to a question-and-answer/or dialogue scenario based on table data, after obtaining the target dialogue information rewritten by the dialogue information of the current round, the reply information corresponding to the target dialogue information is obtained through steps S406-S408, and the reply information is fed back.
步骤S406、将目标对话信息输入语言转换模型进行转换处理,将目标对话信息转换为对应的SQL语句。Step S406: Input the target dialogue information into the language conversion model for conversion processing, and convert the target dialogue information into corresponding SQL statements.
在应用于基于表格数据的问答/或对话场景时,将目标对话信息输入语言转换模型进行转换处理,得到目标对话信息对应的SQL语句。When applied to a question-and-answer/or dialogue scene based on table data, the target dialogue information is input into the language conversion model for conversion processing, and the SQL statement corresponding to the target dialogue information is obtained.
参见图6,图6为一示例性实施例提供的基于上下文改写模型的Text-to-SQL语言转换的框架图,如图6所示,基于图1所示的多轮问答内容,将本轮对话信息和轮次一和轮次二的两轮历史对话信息输入上下文改写模型,利用上下文改写模型确定本轮对话信息改写后的问题(也即目标对话信息):“身高超过200cm的扑克玩家的平均身高是多少”,将该问题和表格数据的模式信息输入text-to-SQL模型,将该问题转换为对应的SQL语句。Referring to FIG. 6, FIG. 6 is a framework diagram of Text-to-SQL language conversion based on a context rewriting model provided by an exemplary embodiment. As shown in FIG. 6, based on the multi-round question and answer content shown in FIG. The dialogue information and the two rounds of historical dialogue information of rounds one and two are input into the context rewriting model, and the context rewriting model is used to determine the problem after the rewriting of the dialogue information in this round (that is, the target dialogue information): "The poker player whose height exceeds 200cm What is the average height", input the question and the schema information of the tabular data into the text-to-SQL model, and convert the question into the corresponding SQL statement.
步骤S407、运行SQL语句,以查询存储有表格数据的数据表得到查询结果,根据查询结果确定答复信息,并反馈答复信息。Step S407 , running the SQL statement to obtain the query result by querying the data table storing the table data, determining the reply information according to the query result, and feeding back the reply information.
服务器通过运行目标对话信息对应的SQL语句,从存储有表格数据的数据表查询得到查询结果。The server obtains the query result from the data table in which the table data is stored by running the SQL statement corresponding to the target dialogue information.
进一步地,服务器可以将查询结果作为问题的答复信息发送给终端,以使终端输出答复信息,以供用户查看。Further, the server may send the query result to the terminal as the answer information of the question, so that the terminal outputs the answer information for the user to view.
可选地,服务器还可以基于查询结果,根据预先设置的答复话术生成答复信息,并将生成的答复信息反馈给终端,以使终端输出答复信息,以供用户查看。Optionally, based on the query result, the server may also generate reply information according to a preset reply phrase, and feed back the generated reply information to the terminal, so that the terminal outputs the reply information for the user to view.
可选地,服务器还可以将查询结果反馈给终端,以使终端预先设置的答复话术生成答复信息,并输出答复信息,以供用户查看。Optionally, the server may also feed back the query result to the terminal, so that the terminal's preset reply phrases generate reply information, and output the reply information for the user to view.
本实施例通过将本轮对话信息和历史对话信息输入上下文改写模型,通过上下文改写模型进行分类处理,得到本轮对话信息中每一位置对应的改写位置类别及改写操作类型,历史对话信息中每一位置对应的候选位置类别;根据每一改写开始位置与对应的改写终止位置,确定一个待改写对象;根据每一待改写对象所在位置的改写操作类型,确定待改写对象的改写操作类型;根据每一候选开始位置与对应的候选终止位置确定一个关键文本;根据本轮对话信息中待改写对象和待改写对象对应的改写操作类型,使用关键文本,对本轮对话信息进行改写,生成候选对话信息,能够将本轮对话中省略的关键信息补充完整,并将指代信息替换为所指代的完整内容信息,从而将本轮对话信息改写为高质量的表达,解决多轮问答中指定和省略的问题,在应用于基于表格数据的问答/对话场景时,基于改写后的目标对话信息获取对应的答复信息,提高了答复信息的质量和准确性。In this embodiment, the current round of dialogue information and historical dialogue information are input into the context rewriting model, and the context rewriting model is used for classification processing to obtain the rewriting position category and rewriting operation type corresponding to each position in the current round of dialogue information. A candidate position category corresponding to a position; according to each rewriting start position and the corresponding rewriting termination position, determine an object to be rewritten; according to the rewriting operation type of the location of each object to be rewritten, determine the rewriting operation type of the object to be rewritten; according to Each candidate start position and the corresponding candidate end position determine a key text; according to the object to be rewritten and the type of rewriting operation corresponding to the object to be rewritten in the current round of dialogue information, use the key text to rewrite the current round of dialogue information to generate candidate dialogues It can supplement the key information omitted in the current round of dialogue, and replace the reference information with the complete content information referred to, so as to rewrite the current round of dialogue information into high-quality expressions and solve the problems specified in multiple rounds of question and answer. When the omitted questions are applied to the question-and-answer/dialogue scenario based on table data, the corresponding reply information is obtained based on the rewritten target dialogue information, which improves the quality and accuracy of the reply information.
图7为本申请一示例性实施例提供的多轮问答的装置的结构示意图。本申请实施例提供的多轮问答的装置可以执行多轮问答的方法实施例提供的处理流程。如图7所示,多轮问答的装置70包括:信息获取模块701,改写预测模块702,改写模块703,选择模块704和答复模块705。FIG. 7 is a schematic structural diagram of an apparatus for multiple rounds of question and answer provided by an exemplary embodiment of the present application. The apparatus for multiple rounds of question and answer provided by the embodiment of the present application may execute the processing flow provided by the embodiment of the method for multiple rounds of question and answer. As shown in FIG. 7 , the
具体地,信息获取模块701,用于响应于对话请求,若确定本轮对话之前存在至少一轮历史对话,则获取本轮对话信息和至少一轮历史对话的历史对话信息。Specifically, the
改写预测模块702,用于将本轮对话信息和历史对话信息输入上下文改写模型,利用上下文改写模型,确定本轮对话信息中待改写对象,待改写对象对应的改写操作类型,以及历史对话信息中用于改写的关键文本。The
改写模块703,用于根据本轮对话信息中待改写对象和待改写对象对应的改写操作类型,使用关键文本,对本轮对话信息进行改写,生成候选对话信息。The
选择模块704,用于根据候选对话信息的质量信息,将其中一个候选对话信息作为本轮对话信息改写后的目标对话信息。The
答复模块705,用于获取目标对话信息对应的答复信息,并反馈答复信息。The
可选地,改写预测模块在应用于将本轮对话信息和历史对话信息输入上下文改写模型,利用上下文改写模型,确定本轮对话信息中待改写对象,待改写对象对应的改写操作类型,以及历史对话信息中用于改写的关键文本时,具体用于:将本轮对话信息和历史对话信息输入上下文改写模型,通过上下文改写模型进行分类处理,得到包含如下信息的分类结果:本轮对话信息中每一位置对应的改写位置类别及改写操作类型,历史对话信息中每一位置对应的候选位置类别,其中,改写位置类别为改写开始位置、改写终止位置、非改写起止位置中的任一种;候选位置类别为候选开始位置、候选终止位置、非候选起止位置中的任一种。根据分类结果,确定本轮对话信息中待改写对象,待改写对象对应的改写操作类型,以及历史对话信息中的关键文本。Optionally, the rewriting prediction module is applied to input the current round of dialogue information and historical dialogue information into the context rewriting model, and uses the context rewriting model to determine the object to be rewritten in the current round of dialogue information, the type of rewriting operation corresponding to the object to be rewritten, and the history. When the key text used for rewriting in the dialogue information, it is specifically used to: input the current round of dialogue information and historical dialogue information into the context rewriting model, and perform classification processing through the context rewriting model to obtain a classification result containing the following information: In the current round of dialogue information The rewriting position category and the rewriting operation type corresponding to each position, the candidate position category corresponding to each position in the historical dialogue information, wherein the rewriting position category is any of the rewriting start position, the rewriting end position, and the non-rewriting start and end positions; The candidate position category is any one of a candidate start position, a candidate end position, and a non-candidate start and end position. According to the classification result, the object to be rewritten in the current round of dialogue information, the rewriting operation type corresponding to the object to be rewritten, and the key text in the historical dialogue information are determined.
可选地,改写预测模块在应用于根据分类结果,确定本轮对话信息中待改写对象,待改写对象对应的改写操作类型,以及历史对话信息中的关键文本时,具体用于:Optionally, when the rewriting prediction module is applied to determine the object to be rewritten in the current round of dialogue information, the type of rewriting operation corresponding to the object to be rewritten, and the key text in the historical dialogue information according to the classification result, it is specifically used for:
根据分类结果中每一改写开始位置与对应的改写终止位置,确定一个待改写对象;根据每一待改写对象所在位置的改写操作类型,确定待改写对象的改写操作类型;根据分类结果中每一候选开始位置与对应的候选终止位置确定一个关键文本。According to each rewriting start position and the corresponding rewriting termination position in the classification result, an object to be rewritten is determined; according to the rewriting operation type of the position of each object to be rewritten, the rewriting operation type of the object to be rewritten is determined; The candidate start position and the corresponding candidate end position determine a key text.
可选地,待改写对象为待插入位置或待改写文本,改写操作类型包括:插入、删除、替换和保持原样,待插入位置对应的改写操作类型为插入。改写模块在应用于根据本轮对话信息中待改写对象和待改写对象对应的改写操作类型,使用关键文本,对本轮对话信息进行改写,生成候选对话信息时,具体用于:Optionally, the object to be rewritten is the position to be inserted or the text to be rewritten, the rewrite operation type includes: insert, delete, replace and keep the same, and the rewrite operation type corresponding to the to-be-inserted position is insert. When the rewriting module is applied to the rewriting operation type corresponding to the object to be rewritten and the object to be rewritten in the dialogue information of the current round, the key text is used to rewrite the dialogue information of the current round, and the candidate dialogue information is generated, and it is specifically used for:
若本轮对话信息中存在待插入位置,则将至少一个关键文本插入待插入位置;若本轮对话信息中存在第一待改写文本,第一待改写文本的改写操作类型为替换,则使用至少一个关键文本替换第一待改写文本;若本轮对话信息中存在第二待改写文本,第二待改写文本的改写操作类型为删除,则删除本轮对话信息中的第二待改写文本。If there is a position to be inserted in the current round of dialogue information, insert at least one key text into the to-be-inserted position; if there is a first text to be rewritten in the current round of dialogue information, and the rewriting operation type of the first text to be rewritten is replace, use at least one text to be rewritten. A key text replaces the first text to be rewritten; if there is a second text to be rewritten in the current round of dialogue information, and the rewriting operation type of the second text to be rewritten is delete, the second text to be rewritten in the current round of dialogue information is deleted.
可选地,选择模块具体用于:Optionally, the selection module is specifically used to:
获取每一候选对话信息的句子概率,将句子概率最高的候选对话信息作为目标对话信息;或者,获取每一候选对话信息的困惑度,将困惑度最低的候选对话信息作为目标对话信息。Obtain the sentence probability of each candidate dialogue information, and use the candidate dialogue information with the highest sentence probability as the target dialogue information; or obtain the confusion degree of each candidate dialogue information, and use the candidate dialogue information with the lowest confusion degree as the target dialogue information.
可选地,答复模块具体用于:Optionally, the reply module is specifically used to:
将目标对话信息输入语言转换模型进行转换处理,将目标对话信息转换为对应的SQL语句;根据SQL语句查询存储有表格数据的数据表,得到查询结果;根据查询结果确定答复信息。Input the target dialogue information into the language conversion model for conversion processing, and convert the target dialogue information into corresponding SQL statements; query the data table storing the table data according to the SQL statements to obtain query results; and determine the reply information according to the query results.
本申请实施例提供的装置可以具体用于执行上述任一方法实施例所提供的方案,具体功能和所能实现的技术效果此处不再赘述。The apparatus provided in this embodiment of the present application may be specifically configured to execute the solution provided by any of the foregoing method embodiments, and specific functions and technical effects that can be achieved will not be repeated here.
图8为本申请一示例实施例提供的电子设备的结构示意图。如图8所示,该电子设备80包括:处理器801,以及与处理器801通信连接的存储器802,存储器802存储计算机执行指令。FIG. 8 is a schematic structural diagram of an electronic device provided by an exemplary embodiment of the present application. As shown in FIG. 8 , the
其中,处理器执行存储器存储的计算机执行指令,以实现上述任一方法实施例所提供的方案,具体功能和所能实现的技术效果此处不再赘述。该电子设备可以为上述提及的服务器。The processor executes the computer-executed instructions stored in the memory to implement the solution provided by any of the above method embodiments, and the specific functions and technical effects that can be achieved are not repeated here. The electronic device may be the server mentioned above.
本申请实施例还提供一种计算机可读存储介质,计算机可读存储介质中存储有计算机执行指令,计算机执行指令被处理器执行时用于实现上述任一方法实施例所提供的方案,具体功能和所能实现的技术效果此处不再赘述。The embodiments of the present application further provide a computer-readable storage medium, where computer-executable instructions are stored in the computer-readable storage medium, and when the computer-executable instructions are executed by a processor, are used to implement the solution provided by any of the above method embodiments, and the specific functions And the technical effects that can be achieved are not repeated here.
本申请实施例还提供了一种计算机程序产品,程序产品包括:计算机程序,计算机程序存储在可读存储介质中,电子设备的至少一个处理器可以从可读存储介质读取计算机程序,至少一个处理器执行计算机程序使得电子设备执行上述任一方法实施例所提供的方案,具体功能和所能实现的技术效果此处不再赘述。The embodiments of the present application also provide a computer program product, the program product includes: a computer program, the computer program is stored in a readable storage medium, at least one processor of the electronic device can read the computer program from the readable storage medium, at least one The processor executes the computer program to cause the electronic device to execute the solution provided by any of the above method embodiments, and the specific functions and technical effects that can be achieved are not repeated here.
本领域技术人员在考虑说明书及实践这里公开的发明后,将容易想到本申请的其它实施方案。本申请旨在涵盖本申请的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本申请的一般性原理并包括本申请未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本申请的真正范围和精神由下面的权利要求书指出。Other embodiments of the present application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses or adaptations of this application that follow the general principles of this application and include common knowledge or conventional techniques in the technical field not disclosed in this application . The specification and examples are to be regarded as exemplary only, with the true scope and spirit of the application being indicated by the following claims.
应当理解的是,本申请并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本申请的范围仅由所附的权利要求书来限制。It is to be understood that the present application is not limited to the precise structures described above and illustrated in the accompanying drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.
Claims (8)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210440996.2A CN114547274B (en) | 2022-04-26 | 2022-04-26 | Multi-turn question and answer method, device and equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210440996.2A CN114547274B (en) | 2022-04-26 | 2022-04-26 | Multi-turn question and answer method, device and equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114547274A CN114547274A (en) | 2022-05-27 |
CN114547274B true CN114547274B (en) | 2022-08-05 |
Family
ID=81666716
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210440996.2A Active CN114547274B (en) | 2022-04-26 | 2022-04-26 | Multi-turn question and answer method, device and equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114547274B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114691852B (en) * | 2022-06-01 | 2022-08-12 | 阿里巴巴达摩院(杭州)科技有限公司 | Human-machine dialogue system and method |
CN115617974B (en) * | 2022-12-14 | 2023-12-01 | 北京红棉小冰科技有限公司 | Dialogue processing method, device, equipment and storage medium |
CN116737756B (en) * | 2023-08-15 | 2023-11-03 | 腾讯科技(深圳)有限公司 | Data query method, device, equipment and storage medium |
CN116881429B (en) * | 2023-09-07 | 2023-12-01 | 四川蜀天信息技术有限公司 | Multi-tenant-based dialogue model interaction method, device and storage medium |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113806508A (en) * | 2021-09-17 | 2021-12-17 | 平安普惠企业管理有限公司 | Multi-turn dialogue method and device based on artificial intelligence and storage medium |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2021128044A1 (en) * | 2019-12-25 | 2021-07-01 | 深圳市优必选科技股份有限公司 | Multi-turn conversation method and apparatus based on context, and device and storage medium |
CN111639170A (en) * | 2020-05-29 | 2020-09-08 | 深圳壹账通智能科技有限公司 | Answer selection method and device, computer equipment and computer readable storage medium |
CN112989008A (en) * | 2021-04-21 | 2021-06-18 | 上海汽车集团股份有限公司 | Multi-turn dialog rewriting method and device and electronic equipment |
CN113673256B (en) * | 2021-07-21 | 2024-08-27 | 杭州阿里云飞天信息技术有限公司 | Inquiry statement rewriting method and device |
CN113609824A (en) * | 2021-08-10 | 2021-11-05 | 上海交通大学 | Multi-turn dialog rewriting method and system based on text editing and grammar error correction |
-
2022
- 2022-04-26 CN CN202210440996.2A patent/CN114547274B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113806508A (en) * | 2021-09-17 | 2021-12-17 | 平安普惠企业管理有限公司 | Multi-turn dialogue method and device based on artificial intelligence and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN114547274A (en) | 2022-05-27 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN114547274B (en) | Multi-turn question and answer method, device and equipment | |
WO2021000676A1 (en) | Q&a method, q&a device, computer equipment and storage medium | |
US8972408B1 (en) | Methods, systems, and articles of manufacture for addressing popular topics in a social sphere | |
WO2019158014A1 (en) | Computer-implemented method for dialoguing with user and computer system | |
WO2022252636A1 (en) | Artificial intelligence-based answer generation method and apparatus, device, and storage medium | |
US11531693B2 (en) | Information processing apparatus, method and non-transitory computer readable medium | |
CN107798123B (en) | Knowledge base and establishing, modifying and intelligent question and answer methods, devices and equipment thereof | |
CN112417846B (en) | Text automatic generation method and device, electronic equipment and storage medium | |
US20220058349A1 (en) | Data processing method, device, and storage medium | |
US11907665B2 (en) | Method and system for processing user inputs using natural language processing | |
US11170765B2 (en) | Contextual multi-channel speech to text | |
CN109522397B (en) | Information processing method and device | |
CN112699645A (en) | Corpus labeling method, apparatus and device | |
CN117743526A (en) | Table question-answering method based on large language model and natural language processing | |
CN118296120A (en) | Large-scale language model retrieval enhancement generation method for multi-mode multi-scale multi-channel recall | |
CN117370190A (en) | Test case generation method and device, electronic equipment and storage medium | |
CN117725188A (en) | Question-and-answer methods, devices, electronic equipment and storage media based on artificial intelligence | |
CN114360678A (en) | Information processing method, device, equipment and storage medium | |
WO2021135103A1 (en) | Method and apparatus for semantic analysis, computer device, and storage medium | |
CN112632106A (en) | Knowledge graph query method, device, equipment and storage medium | |
US12087278B2 (en) | Disfluency removal using machine learning | |
CN117931858B (en) | Data query method, device, computer equipment and storage medium | |
CN111723559B (en) | Real-time information extraction method and device | |
CN118535681A (en) | Information query expansion method, electronic device, storage medium and program product | |
CN112035623A (en) | Intelligent question and answer method and device, electronic 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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |