WO2023236252A1 - Answer generation method and apparatus, electronic device, and storage medium - Google Patents

Answer generation method and apparatus, electronic device, and storage medium Download PDF

Info

Publication number
WO2023236252A1
WO2023236252A1 PCT/CN2022/100568 CN2022100568W WO2023236252A1 WO 2023236252 A1 WO2023236252 A1 WO 2023236252A1 CN 2022100568 W CN2022100568 W CN 2022100568W WO 2023236252 A1 WO2023236252 A1 WO 2023236252A1
Authority
WO
WIPO (PCT)
Prior art keywords
answer
target
query statement
content
fragment
Prior art date
Application number
PCT/CN2022/100568
Other languages
French (fr)
Chinese (zh)
Inventor
段沛宸
Original Assignee
来也科技(北京)有限公司
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 来也科技(北京)有限公司 filed Critical 来也科技(北京)有限公司
Publication of WO2023236252A1 publication Critical patent/WO2023236252A1/en

Links

Images

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/338Presentation of query results
    • 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/35Clustering; Classification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/194Calculation of difference between files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition
    • G06V30/14Image acquisition
    • G06V30/148Segmentation of character regions
    • G06V30/153Segmentation of character regions using recognition of characters or words

Definitions

  • the present disclosure relates to the technical fields of robotic process automation and artificial intelligence, and specifically relates to an answer generation method, device, electronic equipment and storage medium.
  • Robotic Process Automation uses specific "robot software” to simulate human operations on a computer and automatically execute process tasks according to rules.
  • AI Artificial Intelligence
  • Intelligent Automation is a general term for a series of technologies from robotic process automation to artificial intelligence. It combines RPA with Optical Character Recognition (OCR), Intelligent Character Recognition (ICR), and process mining. (Process Mining), Deep Learning (DL), Machine Learning (ML), Natural Language Processing (NLP), Speech Recognition (Automatic Speech Recognition, ASR), Speech Synthesis (Text To Speech) , TTS), Computer Vision (CV) and other AI technologies are combined to create end-to-end business processes that can think, learn and adapt, covering from process discovery, process automation, to automatic and continuous The entire process of data collection, understanding the meaning of data, and using data to manage and optimize business processes.
  • the present disclosure provides an answer generation method, device, electronic device and storage medium to solve the technical problems of high labor and time costs and poor accuracy of the answer generation method.
  • An embodiment of the first aspect of the present disclosure provides an answer generation method.
  • the method includes: obtaining a query statement and a question type to which the query statement belongs; and obtaining a target content fragment matching the query statement from a plurality of content fragments included in at least one document. ; According to the response strategy corresponding to the question type, based on the target content fragment, the target answer corresponding to the query statement is generated.
  • the question type includes one of numeric type, extraction type, and judgment type; the number of target content fragments is multiple; according to the response strategy corresponding to the question type, based on the target content fragment, a target answer corresponding to the query statement is generated. , including: for each target content fragment, input the query statement and the target content fragment into the extraction model in the field of natural language processing NLP to extract the candidate answer fragment corresponding to the query statement from the target content fragment, and obtain the corresponding confidence level; according to The confidence level corresponding to each candidate answer fragment is used to obtain the target answer fragment from each candidate answer fragment; according to the response strategy corresponding to the question type, the target answer is generated based on the target answer fragment.
  • the question type includes an extraction class; according to the response strategy corresponding to the question type, the target answer is generated based on the target answer fragment, including: using the target answer fragment as the target answer.
  • the question type includes a judgment type; according to the response strategy corresponding to the question type, generating the target answer based on the target answer fragment includes: inputting the target answer fragment and the query statement into a judgment model in the NLP field to obtain the query statement corresponding to Judgment result; use the judgment result and/or target answer fragment as the target answer.
  • the question type includes a numeric type
  • generating the target answer based on the target answer fragment includes: obtaining the target number from the target answer fragment according to preset rules, and obtaining the unit corresponding to the target number. ; Generate the target answer based on the target number and the corresponding unit.
  • the question type includes a statistical type; according to the response strategy corresponding to the question type, based on the target content fragment, a target answer corresponding to the query statement is generated, including: extracting the target content fragment through a regular expression extraction rule, so as to Get the target answer.
  • the method before obtaining the target content fragment that matches the query statement from the plurality of content fragments included in at least one document, the method further includes: obtaining the target question that matches the query statement from a preset question and answer set; based on the NLP field The first correlation model is used to obtain the first correlation between the query statement and the target question; it is determined that the first correlation is not greater than the preset threshold.
  • the method further includes: when the first correlation is greater than a preset threshold, obtaining the answer corresponding to the target question from the question and answer set; determining the answer corresponding to the target question as the target answer corresponding to the query statement.
  • obtaining target content fragments matching the query statement from multiple content fragments included in at least one document includes: querying based on the query statement to obtain from the multiple content fragments related to the query statement. Multiple candidate content segments; based on the second correlation model in the NLP field, obtain the second correlation between the query statement and each candidate content segment; based on each second correlation, obtain the target content segment from each candidate content segment.
  • the method before obtaining the target content fragment matching the query statement from multiple content fragments included in at least one document, the method further includes: based on optical character recognition OCR technology in the field of artificial intelligence (AI), performing on each document Recognize to obtain the recognition results of each document; perform structured processing on each recognition result to obtain multiple content fragments included in each document; and store each content fragment in correspondence with the corresponding content field.
  • AI artificial intelligence
  • each document is recognized to obtain the recognition results of each document, including: calling the RPA robot to upload each document to the document processing platform for document processing.
  • the platform uses optical character recognition (OCR) technology to identify each document; and obtains the recognition results of each document returned by the document processing platform.
  • OCR optical character recognition
  • a second embodiment of the present disclosure provides an answer generation device, including: a first acquisition module for acquiring a query statement and the question type to which the query statement belongs; and a second acquisition module for obtaining multiple contents included in at least one document.
  • the fragment the target content fragment matching the query statement is obtained; the generation module is used to generate the target answer corresponding to the query statement based on the target content fragment according to the response strategy corresponding to the question type.
  • the question type includes one of a numerical class, an extraction class, and a judgment class; the number of target content segments is multiple; the generation module includes: a first acquisition unit, used for each target content segment, The query statement and the target content fragment are input into the extraction model in the field of natural language processing NLP to extract the candidate answer fragments corresponding to the query statement from the target content fragment and obtain the corresponding confidence level; the second acquisition unit is used to extract the candidate answer fragments according to each candidate answer fragment. The corresponding confidence level is used to obtain the target answer fragment from each candidate answer fragment; the generation unit is used to generate the target answer based on the target answer fragment according to the response strategy corresponding to the question type.
  • the third embodiment of the present disclosure provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor.
  • the processor executes the computer program, the above-mentioned first step of the present disclosure is implemented. Methods described in aspect embodiments.
  • the fourth embodiment of the present disclosure provides a computer-readable storage medium on which a computer program is stored.
  • the computer program is executed by a processor, the method described in the first embodiment of the present disclosure is implemented.
  • the fifth aspect embodiment of the present disclosure proposes a computer program product, which includes a computer program. When executed by a processor, the computer program implements the method described in the above first aspect embodiment of the present disclosure.
  • the sixth embodiment of the present disclosure provides a computer program.
  • the computer program includes computer program code.
  • the computer program code When the computer program code is run on a computer, it causes the computer to execute the method described in the first embodiment of the present disclosure. method.
  • the query statement and the question type to which the query statement belongs After obtaining the query statement and the question type to which the query statement belongs, obtain the target content fragment that matches the query statement from multiple content fragments included in at least one document, and then generate based on the target content fragment according to the response strategy corresponding to the question type.
  • the target answer corresponding to the query statement Therefore, by automatically generating answers instead of manual work, the labor cost and time cost required to generate answers are reduced, and by accurately determining the target content fragment that can answer the user's question from the document, and generating the query statement corresponding to the target content fragment. answers, improving the accuracy of the generated answers.
  • Figure 1 is a schematic flowchart of an answer generation method according to the first embodiment of the present disclosure
  • Figure 2 is an example diagram of an interactive interface provided by an answer generation device according to the first embodiment of the present disclosure
  • Figure 3 is a schematic flowchart of an answer generation method according to a second embodiment of the present disclosure.
  • Figure 4 is a schematic flowchart of an answer generation method according to a third embodiment of the present disclosure.
  • Figure 5 is a schematic flowchart of an answer generation method according to a fourth embodiment of the present disclosure.
  • Figure 6 is an example diagram of an interactive interface of a document processing platform and a recognition result of a document according to the fourth embodiment of the present disclosure
  • Figure 7 is an example diagram of text recognition results and corresponding content fragments according to the fourth embodiment of the present disclosure.
  • Figure 8 is an example diagram of table recognition results and corresponding content fragments according to the fourth embodiment of the present disclosure.
  • Figure 9 is a schematic structural diagram of an answer generation device according to a fifth embodiment of the present disclosure.
  • FIG. 10 is a block diagram of an electronic device used to implement the answer generation method of an embodiment of the present disclosure.
  • Embodiments of the present disclosure provide an answer generation method. After obtaining a query statement and the question type to which the query statement belongs, target content fragments matching the query statement are obtained from multiple content fragments included in at least one document, and then the target content fragments matching the query statement are obtained according to the question type.
  • the corresponding response strategy generates the target answer corresponding to the query statement based on the target content fragment. Therefore, by replacing the manual automatic generation of the answer, the labor cost and time cost required to generate the answer are reduced, and the answer can be accurately determined from the document.
  • the target content fragment of the user's question is generated, and the answer corresponding to the query statement is generated based on the target content fragment, which improves the accuracy of the generated answer.
  • RPA robot refers to a software robot that can combine AI technology and RPA technology to automatically perform business processing.
  • RPA robots have two characteristics: “connector” and “non-intrusion”. By simulating human operation methods, they can extract, integrate and connect data from different systems in a non-intrusive way without changing the information system.
  • query statement refers to the statement input by the user for query, that is, the question the user wants to ask. It can be a statement in text form or a statement in voice form. This disclosure does not make any comment on this. limit.
  • a "document” is an electronic document used to retrieve specific content that can answer a user's question and generate an answer to the user's question accordingly. It can be a PDF obtained by scanning a paper document. (Portable Document Format, Portable Document Format) format documents can also be documents edited on smart devices such as computers and mobile phones, and this disclosure does not limit this.
  • a "content fragment” is a fragment composed of part of the content in the document.
  • the content fragment can be one sentence or several sentences, or it can be a paragraph in the document, or a table in the document, or Partial content in a table, etc., this disclosure does not limit this.
  • the number of characters included in the content fragments can be set in advance, so that by processing all documents to be retrieved, the content in all documents is divided into multiple content fragments, and the characters included in each content fragment are The number is less than or equal to the preset number of characters.
  • candidate content fragments refer to content fragments related to the query statement obtained from all content fragments included in all documents.
  • Target content fragment refers to the content fragment matching the query statement obtained from the candidate content fragment or all content fragments included in all documents, that is, the specific content that can accurately answer the user's question.
  • “answer fragments” are more fine-grained fragments in content fragments, and answers to user questions can be generated based on the answer fragments.
  • “Candidate answer fragment” is an answer fragment obtained from the target content fragment.
  • “Target answer fragment” is an answer fragment obtained from candidate answer fragments.
  • a "question and answer set” is a preset set including multiple candidate questions and corresponding answers, such as FAQ.
  • attribute information is information that represents the attributes of a content fragment, such as the document name of the document where the content fragment is located, the chapter title and chapter number corresponding to the content fragment, the parent titles of each level of the chapter title, etc.
  • correlation degree is used to express the magnitude of the degree of correlation.
  • correlation model is any machine model that can calculate the degree of correlation, such as Bert (Bidirectional Encoder Representations from Transformers, a bidirectional encoder representation model) and other neural network models.
  • Bert Bidirectional Encoder Representations from Transformers, a bidirectional encoder representation model
  • the relevance model can be obtained by fine-tuning a pre-trained model in the NLP field.
  • judgment model is any machine model that can realize judgment, such as a neural network model, and this disclosure does not limit this.
  • extraction model is any machine model that can realize information extraction, such as a neural network model, and this disclosure does not limit this.
  • preset rules are preset extraction rules, which may be in the form of regular expressions or other forms, and this disclosure does not limit this.
  • the preset extraction rules for extracting target numbers from target answer segments are called first preset rules
  • the preset rules for extracting target answers from target content segments are called second preset rules. Default rules.
  • content relevance is the correlation between the query statement and the content fragment determined based on the content contained in the content fragment, and is used to represent the correlation between the content contained in the content fragment and the query statement.
  • the size of the degree is the correlation between the query statement and the content fragment determined based on the content contained in the content fragment, and is used to represent the correlation between the content contained in the content fragment and the query statement. The size of the degree.
  • attribute correlation is the correlation between the query statement and the content fragment determined based on the attribute information corresponding to the content fragment, and is used to represent the correlation between the attribute information corresponding to the content fragment and the query statement.
  • the size of the degree is the correlation between the query statement and the content fragment determined based on the attribute information corresponding to the content fragment, and is used to represent the correlation between the attribute information corresponding to the content fragment and the query statement. The size of the degree.
  • segmented fragments refer to fragments composed of content obtained by dividing the document. For example, after the document is divided into multiple sentences according to the punctuation marks used at the end of the sentence, each sentence is A split fragment.
  • Each content segment in the embodiment of the present disclosure may include one or more segmented segments.
  • a "document processing platform” is an intelligent automation platform for intelligently processing documents.
  • Intelligent Document Processing is one of the core capabilities of the intelligent automation platform.
  • Intelligent document processing is based on AI technologies such as Optical Character Recognition (OCR), Computer Vision (CV), Natural Language Processing (NLP), and Knowledge Graph (KG). , a new generation of automation technology that identifies, classifies, extracts elements, verifies, compares, and corrects errors in various types of documents, helping enterprises realize the intelligence and automation of document processing.
  • OCR Optical Character Recognition
  • CV Computer Vision
  • NLP Natural Language Processing
  • KG Knowledge Graph
  • a “content field” is a field composed of a single character or multiple consecutive characters.
  • the “content field” can be understood as the attribute item key, and the content contained in the content fragment can be understood as the attribute value value.
  • the content fields and corresponding content fragments together form a piece of structured data.
  • the content field and the fields corresponding to the attribute information of the content fragment such as the field named "Document Name”, the field named “Chapter Title”, and the field named "Parent Title at All Levels”, can form a structure. .
  • Figure 1 is a flowchart of an answer generation method according to the first embodiment of the present disclosure. As shown in Figure 1, the method may include the following steps: 101-103.
  • Step 101 Obtain the query statement and the question type to which the query statement belongs.
  • the answer generation method in the embodiment of the present disclosure can be executed by an answer generation device.
  • the answer generating device can be implemented by software and/or hardware, and the answer generating device can be an electronic device, or can be configured in an electronic device to automatically generate accurate answers to user questions instead of manual work.
  • the electronic device may include but is not limited to a terminal device, a server, etc. This embodiment does not specifically limit the electronic device.
  • the answer generating device may be an intelligent answering system.
  • the answer generation device can provide an interactive interface, so that the user can input a query statement in the interactive interface to perform a query, and accordingly, the answer generation device can obtain the query statement.
  • the classification model can be pre-trained, so that the query statement can be input into the classification model, and the question type to which the query statement belongs can be obtained based on the output of the classification model.
  • the classification model can be any model in related technologies that can realize classification, such as a neural network model, and this disclosure does not limit this.
  • the question type to which the query statement belongs may include numerical type, statistical type, extraction type, judgment type, etc.
  • the numerical type means that the corresponding answer is a specific number. For example, if the query statement is "A newly put into operation 220KV transformer, the rest time should be no less than how many hours before voltage is applied?" If a specific number needs to be answered, the question type to which the query statement belongs is numeric. "KV" means kilovolts.
  • Statistical category means that the corresponding answers need to be counted. For example, if the query statement is "How many types of chip radiators can be divided according to cooling methods?" and the corresponding answer needs to count the types of chip radiators, then the question type to which the query statement belongs is statistical.
  • Extraction type means that the corresponding answer needs to be extracted from a piece of text or a table. For example, if the query statement is "What are the replacement cycle requirements for wearing parts?" and the corresponding answer needs to be extracted from a paragraph of text or a table, then the question type to which the query statement belongs is the extraction class.
  • Judgment type means that the corresponding answer is "yes” or "no". For example, if the query statement is "Does the 750KV oil-immersed transformer meet the requirements for 72 hours of rest after oil change?" and the corresponding answer is "yes” or "no", then the question type to which the query statement belongs is a judgment type. where "h” refers to the hour.
  • Step 102 Obtain a target content fragment matching the query statement from multiple content fragments included in at least one document.
  • the number of target content segments may be one or multiple, and the disclosure does not limit this.
  • a large number of documents to be retrieved (that is, documents that need to retrieve specific content that can answer the user's questions and provide answers accordingly) can be processed in advance to obtain multiple content fragments, and then obtain the query statement. Afterwards, the target content fragment matching the query statement can be obtained from multiple content fragments.
  • the number of target content fragments can be set in advance, so that the answer generation device can obtain the correlation between the query statement and each content fragment, and arrange each content fragment in order from high to low according to the corresponding correlation. Sorting is performed, and the preset number of content fragments that are sorted first are determined as the target content fragments.
  • the correlation threshold can be set in advance (for ease of differentiation, it can be called the first correlation threshold), so that the answer generation device can obtain the correlation between the query statement and each content segment, and combine each content Among the fragments, the content fragment whose corresponding correlation degree is greater than the first correlation degree threshold is determined as the target content fragment.
  • the first correlation threshold can be set arbitrarily as needed, and this disclosure does not limit this.
  • Step 103 Generate a target answer corresponding to the query statement based on the target content fragment according to the response strategy corresponding to the question type.
  • the response strategy is a preset strategy for generating target answers corresponding to query statements based on target content segments.
  • different response strategies can be set for different question types.
  • the answer generation device can provide an interactive interface, so that after generating the target answer corresponding to the query statement based on the target content fragment according to the response strategy corresponding to the question type, the target answer can be displayed through the interactive interface.
  • the answer generation device can also display the question type to which the query statement belongs, the target content fragment, the attribute information corresponding to the target content fragment, and the paragraph or table containing the target content fragment through the interactive interface while displaying the target answer (where the target Content fragments or paragraphs or tables containing target content fragments as the basis for answers) and other information, so that users can more clearly understand the source of the target answer to the query statement.
  • the intelligent response system can provide an interactive interface. After the user enters the query statement "Does the 750KV oil-immersed transformer meet the requirements for resting for 72 hours after oil change" on the interactive interface, The intelligent response system can determine that the question type to which the query statement belongs is a judgment type, and then obtain the target content fragment that matches the query statement "transformers after new installation, overhaul, accident maintenance or oil change" from multiple content fragments included in at least one document , the resting time before applying voltage should not be less than the following provisions: a) 110KV 24h b) 220KV 48h c) 500(330)KV 72h d) 750KV 96h", and obtain the chapter number "5.2.6” corresponding to the content fragment, Then, according to the response strategy corresponding to the judgment type, based on the target content fragment, the target answer "No, 96h” corresponding to the query statement is generated, and as shown in Figure 2, the target
  • the answer generation method provided by the embodiment of the present disclosure, after obtaining the query statement and the question type to which the query statement belongs, obtains the target content fragment matching the query statement from multiple content fragments included in at least one document, and then according to the The response strategy corresponding to the question type generates the target answer corresponding to the query statement based on the target content fragment. Therefore, by automatically generating answers instead of manual work, the labor cost and time cost required to generate answers are reduced, and by accurately determining the target content fragment that can answer the user's question from the document, and generating the query statement corresponding to the target content fragment. answers, improving the accuracy of the generated answers.
  • Figure 3 is a flow chart of an answer generation method according to the second embodiment of the present disclosure. As shown in Figure 3, the method includes steps 301-306.
  • Step 301 Obtain the query statement and the question type to which the query statement belongs.
  • Step 302 Obtain the target content fragment matching the query statement from multiple content fragments included in at least one document.
  • Step 303 When the question type includes one of numerical class, extraction class, and judgment class, for each target content segment, input the query statement and the target content segment into the extraction model in the field of natural language processing NLP to extract the target content from the target content segment. Extract candidate answer fragments corresponding to the query statement from the fragments, and obtain the corresponding confidence levels.
  • the number of target content fragments can be multiple, for example, it can be 20, 30, etc.
  • confidence represents the probability that the target content fragment can answer the query statement.
  • the extraction model can be trained in advance. For each target content fragment, after the answer generation device inputs the query statement and the target content fragment into the trained extraction model, the extraction model can determine that the target answer corresponding to the query statement is in Input the starting position and ending position in the target content segment, and then determine the segment between the starting position and the ending position in the target content segment as the candidate answer segment, determine the corresponding confidence level, and output the candidate answer segment and the corresponding The confidence level, so that the answer generation device can obtain the candidate answer fragments corresponding to the query statement and the corresponding confidence level based on the output of the extraction model.
  • step of obtaining the question type to which the query statement belongs can be performed before step 302 or after step 302. This disclosure does not limit this and it only needs to be performed before step 303.
  • Step 304 Obtain the target answer segment from each candidate answer segment according to the confidence level corresponding to each candidate answer segment.
  • the corresponding candidate answer segment with the highest confidence among each candidate answer segment may be determined as the target answer segment.
  • Step 305 Generate a target answer based on the target answer fragment according to the response strategy corresponding to the question type.
  • the target answer fragment can be directly used as the target answer. That is, step 305 includes: using the target answer fragment as the target answer.
  • the answer generation device obtains a target content fragment that matches the query statement from multiple content fragments included in at least one document. "5.1.6 Replacement cycle of wearing parts. If the oil pump bearing or cooling fan bearing that has been used for more than 10 years makes abnormal noise during operation, it should be replaced when the transformer or shunt reactor is out of operation; if it has been used for more than 15 years, it should be replaced according to the specific conditions.
  • the candidate answer fragment extracted from the target content fragment is "When the oil pump bearing or cooling fan bearing that has been used for more than 10 years makes abnormal noise during operation, the transformer or parallel connection Replace the reactor when it is out of operation; when it is used for more than 15 years, replace all seals according to specific conditions.”
  • the candidate answer fragment can be determined as the target answer fragment, and the target answer fragment can be used as the target answer corresponding to the query statement.
  • the target answer corresponding to the query statement can be accurately generated from the document.
  • step 305 can be implemented in the following manner: input the target answer fragment and the query statement into the judgment model in the NLP field to obtain the judgment result corresponding to the query statement, and convert the judgment The result and/or target answer fragment serves as the target answer.
  • the judgment result can be "yes” or "no".
  • the probability threshold can be set in advance, such as 0.5, and a judgment model in the NLP field can be pre-trained. After inputting the target answer fragment and query statement into the judgment model, the judgment model can determine and output the answer corresponding to the query statement as "yes” "The probability.
  • the answer generating device can determine the judgment result to be "yes” when the probability is greater than the probability threshold 0.5, and determine the judgment result to be "no” when the probability is not greater than the probability threshold 0.5, and then combine the judgment result with/ or a target answer fragment as the target answer.
  • the answer generation device obtains one that matches the query statement from multiple content fragments included in at least one document.
  • the target content fragment is "For newly installed, overhauled, accident-repaired or oil-changed transformers, the resting time before applying voltage should not be less than the following provisions: a) 110KV 24h b) 220KV 48h c) 500 (330) KV 72h d) 750KV 96h", according to the process of step 303, the candidate answer segment extracted from the target content segment is "96h".
  • the candidate answer fragment "96h” can be determined as the target answer fragment, and then the target answer fragment "96h” and the query statement can be input into the judgment model in the NLP field , to obtain the judgment results corresponding to the query statement. Since the target answer fragment "96h” is greater than "72h” in the query statement, the probability that the answer corresponding to the query statement output by the judgment model is "yes” is less than 0.5, so the answer generation device can determine that the judgment result is "no", and then The judgment result "No” and the target answer fragment "96h” can be used as the target answer.
  • the target answer corresponding to the query statement can be accurately generated from the document.
  • step 305 can be implemented in the following manner: according to the first preset rule, obtain the target number from the target answer fragment, and obtain the unit corresponding to the target number; according to The target number and the corresponding unit are used to generate the target answer.
  • the first preset rule may be in the form of a regular expression.
  • the answer generation device can extract the target number from the target answer fragment based on the regular expression, and at the same time extract the unit corresponding to the target number, and then splice the target number and the corresponding unit into the target answer.
  • the units corresponding to the target answer fragments can also be set in advance, so that after the answer generating device extracts the target number from the target answer fragment, the target number and the preset unit can be spliced into the target answer.
  • the answer generation device obtains it from multiple content fragments included in at least one document.
  • One of the target content fragments that matches the query statement is "3.0.3
  • the insulation test of oil-immersed transformers and reactors should be filled with qualified oil and allowed to stand for a certain period of time until the bubbles are eliminated.
  • the standing time should be determined by the manufacturer. When the manufacturer does not specify, the relationship between the voltage level of oil-immersed transformers and reactors and the resting time after oil filling should be determined according to Table 3.0.3.
  • the target answer corresponding to the query statement can be accurately generated from the document.
  • Step 306 If the question type includes statistics, extract the target answer from the target content segment according to the second preset rule.
  • the second preset rule may be in the form of a regular expression.
  • the number of target content fragments may be one.
  • the target content fragment can be extracted based on the regular expression to obtain the target answer.
  • the answer generation device obtains from multiple content fragments included in at least one document.
  • the target content fragment matching the query statement is "4.1.2 According to the cooling method, it is divided into: a) self-cooling (ONAN); b) air-cooling (ONAF); c) strong oil air-cooling (OFAF)".
  • the answer generation device can extract the target content fragment based on the regular expression and obtain the target answer "self-cooling (ONAN), air-cooling (ONAF), strong oil air-cooling (OFAF)".
  • ONAN self-cooling
  • ONAF air-cooling
  • OFAF strong oil air-cooling
  • the target answer corresponding to the query statement can be accurately generated from the document.
  • the answer generation method after obtaining the query statement and the question type to which the query statement belongs, obtains the target content fragment matching the query statement from multiple content fragments included in at least one document.
  • the type includes one of numeric class, extraction class, and judgment class
  • for each target content fragment input the query statement and the target content fragment into an extraction model in the field of natural language processing NLP to extract the query statement from the target content fragment.
  • Corresponding candidate answer fragments and obtain the corresponding confidence. According to the confidence corresponding to each candidate answer fragment, obtain the target answer fragment from each candidate answer fragment.
  • the response strategy corresponding to the question type generate the target answer based on the target answer fragment.
  • the target answer is extracted from the target content segment according to the second preset rule.
  • the target content fragment that can answer the user's question can be accurately determined from the document, and based on The target content fragment generates answers corresponding to the query statements, which improves the accuracy of the generated answers.
  • the target answer corresponding to the query statement can also be generated based on the answer generation process in the above embodiment and a preset question and answer set such as FAQ.
  • the answer generation method provided by the embodiment of the present disclosure will be further described below with reference to FIG. 4 .
  • Figure 4 is a flow chart of an answer generation method according to the third embodiment of the present disclosure. As shown in Figure 4, the method includes steps 401-408.
  • Step 401 Obtain the query statement and the question type to which the query statement belongs.
  • step 401 For the specific implementation process and principle of step 401, reference can be made to the description of the above embodiments and will not be described again here.
  • Step 402 Obtain target questions matching the query statement from the preset question and answer set.
  • target questions matching the query statement can be obtained from a preset question and answer set based on a search engine.
  • each candidate question included in the preset question and answer set can correspond to the question type to which the annotation belongs, and then based on the search engine, the query statement can be obtained from each candidate question whose annotated question type is the same as the question type to which the query statement belongs. Matching target problem.
  • Step 403 Based on the first correlation model in the NLP field, obtain the first correlation between the query statement and the target question.
  • the first relevance model can be trained in advance. After obtaining the target question, the answer generation device can input the query statement and the target question into the first relevance model, and the first relevance model can output the query statement and the target question. The correlation score between the questions is scored, so that the answer generating device can obtain the first correlation between the query statement and the target question according to the output of the first correlation model.
  • Step 404 Determine whether the first correlation degree is greater than the preset threshold. If so, execute step 405; otherwise, execute step 407.
  • Step 405 Obtain the answer corresponding to the target question from the question and answer set.
  • Step 406 Determine the answer corresponding to the target question as the target answer corresponding to the query statement.
  • the preset threshold can be set as needed, and this disclosure does not limit this.
  • the answer corresponding to the target question can be obtained from the question and answer set, and the answer corresponding to the target question is determined as the target answer corresponding to the query statement.
  • the target answer corresponding to the query statement can be quickly generated based on the preset question and answer set, and the generated target answer is highly accurate.
  • Step 407 Obtain the target content fragment matching the query statement from multiple content fragments included in at least one document.
  • Step 408 Generate a target answer corresponding to the query statement based on the target content fragment according to the response strategy corresponding to the question type.
  • the target content fragment matching the query statement can be obtained from multiple content fragments included in at least one document, and the target content fragment corresponding to the question type can be obtained.
  • the response strategy generates the target answer corresponding to the query statement based on the target content fragment.
  • the target content fragment that can answer the user's question can be accurately determined from the document, and the answer corresponding to the query statement is generated based on the target content fragment, and the generated The accuracy of the target answer is high.
  • these two methods are used to generate the target answer, so that there is no need to waste a lot of labor costs to maintain the preset question and answer set, thereby reducing The cost of manually maintaining a preset question and answer set.
  • Figure 5 is a flow chart of an answer generation method according to the fourth embodiment of the present disclosure. As shown in Figure 5, the method includes steps 501-508.
  • Step 501 Obtain the query statement and the question type to which the query statement belongs.
  • Step 502 Perform a query based on the query statement to obtain multiple candidate content fragments related to the query statement from multiple content fragments included in at least one document.
  • a large number of documents to be retrieved can be processed in advance to obtain multiple content fragments, and the multiple content fragments can be saved in the retrieval engine. Then, after the answer generation device obtains the query statement, the retrieval can be based on the The engine performs a query based on the query statement to obtain multiple candidate content fragments related to the query statement from multiple content fragments, and returns them to the answer generation device. Correspondingly, the answer generating device can obtain multiple candidate content segments.
  • the retrieval engine can be any retrieval engine with a retrieval function, and this disclosure does not limit this.
  • the retrieval engine may be configured in the answer generation device, or the retrieval engine may be configured separately and connected to the answer generation device through an interface, which is not limited by the present disclosure.
  • the number of candidate content fragments can be set in advance, so that the retrieval engine can obtain the correlation between the query statement and each content fragment, and process each content fragment in order from high to low according to the corresponding correlation.
  • Sorting determine a preset number of content fragments that are ranked first as multiple candidate content fragments.
  • the correlation threshold can be set in advance (for ease of differentiation, it can be called the second correlation threshold), so that the retrieval engine can obtain the correlation between the query statement and each content fragment, and combine each content fragment , multiple content segments whose corresponding correlation degrees are greater than the second correlation threshold are determined as multiple candidate content segments.
  • the second correlation threshold can be set arbitrarily as needed, and this disclosure does not limit this.
  • step 502 can be implemented in the following manner: obtaining the content contained in each content fragment and the attribute information of each content fragment; based on the content contained in each content fragment, obtaining the relationship between the query statement and the corresponding content fragment.
  • content correlation and based on the attribute information of each content fragment, obtain the attribute correlation between the query statement and the corresponding content fragment; based on the content correlation and attribute correlation between the query statement and each content fragment, from multiple In the content fragments, obtain multiple candidate content fragments related to the query statement.
  • the attribute information of the content fragment may include at least one of the document name of the document in which the content fragment is located, the chapter title corresponding to the content fragment, and the parent titles at all levels of the chapter title corresponding to the content fragment.
  • the attribute information of the content fragment includes multiple information such as document name, chapter title, parent title at each level, etc., correspondingly, for each content fragment, each attribute information between the query statement and the corresponding content fragment can be obtained. Attribute correlation.
  • the content contained in each content fragment and the attribute information of the content fragment can be saved in the form of a structure.
  • the fields in the structure can include names.
  • the content contained in the fragment and the corresponding attribute information can be saved in the form of a structure.
  • the query statement can be segmented into words, and the content correlation between the query statement and the content segment can be determined based on the number of times each segment appears in the content contained in the content segment. For example, the more times each segment appears in the content contained in a certain content segment, the higher the content correlation between the query statement and the content segment is determined; when each segment appears in the content contained in a certain content segment, The fewer the occurrences in , the lower the content relevance between the query statement and the content fragment.
  • the query statement can be segmented, and the attribute correlation between the query statement and the content segment can be determined based on the number of times each segment appears in the attribute information of a certain content segment. For example, the more times each segment appears in the document name of a certain content fragment, the higher the attribute correlation of the corresponding document name between the query statement and the content fragment is determined; when each segment appears in the document name of a certain content fragment, The fewer the occurrences in the document name, the lower the correlation of the attribute corresponding to the document name between the query statement and the content fragment.
  • the query statement can be segmented to obtain “transformer” and "type", and then according to the content contained in each content fragment,
  • the number of times "transformer” and “type” are used to determine the content correlation between the query statement “transformer type” and the corresponding content fragment, and based on the number of times "transformer” and “type” appear in the document name of the document where each content fragment is located, Determine the attribute correlation of the corresponding document name between the query statement "Transformer Type” and the corresponding content fragment, and determine the query statement “Transformer Type” based on the number of times "Transformer” and "Type” appear in the chapter title corresponding to each content fragment.
  • the attribute correlation between the corresponding chapter title and the corresponding content fragment is
  • a third correlation threshold corresponding to the content correlation and a fourth correlation threshold corresponding to the attribute correlation can be set, so that among multiple content segments, the corresponding content correlation can be greater than the third correlation
  • the degree threshold, and/or the content fragments whose corresponding attribute correlation is greater than the fourth correlation threshold, are determined as multiple candidate content fragments related to the query statement.
  • the third correlation threshold and the fourth correlation threshold can be set as needed, and are not limited here.
  • the fifth correlation threshold can be set, and the content correlation and attribute correlation can be set to have corresponding weights (the weights can be the same or different), and then the weighted sum can be determined according to the weight corresponding to the content correlation and attribute correlation, and Content fragments whose weighted sum is greater than the fifth relevance threshold are determined as multiple candidate content fragments related to the query statement.
  • the fifth correlation threshold can be set as needed, and is not limited here.
  • Step 503 Based on the second correlation model in the NLP field, obtain the second correlation between the query statement and each candidate content segment.
  • the second correlation model can be pre-trained.
  • the input of the second correlation model is the candidate content fragment and the query statement, and the output is the correlation score (ie, confidence) between the candidate content fragment and the query statement.
  • the query statement and the candidate content fragment can be input into the trained second correlation model, so that the second correlation model determines the candidate content based on the content contained in the query statement and the candidate content fragment.
  • the degree of correlation between the fragment and the query statement is determined, and the second correlation degree is output, so that the answer generation device can obtain the second degree of correlation between the query statement and the candidate content fragment according to the output of the second correlation degree model.
  • the corresponding attribute information can be obtained, and the attribute information and the candidate content segment can be spliced to obtain the corresponding splicing result, and the query statement and the splicing result corresponding to the candidate content segment can be obtained.
  • input the second correlation model so that the second correlation model determines the degree of correlation between the candidate content fragment and the query statement based on the query statement and the content and attribute information of the candidate content fragment itself, and outputs the second correlation degree, thereby
  • the answer generating device may obtain the second correlation between the query statement and the candidate content segment according to the output of the second correlation model.
  • the attribute information of the candidate content fragment may include at least one of the name of the document in which the candidate content fragment is located, the chapter title corresponding to the candidate content fragment, and the parent titles of each level of the chapter title.
  • Step 504 Obtain target content segments from each candidate content segment based on each second correlation degree.
  • the second correlation model based on the NLP field the second correlation between each candidate content segment and the query sentence is determined based on the query sentence, the attribute information of each candidate content segment, and the content contained in the candidate content segment itself. , further improving the accuracy of the identified target content segments.
  • Step 505 Generate a target answer corresponding to the query statement based on the target content fragment according to the response strategy corresponding to the question type.
  • step 505 For the specific implementation process and principle of step 505, please refer to the descriptions of other embodiments and will not be described again here.
  • step 502 the following steps 506-508 may also be included:
  • Step 506 Recognize each document based on the optical character recognition OCR technology in the field of artificial intelligence AI to obtain the recognition results of each document.
  • the answer generation device may use optical character recognition (OCR) technology to recognize each document to obtain the recognition results of each document.
  • OCR optical character recognition
  • the answer generation device can also be connected to the document processing platform through an interface, thereby uploading each document to the document processing platform, so as to recognize each document based on the document processing platform and using optical character recognition OCR technology, and then Obtain the recognition results of each document returned by the document processing platform.
  • the answer generation device can also call the RPA robot to upload each document to the document processing platform.
  • OCR optical character recognition
  • the answer generation device can also call the RPA robot to upload each document to the document processing platform.
  • OCR optical character recognition
  • OCR optical character recognition
  • the document processing platform may provide an interactive interface, which may include an "upload document” button for uploading documents and a "start recognition” button for starting the document recognition process.
  • the answer generation device can call the RPA robot to simulate mouse operations, click the "Upload Document” button on the interactive interface for uploading documents to upload the document to be processed to the document processing platform, and then click the "Upload Document” button on the interactive interface for starting Click the "Start Recognition” button of the document recognition process to start the document recognition process on the document processing platform, and then obtain the document recognition results shown in the right side of Figure 6.
  • “cl_num” in Figure 6 represents the chapter serial number
  • "cl_name” represents the chapter title
  • “cl_rank” represents the row where the chapter is located
  • “cl_content” represents the content contained in the chapter.
  • Step 507 Perform structured processing on each recognition result to obtain multiple content fragments included in each document.
  • documents may include text and/or tables.
  • the document recognition results may include text recognition results and/or table recognition results.
  • step 507 can be implemented in the following ways: segment the text recognition results and/or table recognition results according to a preset segmentation method to obtain multiple segmented segments; aggregate the multiple segmented segments according to a preset aggregation method, To obtain multiple content segments, each content segment is obtained by aggregating at least one segmented segment.
  • the preset segmentation method is a method of dividing the recognition result of the document into multiple segmented segments, which can be determined according to the type of content contained in the document (such as text type, table type).
  • the default aggregation method is a method of aggregating divided fragments to obtain content fragments, which can be determined according to the type of content contained in the document (such as text type, table type).
  • the document recognition results include text recognition results
  • the text recognition results include chapter numbers, commas, periods and other punctuation marks.
  • the answer generation device can perform the first segmentation of the text recognition result based on the chapter number, and then perform the second segmentation on the result of the first segmentation based on punctuation marks (usually period and other end-of-sentence punctuation marks), thereby segmenting the text recognition result. It is a plurality of sentences, each sentence is a segmented segment, and each segmented segment is arranged from front to back according to its corresponding position in the document.
  • a specific length can be given, such as 200 characters, and then gradually accumulated from the first segmented segment backwards.
  • the previously accumulated segmented segments are regarded as one content segment.
  • the first sentence, and then the subsequent sentences are accumulated to determine the next content fragment.
  • the recognition results of the document include table recognition results
  • the table recognition results include delimiter symbols used to distinguish different cells, and the row numbers where the cells are located.
  • the answer generation device can perform the first segmentation of the table recognition result according to the row number, and then the second segmentation of the first segmentation result according to the delimiter symbol, thereby dividing the table recognition result into multiple cell contents, each cell
  • the content of the grid is a segmented segment, and the segmented segments in each row are arranged from front to back according to their corresponding positions in the document. Furthermore, the divided fragments in each row can be spliced into one content fragment.
  • Step 508 Save each content segment in correspondence with the corresponding content field.
  • the name of the content field can be set to "content fragment”, and each content fragment can be saved corresponding to the corresponding content field, so that when the content contained in the content fragment needs to be obtained later, the content can be obtained through the content
  • the field obtains the content contained in the corresponding content fragment.
  • each content segment and the document name, chapter title, and parent title at each level corresponding to each content segment can also be saved in the form of a structure.
  • the fields in the structure can include corresponding A field named "Content Fragment”, a field named “Document Name”, a field named "Chapter Title”, and a field named "Level Parent Title”.
  • each document is recognized to obtain the recognition results of each document, and each recognition result is structured to obtain multiple content fragments included in each document.
  • Each content fragment is compared with the corresponding
  • the content fields are saved correspondingly, which enables the document to be retrieved to be processed and multiple content fragments obtained, which lays the foundation for accurately determining the target content fragment that can answer the user's question from the document, and generating the answer corresponding to the query statement based on the target content fragment.
  • OCR optical character recognition
  • Figure 9 is a schematic structural diagram of an answer generating device according to the fifth embodiment of the present disclosure.
  • the answer generation device 900 includes: a first acquisition module 901, a second acquisition module 902 and a generation module 903.
  • the first acquisition module 901 is used to acquire the query statement and the question type to which the query statement belongs;
  • the second acquisition module 902 is configured to acquire target content segments that match the query statement from multiple content segments included in at least one document;
  • the generation module 903 is used to generate a target answer corresponding to the query statement based on the target content fragment according to the response strategy corresponding to the question type.
  • the answer generation device 900 in the embodiment of the present disclosure can execute the answer generation method provided in the above embodiment.
  • the answer generating device 900 may be implemented by software and/or hardware.
  • the answer generating device may be an electronic device, or may be configured in an electronic device to automatically generate accurate answers to user questions instead of manual work.
  • the electronic device may include but is not limited to a terminal device, a server, etc., and this embodiment does not specifically limit the electronic device.
  • the question type includes one of numerical type, extraction type, and judgment type; the number of target content segments is multiple; the generation module 903 includes:
  • the first acquisition unit is used to input the query statement and the target content fragment into an extraction model in the field of natural language processing NLP for each target content fragment, so as to extract the candidate answer fragment corresponding to the query statement from the target content fragment, and obtain the corresponding Confidence;
  • the second acquisition unit is used to acquire the target answer segment from each candidate answer segment according to the confidence level corresponding to each candidate answer segment;
  • the generation unit is used to generate the target answer based on the target answer fragment according to the response strategy corresponding to the question type.
  • the question type includes an extraction class; a generation unit for:
  • the question type includes a judgment class; a generation unit for:
  • the question type includes a numeric class; a generation unit for:
  • the target number from the target answer fragment and obtain the unit corresponding to the target number
  • the question type includes a statistical class
  • the generation module 903 includes:
  • the extraction unit is used to extract the target answer from the target content fragment according to the second preset rule.
  • the answer generation device 900 may also include:
  • the third acquisition module is used to acquire target questions matching the query statement from the preset question and answer set;
  • the fourth acquisition module is used to obtain the first correlation between the query statement and the target question based on the first correlation model in the NLP field;
  • the first determination module is used to determine that the first correlation degree is not greater than the preset threshold.
  • the answer generation device 900 may also include:
  • the fifth acquisition module is used to obtain the answer corresponding to the target question from the question and answer set when the first correlation degree is greater than the preset threshold;
  • the second determination module is used to determine the answer corresponding to the target question as the target answer corresponding to the query statement.
  • the second acquisition module 902 includes:
  • the third acquisition unit is used to query based on the query statement to obtain multiple candidate content fragments related to the query statement from multiple content fragments;
  • the fourth acquisition unit is used to obtain the second correlation between the query statement and each candidate content fragment based on the second correlation model in the NLP field;
  • the fifth acquisition unit is used to acquire the target content segment from each candidate content segment based on each second correlation degree.
  • the answer generation device 900 may also include:
  • the recognition module is used to identify each document based on the optical character recognition OCR technology in the field of artificial intelligence to obtain the recognition results of each document;
  • the processing module is used to perform structured processing on each recognition result to obtain multiple content fragments included in each document;
  • the saving module is used to save each content fragment correspondingly to the corresponding content field.
  • the identification module includes:
  • the upload unit is used to call the RPA robot to upload each document to the document processing platform, so that based on the document processing platform, optical character recognition OCR technology can be used to identify each document;
  • the sixth acquisition unit is used to acquire the recognition results of each document returned by the document processing platform.
  • the answer generation device of the embodiment of the present disclosure after obtaining the query statement and the question type to which the query statement belongs, obtains the target content fragment matching the query statement from multiple content fragments included in at least one document, and then according to the question
  • the response strategy corresponding to the type generates the target answer corresponding to the query statement based on the target content fragment. Therefore, by automatically generating answers instead of manual work, the labor cost and time cost required to generate answers are reduced, and by accurately determining the target content fragment that can answer the user's question from the document, and generating the query statement corresponding to the target content fragment. answers, improving the accuracy of the generated answers.
  • embodiments of the present disclosure also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor.
  • the processor executes the computer program, The answer generation method as described in any of the aforementioned method embodiments.
  • embodiments of the present disclosure also provide a computer-readable storage medium on which a computer program is stored.
  • the computer program is executed by a processor, the answer generation method as described in any of the foregoing method embodiments is implemented.
  • the computer-readable storage medium is a non-transitory computer-readable storage medium.
  • embodiments of the present disclosure also provide a computer program product.
  • the instruction processor in the computer program product is executed, the answer generation method as described in any of the foregoing method embodiments is implemented.
  • an embodiment of the present disclosure also proposes a computer program.
  • the computer program includes computer program code.
  • the computer program code When the computer program code is run on a computer, it causes the computer to execute as described in any of the foregoing method embodiments. answer generation method.
  • FIG. 10 illustrates a block diagram of an exemplary electronic device suitable for implementing embodiments of the present disclosure.
  • the electronic device 10 shown in FIG. 10 is only an example and should not bring any limitations to the functions and scope of use of the embodiments of the present disclosure.
  • electronic device 10 is embodied in the form of a general computing device.
  • the components of electronic device 10 may include, but are not limited to: one or more processors or processing units 16, system memory 28, and a bus 18 connecting various system components, including memory 28 and processing unit 16.
  • Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics accelerated port, a processor, or a local bus using any of a variety of bus structures.
  • these architectures include but are not limited to Industry Standard Architecture (hereinafter referred to as: ISA) bus, Micro Channel Architecture (Micro Channel Architecture; hereafter referred to as: MAC) bus, enhanced ISA bus, video electronics Standards Association (Video Electronics Standards Association; hereinafter referred to as: VESA) local bus and Peripheral Component Interconnection (hereinafter referred to as: PCI) bus.
  • ISA Industry Standard Architecture
  • MAC Micro Channel Architecture
  • VESA Video Electronics Standards Association
  • PCI Peripheral Component Interconnection
  • Electronic device 10 typically includes a variety of computer system readable media. These media may be any available media that can be accessed by electronic device 10, including volatile and nonvolatile media, removable and non-removable media.
  • the memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (Random Access Memory; hereinafter referred to as: RAM) 30 and/or cache memory 32.
  • Electronic device 10 may further include other removable/non-removable, volatile/non-volatile computer system storage media.
  • storage system 34 may be used to read and write to non-removable, non-volatile magnetic media (not shown in Figure 10, commonly referred to as a "hard drive”).
  • a disk drive for reading and writing a removable non-volatile disk (e.g., a "floppy disk") and a removable non-volatile optical disk (e.g., a compact disk read-only memory) may be provided.
  • CD-ROM Compact Disc Read Only Memory
  • DVD-ROM Digital Video Disc Read Only Memory
  • Memory 28 may include at least one program product having a set (eg, at least one) of program modules configured to perform the functions of embodiments of the present disclosure.
  • a program/utility 40 having a set of (at least one) program modules 42 may be stored, for example, in memory 28 , each of these examples or some combination may include the implementation of a network environment.
  • Program modules 42 generally perform functions and/or methods in the embodiments described in this disclosure.
  • Electronic device 10 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), may also communicate with one or more devices that enable a user to interact with electronic device 10, and/or with Any device (eg, network card, modem, etc.) that enables the electronic device 10 to communicate with one or more other computing devices. This communication may occur through input/output (I/O) interface 22.
  • the electronic device 10 can also communicate with one or more networks (such as a local area network (Local Area Network; hereinafter referred to as: LAN), a wide area network (Wide Area Network; hereinafter referred to as: WAN)) and/or a public network, such as the Internet, through the network adapter 20 ) communication.
  • networks such as a local area network (Local Area Network; hereinafter referred to as: LAN), a wide area network (Wide Area Network; hereinafter referred to as: WAN)
  • a public network such as the Internet
  • network adapter 20 communicates with other modules of electronic device 10 via bus 18 .
  • bus 18 It should be understood that, although not shown in Figure 10, other hardware and/or software modules may be used in conjunction with electronic device 10, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tapes drives and data backup storage systems, etc.
  • the processing unit 16 executes programs stored in the memory 28 to perform various functional applications and data processing, such as implementing the methods mentioned in the previous embodiments.
  • references to the terms “one embodiment,” “some embodiments,” “an example,” “specific examples,” or “some examples” or the like means that specific features are described in connection with the embodiment or example. , structures, materials, or features are included in at least one embodiment or example of the present disclosure. In this specification, the schematic expressions of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the specific features, structures, materials or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, those skilled in the art may combine and combine different embodiments or examples and features of different embodiments or examples described in this specification unless they are inconsistent with each other.
  • first and second are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the quantity of indicated technical features. Therefore, features defined as “first” and “second” may explicitly or implicitly include at least one of these features.
  • “plurality” means at least two, such as two, three, etc., unless otherwise expressly and specifically limited.
  • a "computer-readable medium” may be any device that can contain, store, communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
  • Non-exhaustive list of computer readable media include the following: electrical connections with one or more wires (electronic device), portable computer disk cartridges (magnetic device), random access memory (RAM), Read-only memory (ROM), erasable and programmable read-only memory (EPROM or flash memory), fiber optic devices, and portable compact disc read-only memory (CDROM).
  • the computer-readable medium may even be paper or other suitable medium on which the program may be printed, as the paper or other medium may be optically scanned, for example, and subsequently edited, interpreted, or otherwise suitable as necessary. process to obtain the program electronically and then store it in computer memory.
  • various parts of the present disclosure may be implemented in hardware, software, firmware, or combinations thereof.
  • various steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system.
  • a suitable instruction execution system For example, if it is implemented in hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: discrete logic gate circuits with logic functions for implementing data signals; Logic circuits, application specific integrated circuits with suitable combinational logic gates, programmable gate arrays (PGA), field programmable gate arrays (FPGA), etc.
  • the program can be stored in a computer-readable storage medium.
  • the program can be stored in a computer-readable storage medium.
  • each functional unit in various embodiments of the present disclosure may be integrated into one processing module, each unit may exist physically alone, or two or more units may be integrated into one module.
  • the above integrated modules can be implemented in the form of hardware or software function modules. If the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
  • the storage media mentioned above can be read-only memory, magnetic disks or optical disks, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Mathematical Physics (AREA)
  • Artificial Intelligence (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Biophysics (AREA)
  • Evolutionary Computation (AREA)
  • Biomedical Technology (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Software Systems (AREA)
  • Human Computer Interaction (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Multimedia (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present invention relates to the technical fields of robotic process automation (RPA) and artificial intelligence (AI), and relates to an answer generation method and apparatus, an electronic device, and a storage medium. The method comprises: obtaining a query statement and a question type to which the query statement belongs; obtaining a target content fragment matching the query statement from among a plurality of content fragments comprised in at least one document; and according to a response policy corresponding to the question type, on the basis of the target content fragment, generating a target answer corresponding to the query statement. Therefore, an answer is automatically generated instead of manual work, thereby reducing labor and time costs required for generating the answer; and the target content fragment capable of answering a question of a user is accurately determined from the document, and the answer corresponding to the query statement is generated according to the target content fragment, thereby improving the accuracy of the generated answer. According to the present invention, a content fragment in an acquisition document of IA can be achieved by combining the RPA and the AI, thereby further reducing the labor costs for generating an answer.

Description

答案生成方法、装置、电子设备及存储介质Answer generation method, device, electronic device and storage medium
相关申请的交叉引用Cross-references to related applications
本申请基于申请号为2022106357290、申请日为2022年6月7日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。This application is filed based on a Chinese patent application with application number 2022106357290 and a filing date of June 7, 2022, and claims the priority of the Chinese patent application. The entire content of the Chinese patent application is hereby incorporated by reference into this application.
技术领域Technical field
本公开涉及机器人流程自动化及人工智能技术领域,具体涉及一种答案生成方法、装置、电子设备及存储介质。The present disclosure relates to the technical fields of robotic process automation and artificial intelligence, and specifically relates to an answer generation method, device, electronic equipment and storage medium.
背景技术Background technique
机器人流程自动化(Robotic Process Automation,简称RPA),是通过特定的“机器人软件”,模拟人在计算机上的操作,按规则自动执行流程任务。Robotic Process Automation (RPA) uses specific "robot software" to simulate human operations on a computer and automatically execute process tasks according to rules.
人工智能(Artificial Intelligence,简称AI)是研究、开发用于模拟、延伸和扩展人的智能的理论、方法、技术及应用系统的一门技术科学。Artificial Intelligence (AI for short) is a technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence.
智能自动化(Intelligent Automation,简称IA)是一系列从机器人流程自动化到人工智能的技术总称,将RPA与光学字符识别(Optical Character Recognition,OCR)、智能字符识别(Intelligent Character Recognition,ICR)、流程挖掘(Process Mining)、深度学习(Deep Learning,DL)、机器学习(Machine Learning,ML)、自然语言处理(Natural Language Processing,NLP)、语音识别(Automatic Speech Recognition,ASR)、语音合成(Text To Speech,TTS)、计算机视觉(Computer Vision,CV)等多种AI技术相结合,以创建能够思考、学习及自适应的端到端的业务流程,涵盖从流程发现、流程自动化,到通过自动而持续的数据收集、理解数据的含义,使用数据来管理和优化业务流程的整个历程。Intelligent Automation (IA) is a general term for a series of technologies from robotic process automation to artificial intelligence. It combines RPA with Optical Character Recognition (OCR), Intelligent Character Recognition (ICR), and process mining. (Process Mining), Deep Learning (DL), Machine Learning (ML), Natural Language Processing (NLP), Speech Recognition (Automatic Speech Recognition, ASR), Speech Synthesis (Text To Speech) , TTS), Computer Vision (CV) and other AI technologies are combined to create end-to-end business processes that can think, learn and adapt, covering from process discovery, process automation, to automatic and continuous The entire process of data collection, understanding the meaning of data, and using data to manage and optimize business processes.
目前,在很多业务场景中,比如电力问答系统中,需要对于用户提出的问题,从大量文档中找到能够回答该问题的具体内容,比如某句话,或者某个表格中的某几个单元格内容等,进而根据该内容给出准确的答案。相关技术中,在获取到用户提出的问题后,通常是通过人工查询大量文档,从中找到能够回答用户问题的具体内容,并根据该具体内容给出答案,或者从FAQ(Frequently Asked Questions,常见问题解答)库中找到与用户问题匹配的答案。上述通过人工查询来回答问题的方式,会浪费大量的人力成本和时间成本,而通过FAQ来回答问题的方式,仅能回答FAQ中已存在的问题,对于FAQ中不存在的问题,无法给出准确的答案。如何以较低的人力成本和时间成本,准确回答用户问题,已经成为一个亟待解决的问题。At present, in many business scenarios, such as power question and answer systems, it is necessary to find specific content that can answer the questions raised by users from a large number of documents, such as a certain sentence or certain cells in a table. content, etc., and then give accurate answers based on the content. In related technologies, after obtaining questions raised by users, a large number of documents are usually manually queried to find specific content that can answer the user's questions, and answers are given based on the specific content, or from FAQ (Frequently Asked Questions) Answers) library to find answers that match the user's questions. The above-mentioned method of answering questions through manual query will waste a lot of labor costs and time costs, and the method of answering questions through FAQ can only answer questions that already exist in the FAQ, and cannot answer questions that do not exist in the FAQ. Accurate answer. How to accurately answer user questions with lower labor costs and time costs has become an urgent problem to be solved.
发明内容Contents of the invention
本公开提供一种答案生成方法、装置、电子设备及存储介质,以解决答案生成方法存在的人力成本和时间成本高,且准确性差的技术问题。The present disclosure provides an answer generation method, device, electronic device and storage medium to solve the technical problems of high labor and time costs and poor accuracy of the answer generation method.
本公开第一方面实施例提供一种答案生成方法,该方法包括:获取查询语句以及查询语句所属的问题类型;从至少一个文档包括的多个内容片段中,获取与查询语句匹配的目标内容片段;按照问题类型对应的应答策略,基于目标内容片段,生成查询语句对应的目标答案。An embodiment of the first aspect of the present disclosure provides an answer generation method. The method includes: obtaining a query statement and a question type to which the query statement belongs; and obtaining a target content fragment matching the query statement from a plurality of content fragments included in at least one document. ; According to the response strategy corresponding to the question type, based on the target content fragment, the target answer corresponding to the query statement is generated.
在一些实施例中,问题类型包括数字类、抽取类、判断类中的一个;目标内容片段的数量为多个;按照问题类型对应的应答策略,基于目标内容片段,生成查询语句对应的目标答案,包括:对于每个目标内容片段,将查询语句与目标内容片段输入自然语言处理NLP领域的抽取模型,以从目标内容片段中 抽取查询语句对应的候选答案片段,并获取对应的置信度;根据各候选答案片段对应的置信度,从各候选答案片段中获取目标答案片段;按照问题类型对应的应答策略,基于目标答案片段生成目标答案。In some embodiments, the question type includes one of numeric type, extraction type, and judgment type; the number of target content fragments is multiple; according to the response strategy corresponding to the question type, based on the target content fragment, a target answer corresponding to the query statement is generated. , including: for each target content fragment, input the query statement and the target content fragment into the extraction model in the field of natural language processing NLP to extract the candidate answer fragment corresponding to the query statement from the target content fragment, and obtain the corresponding confidence level; according to The confidence level corresponding to each candidate answer fragment is used to obtain the target answer fragment from each candidate answer fragment; according to the response strategy corresponding to the question type, the target answer is generated based on the target answer fragment.
在一些实施例中,问题类型包括抽取类;按照问题类型对应的应答策略,基于目标答案片段生成目标答案,包括:将目标答案片段作为目标答案。In some embodiments, the question type includes an extraction class; according to the response strategy corresponding to the question type, the target answer is generated based on the target answer fragment, including: using the target answer fragment as the target answer.
在一些实施例中,问题类型包括判断类;按照问题类型对应的应答策略,基于目标答案片段生成目标答案,包括:将目标答案片段和查询语句输入NLP领域的判断模型,以获取查询语句对应的判断结果;将判断结果和/或目标答案片段作为目标答案。In some embodiments, the question type includes a judgment type; according to the response strategy corresponding to the question type, generating the target answer based on the target answer fragment includes: inputting the target answer fragment and the query statement into a judgment model in the NLP field to obtain the query statement corresponding to Judgment result; use the judgment result and/or target answer fragment as the target answer.
在一些实施例中,问题类型包括数字类;按照问题类型对应的应答策略,基于目标答案片段生成目标答案,包括:根据预设规则从目标答案片段中获取目标数字,并获取目标数字对应的单位;根据目标数字以及对应的单位,生成目标答案。In some embodiments, the question type includes a numeric type; according to the response strategy corresponding to the question type, generating the target answer based on the target answer fragment includes: obtaining the target number from the target answer fragment according to preset rules, and obtaining the unit corresponding to the target number. ; Generate the target answer based on the target number and the corresponding unit.
在一些实施例中,问题类型包括统计类;按照问题类型对应的应答策略,基于目标内容片段,生成查询语句对应的目标答案,包括:通过正则表达式抽取规则,对目标内容片段进行抽取,以获取目标答案。In some embodiments, the question type includes a statistical type; according to the response strategy corresponding to the question type, based on the target content fragment, a target answer corresponding to the query statement is generated, including: extracting the target content fragment through a regular expression extraction rule, so as to Get the target answer.
在一些实施例中,从至少一个文档包括的多个内容片段中,获取与查询语句匹配的目标内容片段之前,还包括:从预设的问答集中获取与查询语句匹配的目标问题;基于NLP领域的第一相关度模型,获取查询语句与目标问题之间的第一相关度;确定第一相关度不大于预设阈值。In some embodiments, before obtaining the target content fragment that matches the query statement from the plurality of content fragments included in at least one document, the method further includes: obtaining the target question that matches the query statement from a preset question and answer set; based on the NLP field The first correlation model is used to obtain the first correlation between the query statement and the target question; it is determined that the first correlation is not greater than the preset threshold.
在一些实施例中,方法还包括:在第一相关度大于预设阈值的情况下,从问答集中获取目标问题对应的答案;将目标问题对应的答案,确定为查询语句对应的目标答案。In some embodiments, the method further includes: when the first correlation is greater than a preset threshold, obtaining the answer corresponding to the target question from the question and answer set; determining the answer corresponding to the target question as the target answer corresponding to the query statement.
在一些实施例中,从至少一个文档包括的多个内容片段中,获取与查询语句匹配的目标内容片段,包括:基于查询语句进行查询,以从多个内容片段中,获取与查询语句相关的多个候选内容片段;基于NLP领域的第二相关度模型,获取查询语句与各候选内容片段之间的第二相关度;基于各第二相关度,从各候选内容片段中获取目标内容片段。In some embodiments, obtaining target content fragments matching the query statement from multiple content fragments included in at least one document includes: querying based on the query statement to obtain from the multiple content fragments related to the query statement. Multiple candidate content segments; based on the second correlation model in the NLP field, obtain the second correlation between the query statement and each candidate content segment; based on each second correlation, obtain the target content segment from each candidate content segment.
在一些实施例中,从至少一个文档包括的多个内容片段中,获取与所述查询语句匹配的目标内容片段之前,还包括:基于人工智能AI领域的光学字符识别OCR技术,对各文档进行识别,以获取各文档的识别结果;对各识别结果进行结构化处理,以得到各文档中包括的多个内容片段;将各内容片段与对应的内容字段对应保存。In some embodiments, before obtaining the target content fragment matching the query statement from multiple content fragments included in at least one document, the method further includes: based on optical character recognition OCR technology in the field of artificial intelligence (AI), performing on each document Recognize to obtain the recognition results of each document; perform structured processing on each recognition result to obtain multiple content fragments included in each document; and store each content fragment in correspondence with the corresponding content field.
在一些实施例中,基于人工智能AI领域的光学字符识别OCR技术,对各文档进行识别,以获取各文档的识别结果,包括:调用RPA机器人将各文档上传至文档处理平台,以基于文档处理平台,采用光学字符识别OCR技术,对各文档进行识别;获取文档处理平台返回的各文档的识别结果。In some embodiments, based on the optical character recognition OCR technology in the field of artificial intelligence, each document is recognized to obtain the recognition results of each document, including: calling the RPA robot to upload each document to the document processing platform for document processing. The platform uses optical character recognition (OCR) technology to identify each document; and obtains the recognition results of each document returned by the document processing platform.
本公开第二方面实施例提供一种答案生成装置,包括:第一获取模块,用于获取查询语句以及查询语句所属的问题类型;第二获取模块,用于从至少一个文档包括的多个内容片段中,获取与查询语句匹配的目标内容片段;生成模块,用于按照问题类型对应的应答策略,基于目标内容片段,生成查询语句对应的目标答案。A second embodiment of the present disclosure provides an answer generation device, including: a first acquisition module for acquiring a query statement and the question type to which the query statement belongs; and a second acquisition module for obtaining multiple contents included in at least one document. In the fragment, the target content fragment matching the query statement is obtained; the generation module is used to generate the target answer corresponding to the query statement based on the target content fragment according to the response strategy corresponding to the question type.
在一些实施例中,问题类型包括数字类、抽取类、判断类中的一个;目标内容片段的数量为多个;生成模块,包括:第一获取单元,用于对于每个目标内容片段,将查询语句与目标内容片段输入自然语言处理NLP领域的抽取模型,以从目标内容片段中抽取查询语句对应的候选答案片段,并获取对应的置信度;第二获取单元,用于根据各候选答案片段对应的置信度,从各候选答案片段中获取目标答案片段;生成单元,用于按照问题类型对应的应答策略,基于目标答案片段生成目标答案。In some embodiments, the question type includes one of a numerical class, an extraction class, and a judgment class; the number of target content segments is multiple; the generation module includes: a first acquisition unit, used for each target content segment, The query statement and the target content fragment are input into the extraction model in the field of natural language processing NLP to extract the candidate answer fragments corresponding to the query statement from the target content fragment and obtain the corresponding confidence level; the second acquisition unit is used to extract the candidate answer fragments according to each candidate answer fragment. The corresponding confidence level is used to obtain the target answer fragment from each candidate answer fragment; the generation unit is used to generate the target answer based on the target answer fragment according to the response strategy corresponding to the question type.
本公开第三方面实施例提出了一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,该处理器执行计算机程序时,实现如本公开上述第一方面实施例所述的方法。The third embodiment of the present disclosure provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the above-mentioned first step of the present disclosure is implemented. Methods described in aspect embodiments.
本公开第四方面实施例提出了一种计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如本公开上述第一方面实施例所述的方法。The fourth embodiment of the present disclosure provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method described in the first embodiment of the present disclosure is implemented.
本公开第五方面实施例提出了一种计算机程序产品,包括计算机程序,所述计算机程序在被处理器执行时实现如本公开上述第一方面实施例所述的方法。The fifth aspect embodiment of the present disclosure proposes a computer program product, which includes a computer program. When executed by a processor, the computer program implements the method described in the above first aspect embodiment of the present disclosure.
本公开第六方面实施例提出了一种计算机程序,所述计算机程序包括计算机程序代码,当所述计算机程序代码在计算机上运行时,使得计算机执行如本公开上述第一方面实施例所述的方法。The sixth embodiment of the present disclosure provides a computer program. The computer program includes computer program code. When the computer program code is run on a computer, it causes the computer to execute the method described in the first embodiment of the present disclosure. method.
本公开实施例提供的技术方案可以包括以下有益效果:The technical solutions provided by the embodiments of the present disclosure may include the following beneficial effects:
在获取查询语句以及查询语句所属的问题类型后,从至少一个文档包括的多个内容片段中,获取与查询语句匹配的目标内容片段,进而按照问题类型对应的应答策略,基于目标内容片段,生成查询语句对应的目标答案。由此,通过代替人工自动生成答案,减少了生成答案所需的人力成本及时间成本,且通过从文档中精确确定能够回答用户问题的目标内容片段,并根据该目标内容片段生成查询语句对应的答案,提高了生成的答案的准确性。After obtaining the query statement and the question type to which the query statement belongs, obtain the target content fragment that matches the query statement from multiple content fragments included in at least one document, and then generate based on the target content fragment according to the response strategy corresponding to the question type. The target answer corresponding to the query statement. Therefore, by automatically generating answers instead of manual work, the labor cost and time cost required to generate answers are reduced, and by accurately determining the target content fragment that can answer the user's question from the document, and generating the query statement corresponding to the target content fragment. answers, improving the accuracy of the generated answers.
本公开的附加方面和优点将在下面的描述中部分给出,部分将从下面的描述中变得明显,或通过本公开的实践了解到。Additional aspects and advantages of the disclosure will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the disclosure.
附图说明Description of the drawings
在附图中,除非另外规定,否则贯穿多个附图相同的附图标记表示相同或相似的部件或元素。这些附图不一定是按照比例绘制的。应该理解,这些附图仅描绘了根据本公开的一些实施方式,而不应将其视为是对本公开范围的限制。In the drawings, unless otherwise specified, the same reference numbers refer to the same or similar parts or elements throughout the several figures. The drawings are not necessarily to scale. It should be understood that these drawings depict only some embodiments in accordance with the disclosure and are not to be considered limiting of the scope of the disclosure.
图1是根据本公开第一实施例的答案生成方法的流程示意图;Figure 1 is a schematic flowchart of an answer generation method according to the first embodiment of the present disclosure;
图2是根据本公开第一实施例的答案生成装置提供的交互界面的示例图;Figure 2 is an example diagram of an interactive interface provided by an answer generation device according to the first embodiment of the present disclosure;
图3是根据本公开第二实施例的答案生成方法的流程示意图;Figure 3 is a schematic flowchart of an answer generation method according to a second embodiment of the present disclosure;
图4是根据本公开第三实施例的答案生成方法的流程示意图;Figure 4 is a schematic flowchart of an answer generation method according to a third embodiment of the present disclosure;
图5是根据本公开第四实施例的答案生成方法的流程示意图;Figure 5 is a schematic flowchart of an answer generation method according to a fourth embodiment of the present disclosure;
图6是根据本公开第四实施例的文档处理平台的交互界面及文档的识别结果的示例图;Figure 6 is an example diagram of an interactive interface of a document processing platform and a recognition result of a document according to the fourth embodiment of the present disclosure;
图7是根据本公开第四实施例的文本识别结果及对应的内容片段的示例图;Figure 7 is an example diagram of text recognition results and corresponding content fragments according to the fourth embodiment of the present disclosure;
图8是根据本公开第四实施例的表格识别结果及对应的内容片段的示例图;Figure 8 is an example diagram of table recognition results and corresponding content fragments according to the fourth embodiment of the present disclosure;
图9是根据本公开第五实施例的答案生成装置的结构示意图;Figure 9 is a schematic structural diagram of an answer generation device according to a fifth embodiment of the present disclosure;
图10是用来实现本公开实施例的答案生成方法的电子设备的框图。FIG. 10 is a block diagram of an electronic device used to implement the answer generation method of an embodiment of the present disclosure.
具体实施方式Detailed ways
下面详细描述本公开的实施例,所述实施例的示例在附图中示出,其中自始至终相同或类似的标号表示相同或类似的元件或具有相同或类似功能的元件。下面通过参考附图描述的实施例是示例性的,仅用于解释本公开,而不能理解为对本公开的限制。Embodiments of the present disclosure are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the drawings are exemplary and are only used to explain the present disclosure and are not to be construed as limitations of the present disclosure.
参照下面的描述和附图,将清楚本公开的实施例的这些和其他方面。在这些描述和附图中,具体公开了本公开的实施例中的一些特定实施方式,来表示实施本公开的实施例的原理的一些方式,但是应当理解,本公开的实施例的范围不受此限制。相反,本公开的实施例包括落入所附加权利要求书的精神和 内涵范围内的所有变化、修改和等同物。These and other aspects of embodiments of the present disclosure will become apparent with reference to the following description and accompanying drawings. In these descriptions and drawings, some specific implementations of the embodiments of the disclosure are specifically disclosed to represent some of the ways of implementing the principles of the embodiments of the disclosure, but it should be understood that the scope of the embodiments of the disclosure is not limited by this restriction. On the contrary, the disclosed embodiments include all changes, modifications and equivalents falling within the spirit and scope of the appended claims.
需要说明的是,本公开的技术方案中,所涉及的用户个人信息的获取,存储和应用等,均符合相关法律法规的规定,且不违背公序良俗。It should be noted that in the technical solution of this disclosure, the acquisition, storage and application of user personal information involved are in compliance with relevant laws and regulations and do not violate public order and good customs.
本公开实施例提供一种答案生成方法,在获取查询语句以及查询语句所属的问题类型后,从至少一个文档包括的多个内容片段中,获取与查询语句匹配的目标内容片段,进而按照问题类型对应的应答策略,基于目标内容片段,生成查询语句对应的目标答案,由此,通过代替人工自动生成答案,减少了生成答案所需的人力成本及时间成本,且通过从文档中精确确定能够回答用户问题的目标内容片段,并根据该目标内容片段生成查询语句对应的答案,提高了生成的答案的准确性。Embodiments of the present disclosure provide an answer generation method. After obtaining a query statement and the question type to which the query statement belongs, target content fragments matching the query statement are obtained from multiple content fragments included in at least one document, and then the target content fragments matching the query statement are obtained according to the question type. The corresponding response strategy generates the target answer corresponding to the query statement based on the target content fragment. Therefore, by replacing the manual automatic generation of the answer, the labor cost and time cost required to generate the answer are reduced, and the answer can be accurately determined from the document. The target content fragment of the user's question is generated, and the answer corresponding to the query statement is generated based on the target content fragment, which improves the accuracy of the generated answer.
为了清楚说明本公开的各实施例,首先对本公开实施例中涉及到的技术名词进行解释说明。In order to clearly explain the various embodiments of the present disclosure, technical terms involved in the embodiments of the present disclosure are first explained.
在本公开的描述中,术语“多个”指两个或两个以上。In the description of the present disclosure, the term "plurality" means two or more.
在本公开的描述中,“RPA机器人”,是指可结合AI技术和RPA技术,自动进行业务处理的软件机器人。RPA机器人拥有“连接器”和“无侵入”两个特性,通过模拟人类的操作方法,在不更改信息系统的前提下,使用非侵入的方式,将不同系统的数据进行提取、整合和连通。In the description of this disclosure, "RPA robot" refers to a software robot that can combine AI technology and RPA technology to automatically perform business processing. RPA robots have two characteristics: "connector" and "non-intrusion". By simulating human operation methods, they can extract, integrate and connect data from different systems in a non-intrusive way without changing the information system.
在本公开的描述中,“查询语句”,指用户输入的用于查询的语句,即用户想问的问题,其可以是文本形式的语句,也可以是语音形式的语句,本公开对此不作限制。In the description of this disclosure, "query statement" refers to the statement input by the user for query, that is, the question the user wants to ask. It can be a statement in text form or a statement in voice form. This disclosure does not make any comment on this. limit.
在本公开的描述中,“文档”,为用于从中检索能够回答用户问题的具体内容,并依此生成用户问题的答案的电子形式的文档,其可以是对纸质文件进行扫描得到的PDF(Portable Document Format,便携式文档格式)格式的文档,也可以是在电脑、手机等智能设备中编辑形成的文档,本公开对此不作限制。In the description of this disclosure, a "document" is an electronic document used to retrieve specific content that can answer a user's question and generate an answer to the user's question accordingly. It can be a PDF obtained by scanning a paper document. (Portable Document Format, Portable Document Format) format documents can also be documents edited on smart devices such as computers and mobile phones, and this disclosure does not limit this.
在本公开的描述中,“内容片段”,为文档中的部分内容组成的片段,内容片段可以是一句话或几句话,也可以是文档中的一个段落,或者文档中的一个表格,或者一个表格中的部分内容等,本公开对此不作限制。本公开的一些实施例中,可以预先设置内容片段中包括的字符数量,从而通过对待检索的所有文档进行处理,将所有文档中的内容划分为多个内容片段,每个内容片段中包括的字符数量小于或等于预设字符数量。In the description of this disclosure, a "content fragment" is a fragment composed of part of the content in the document. The content fragment can be one sentence or several sentences, or it can be a paragraph in the document, or a table in the document, or Partial content in a table, etc., this disclosure does not limit this. In some embodiments of the present disclosure, the number of characters included in the content fragments can be set in advance, so that by processing all documents to be retrieved, the content in all documents is divided into multiple content fragments, and the characters included in each content fragment are The number is less than or equal to the preset number of characters.
在本公开的描述中,“候选内容片段”,指从所有文档包括的所有内容片段中,获取的与查询语句相关的内容片段。“目标内容片段”,指从候选内容片段或所有文档包括的所有内容片段中,获取的与查询语句匹配的内容片段,即能够准确回答用户问题的具体内容。In the description of this disclosure, "candidate content fragments" refer to content fragments related to the query statement obtained from all content fragments included in all documents. "Target content fragment" refers to the content fragment matching the query statement obtained from the candidate content fragment or all content fragments included in all documents, that is, the specific content that can accurately answer the user's question.
在本公开的描述中,“答案片段”,为内容片段中更细粒度的片段,根据答案片段可以生成用户问题的答案。“候选答案片段”,为从目标内容片段中获取的答案片段。“目标答案片段”,为从候选答案片段中获取的答案片段。In the description of this disclosure, "answer fragments" are more fine-grained fragments in content fragments, and answers to user questions can be generated based on the answer fragments. "Candidate answer fragment" is an answer fragment obtained from the target content fragment. "Target answer fragment" is an answer fragment obtained from candidate answer fragments.
在本公开的描述中,“问答集”为预先设置的包括多个候选问题及对应的答案的集合,比如FAQ。In the description of this disclosure, a "question and answer set" is a preset set including multiple candidate questions and corresponding answers, such as FAQ.
在本公开的描述中,“属性信息”,为表示内容片段的属性的信息,比如内容片段所在文档的文档名称,内容片段对应的章节标题及章节号,章节标题的各级父标题等。In the description of this disclosure, "attribute information" is information that represents the attributes of a content fragment, such as the document name of the document where the content fragment is located, the chapter title and chapter number corresponding to the content fragment, the parent titles of each level of the chapter title, etc.
在本公开的描述中,“相关度”,用于表示相关程度的大小。In the description of this disclosure, "correlation degree" is used to express the magnitude of the degree of correlation.
在本公开的描述中,“相关度模型”,为任意能够进行相关程度计算的机器模型,比如Bert(Bidirectional Encoder Representations from Transformers,一种基于双向编码器表示模型)等神经网络模型。在一些实施例中,相关度模型可以通过对NLP领域的预训练模型进行微调得到。In the description of this disclosure, "correlation model" is any machine model that can calculate the degree of correlation, such as Bert (Bidirectional Encoder Representations from Transformers, a bidirectional encoder representation model) and other neural network models. In some embodiments, the relevance model can be obtained by fine-tuning a pre-trained model in the NLP field.
在本公开的描述中,“判断模型”,为任意能够实现判断的机器模型,比如神经网络模型,本公开对此不作限制。In the description of this disclosure, "judgment model" is any machine model that can realize judgment, such as a neural network model, and this disclosure does not limit this.
在本公开的描述中,“抽取模型”,为任意能够实现信息抽取的机器模型,比如神经网络模型,本公开对此不作限制。In the description of this disclosure, "extraction model" is any machine model that can realize information extraction, such as a neural network model, and this disclosure does not limit this.
在本公开的描述中,“预设规则”,为预先设置的抽取规则,其可以为正则表达式的形式,也可以为其它形式,本公开对此不作限制。本公开中为了便于区分,将预先设置的从目标答案片段中抽取目标数字的抽取规则,称为第一预设规则,将预先设置的从目标内容片段中抽取目标答案的规则,称为第二预设规则。In the description of this disclosure, "preset rules" are preset extraction rules, which may be in the form of regular expressions or other forms, and this disclosure does not limit this. In order to facilitate distinction in this disclosure, the preset extraction rules for extracting target numbers from target answer segments are called first preset rules, and the preset rules for extracting target answers from target content segments are called second preset rules. Default rules.
在本公开的描述中,“内容相关度”,为基于内容片段所包含的内容确定的查询语句与内容片段之间的相关度,用于表示内容片段所包含的内容与查询语句之间的相关程度的大小。In the description of the present disclosure, "content relevance" is the correlation between the query statement and the content fragment determined based on the content contained in the content fragment, and is used to represent the correlation between the content contained in the content fragment and the query statement. The size of the degree.
在本公开的描述中,“属性相关度”,为基于内容片段对应的属性信息确定的查询语句与内容片段之间的相关度,用于表示内容片段对应的属性信息与查询语句之间的相关程度的大小。In the description of this disclosure, "attribute correlation" is the correlation between the query statement and the content fragment determined based on the attribute information corresponding to the content fragment, and is used to represent the correlation between the attribute information corresponding to the content fragment and the query statement. The size of the degree.
在本公开的描述中,“分割片段”,指对文档进行分割得到的内容所组成的片段,比如,按照用于句末的标点符号,将文档分割成多个句子后,每个句子即为一个分割片段。本公开实施例中的每个内容片段,可以包括一个或多个分割片段。In the description of this disclosure, "segmented fragments" refer to fragments composed of content obtained by dividing the document. For example, after the document is divided into multiple sentences according to the punctuation marks used at the end of the sentence, each sentence is A split fragment. Each content segment in the embodiment of the present disclosure may include one or more segmented segments.
在本公开的描述中,“文档处理平台”,为用于对文档进行智能处理的智能自动化平台。其中,智能文档处理(Intelligent Document Processing,IDP)是智能自动化平台的核心能力之一。智能文档处理(IDP)是基于光学字符识别(Optical Character Recognition,OCR)、计算机视觉(Computer Vision,CV)、自然语言处理(Natural Language Processing,NLP)、知识图谱(Knowledge Graph,KG)等AI技术,对各类文档进行识别、分类、要素提取、校验、比对、纠错等处理,帮助企业实现文档处理工作的智能化和自动化的新一代自动化技术。In the description of this disclosure, a "document processing platform" is an intelligent automation platform for intelligently processing documents. Among them, Intelligent Document Processing (IDP) is one of the core capabilities of the intelligent automation platform. Intelligent document processing (IDP) is based on AI technologies such as Optical Character Recognition (OCR), Computer Vision (CV), Natural Language Processing (NLP), and Knowledge Graph (KG). , a new generation of automation technology that identifies, classifies, extracts elements, verifies, compares, and corrects errors in various types of documents, helping enterprises realize the intelligence and automation of document processing.
在本公开的描述中,“内容字段”,为由单个字符或连续的多个字符组成的字段,“内容字段”可以理解为属性项key,内容片段所包含的内容可以理解为属性值value。内容字段和对应的内容片段共同组成一条结构化数据。另外,内容字段、以及内容片段的属性信息对应的字段,比如名称为“文档名称”的字段、名称为“章节标题”的字段、名称为“各级父标题”的字段,可以组成一个结构体。In the description of this disclosure, a "content field" is a field composed of a single character or multiple consecutive characters. The "content field" can be understood as the attribute item key, and the content contained in the content fragment can be understood as the attribute value value. The content fields and corresponding content fragments together form a piece of structured data. In addition, the content field and the fields corresponding to the attribute information of the content fragment, such as the field named "Document Name", the field named "Chapter Title", and the field named "Parent Title at All Levels", can form a structure. .
以下结合附图描述根据本公开实施例的答案生成方法、装置、电子设备及存储介质。Answer generation methods, devices, electronic devices and storage media according to embodiments of the present disclosure are described below with reference to the accompanying drawings.
首先结合附图,对本公开实施例中的答案生成方法进行说明。First, the answer generation method in the embodiment of the present disclosure will be described with reference to the accompanying drawings.
图1是本公开第一实施例的答案生成方法的流程图。如图1所示,该方法可包括以下步骤:101-103。Figure 1 is a flowchart of an answer generation method according to the first embodiment of the present disclosure. As shown in Figure 1, the method may include the following steps: 101-103.
步骤101,获取查询语句以及查询语句所属的问题类型。Step 101: Obtain the query statement and the question type to which the query statement belongs.
需要说明的是,本公开实施例的答案生成方法,可以由答案生成装置执行。在一些实施例中,该答案生成装置可以由软件和/或硬件实现,该答案生成装置可以为电子设备,或者也可以配置在电子设备中,以实现代替人工自动生成用户问题的准确答案。在一些实施例中,该电子设备可以包括但不限于终端设备、服务器等,该实施例对电子设备不作具体限定。在一些实施例中,答案生成装置可以为智能应答系统。It should be noted that the answer generation method in the embodiment of the present disclosure can be executed by an answer generation device. In some embodiments, the answer generating device can be implemented by software and/or hardware, and the answer generating device can be an electronic device, or can be configured in an electronic device to automatically generate accurate answers to user questions instead of manual work. In some embodiments, the electronic device may include but is not limited to a terminal device, a server, etc. This embodiment does not specifically limit the electronic device. In some embodiments, the answer generating device may be an intelligent answering system.
在本公开实施例中,答案生成装置可以提供交互界面,从而用户可以在交互界面中输入查询语句进行查询,相应的,答案生成装置可以获取查询语句。In the embodiment of the present disclosure, the answer generation device can provide an interactive interface, so that the user can input a query statement in the interactive interface to perform a query, and accordingly, the answer generation device can obtain the query statement.
在本公开实施例中,可以预先训练分类模型,从而可以将查询语句输入分类模型,并根据分类模型的输出,获取查询语句所属的问题类型。其中,分类模型,可以为相关技术中任意能够实现分类的模型,比如神经网络模型,本公开对此不作限制。In the embodiment of the present disclosure, the classification model can be pre-trained, so that the query statement can be input into the classification model, and the question type to which the query statement belongs can be obtained based on the output of the classification model. The classification model can be any model in related technologies that can realize classification, such as a neural network model, and this disclosure does not limit this.
在本公开实施例中,查询语句所属的问题类型,可以包括数字类、统计类、抽取类、判断类等。In the embodiment of the present disclosure, the question type to which the query statement belongs may include numerical type, statistical type, extraction type, judgment type, etc.
在本公开实施例中,数字类,指对应的答案为具体数字。比如,查询语句为“新投运的220KV变压器,在施加电压前静止时间应不少于多少小时?”的情况下,需要回答一个具体的数字,则该查询语句所属的问题类型为数字类。“KV”指千伏。In the embodiment of the present disclosure, the numerical type means that the corresponding answer is a specific number. For example, if the query statement is "A newly put into operation 220KV transformer, the rest time should be no less than how many hours before voltage is applied?" If a specific number needs to be answered, the question type to which the query statement belongs is numeric. "KV" means kilovolts.
统计类,指对应的答案需要进行统计。比如,查询语句为“片式散热器按冷却方式可以分为几类”的情况下,对应的答案需要统计片式散热器的几种类型,则该查询语句所属的问题类型为统计类。Statistical category means that the corresponding answers need to be counted. For example, if the query statement is "How many types of chip radiators can be divided according to cooling methods?" and the corresponding answer needs to count the types of chip radiators, then the question type to which the query statement belongs is statistical.
抽取类,指对应的答案需要从一段文字或表格中进行抽取。比如,查询语句为“易损件的更换周期要求是什么”的情况下,需要从一段文字或表格中抽取得到对应的答案,则该查询语句所属的问题类型为抽取类。Extraction type means that the corresponding answer needs to be extracted from a piece of text or a table. For example, if the query statement is "What are the replacement cycle requirements for wearing parts?" and the corresponding answer needs to be extracted from a paragraph of text or a table, then the question type to which the query statement belongs is the extraction class.
判断类,指对应的答案为“是”或“否”。比如,查询语句为“750KV油浸式变压器换油后静止72h是否满足要求”的情况下,对应的答案为“是”或“否”,则该查询语句所属的问题类型为判断类。其中,“h”指小时。Judgment type means that the corresponding answer is "yes" or "no". For example, if the query statement is "Does the 750KV oil-immersed transformer meet the requirements for 72 hours of rest after oil change?" and the corresponding answer is "yes" or "no", then the question type to which the query statement belongs is a judgment type. where "h" refers to the hour.
步骤102,从至少一个文档包括的多个内容片段中,获取与查询语句匹配的目标内容片段。Step 102: Obtain a target content fragment matching the query statement from multiple content fragments included in at least one document.
在本公开实施例中,目标内容片段的数量可以为一个,也可以为多个,本公开对此不作限制。In this embodiment of the disclosure, the number of target content segments may be one or multiple, and the disclosure does not limit this.
在本公开实施例中,可以预先对待检索的大量文档(即需要从中检索能够回答用户问题的具体内容并依此给出答案的文档)进行处理,以得到多个内容片段,进而在获取查询语句后,可以从多个内容片段中获取与查询语句匹配的目标内容片段。In the embodiment of the present disclosure, a large number of documents to be retrieved (that is, documents that need to retrieve specific content that can answer the user's questions and provide answers accordingly) can be processed in advance to obtain multiple content fragments, and then obtain the query statement. Afterwards, the target content fragment matching the query statement can be obtained from multiple content fragments.
在本公开实施例中,可以预先设置目标内容片段的数量,从而答案生成装置可以获取查询语句与各内容片段之间的相关度,并将各内容片段按照对应的相关度从高到低的顺序进行排序,将排序在前的预设数量的内容片段,确定为目标内容片段。In the embodiment of the present disclosure, the number of target content fragments can be set in advance, so that the answer generation device can obtain the correlation between the query statement and each content fragment, and arrange each content fragment in order from high to low according to the corresponding correlation. Sorting is performed, and the preset number of content fragments that are sorted first are determined as the target content fragments.
在本公开实施例中,可以预先设置相关度阈值(为了便于区分,可以称为第一相关度阈值),从而答案生成装置可以获取查询语句与各内容片段之间的相关度,并将各内容片段中,对应的相关度大于第一相关度阈值的内容片段,确定为目标内容片段。其中,第一相关度阈值可以根据需要任意设置,本公开对此不作限制。In the embodiment of the present disclosure, the correlation threshold can be set in advance (for ease of differentiation, it can be called the first correlation threshold), so that the answer generation device can obtain the correlation between the query statement and each content segment, and combine each content Among the fragments, the content fragment whose corresponding correlation degree is greater than the first correlation degree threshold is determined as the target content fragment. The first correlation threshold can be set arbitrarily as needed, and this disclosure does not limit this.
步骤103,按照问题类型对应的应答策略,基于目标内容片段,生成查询语句对应的目标答案。Step 103: Generate a target answer corresponding to the query statement based on the target content fragment according to the response strategy corresponding to the question type.
在本公开实施例中,应答策略,为预先设置的根据目标内容片段,生成查询语句对应的目标答案的策略。其中,不同的问题类型可以设置不同的应答策略。In the embodiment of the present disclosure, the response strategy is a preset strategy for generating target answers corresponding to query statements based on target content segments. Among them, different response strategies can be set for different question types.
在本公开实施例中,答案生成装置可以提供交互界面,从而在按照问题类型对应的应答策略,基于目标内容片段,生成查询语句对应的目标答案后,可以通过交互界面展示目标答案。另外,答案生成装置还可以在展示目标答案的同时,通过交互界面展示查询语句所属的问题类型、目标内容片段、目标内容片段对应的属性信息,以及包含目标内容片段的段落或表格(其中,目标内容片段或包含目标内容片段的段落或表格作为回答依据)等信息,以使用户可以更清楚的了解查询语句的目标答案的出处。In the embodiment of the present disclosure, the answer generation device can provide an interactive interface, so that after generating the target answer corresponding to the query statement based on the target content fragment according to the response strategy corresponding to the question type, the target answer can be displayed through the interactive interface. In addition, the answer generation device can also display the question type to which the query statement belongs, the target content fragment, the attribute information corresponding to the target content fragment, and the paragraph or table containing the target content fragment through the interactive interface while displaying the target answer (where the target Content fragments or paragraphs or tables containing target content fragments as the basis for answers) and other information, so that users can more clearly understand the source of the target answer to the query statement.
比如,参考图2,以答案生成装置为智能应答系统为例,智能应答系统可以提供交互界面,用户在交互界面上输入查询语句“750KV油浸式变压器换油后静止72h是否满足要求”后,智能应答系统可以确定查询语句所属的问题类型为判断类,进而从至少一个文档包括的多个内容片段中,获取与查询语句匹配的目标内容片段“新装、大修、事故检修或换油后的变压器,在施加电压前静止时间不应少于以下规定:a)110KV 24h b)220KV 48h c)500(330)KV 72h d)750KV 96h”,并获取内容片段对应的章节号“5.2.6”,进而按照判断类对应的应答策略,基于目标内容片段,生成查询语句对应的目标答案“否,96h”,并如图2所示,通过交互界面展示目标答案、问题类型、目标内容片段及对应的章节号。For example, refer to Figure 2, taking the answer generation device as an intelligent response system as an example. The intelligent response system can provide an interactive interface. After the user enters the query statement "Does the 750KV oil-immersed transformer meet the requirements for resting for 72 hours after oil change" on the interactive interface, The intelligent response system can determine that the question type to which the query statement belongs is a judgment type, and then obtain the target content fragment that matches the query statement "transformers after new installation, overhaul, accident maintenance or oil change" from multiple content fragments included in at least one document , the resting time before applying voltage should not be less than the following provisions: a) 110KV 24h b) 220KV 48h c) 500(330)KV 72h d) 750KV 96h", and obtain the chapter number "5.2.6" corresponding to the content fragment, Then, according to the response strategy corresponding to the judgment type, based on the target content fragment, the target answer "No, 96h" corresponding to the query statement is generated, and as shown in Figure 2, the target answer, question type, target content fragment and corresponding are displayed through the interactive interface Chapter number.
综上,本公开实施例提供的答案生成方法,在获取查询语句以及查询语句所属的问题类型后,从至少一个文档包括的多个内容片段中,获取与查询语句匹配的目标内容片段,进而按照问题类型对应的应答策略,基于目标内容片段,生成查询语句对应的目标答案。由此,通过代替人工自动生成答案,减少了生成答案所需的人力成本及时间成本,且通过从文档中精确确定能够回答用户问题的目标内容片段,并根据该目标内容片段生成查询语句对应的答案,提高了生成的答案的准确性。In summary, the answer generation method provided by the embodiment of the present disclosure, after obtaining the query statement and the question type to which the query statement belongs, obtains the target content fragment matching the query statement from multiple content fragments included in at least one document, and then according to the The response strategy corresponding to the question type generates the target answer corresponding to the query statement based on the target content fragment. Therefore, by automatically generating answers instead of manual work, the labor cost and time cost required to generate answers are reduced, and by accurately determining the target content fragment that can answer the user's question from the document, and generating the query statement corresponding to the target content fragment. answers, improving the accuracy of the generated answers.
下面结合图3,对本公开实施例提供的答案生成方法中,按照问题类型对应的应答策略,基于目标内容片段,生成查询语句对应的目标答案的过程进行进一步说明。The following is a further explanation of the process of generating the target answer corresponding to the query statement based on the target content fragment according to the response strategy corresponding to the question type in the answer generation method provided by the embodiment of the present disclosure with reference to FIG. 3 .
图3是根据本公开第二实施例的答案生成方法的流程图,如图3所示,该方法包括步骤301-306。Figure 3 is a flow chart of an answer generation method according to the second embodiment of the present disclosure. As shown in Figure 3, the method includes steps 301-306.
步骤301,获取查询语句以及查询语句所属的问题类型。Step 301: Obtain the query statement and the question type to which the query statement belongs.
步骤302,从至少一个文档包括的多个内容片段中,获取与查询语句匹配的目标内容片段。Step 302: Obtain the target content fragment matching the query statement from multiple content fragments included in at least one document.
其中,步骤302的具体实现过程及原理,可以参考其它实施例的描述,此处不再赘述。For the specific implementation process and principle of step 302, please refer to the descriptions of other embodiments and will not be described again here.
步骤303,在问题类型包括数字类、抽取类、判断类中的一个的情况下,对于每个目标内容片段,将查询语句与目标内容片段输入自然语言处理NLP领域的抽取模型,以从目标内容片段中抽取查询语句对应的候选答案片段,并获取对应的置信度。Step 303: When the question type includes one of numerical class, extraction class, and judgment class, for each target content segment, input the query statement and the target content segment into the extraction model in the field of natural language processing NLP to extract the target content from the target content segment. Extract candidate answer fragments corresponding to the query statement from the fragments, and obtain the corresponding confidence levels.
其中,在问题类型包括数字类、抽取类、判断类中的一个的情况下,目标内容片段的数量可以为多个,比如可以为20个、30个等。Wherein, when the question type includes one of numerical type, extraction type, and judgment type, the number of target content fragments can be multiple, for example, it can be 20, 30, etc.
其中,置信度,表示目标内容片段能够回答查询语句的概率。Among them, confidence represents the probability that the target content fragment can answer the query statement.
在本公开实施例中,可以预先训练抽取模型,对于每个目标内容片段,在答案生成装置将查询语句以及目标内容片段输入训练好的抽取模型后,抽取模型可以确定查询语句对应的目标答案在输入的目标内容片段中的起始位置以及终止位置,进而将目标内容片段中起始位置与终止位置之间的片段确定为候选答案片段,并确定对应的置信度,并输出候选答案片段及对应的置信度,从而答案生成装置可以根据抽取模型的输出,获取查询语句对应的候选答案片段及对应的置信度。In the embodiment of the present disclosure, the extraction model can be trained in advance. For each target content fragment, after the answer generation device inputs the query statement and the target content fragment into the trained extraction model, the extraction model can determine that the target answer corresponding to the query statement is in Input the starting position and ending position in the target content segment, and then determine the segment between the starting position and the ending position in the target content segment as the candidate answer segment, determine the corresponding confidence level, and output the candidate answer segment and the corresponding The confidence level, so that the answer generation device can obtain the candidate answer fragments corresponding to the query statement and the corresponding confidence level based on the output of the extraction model.
需要说明的是,获取查询语句所属的问题类型的步骤,可以在步骤302之前执行,也可以在步骤302之后执行,本公开对此不作限制,只需在步骤303之前执行即可。It should be noted that the step of obtaining the question type to which the query statement belongs can be performed before step 302 or after step 302. This disclosure does not limit this and it only needs to be performed before step 303.
步骤304,根据各候选答案片段对应的置信度,从各候选答案片段中获取目标答案片段。Step 304: Obtain the target answer segment from each candidate answer segment according to the confidence level corresponding to each candidate answer segment.
在本公开实施例中,可以将各候选答案片段中,对应的置信度最高的候选答案片段,确定为目标答案片段。In the embodiment of the present disclosure, the corresponding candidate answer segment with the highest confidence among each candidate answer segment may be determined as the target answer segment.
步骤305,按照问题类型对应的应答策略,基于目标答案片段生成目标答案。Step 305: Generate a target answer based on the target answer fragment according to the response strategy corresponding to the question type.
在本公开实施例中,在问题类型包括抽取类的情况下,可以直接将目标答案片段作为目标答案。即步骤305包括:将目标答案片段作为目标答案。In the embodiment of the present disclosure, when the question type includes an extraction class, the target answer fragment can be directly used as the target answer. That is, step 305 includes: using the target answer fragment as the target answer.
举例来说,假设查询语句为抽取类的“易损件的更换周期要求是什么”,答案生成装置从至少一个文档包括的多个内容片段中,获取的与查询语句匹配的一个目标内容片段为“5.1.6易损件的更换周期使用10年以上的油泵轴承或冷却风扇轴承运行中发出不正常的噪声时,在变压器或并联电抗器退出运行时予以更换;使用15年以上时,根据具体情况更换所有密封垫”,按照步骤303的过程,从目标内容片段中抽取得到的候选答案片段为“使用10年以上的油泵轴承或冷却风扇轴承运行中发出不正常的噪声时,在变压器或并联电抗器退出运行时予以更换;使用15年以上时,根据具体情况更换所有密封垫”。For example, assuming that the query statement is "What are the replacement cycle requirements for wearing parts" of the extraction class, the answer generation device obtains a target content fragment that matches the query statement from multiple content fragments included in at least one document. "5.1.6 Replacement cycle of wearing parts. If the oil pump bearing or cooling fan bearing that has been used for more than 10 years makes abnormal noise during operation, it should be replaced when the transformer or shunt reactor is out of operation; if it has been used for more than 15 years, it should be replaced according to the specific conditions. "Replace all gaskets", according to the process of step 303, the candidate answer fragment extracted from the target content fragment is "When the oil pump bearing or cooling fan bearing that has been used for more than 10 years makes abnormal noise during operation, the transformer or parallel connection Replace the reactor when it is out of operation; when it is used for more than 15 years, replace all seals according to specific conditions."
假设该候选答案片段对应的置信度在各候选答案片段中最高,则可以将该候选答案片段确定为目标答案片段,并将目标答案片段作为查询语句对应的目标答案。Assuming that the confidence corresponding to the candidate answer fragment is the highest among the candidate answer fragments, the candidate answer fragment can be determined as the target answer fragment, and the target answer fragment can be used as the target answer corresponding to the query statement.
由此,实现了在查询语句为抽取类的情况下,从文档中准确生成查询语句对应的目标答案。Thus, when the query statement is an extracted class, the target answer corresponding to the query statement can be accurately generated from the document.
在本公开实施例中,在问题类型包括判断类的情况下,步骤305可以通过以下方式实现:将目标答案片段和查询语句输入NLP领域的判断模型,以获取查询语句对应的判断结果,将判断结果和/或目标答案片段作为目标答案。In the embodiment of the present disclosure, when the question type includes a judgment class, step 305 can be implemented in the following manner: input the target answer fragment and the query statement into the judgment model in the NLP field to obtain the judgment result corresponding to the query statement, and convert the judgment The result and/or target answer fragment serves as the target answer.
其中,判断结果,可以为“是”或“否”。Among them, the judgment result can be "yes" or "no".
具体的,可以预先设置概率阈值,比如为0.5,并且可以预先训练NLP领域的判断模型,在将目标答案片段和查询语句输入判断模型后,判断模型可以确定并输出查询语句对应的答案为“是”的概率。答案生成装置可以在该概率大于概率阈值0.5的情况下,确定判断结果为“是”,在该概率不大于概率阈值0.5的情况下,确定判断结果为“否”,进而可以将判断结果和/或目标答案片段作为目标答案。Specifically, the probability threshold can be set in advance, such as 0.5, and a judgment model in the NLP field can be pre-trained. After inputting the target answer fragment and query statement into the judgment model, the judgment model can determine and output the answer corresponding to the query statement as "yes" "The probability. The answer generating device can determine the judgment result to be "yes" when the probability is greater than the probability threshold 0.5, and determine the judgment result to be "no" when the probability is not greater than the probability threshold 0.5, and then combine the judgment result with/ or a target answer fragment as the target answer.
举例来说,假设查询语句为判断类的“750KV油浸式变压器换油后静止72h是否满足要求”,答案生成装置从至少一个文档包括的多个内容片段中,获取的与查询语句匹配的一个目标内容片段为“新装、大修、事故检修或换油后的变压器,在施加电压前静止时间不应少于以下规定:a)110KV 24h b)220KV 48h c)500(330)KV 72h d)750KV 96h”,按照步骤303的过程,从目标内容片段中抽取得到的候选答案片段为“96h”。For example, assuming that the query statement is of the judgment type "Does a 750KV oil-immersed transformer meet the requirements for 72 hours of rest after oil change?", the answer generation device obtains one that matches the query statement from multiple content fragments included in at least one document. The target content fragment is "For newly installed, overhauled, accident-repaired or oil-changed transformers, the resting time before applying voltage should not be less than the following provisions: a) 110KV 24h b) 220KV 48h c) 500 (330) KV 72h d) 750KV 96h", according to the process of step 303, the candidate answer segment extracted from the target content segment is "96h".
假设该候选答案片段对应的置信度在各候选答案片段中最高,则可以确定该候选答案片段“96h”为目标答案片段,进而可以将目标答案片段“96h”和查询语句输入NLP领域的判断模型,以获取查询语句对应的判断结果。由于目标答案片段“96h”大于查询语句中的“72h”,则判断模型输出的查询语句对应的答案为“是”的概率低于0.5,从而答案生成装置可以确定判断结果为“否”,进而可以将判断结果“否”和目标答案片段“96h”作为目标答案。Assuming that the confidence corresponding to the candidate answer fragment is the highest among the candidate answer fragments, the candidate answer fragment "96h" can be determined as the target answer fragment, and then the target answer fragment "96h" and the query statement can be input into the judgment model in the NLP field , to obtain the judgment results corresponding to the query statement. Since the target answer fragment "96h" is greater than "72h" in the query statement, the probability that the answer corresponding to the query statement output by the judgment model is "yes" is less than 0.5, so the answer generation device can determine that the judgment result is "no", and then The judgment result "No" and the target answer fragment "96h" can be used as the target answer.
由此,实现了在查询语句为判断类的情况下,从文档中准确生成查询语句对应的目标答案。Thus, when the query statement is a judgment type, the target answer corresponding to the query statement can be accurately generated from the document.
在本公开实施例中,在问题类型包括数字类的情况下,步骤305可以通过以下方式实现:根据第一预设规则,从目标答案片段中获取目标数字,并获取目标数字对应的单位;根据目标数字以及对应的单位,生成目标答案。In the embodiment of the present disclosure, when the question type includes numbers, step 305 can be implemented in the following manner: according to the first preset rule, obtain the target number from the target answer fragment, and obtain the unit corresponding to the target number; according to The target number and the corresponding unit are used to generate the target answer.
其中,第一预设规则可以为正则表达式的形式。The first preset rule may be in the form of a regular expression.
具体的,答案生成装置可以基于正则表达式,从目标答案片段中抽取出目标数字,并同时抽取出目标数字对应的单位,进而将目标数字以及对应的单位拼接成目标答案。或者,也可以预先设置目标答案片段对应的单位,从而在答案生成装置从目标答案片段中抽取出目标数字后,可以将目标数字与预设单位拼接成目标答案。Specifically, the answer generation device can extract the target number from the target answer fragment based on the regular expression, and at the same time extract the unit corresponding to the target number, and then splice the target number and the corresponding unit into the target answer. Alternatively, the units corresponding to the target answer fragments can also be set in advance, so that after the answer generating device extracts the target number from the target answer fragment, the target number and the preset unit can be spliced into the target answer.
举例来说,假设查询语句为数字类的“新投运的220KV变压器,在施加电压前静止时间应不少于多少小时?”,答案生成装置从至少一个文档包括的多个内容片段中,获取的与查询语句匹配的一个目标内容片段为“3.0.3油浸式变压器及电抗器的绝缘试验应在充满合格油,静置一定时间,待气泡消除后方可进行。静置时间应按制造厂规定进行,当制造厂无规定时,油浸式变压器及电抗器电压等级与充油后静置时间关系应按表3.0.3确定。表3.0.3油浸式变压器及电抗器电压等级与充油后静置时间关系>=48”,按照步骤303的过程,从目标内容片段中抽取得到的候选答案片段为“油浸式变压器及电抗器电压等级与充油后静置时间关系>=48”。For example, assuming that the query statement is a numeric type "A newly put into operation 220KV transformer, the rest time should be no less than how many hours before applying voltage?", the answer generation device obtains it from multiple content fragments included in at least one document. One of the target content fragments that matches the query statement is "3.0.3 The insulation test of oil-immersed transformers and reactors should be filled with qualified oil and allowed to stand for a certain period of time until the bubbles are eliminated. The standing time should be determined by the manufacturer. When the manufacturer does not specify, the relationship between the voltage level of oil-immersed transformers and reactors and the resting time after oil filling should be determined according to Table 3.0.3. Table 3.0.3 The voltage levels of oil-immersed transformers and reactors and the relationship between oil filling and charging The relationship between the resting time after oil filling >= 48", according to the process of step 303, the candidate answer fragment extracted from the target content fragment is "The relationship between the voltage level of oil-immersed transformer and reactor and the resting time after oil filling >= 48 ".
假设该候选答案片段对应的置信度在各候选答案片段中最高,则可以确定该候选答案片段“油浸式变压器及电抗器电压等级与充油后静置时间关系>=48”为目标答案片段,进而可以基于正则表达式,从目标答案片段中抽取出目标数字“48”。假设预先设置的单位为“h”,则可以将目标数字“48”与预设单位“h”拼接 成目标答案“48h”。Assuming that the confidence level corresponding to this candidate answer fragment is the highest among all candidate answer fragments, it can be determined that the candidate answer fragment "The relationship between the voltage level of oil-immersed transformers and reactors and the rest time after oil filling >= 48" is the target answer fragment , and then based on regular expressions, the target number "48" can be extracted from the target answer fragment. Assuming that the preset unit is "h", the target number "48" and the preset unit "h" can be spliced into the target answer "48h".
由此,实现了在查询语句为数字类的情况下,从文档中准确生成查询语句对应的目标答案。As a result, when the query statement is numeric, the target answer corresponding to the query statement can be accurately generated from the document.
步骤306,在问题类型包括统计类的情况下,根据第二预设规则,从目标内容片段中抽取得到目标答案。Step 306: If the question type includes statistics, extract the target answer from the target content segment according to the second preset rule.
其中,第二预设规则可以为正则表达式的形式。The second preset rule may be in the form of a regular expression.
其中,在问题类型为统计类的情况下,目标内容片段的数量可以为一个。Wherein, when the question type is statistics, the number of target content fragments may be one.
在本公开实施例中,可以基于正则表达式,对目标内容片段进行抽取,以得到目标答案。In the embodiment of the present disclosure, the target content fragment can be extracted based on the regular expression to obtain the target answer.
举例来说,假设目标内容片段的数量为一个,查询语句为统计类的“片式散热器按冷却方式可以分为几类”,答案生成装置从至少一个文档包括的多个内容片段中,获取的与查询语句匹配的目标内容片段为“4.1.2按冷却方式分为:a)自冷式(ONAN);b)风冷式(ONAF);c)强油风冷式(OFAF)”。For example, assuming that the number of target content fragments is one and the query statement is a statistical "chip radiator can be divided into several categories according to cooling methods", the answer generation device obtains from multiple content fragments included in at least one document. The target content fragment matching the query statement is "4.1.2 According to the cooling method, it is divided into: a) self-cooling (ONAN); b) air-cooling (ONAF); c) strong oil air-cooling (OFAF)".
则答案生成装置可以基于正则表达式,对目标内容片段进行抽取,得到目标答案“自冷式(ONAN),风冷式(ONAF),强油风冷式(OFAF)”。Then the answer generation device can extract the target content fragment based on the regular expression and obtain the target answer "self-cooling (ONAN), air-cooling (ONAF), strong oil air-cooling (OFAF)".
由此,实现了在查询语句为统计类的情况下,从文档中准确生成查询语句对应的目标答案。As a result, when the query statement is of statistical type, the target answer corresponding to the query statement can be accurately generated from the document.
综上,本公开实施例提供的答案生成方法,在获取查询语句以及查询语句所属的问题类型后,从至少一个文档包括的多个内容片段中,获取与查询语句匹配的目标内容片段,在问题类型包括数字类、抽取类、判断类中的一个的情况下,对于每个目标内容片段,将查询语句与目标内容片段输入自然语言处理NLP领域的抽取模型,以从目标内容片段中抽取查询语句对应的候选答案片段,并获取对应的置信度,根据各候选答案片段对应的置信度,从各候选答案片段中获取目标答案片段,按照问题类型对应的应答策略,基于目标答案片段生成目标答案,在问题类型包括统计类的情况下,根据第二预设规则,从目标内容片段中抽取得到目标答案。由此,通过代替人工自动生成答案,减少了生成答案所需的人力成本及时间成本,且对于各问题类型的查询语句,均能从文档中精确确定能够回答用户问题的目标内容片段,并根据该目标内容片段生成查询语句对应的答案,提高了生成的答案的准确性。In summary, the answer generation method provided by the embodiment of the present disclosure, after obtaining the query statement and the question type to which the query statement belongs, obtains the target content fragment matching the query statement from multiple content fragments included in at least one document. When the type includes one of numeric class, extraction class, and judgment class, for each target content fragment, input the query statement and the target content fragment into an extraction model in the field of natural language processing NLP to extract the query statement from the target content fragment. Corresponding candidate answer fragments and obtain the corresponding confidence. According to the confidence corresponding to each candidate answer fragment, obtain the target answer fragment from each candidate answer fragment. According to the response strategy corresponding to the question type, generate the target answer based on the target answer fragment. When the question type includes statistics, the target answer is extracted from the target content segment according to the second preset rule. As a result, by automatically generating answers instead of manual work, the labor cost and time cost required to generate answers are reduced. For query statements of each question type, the target content fragment that can answer the user's question can be accurately determined from the document, and based on The target content fragment generates answers corresponding to the query statements, which improves the accuracy of the generated answers.
在本公开实施例中,还可以综合根据上述实施例中的答案生成过程与预设的问答集比如FAQ来生成查询语句对应的目标答案。下面结合图4,针对上述情况,对本公开实施例提供的答案生成方法进行进一步说明。In the embodiment of the present disclosure, the target answer corresponding to the query statement can also be generated based on the answer generation process in the above embodiment and a preset question and answer set such as FAQ. In view of the above situation, the answer generation method provided by the embodiment of the present disclosure will be further described below with reference to FIG. 4 .
图4是根据本公开第三实施例的答案生成方法的流程图,如图4所示,该方法包括步骤401-408。Figure 4 is a flow chart of an answer generation method according to the third embodiment of the present disclosure. As shown in Figure 4, the method includes steps 401-408.
步骤401,获取查询语句以及查询语句所属的问题类型。Step 401: Obtain the query statement and the question type to which the query statement belongs.
其中,步骤401的具体实现过程及原理,可以参考上述实施例的描述,此处不再赘述。For the specific implementation process and principle of step 401, reference can be made to the description of the above embodiments and will not be described again here.
步骤402,从预设的问答集中获取与查询语句匹配的目标问题。Step 402: Obtain target questions matching the query statement from the preset question and answer set.
在本公开实施例中,可以基于搜索引擎,从预设的问答集中获取与查询语句匹配的目标问题。In the embodiment of the present disclosure, target questions matching the query statement can be obtained from a preset question and answer set based on a search engine.
具体的,预设的问答集中包括的各候选问题可以对应标注所属的问题类型,进而可以基于搜索引擎,从标注的问题类型与查询语句所属的问题类型相同的各候选问题中,获取与查询语句匹配的目标问题。Specifically, each candidate question included in the preset question and answer set can correspond to the question type to which the annotation belongs, and then based on the search engine, the query statement can be obtained from each candidate question whose annotated question type is the same as the question type to which the query statement belongs. Matching target problem.
步骤403,基于NLP领域的第一相关度模型,获取查询语句与目标问题之间的第一相关度。Step 403: Based on the first correlation model in the NLP field, obtain the first correlation between the query statement and the target question.
在本公开实施例中,可以预先训练第一相关度模型,在获取目标问题后,答案生成装置可以将查询语句与目标问题输入第一相关度模型,第一相关度模型可以输出查询语句与目标问题之间的相关程度得分,从而答案生成装置可以根据第一相关度模型的输出,获取查询语句与目标问题之间的第一相关度。In the embodiment of the present disclosure, the first relevance model can be trained in advance. After obtaining the target question, the answer generation device can input the query statement and the target question into the first relevance model, and the first relevance model can output the query statement and the target question. The correlation score between the questions is scored, so that the answer generating device can obtain the first correlation between the query statement and the target question according to the output of the first correlation model.
步骤404,判断第一相关度是否大于预设阈值,若是,则执行步骤405,否则,执行步骤407。Step 404: Determine whether the first correlation degree is greater than the preset threshold. If so, execute step 405; otherwise, execute step 407.
步骤405,从问答集中获取目标问题对应的答案。Step 405: Obtain the answer corresponding to the target question from the question and answer set.
步骤406,将目标问题对应的答案,确定为查询语句对应的目标答案。Step 406: Determine the answer corresponding to the target question as the target answer corresponding to the query statement.
其中,预设阈值,可以根据需要设置,本公开对此不作限制。The preset threshold can be set as needed, and this disclosure does not limit this.
在本公开实施例中,在第一相关度大于预设阈值的情况下,可以从问答集中获取目标问题对应的答案,并将目标问题对应的答案,确定为查询语句对应的目标答案。In the embodiment of the present disclosure, when the first correlation is greater than the preset threshold, the answer corresponding to the target question can be obtained from the question and answer set, and the answer corresponding to the target question is determined as the target answer corresponding to the query statement.
由此,可以基于预设的问答集,快速生成查询语句对应的目标答案,且生成的目标答案的准确性高。As a result, the target answer corresponding to the query statement can be quickly generated based on the preset question and answer set, and the generated target answer is highly accurate.
步骤407,从至少一个文档包括的多个内容片段中,获取与查询语句匹配的目标内容片段。Step 407: Obtain the target content fragment matching the query statement from multiple content fragments included in at least one document.
步骤408,按照问题类型对应的应答策略,基于目标内容片段,生成查询语句对应的目标答案。Step 408: Generate a target answer corresponding to the query statement based on the target content fragment according to the response strategy corresponding to the question type.
其中,步骤407-408的具体实现过程及原理,可以参考其它实施例的描述,此处不再赘述。For the specific implementation process and principles of steps 407-408, please refer to the descriptions of other embodiments and will not be described again here.
在本公开实施例中,在第一相关度不大于预设阈值的情况下,可以从至少一个文档包括的多个内容片段中,获取与查询语句匹配的目标内容片段,并按照问题类型对应的应答策略,基于目标内容片段,生成查询语句对应的目标答案。In the embodiment of the present disclosure, when the first correlation is not greater than the preset threshold, the target content fragment matching the query statement can be obtained from multiple content fragments included in at least one document, and the target content fragment corresponding to the question type can be obtained. The response strategy generates the target answer corresponding to the query statement based on the target content fragment.
由此,可以在基于预设的问答集不能准确回答用户问题的情况下,从文档中精确确定能够回答用户问题的目标内容片段,并根据该目标内容片段生成查询语句对应的答案,且生成的目标答案的准确性高。并且,通过结合从预设的问答集中获取目标答案以及基于文档中目标内容片段生成目标答案,这两种方式来生成目标答案,使得无需浪费大量人力成本来维护预设的问答集,从而减少了人工维护预设的问答集的成本。Thus, when the user's question cannot be accurately answered based on the preset question and answer set, the target content fragment that can answer the user's question can be accurately determined from the document, and the answer corresponding to the query statement is generated based on the target content fragment, and the generated The accuracy of the target answer is high. Moreover, by combining obtaining the target answer from the preset question and answer set and generating the target answer based on the target content fragment in the document, these two methods are used to generate the target answer, so that there is no need to waste a lot of labor costs to maintain the preset question and answer set, thereby reducing The cost of manually maintaining a preset question and answer set.
下面结合图5,对本公开实施例提供的答案生成方法中,从至少一个文档包括的多个内容片段中,获取与查询语句匹配的目标内容片段的过程进行进一步说明。The following is a further explanation of the process of obtaining a target content segment that matches a query statement from multiple content segments included in at least one document in the answer generation method provided by the embodiment of the present disclosure with reference to FIG. 5 .
图5是根据本公开第四实施例的答案生成方法的流程图,如图5所示,该方法包括步骤501-508。Figure 5 is a flow chart of an answer generation method according to the fourth embodiment of the present disclosure. As shown in Figure 5, the method includes steps 501-508.
步骤501,获取查询语句以及查询语句所属的问题类型。Step 501: Obtain the query statement and the question type to which the query statement belongs.
步骤502,基于查询语句进行查询,以从至少一个文档包括的多个内容片段中,获取与查询语句相关的多个候选内容片段。Step 502: Perform a query based on the query statement to obtain multiple candidate content fragments related to the query statement from multiple content fragments included in at least one document.
在本公开实施例中,可以预先对待检索的大量文档进行处理,以得到多个内容片段,并将多个内容片段保存到检索引擎中,进而在答案生成装置获取查询语句后,可以基于该检索引擎,基于查询语句进行查询,以从多个内容片段中,获取与查询语句相关的多个候选内容片段,并返回至答案生成装置。相应的,答案生成装置可以获取多个候选内容片段。In the embodiment of the present disclosure, a large number of documents to be retrieved can be processed in advance to obtain multiple content fragments, and the multiple content fragments can be saved in the retrieval engine. Then, after the answer generation device obtains the query statement, the retrieval can be based on the The engine performs a query based on the query statement to obtain multiple candidate content fragments related to the query statement from multiple content fragments, and returns them to the answer generation device. Correspondingly, the answer generating device can obtain multiple candidate content segments.
其中,检索引擎可以为任意具有检索功能的检索引擎,本公开对此不作限制。另外,检索引擎可以配置在答案生成装置中,或者检索引擎也可以单独配置并通过接口与答案生成装置连接,本公开对此不作限制。The retrieval engine can be any retrieval engine with a retrieval function, and this disclosure does not limit this. In addition, the retrieval engine may be configured in the answer generation device, or the retrieval engine may be configured separately and connected to the answer generation device through an interface, which is not limited by the present disclosure.
在本公开实施例中,可以预先设置候选内容片段的数量,从而检索引擎可以获取查询语句与各内容片段之间的相关度,并将各内容片段按照对应的相关度从高到低的顺序进行排序,将排序在前的预设数量的多个内容片段,确定为多个候选内容片段。In the embodiment of the present disclosure, the number of candidate content fragments can be set in advance, so that the retrieval engine can obtain the correlation between the query statement and each content fragment, and process each content fragment in order from high to low according to the corresponding correlation. Sorting: determine a preset number of content fragments that are ranked first as multiple candidate content fragments.
在本公开实施例中,可以预先设置相关度阈值(为了便于区分,可以称为第二相关度阈值),从而检索引擎可以获取查询语句与各内容片段之间的相关度,并将各内容片段中,对应的相关度大于第二相关度阈值的多个内容片段,确定为多个候选内容片段。其中,第二相关度阈值可以根据需要任意设置,本公开对此不作限制。In the embodiment of the present disclosure, the correlation threshold can be set in advance (for ease of differentiation, it can be called the second correlation threshold), so that the retrieval engine can obtain the correlation between the query statement and each content fragment, and combine each content fragment , multiple content segments whose corresponding correlation degrees are greater than the second correlation threshold are determined as multiple candidate content segments. The second correlation threshold can be set arbitrarily as needed, and this disclosure does not limit this.
在本公开实施例中,步骤502可以通过以下方式实现:获取各内容片段所包含的内容以及各内容片段的属性信息;基于各内容片段所包含的内容,获取查询语句与对应的内容片段之间的内容相关度,以 及基于各内容片段的属性信息,获取查询语句与对应的内容片段之间的属性相关度;基于查询语句与各内容片段之间的内容相关度以及属性相关度,从多个内容片段中,获取与查询语句相关的多个候选内容片段。In this embodiment of the present disclosure, step 502 can be implemented in the following manner: obtaining the content contained in each content fragment and the attribute information of each content fragment; based on the content contained in each content fragment, obtaining the relationship between the query statement and the corresponding content fragment. content correlation, and based on the attribute information of each content fragment, obtain the attribute correlation between the query statement and the corresponding content fragment; based on the content correlation and attribute correlation between the query statement and each content fragment, from multiple In the content fragments, obtain multiple candidate content fragments related to the query statement.
其中,内容片段的属性信息,可以包括内容片段所在文档的文档名称、内容片段对应的章节标题、内容片段对应的章节标题的各级父标题中的至少一个。在内容片段的属性信息包括文档名称、章节标题、各级父标题等多个信息时,相应的,对于每个内容片段,可以基于各属性信息,获取查询语句与对应的内容片段之间的各属性相关度。The attribute information of the content fragment may include at least one of the document name of the document in which the content fragment is located, the chapter title corresponding to the content fragment, and the parent titles at all levels of the chapter title corresponding to the content fragment. When the attribute information of the content fragment includes multiple information such as document name, chapter title, parent title at each level, etc., correspondingly, for each content fragment, each attribute information between the query statement and the corresponding content fragment can be obtained. Attribute correlation.
以属性信息包括文档名称、章节标题、各级父标题为例,每个内容片段所包含的内容、以及内容片段的属性信息,可以以结构体的形式进行保存,结构体中的字段可以包括名称为“文档名称”的字段、名称为“章节标题”的字段、名称为“各级父标题”的字段以及名称为“内容片段”的字段,从而答案生成装置可以基于各结构体,获取对应内容片段所包含的内容以及对应的属性信息。Taking the attribute information including document name, chapter title, and parent title at all levels as an example, the content contained in each content fragment and the attribute information of the content fragment can be saved in the form of a structure. The fields in the structure can include names. A field named "Document Name", a field named "Chapter Title", a field named "Parent Title at All Levels" and a field named "Content Fragment", so that the answer generation device can obtain the corresponding content based on each structure. The content contained in the fragment and the corresponding attribute information.
在本公开实施例中,可以对查询语句进行分词,并根据各分词在某个内容片段所包含的内容中出现的次数,确定查询语句与该内容片段之间的内容相关度。比如,在各分词在某个内容片段所包含的内容中出现的次数越多时,则确定查询语句与该内容片段之间的内容相关度越高;在各分词在某个内容片段所包含的内容中出现的次数越少时,则确定查询语句与该内容片段之间的内容相关度越低。In the embodiment of the present disclosure, the query statement can be segmented into words, and the content correlation between the query statement and the content segment can be determined based on the number of times each segment appears in the content contained in the content segment. For example, the more times each segment appears in the content contained in a certain content segment, the higher the content correlation between the query statement and the content segment is determined; when each segment appears in the content contained in a certain content segment, The fewer the occurrences in , the lower the content relevance between the query statement and the content fragment.
类似的,可以对查询语句进行分词,并根据各分词在某个内容片段的属性信息中出现的次数,确定查询语句与该内容片段之间的属性相关度。比如,在各分词在某个内容片段的文档名称中出现的次数越多时,则确定查询语句与该内容片段之间的对应文档名称的属性相关度越高;在各分词在某个内容片段的文档名称中出现的次数越少时,则确定查询语句与该内容片段之间的对应文档名称的属性相关度越低。Similarly, the query statement can be segmented, and the attribute correlation between the query statement and the content segment can be determined based on the number of times each segment appears in the attribute information of a certain content segment. For example, the more times each segment appears in the document name of a certain content fragment, the higher the attribute correlation of the corresponding document name between the query statement and the content fragment is determined; when each segment appears in the document name of a certain content fragment, The fewer the occurrences in the document name, the lower the correlation of the attribute corresponding to the document name between the query statement and the content fragment.
举例来说,假设查询语句为“变压器类型”,属性信息包括文档名称、章节标题,则可以对查询语句进行分词,得到“变压器”及“类型”,进而根据各内容片段所包含的内容中出现“变压器”及“类型”的次数,确定查询语句“变压器类型”与对应内容片段之间的内容相关度,并根据各内容片段所在文档的文档名称中出现“变压器”及“类型”的次数,确定查询语句“变压器类型”与对应内容片段之间的对应文档名称的属性相关度,并根据各内容片段对应的章节标题中出现“变压器”及“类型”的次数,确定查询语句“变压器类型”与对应内容片段之间的对应章节标题的属性相关度。For example, assuming that the query statement is "transformer type" and the attribute information includes the document name and chapter title, the query statement can be segmented to obtain "transformer" and "type", and then according to the content contained in each content fragment, The number of times "transformer" and "type" are used to determine the content correlation between the query statement "transformer type" and the corresponding content fragment, and based on the number of times "transformer" and "type" appear in the document name of the document where each content fragment is located, Determine the attribute correlation of the corresponding document name between the query statement "Transformer Type" and the corresponding content fragment, and determine the query statement "Transformer Type" based on the number of times "Transformer" and "Type" appear in the chapter title corresponding to each content fragment. The attribute correlation between the corresponding chapter title and the corresponding content fragment.
在本公开实施例中,可以设置内容相关度对应的第三相关度阈值,以及属性相关度对应的第四相关度阈值,进而可以将多个内容片段中,对应的内容相关度大于第三相关度阈值,和/或对应的属性相关度大于第四相关度阈值的内容片段,确定为与查询语句相关的多个候选内容片段。其中,第三相关度阈值与第四相关度阈值可以根据需要设置,此处不作限制。In the embodiment of the present disclosure, a third correlation threshold corresponding to the content correlation and a fourth correlation threshold corresponding to the attribute correlation can be set, so that among multiple content segments, the corresponding content correlation can be greater than the third correlation The degree threshold, and/or the content fragments whose corresponding attribute correlation is greater than the fourth correlation threshold, are determined as multiple candidate content fragments related to the query statement. The third correlation threshold and the fourth correlation threshold can be set as needed, and are not limited here.
或者,可以设置第五相关度阈值,并且设置内容相关度以及属性相关度具有对应的权重(权重可以相同,也可以不同),进而按照内容相关度与属性相关度对应的权重确定加权和,并将加权和大于第五相关度阈值的内容片段,确定为与查询语句相关的多个候选内容片段。其中,第五相关度阈值可以根据需要设置,此处不作限制。Alternatively, the fifth correlation threshold can be set, and the content correlation and attribute correlation can be set to have corresponding weights (the weights can be the same or different), and then the weighted sum can be determined according to the weight corresponding to the content correlation and attribute correlation, and Content fragments whose weighted sum is greater than the fifth relevance threshold are determined as multiple candidate content fragments related to the query statement. Among them, the fifth correlation threshold can be set as needed, and is not limited here.
由此,可以从所有文档包括的所有内容片段中,准确获取与查询语句相关程度较高的多个候选内容片段。As a result, multiple candidate content segments that are highly relevant to the query statement can be accurately obtained from all content segments included in all documents.
步骤503,基于NLP领域的第二相关度模型,获取查询语句与各候选内容片段之间的第二相关度。Step 503: Based on the second correlation model in the NLP field, obtain the second correlation between the query statement and each candidate content segment.
在本公开实施例中,可以预先训练第二相关度模型,第二相关度模型的输入为候选内容片段以及查询语句,输出为候选内容片段以及查询语句之间的相关程度得分(即置信度),进而对于每个候选内容片 段,可以将查询语句与候选内容片段,输入训练好的第二相关度模型,以使第二相关度模型基于查询语句与候选内容片段所包含的内容,确定候选内容片段与查询语句之间的相关程度,并输出第二相关度,从而答案生成装置可以根据第二相关度模型的输出,获取查询语句与候选内容片段之间的第二相关度。In the embodiment of the present disclosure, the second correlation model can be pre-trained. The input of the second correlation model is the candidate content fragment and the query statement, and the output is the correlation score (ie, confidence) between the candidate content fragment and the query statement. , and then for each candidate content fragment, the query statement and the candidate content fragment can be input into the trained second correlation model, so that the second correlation model determines the candidate content based on the content contained in the query statement and the candidate content fragment. The degree of correlation between the fragment and the query statement is determined, and the second correlation degree is output, so that the answer generation device can obtain the second degree of correlation between the query statement and the candidate content fragment according to the output of the second correlation degree model.
在本公开实施例中,对于每个候选内容片段,可以获取对应的属性信息,并将属性信息与候选内容片段进行拼接,以得到对应的拼接结果,将查询语句以及候选内容片段对应的拼接结果,输入第二相关度模型,以使第二相关度模型基于查询语句以及候选内容片段本身的内容和属性信息,确定候选内容片段与查询语句之间的相关程度,并输出第二相关度,从而答案生成装置可以根据第二相关度模型的输出,获取查询语句与候选内容片段之间的第二相关度。In the embodiment of the present disclosure, for each candidate content segment, the corresponding attribute information can be obtained, and the attribute information and the candidate content segment can be spliced to obtain the corresponding splicing result, and the query statement and the splicing result corresponding to the candidate content segment can be obtained. , input the second correlation model, so that the second correlation model determines the degree of correlation between the candidate content fragment and the query statement based on the query statement and the content and attribute information of the candidate content fragment itself, and outputs the second correlation degree, thereby The answer generating device may obtain the second correlation between the query statement and the candidate content segment according to the output of the second correlation model.
其中,候选内容片段的属性信息,可以包括候选内容片段所在的文档名称、候选内容片段对应的章节标题、章节标题的各级父标题中的至少一个。The attribute information of the candidate content fragment may include at least one of the name of the document in which the candidate content fragment is located, the chapter title corresponding to the candidate content fragment, and the parent titles of each level of the chapter title.
步骤504,基于各第二相关度,从各候选内容片段中获取目标内容片段。Step 504: Obtain target content segments from each candidate content segment based on each second correlation degree.
由此,通过基于NLP领域的第二相关度模型,根据查询语句、各候选内容片段的属性信息以及候选内容片段本身所包含的内容,确定各候选内容片段与查询语句之间的第二相关度,进一步提高了确定的目标内容片段的准确性。Therefore, through the second correlation model based on the NLP field, the second correlation between each candidate content segment and the query sentence is determined based on the query sentence, the attribute information of each candidate content segment, and the content contained in the candidate content segment itself. , further improving the accuracy of the identified target content segments.
步骤505,按照问题类型对应的应答策略,基于目标内容片段,生成查询语句对应的目标答案。Step 505: Generate a target answer corresponding to the query statement based on the target content fragment according to the response strategy corresponding to the question type.
其中,步骤505的具体实现过程及原理,可以参考其它实施例的描述,此处不再赘述。For the specific implementation process and principle of step 505, please refer to the descriptions of other embodiments and will not be described again here.
另外,在步骤502之前,还可以包括以下步骤506-508:In addition, before step 502, the following steps 506-508 may also be included:
步骤506,基于人工智能AI领域的光学字符识别OCR技术,对各文档进行识别,以获取各文档的识别结果。Step 506: Recognize each document based on the optical character recognition OCR technology in the field of artificial intelligence AI to obtain the recognition results of each document.
在本公开实施例中,答案生成装置可以采用光学字符识别OCR技术,对各文档进行识别,以获取各文档的识别结果。In the embodiment of the present disclosure, the answer generation device may use optical character recognition (OCR) technology to recognize each document to obtain the recognition results of each document.
在本公开实施例中,答案生成装置也可以通过接口与文档处理平台连接,从而将各文档上传至文档处理平台,以基于文档处理平台,采用光学字符识别OCR技术,对各文档进行识别,再获取文档处理平台返回的各文档的识别结果。In the embodiment of the present disclosure, the answer generation device can also be connected to the document processing platform through an interface, thereby uploading each document to the document processing platform, so as to recognize each document based on the document processing platform and using optical character recognition OCR technology, and then Obtain the recognition results of each document returned by the document processing platform.
在本公开实施例中,答案生成装置也可以调用RPA机器人将各文档上传至文档处理平台,以基于文档处理平台,采用光学字符识别OCR技术,对各文档进行识别,再获取文档处理平台返回的各文档的识别结果。由此,在待检索的文档数量较多时,通过调用RPA机器人将各文档一一上传至文档处理平台,可以减少文档上传所需的人工成本。In the embodiment of the present disclosure, the answer generation device can also call the RPA robot to upload each document to the document processing platform. Based on the document processing platform, optical character recognition (OCR) technology is used to identify each document, and then obtain the document returned by the document processing platform. Recognition results for each document. Therefore, when there are a large number of documents to be retrieved, the labor costs required for document uploading can be reduced by calling the RPA robot to upload each document one by one to the document processing platform.
参考图6的左侧附图,文档处理平台可以提供交互界面,该交互界面上可以包括用于上传文档的“上传文档”按钮以及用于启动文档识别过程的“开始识别”按钮。答案生成装置可以调用RPA机器人模拟鼠标操作,点击该交互界面上的用于上传文档的“上传文档”按钮,以将待处理的文档上传至文档处理平台,进而点击该交互界面上的用于启动文档识别过程的“开始识别”按钮,以启动文档处理平台对文档的识别过程,进而得到图6右侧附图所示的文档的识别结果。其中,图6中的“cl_num”表示章节序号,“cl_name”表示章节标题,“cl_rank”表示章节所在行,“cl_content”表示章节所包含的内容。Referring to the left drawing of Figure 6, the document processing platform may provide an interactive interface, which may include an "upload document" button for uploading documents and a "start recognition" button for starting the document recognition process. The answer generation device can call the RPA robot to simulate mouse operations, click the "Upload Document" button on the interactive interface for uploading documents to upload the document to be processed to the document processing platform, and then click the "Upload Document" button on the interactive interface for starting Click the "Start Recognition" button of the document recognition process to start the document recognition process on the document processing platform, and then obtain the document recognition results shown in the right side of Figure 6. Among them, "cl_num" in Figure 6 represents the chapter serial number, "cl_name" represents the chapter title, "cl_rank" represents the row where the chapter is located, and "cl_content" represents the content contained in the chapter.
步骤507,对各识别结果进行结构化处理,以得到各文档中包括的多个内容片段。Step 507: Perform structured processing on each recognition result to obtain multiple content fragments included in each document.
在本公开实施例中,文档可以包括文本和/或表格。相应的,文档的识别结果,可以包括文本识别结果和/或表格识别结果。In embodiments of the present disclosure, documents may include text and/or tables. Correspondingly, the document recognition results may include text recognition results and/or table recognition results.
相应的,步骤507可以通过以下方式实现:按照预设分割方式,对文本识别结果和/或表格识别结果 进行分割,以得到多个分割片段;将多个分割片段按照预设聚合方式进行聚合,以得到多个内容片段,其中,每个内容片段通过至少一个分割片段聚合得到。Accordingly, step 507 can be implemented in the following ways: segment the text recognition results and/or table recognition results according to a preset segmentation method to obtain multiple segmented segments; aggregate the multiple segmented segments according to a preset aggregation method, To obtain multiple content segments, each content segment is obtained by aggregating at least one segmented segment.
其中,预设分割方式,为将文档的识别结果分割为多个分割片段的方式,可以根据文档所包含的内容的类型(比如文本类型、表格类型)确定。The preset segmentation method is a method of dividing the recognition result of the document into multiple segmented segments, which can be determined according to the type of content contained in the document (such as text type, table type).
预设聚合方式,为将分割片段聚合得到内容片段的方式,可以根据文档所包含的内容的类型(比如文本类型、表格类型)确定。The default aggregation method is a method of aggregating divided fragments to obtain content fragments, which can be determined according to the type of content contained in the document (such as text type, table type).
举例来说,假设文档的识别结果包括文本识别结果,文本识别结果中包括章节序号、逗号、句号等标点符号。答案生成装置可以通过章节序号对文本识别结果进行第一次分割,再按照标点符号(一般是句号等句末标点符号)对第一次分割的结果进行第二次分割,从而将文本识别结果分割为多个句子,每个句子为一个分割片段,各分割片段按照在文档中的对应位置依次从前向后排列。For example, assume that the document recognition results include text recognition results, and the text recognition results include chapter numbers, commas, periods and other punctuation marks. The answer generation device can perform the first segmentation of the text recognition result based on the chapter number, and then perform the second segmentation on the result of the first segmentation based on punctuation marks (usually period and other end-of-sentence punctuation marks), thereby segmenting the text recognition result. It is a plurality of sentences, each sentence is a segmented segment, and each segmented segment is arranged from front to back according to its corresponding position in the document.
进一步的,可以给定一个特定长度,比如200个字符,再从第一个分割片段开始向后逐渐累加,直到累加后的长度大于200个字符时,将之前累加的分割片段作为一个内容片段,将当前累加的分割片段作为下一个内容片段的第一个分割片段。比如累加到第5个句子时的长度为203个字符,之前累加的句子的长度为197个字符,则将之前累加的4个句子作为一个内容片段,将第5个句子作为下一个内容片段的第一个句子,再依次将之后的句子累加,确定下一个内容片段。Furthermore, a specific length can be given, such as 200 characters, and then gradually accumulated from the first segmented segment backwards. When the accumulated length is greater than 200 characters, the previously accumulated segmented segments are regarded as one content segment. Use the currently accumulated split segment as the first split segment of the next content segment. For example, when the length of the fifth sentence is 203 characters, and the length of the previously accumulated sentences is 197 characters, the four previously accumulated sentences will be regarded as one content fragment, and the fifth sentence will be used as the next content fragment. The first sentence, and then the subsequent sentences are accumulated to determine the next content fragment.
参考图7,通过对左侧附图所示的文本识别结果进行结构化处理,可以得到图7右侧附图所示的多个内容片段。Referring to Figure 7, by performing structured processing on the text recognition results shown in the left figure, multiple content fragments shown in the right figure of Figure 7 can be obtained.
或者,假设文档的识别结果包括表格识别结果,表格识别结果中包括用于区分不同单元格的分隔符号,以及单元格所在行号。答案生成装置可以通过行号对表格识别结果进行第一次分割,再按照分隔符号对第一次分割的结果进行第二次分割,从而将表格识别结果分割为多个单元格内容,每个单元格内容为一个分割片段,每行中的各分割片段按照在文档中的对应位置依次从前向后排列。进一步的,可以将每行中的各分割片段拼接为一个内容片段。Or, assume that the recognition results of the document include table recognition results, and the table recognition results include delimiter symbols used to distinguish different cells, and the row numbers where the cells are located. The answer generation device can perform the first segmentation of the table recognition result according to the row number, and then the second segmentation of the first segmentation result according to the delimiter symbol, thereby dividing the table recognition result into multiple cell contents, each cell The content of the grid is a segmented segment, and the segmented segments in each row are arranged from front to back according to their corresponding positions in the document. Furthermore, the divided fragments in each row can be spliced into one content fragment.
参考图8,通过对左侧附图所示的表格识别结果进行结构化处理,可以得到图8右侧附图所示的多个内容片段。Referring to Figure 8, by performing structured processing on the table recognition results shown in the left figure, multiple content fragments shown in the right figure of Figure 8 can be obtained.
需要说明的是,上述对文本识别结果或表格识别结果进行分割的方式,以及将分割得到的多个分割片段进行聚合的方式,仅是示例性说明,不能理解为对本公开技术方案的限制,在实际应用中,本领域技术人员可以根据需要设置对文档的识别结果进行分割的预设分割方式,以及对多个分割片段进行聚合的预设聚合方式,本公开对此不作限制。It should be noted that the above-mentioned ways of segmenting text recognition results or table recognition results, and the ways of aggregating multiple segmented segments obtained by segmentation are only illustrative descriptions and cannot be understood as limitations to the technical solution of the present disclosure. In practical applications, those skilled in the art can set a preset segmentation method for segmenting the recognition results of the document as needed, and a preset aggregation method for aggregating multiple segmented fragments, and this disclosure does not limit this.
步骤508,将各内容片段与对应的内容字段对应保存。Step 508: Save each content segment in correspondence with the corresponding content field.
在本公开的实施例中,可以将内容字段的名称设置为“内容片段”,并将各内容片段与对应的内容字段对应保存,从而在后续需要获取内容片段所包含的内容时,可以通过内容字段获取对应的内容片段所包含的内容。In the embodiment of the present disclosure, the name of the content field can be set to "content fragment", and each content fragment can be saved corresponding to the corresponding content field, so that when the content contained in the content fragment needs to be obtained later, the content can be obtained through the content The field obtains the content contained in the corresponding content fragment.
另外,本公开实施例中,还可以将各内容片段所包含的内容以及各内容片段对应的文档名称、章节标题、各级父标题,以结构体的形式保存,结构体中的字段可以对应包括名称为“内容片段”的字段、名称为“文档名称”的字段、名称为“章节标题”的字段,以及名称为“各级父标题”的字段。In addition, in the embodiment of the present disclosure, the content contained in each content segment and the document name, chapter title, and parent title at each level corresponding to each content segment can also be saved in the form of a structure. The fields in the structure can include corresponding A field named "Content Fragment", a field named "Document Name", a field named "Chapter Title", and a field named "Level Parent Title".
通过采用光学字符识别OCR技术,对各文档进行识别,以获取各文档的识别结果,对各识别结果进行结构化处理,以得到各文档中包括的多个内容片段,将各内容片段与对应的内容字段对应保存,实现了对待检索的文档进行处理,得到多个内容片段,为实现从文档中精确确定能够回答用户问题的目标内 容片段,并根据该目标内容片段生成查询语句对应的答案奠定了基础。且通过调用RPA机器人将各文档上传至文档处理平台,以基于文档处理平台,采用AI领域的OCR技术对各文档进行识别,再获取文档处理平台返回的各文档的识别结果,进而对各识别结果进行结构化处理,得到各文档中包括的多个内容片段,实现了结合RPA和AI实现IA的获取文档中的内容片段,进一步减少了生成答案所需的人工成本。By using optical character recognition (OCR) technology, each document is recognized to obtain the recognition results of each document, and each recognition result is structured to obtain multiple content fragments included in each document. Each content fragment is compared with the corresponding The content fields are saved correspondingly, which enables the document to be retrieved to be processed and multiple content fragments obtained, which lays the foundation for accurately determining the target content fragment that can answer the user's question from the document, and generating the answer corresponding to the query statement based on the target content fragment. Base. And by calling the RPA robot to upload each document to the document processing platform, based on the document processing platform, OCR technology in the AI field is used to identify each document, and then obtain the recognition results of each document returned by the document processing platform, and then analyze each recognition result Through structured processing, multiple content fragments included in each document are obtained, which realizes the combination of RPA and AI to implement IA to obtain the content fragments in the document, further reducing the labor cost required to generate answers.
为了实现上述实施例,本公开还提出了一种答案生成装置。图9是根据本公开第五实施例的答案生成装置的结构示意图。In order to implement the above embodiments, the present disclosure also proposes an answer generating device. Figure 9 is a schematic structural diagram of an answer generating device according to the fifth embodiment of the present disclosure.
如图9所示,该答案生成装置900,包括:第一获取模块901、第二获取模块902及生成模块903。As shown in Figure 9, the answer generation device 900 includes: a first acquisition module 901, a second acquisition module 902 and a generation module 903.
其中,第一获取模块901,用于获取查询语句以及查询语句所属的问题类型;Among them, the first acquisition module 901 is used to acquire the query statement and the question type to which the query statement belongs;
第二获取模块902,用于从至少一个文档包括的多个内容片段中,获取与查询语句匹配的目标内容片段;The second acquisition module 902 is configured to acquire target content segments that match the query statement from multiple content segments included in at least one document;
生成模块903,用于按照问题类型对应的应答策略,基于目标内容片段,生成查询语句对应的目标答案。The generation module 903 is used to generate a target answer corresponding to the query statement based on the target content fragment according to the response strategy corresponding to the question type.
需要说明的是,本公开实施例的答案生成装置900,可以执行上述实施例提供的答案生成方法。其中,答案生成装置900可以由软件和/或硬件实现,该答案生成装置可以为电子设备,或者也可以配置在电子设备中,以实现代替人工自动生成用户问题的准确答案。其中,该电子设备可以包括但不限于终端设备、服务器等,该实施例对电子设备不作具体限定。It should be noted that the answer generation device 900 in the embodiment of the present disclosure can execute the answer generation method provided in the above embodiment. The answer generating device 900 may be implemented by software and/or hardware. The answer generating device may be an electronic device, or may be configured in an electronic device to automatically generate accurate answers to user questions instead of manual work. The electronic device may include but is not limited to a terminal device, a server, etc., and this embodiment does not specifically limit the electronic device.
在本公开的一个实施例中,问题类型包括数字类、抽取类、判断类中的一个;目标内容片段的数量为多个;生成模块903,包括:In one embodiment of the present disclosure, the question type includes one of numerical type, extraction type, and judgment type; the number of target content segments is multiple; the generation module 903 includes:
第一获取单元,用于对于每个目标内容片段,将查询语句与目标内容片段输入自然语言处理NLP领域的抽取模型,以从目标内容片段中抽取查询语句对应的候选答案片段,并获取对应的置信度;The first acquisition unit is used to input the query statement and the target content fragment into an extraction model in the field of natural language processing NLP for each target content fragment, so as to extract the candidate answer fragment corresponding to the query statement from the target content fragment, and obtain the corresponding Confidence;
第二获取单元,用于根据各候选答案片段对应的置信度,从各候选答案片段中获取目标答案片段;The second acquisition unit is used to acquire the target answer segment from each candidate answer segment according to the confidence level corresponding to each candidate answer segment;
生成单元,用于按照问题类型对应的应答策略,基于目标答案片段生成目标答案。The generation unit is used to generate the target answer based on the target answer fragment according to the response strategy corresponding to the question type.
在本公开的一个实施例中,问题类型包括抽取类;生成单元,用于:In one embodiment of the present disclosure, the question type includes an extraction class; a generation unit for:
将目标答案片段作为目标答案。Use the target answer fragment as the target answer.
在本公开的一个实施例中,问题类型包括判断类;生成单元,用于:In one embodiment of the present disclosure, the question type includes a judgment class; a generation unit for:
将目标答案片段和查询语句输入NLP领域的判断模型,以获取查询语句对应的判断结果;Input the target answer fragment and query statement into the judgment model in the NLP field to obtain the judgment result corresponding to the query statement;
将判断结果和/或目标答案片段作为目标答案。Use the judgment result and/or the target answer fragment as the target answer.
在本公开的一个实施例中,问题类型包括数字类;生成单元,用于:In one embodiment of the present disclosure, the question type includes a numeric class; a generation unit for:
根据第一预设规则,从目标答案片段中获取目标数字,并获取目标数字对应的单位;According to the first preset rule, obtain the target number from the target answer fragment and obtain the unit corresponding to the target number;
根据目标数字以及对应的单位,生成目标答案。Generate the target answer based on the target number and the corresponding unit.
在本公开的一个实施例中,问题类型包括统计类;生成模块903,包括:In one embodiment of the present disclosure, the question type includes a statistical class; the generation module 903 includes:
抽取单元,用于根据第二预设规则,从目标内容片段中抽取得到目标答案。The extraction unit is used to extract the target answer from the target content fragment according to the second preset rule.
在本公开的一个实施例中,答案生成装置900,还可以包括:In one embodiment of the present disclosure, the answer generation device 900 may also include:
第三获取模块,用于从预设的问答集中获取与查询语句匹配的目标问题;The third acquisition module is used to acquire target questions matching the query statement from the preset question and answer set;
第四获取模块,用于基于NLP领域的第一相关度模型,获取查询语句与目标问题之间的第一相关度;The fourth acquisition module is used to obtain the first correlation between the query statement and the target question based on the first correlation model in the NLP field;
第一确定模块,用于确定第一相关度不大于预设阈值。The first determination module is used to determine that the first correlation degree is not greater than the preset threshold.
在本公开的一个实施例中,答案生成装置900,还可以包括:In one embodiment of the present disclosure, the answer generation device 900 may also include:
第五获取模块,用于在第一相关度大于预设阈值的情况下,从问答集中获取目标问题对应的答案;The fifth acquisition module is used to obtain the answer corresponding to the target question from the question and answer set when the first correlation degree is greater than the preset threshold;
第二确定模块,用于将目标问题对应的答案,确定为查询语句对应的目标答案。The second determination module is used to determine the answer corresponding to the target question as the target answer corresponding to the query statement.
在本公开的一个实施例中,第二获取模块902,包括:In one embodiment of the present disclosure, the second acquisition module 902 includes:
第三获取单元,用于基于查询语句进行查询,以从多个内容片段中,获取与查询语句相关的多个候选内容片段;The third acquisition unit is used to query based on the query statement to obtain multiple candidate content fragments related to the query statement from multiple content fragments;
第四获取单元,用于基于NLP领域的第二相关度模型,获取查询语句与各候选内容片段之间的第二相关度;The fourth acquisition unit is used to obtain the second correlation between the query statement and each candidate content fragment based on the second correlation model in the NLP field;
第五获取单元,用于基于各第二相关度,从各候选内容片段中获取目标内容片段。The fifth acquisition unit is used to acquire the target content segment from each candidate content segment based on each second correlation degree.
在本公开的一个实施例中,答案生成装置900,还可以包括:In one embodiment of the present disclosure, the answer generation device 900 may also include:
识别模块,用于基于人工智能AI领域的光学字符识别OCR技术,对各文档进行识别,以获取各文档的识别结果;The recognition module is used to identify each document based on the optical character recognition OCR technology in the field of artificial intelligence to obtain the recognition results of each document;
处理模块,用于对各识别结果进行结构化处理,以得到各文档中包括的多个内容片段;The processing module is used to perform structured processing on each recognition result to obtain multiple content fragments included in each document;
保存模块,用于将各内容片段与对应的内容字段对应保存。The saving module is used to save each content fragment correspondingly to the corresponding content field.
在本公开的一个实施例中,识别模块,包括:In one embodiment of the present disclosure, the identification module includes:
上传单元,用于调用RPA机器人将各文档上传至文档处理平台,以基于文档处理平台,采用光学字符识别OCR技术,对各文档进行识别;The upload unit is used to call the RPA robot to upload each document to the document processing platform, so that based on the document processing platform, optical character recognition OCR technology can be used to identify each document;
第六获取单元,用于获取文档处理平台返回的各文档的识别结果。The sixth acquisition unit is used to acquire the recognition results of each document returned by the document processing platform.
需要说明的是,前述对答案生成方法实施例的解释说明也适用于该实施例的答案生成装置,本公开答案生成装置实施例中未公布的细节,此处不再赘述。It should be noted that the foregoing explanation of the embodiment of the answer generation method also applies to the answer generation device of this embodiment. Unpublished details of the embodiments of the answer generation device of the present disclosure will not be described again here.
综上,本公开实施例的答案生成装置,在获取查询语句以及查询语句所属的问题类型后,从至少一个文档包括的多个内容片段中,获取与查询语句匹配的目标内容片段,进而按照问题类型对应的应答策略,基于目标内容片段,生成查询语句对应的目标答案。由此,通过代替人工自动生成答案,减少了生成答案所需的人力成本及时间成本,且通过从文档中精确确定能够回答用户问题的目标内容片段,并根据该目标内容片段生成查询语句对应的答案,提高了生成的答案的准确性。In summary, the answer generation device of the embodiment of the present disclosure, after obtaining the query statement and the question type to which the query statement belongs, obtains the target content fragment matching the query statement from multiple content fragments included in at least one document, and then according to the question The response strategy corresponding to the type generates the target answer corresponding to the query statement based on the target content fragment. Therefore, by automatically generating answers instead of manual work, the labor cost and time cost required to generate answers are reduced, and by accurately determining the target content fragment that can answer the user's question from the document, and generating the query statement corresponding to the target content fragment. answers, improving the accuracy of the generated answers.
为了实现上述实施例,本公开实施例还提出一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时,实现如前述任一方法实施例所述的答案生成方法。In order to implement the above embodiments, embodiments of the present disclosure also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, The answer generation method as described in any of the aforementioned method embodiments.
为了实现上述实施例,本公开实施例还提出一种计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如前述任一方法实施例所述的答案生成方法。在一些实施例中,该计算机可读存储介质是非临时性计算机可读存储介质。In order to implement the above embodiments, embodiments of the present disclosure also provide a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the answer generation method as described in any of the foregoing method embodiments is implemented. In some embodiments, the computer-readable storage medium is a non-transitory computer-readable storage medium.
为了实现上述实施例,本公开实施例还提出一种计算机程序产品,当所述计算机程序产品中的指令处理器执行时,实现如前述任一方法实施例所述的答案生成方法。In order to implement the above embodiments, embodiments of the present disclosure also provide a computer program product. When the instruction processor in the computer program product is executed, the answer generation method as described in any of the foregoing method embodiments is implemented.
为了实现上述实施例,本公开实施例还提出一种计算机程序,所述计算机程序包括计算机程序代码,当所述计算机程序代码在计算机上运行时,使得计算机执行如前述任一方法实施例所述的答案生成方法。In order to implement the above embodiments, an embodiment of the present disclosure also proposes a computer program. The computer program includes computer program code. When the computer program code is run on a computer, it causes the computer to execute as described in any of the foregoing method embodiments. answer generation method.
图10示出了适于用来实现本公开实施方式的示例性电子设备的框图。图10显示的电子设备10仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。Figure 10 illustrates a block diagram of an exemplary electronic device suitable for implementing embodiments of the present disclosure. The electronic device 10 shown in FIG. 10 is only an example and should not bring any limitations to the functions and scope of use of the embodiments of the present disclosure.
如图10所示,电子设备10以通用计算设备的形式表现。电子设备10的组件可以包括但不限于:一个或者多个处理器或者处理单元16,系统存储器28,连接不同系统组件(包括存储器28和处理单元16)的总线18。As shown in Figure 10, electronic device 10 is embodied in the form of a general computing device. The components of electronic device 10 may include, but are not limited to: one or more processors or processing units 16, system memory 28, and a bus 18 connecting various system components, including memory 28 and processing unit 16.
总线18表示几类总线结构中的一种或多种,包括存储器总线或者存储器控制器,外围总线,图形加速端口,处理器或者使用多种总线结构中的任意总线结构的局域总线。举例来说,这些体系结构包括但不限于工业标准体系结构(Industry Standard Architecture;以下简称:ISA)总线,微通道体系结构(Micro Channel Architecture;以下简称:MAC)总线,增强型ISA总线、视频电子标准协会(Video Electronics Standards Association;以下简称:VESA)局域总线以及外围组件互连(Peripheral Component Interconnection;以下简称:PCI)总线。 Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics accelerated port, a processor, or a local bus using any of a variety of bus structures. For example, these architectures include but are not limited to Industry Standard Architecture (hereinafter referred to as: ISA) bus, Micro Channel Architecture (Micro Channel Architecture; hereafter referred to as: MAC) bus, enhanced ISA bus, video electronics Standards Association (Video Electronics Standards Association; hereinafter referred to as: VESA) local bus and Peripheral Component Interconnection (hereinafter referred to as: PCI) bus.
电子设备10典型地包括多种计算机系统可读介质。这些介质可以是任何能够被电子设备10访问的可用介质,包括易失性和非易失性介质,可移动的和不可移动的介质。 Electronic device 10 typically includes a variety of computer system readable media. These media may be any available media that can be accessed by electronic device 10, including volatile and nonvolatile media, removable and non-removable media.
存储器28可以包括易失性存储器形式的计算机系统可读介质,例如随机存取存储器(Random Access Memory;以下简称:RAM)30和/或高速缓存存储器32。电子设备10可以进一步包括其它可移动/不可移动的、易失性/非易失性计算机系统存储介质。仅作为举例,存储系统34可以用于读写不可移动的、非易失性磁介质(图10未显示,通常称为“硬盘驱动器”)。尽管图10中未示出,可以提供用于对可移动非易失性磁盘(例如“软盘”)读写的磁盘驱动器,以及对可移动非易失性光盘(例如:光盘只读存储器(Compact Disc Read Only Memory;以下简称:CD-ROM)、数字多功能只读光盘(Digital Video Disc Read Only Memory;以下简称:DVD-ROM)或者其它光介质)读写的光盘驱动器。在这些情况下,每个驱动器可以通过一个或者多个数据介质接口与总线18相连。存储器28可以包括至少一个程序产品,该程序产品具有一组(例如至少一个)程序模块,这些程序模块被配置以执行本公开各实施例的功能。The memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (Random Access Memory; hereinafter referred to as: RAM) 30 and/or cache memory 32. Electronic device 10 may further include other removable/non-removable, volatile/non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write to non-removable, non-volatile magnetic media (not shown in Figure 10, commonly referred to as a "hard drive"). Although not shown in FIG. 10, a disk drive for reading and writing a removable non-volatile disk (e.g., a "floppy disk") and a removable non-volatile optical disk (e.g., a compact disk read-only memory) may be provided. Disc Read Only Memory (hereinafter referred to as: CD-ROM), Digital Video Disc Read Only Memory (hereinafter referred to as: DVD-ROM) or other optical media) read and write optical disc drives. In these cases, each drive may be connected to bus 18 through one or more data media interfaces. Memory 28 may include at least one program product having a set (eg, at least one) of program modules configured to perform the functions of embodiments of the present disclosure.
具有一组(至少一个)程序模块42的程序/实用工具40,可以存储在例如存储器28中,这样的程序模块42包括但不限于操作系统、一个或者多个应用程序、其它程序模块以及程序数据,这些示例中的每一个或某种组合中可能包括网络环境的实现。程序模块42通常执行本公开所描述的实施例中的功能和/或方法。A program/utility 40 having a set of (at least one) program modules 42, including but not limited to an operating system, one or more application programs, other program modules, and program data, may be stored, for example, in memory 28 , each of these examples or some combination may include the implementation of a network environment. Program modules 42 generally perform functions and/or methods in the embodiments described in this disclosure.
电子设备10也可以与一个或多个外部设备14(例如键盘、指向设备、显示器24等)通信,还可与一个或者多个使得用户能与该电子设备10交互的设备通信,和/或与使得该电子设备10能与一个或多个其它计算设备进行通信的任何设备(例如网卡,调制解调器等等)通信。这种通信可以通过输入/输出(I/O)接口22进行。并且,电子设备10还可以通过网络适配器20与一个或者多个网络(例如局域网(Local Area Network;以下简称:LAN),广域网(Wide Area Network;以下简称:WAN)和/或公共网络,例如因特网)通信。如图10所示,网络适配器20通过总线18与电子设备10的其它模块通信。应当明白,尽管图10中未示出,可以结合电子设备10使用其它硬件和/或软件模块,包括但不限于:微代码、设备驱动器、冗余处理单元、外部磁盘驱动阵列、RAID系统、磁带驱动器以及数据备份存储系统等。 Electronic device 10 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), may also communicate with one or more devices that enable a user to interact with electronic device 10, and/or with Any device (eg, network card, modem, etc.) that enables the electronic device 10 to communicate with one or more other computing devices. This communication may occur through input/output (I/O) interface 22. Moreover, the electronic device 10 can also communicate with one or more networks (such as a local area network (Local Area Network; hereinafter referred to as: LAN), a wide area network (Wide Area Network; hereinafter referred to as: WAN)) and/or a public network, such as the Internet, through the network adapter 20 ) communication. As shown in FIG. 10 , network adapter 20 communicates with other modules of electronic device 10 via bus 18 . It should be understood that, although not shown in Figure 10, other hardware and/or software modules may be used in conjunction with electronic device 10, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tapes drives and data backup storage systems, etc.
处理单元16通过运行存储在存储器28中的程序,从而执行各种功能应用以及数据处理,例如实现前述实施例中提及的方法。The processing unit 16 executes programs stored in the memory 28 to perform various functional applications and data processing, such as implementing the methods mentioned in the previous embodiments.
需要说明的是,前述对答案生成方法实施例的解释说明也适用于本公开实施例的电子设备、计算机可读存储介质、计算机程序产品和计算机程序,此处不再赘述。It should be noted that the foregoing explanations of the embodiments of the answer generation method are also applicable to the electronic devices, computer-readable storage media, computer program products and computer programs of the embodiments of the present disclosure, and will not be described again here.
在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本公开的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不必须针对的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或 示例的特征进行结合和组合。In the description of this specification, reference to the terms "one embodiment," "some embodiments," "an example," "specific examples," or "some examples" or the like means that specific features are described in connection with the embodiment or example. , structures, materials, or features are included in at least one embodiment or example of the present disclosure. In this specification, the schematic expressions of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the specific features, structures, materials or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, those skilled in the art may combine and combine different embodiments or examples and features of different embodiments or examples described in this specification unless they are inconsistent with each other.
此外,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括至少一个该特征。在本公开的描述中,“多个”的含义是至少两个,例如两个,三个等,除非另有明确具体的限定。In addition, the terms “first” and “second” are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the quantity of indicated technical features. Therefore, features defined as "first" and "second" may explicitly or implicitly include at least one of these features. In the description of the present disclosure, "plurality" means at least two, such as two, three, etc., unless otherwise expressly and specifically limited.
流程图中或在此以其他方式描述的任何过程或方法描述可以被理解为,表示包括一个或更多个用于实现定制逻辑功能或过程的步骤的可执行指令的代码的模块、片段或部分,并且本公开的优选实施方式的范围包括另外的实现,其中可以不按所示出或讨论的顺序,包括根据所涉及的功能按基本同时的方式或按相反的顺序,来执行功能,这应被本公开的实施例所属技术领域的技术人员所理解。Any process or method descriptions in flowcharts or otherwise described herein may be understood to represent modules, segments, or portions of code that include one or more executable instructions for implementing customized logical functions or steps of the process. , and the scope of the preferred embodiments of the present disclosure includes additional implementations in which functions may be performed out of the order shown or discussed, including in a substantially simultaneous manner or in the reverse order, depending on the functionality involved, which shall It should be understood by those skilled in the art to which embodiments of the present disclosure belong.
在流程图中表示或在此以其他方式描述的逻辑和/或步骤,例如,可以被认为是用于实现逻辑功能的可执行指令的定序列表,可以具体实现在任何计算机可读介质中,以供指令执行系统、装置或设备(如基于计算机的系统、包括处理器的系统或其他可以从指令执行系统、装置或设备取指令并执行指令的系统)使用,或结合这些指令执行系统、装置或设备而使用。就本说明书而言,"计算机可读介质"可以是任何可以包含、存储、通信、传播或传输程序以供指令执行系统、装置或设备或结合这些指令执行系统、装置或设备而使用的装置。计算机可读介质的更具体的示例(非穷尽性列表)包括以下:具有一个或多个布线的电连接部(电子装置),便携式计算机盘盒(磁装置),随机存取存储器(RAM),只读存储器(ROM),可擦除可编辑只读存储器(EPROM或闪速存储器),光纤装置,以及便携式光盘只读存储器(CDROM)。另外,计算机可读介质甚至可以是可在其上打印所述程序的纸或其他合适的介质,因为可以例如通过对纸或其他介质进行光学扫描,接着进行编辑、解译或必要时以其他合适方式进行处理来以电子方式获得所述程序,然后将其存储在计算机存储器中。The logic and/or steps represented in the flowcharts or otherwise described herein, for example, may be considered a sequenced list of executable instructions for implementing the logical functions, and may be embodied in any computer-readable medium, For use by, or in combination with, instruction execution systems, devices or devices (such as computer-based systems, systems including processors or other systems that can fetch instructions from and execute instructions from the instruction execution system, device or device) or equipment. For the purposes of this specification, a "computer-readable medium" may be any device that can contain, store, communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. More specific examples (non-exhaustive list) of computer readable media include the following: electrical connections with one or more wires (electronic device), portable computer disk cartridges (magnetic device), random access memory (RAM), Read-only memory (ROM), erasable and programmable read-only memory (EPROM or flash memory), fiber optic devices, and portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium may even be paper or other suitable medium on which the program may be printed, as the paper or other medium may be optically scanned, for example, and subsequently edited, interpreted, or otherwise suitable as necessary. process to obtain the program electronically and then store it in computer memory.
应当理解,本公开的各部分可以用硬件、软件、固件或它们的组合来实现。在上述实施方式中,多个步骤或方法可以用存储在存储器中且由合适的指令执行系统执行的软件或固件来实现。如,如果用硬件来实现和在另一实施方式中一样,可用本领域公知的下列技术中的任一项或他们的组合来实现:具有用于对数据信号实现逻辑功能的逻辑门电路的离散逻辑电路,具有合适的组合逻辑门电路的专用集成电路,可编程门阵列(PGA),现场可编程门阵列(FPGA)等。It should be understood that various parts of the present disclosure may be implemented in hardware, software, firmware, or combinations thereof. In the above embodiments, various steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if it is implemented in hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: discrete logic gate circuits with logic functions for implementing data signals; Logic circuits, application specific integrated circuits with suitable combinational logic gates, programmable gate arrays (PGA), field programmable gate arrays (FPGA), etc.
本技术领域的普通技术人员可以理解实现上述实施例方法携带的全部或部分步骤是可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,该程序在执行时,包括方法实施例的步骤之一或其组合。Those of ordinary skill in the art can understand that all or part of the steps involved in implementing the methods of the above embodiments can be completed by instructing relevant hardware through a program. The program can be stored in a computer-readable storage medium. The program can be stored in a computer-readable storage medium. When executed, one of the steps of the method embodiment or a combination thereof is included.
此外,在本公开各个实施例中的各功能单元可以集成在一个处理模块中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。所述集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。In addition, each functional unit in various embodiments of the present disclosure may be integrated into one processing module, each unit may exist physically alone, or two or more units may be integrated into one module. The above integrated modules can be implemented in the form of hardware or software function modules. If the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
上述提到的存储介质可以是只读存储器,磁盘或光盘等。尽管上面已经示出和描述了本公开的实施例,可以理解的是,上述实施例是示例性的,不能理解为对本公开的限制,本领域的普通技术人员在本公开的范围内可以对上述实施例进行变化、修改、替换和变型。The storage media mentioned above can be read-only memory, magnetic disks or optical disks, etc. Although the embodiments of the present disclosure have been shown and described above, it can be understood that the above-mentioned embodiments are illustrative and should not be construed as limitations of the present disclosure. Those of ordinary skill in the art can make modifications to the above-mentioned embodiments within the scope of the present disclosure. The embodiments are subject to changes, modifications, substitutions and variations.

Claims (17)

  1. 一种答案生成方法,包括:An answer generation method that includes:
    获取查询语句以及所述查询语句所属的问题类型;Obtain the query statement and the question type to which the query statement belongs;
    从至少一个文档包括的多个内容片段中,获取与所述查询语句匹配的目标内容片段;Obtain a target content fragment that matches the query statement from a plurality of content fragments included in at least one document;
    按照所述问题类型对应的应答策略,基于所述目标内容片段,生成所述查询语句对应的目标答案。According to the response strategy corresponding to the question type and based on the target content segment, a target answer corresponding to the query statement is generated.
  2. 根据权利要求1所述的方法,其中,所述问题类型包括数字类、抽取类、判断类中的一个;所述目标内容片段的数量为多个;The method according to claim 1, wherein the question type includes one of a numerical type, an extraction type, and a judgment type; the number of the target content segments is multiple;
    所述按照所述问题类型对应的应答策略,基于所述目标内容片段,生成所述查询语句对应的目标答案,包括:According to the response strategy corresponding to the question type, based on the target content fragment, the target answer corresponding to the query statement is generated, including:
    对于每个所述目标内容片段,将所述查询语句与所述目标内容片段输入自然语言处理NLP领域的抽取模型,以从所述目标内容片段中抽取所述查询语句对应的候选答案片段,并获取对应的置信度;For each target content segment, input the query statement and the target content segment into an extraction model in the field of natural language processing NLP to extract candidate answer segments corresponding to the query statement from the target content segment, and Get the corresponding confidence level;
    根据各所述候选答案片段对应的置信度,从各所述候选答案片段中获取目标答案片段;Obtain target answer segments from each of the candidate answer segments according to the confidence level corresponding to each of the candidate answer segments;
    按照所述问题类型对应的应答策略,基于所述目标答案片段生成所述目标答案。The target answer is generated based on the target answer fragment according to the response strategy corresponding to the question type.
  3. 根据权利要求2所述的方法,其中,所述问题类型包括抽取类;The method of claim 2, wherein the question type includes an extraction class;
    所述按照所述问题类型对应的应答策略,基于所述目标答案片段生成所述目标答案,包括:Generating the target answer based on the target answer fragment according to the response strategy corresponding to the question type includes:
    将所述目标答案片段作为所述目标答案。Use the target answer fragment as the target answer.
  4. 根据权利要求2所述的方法,其中,所述问题类型包括判断类;The method according to claim 2, wherein the question type includes a judgment type;
    所述按照所述问题类型对应的应答策略,基于所述目标答案片段生成所述目标答案,包括:Generating the target answer based on the target answer fragment according to the response strategy corresponding to the question type includes:
    将所述目标答案片段和所述查询语句输入NLP领域的判断模型,以获取所述查询语句对应的判断结果;Enter the target answer fragment and the query statement into a judgment model in the NLP field to obtain the judgment result corresponding to the query statement;
    将所述判断结果和/或所述目标答案片段作为所述目标答案。The judgment result and/or the target answer fragment are used as the target answer.
  5. 根据权利要求2所述的方法,其中,所述问题类型包括数字类;The method of claim 2, wherein the question type includes a numeric type;
    所述按照所述问题类型对应的应答策略,基于所述目标答案片段生成所述目标答案,包括:Generating the target answer based on the target answer fragment according to the response strategy corresponding to the question type includes:
    根据第一预设规则,从所述目标答案片段中获取目标数字,并获取所述目标数字对应的单位;According to the first preset rule, obtain the target number from the target answer fragment, and obtain the unit corresponding to the target number;
    根据所述目标数字以及对应的单位,生成所述目标答案。The target answer is generated based on the target number and the corresponding unit.
  6. 根据权利要求1所述的方法,其中,所述问题类型包括统计类;The method of claim 1, wherein the question type includes a statistical class;
    所述按照所述问题类型对应的应答策略,基于所述目标内容片段,生成所述查询语句对应的目标答案,包括:According to the response strategy corresponding to the question type, based on the target content fragment, the target answer corresponding to the query statement is generated, including:
    根据第二预设规则,从所述目标内容片段中抽取得到所述目标答案。According to the second preset rule, the target answer is extracted from the target content segment.
  7. 根据权利要求1-6中任一项所述的方法,其中,所述从至少一个文档包括的多个内容片段中,获取与所述查询语句匹配的目标内容片段之前,还包括:The method according to any one of claims 1 to 6, wherein before obtaining the target content fragment matching the query statement from a plurality of content fragments included in at least one document, it further includes:
    从预设的问答集中获取与所述查询语句匹配的目标问题;Obtain target questions matching the query statement from the preset question and answer set;
    基于NLP领域的第一相关度模型,获取所述查询语句与所述目标问题之间的第一相关度;Based on the first correlation model in the NLP field, obtain the first correlation between the query statement and the target question;
    确定所述第一相关度不大于预设阈值。It is determined that the first correlation degree is not greater than a preset threshold.
  8. 根据权利要求7所述的方法,其中,所述方法还包括:The method of claim 7, further comprising:
    在所述第一相关度大于所述预设阈值的情况下,从所述问答集中获取所述目标问题对应的答案;When the first correlation is greater than the preset threshold, obtain the answer corresponding to the target question from the question and answer set;
    将所述目标问题对应的答案,确定为所述查询语句对应的目标答案。The answer corresponding to the target question is determined as the target answer corresponding to the query statement.
  9. 根据权利要求1-6中任一项所述的方法,其中,所述从至少一个文档包括的多个内容片段中,获 取与所述查询语句匹配的目标内容片段,包括:The method according to any one of claims 1-6, wherein said obtaining a target content segment matching the query statement from a plurality of content segments included in at least one document includes:
    基于所述查询语句进行查询,以从所述多个内容片段中,获取与所述查询语句相关的多个候选内容片段;Perform a query based on the query statement to obtain a plurality of candidate content fragments related to the query statement from the plurality of content fragments;
    基于NLP领域的第二相关度模型,获取所述查询语句与各所述候选内容片段之间的第二相关度;Based on the second correlation model in the NLP field, obtain the second correlation between the query statement and each of the candidate content fragments;
    基于各所述第二相关度,从各所述候选内容片段中获取所述目标内容片段。Based on each of the second correlations, the target content segment is obtained from each of the candidate content segments.
  10. 根据权利要求1-6中任一项所述的方法,其中,所述从至少一个文档包括的多个内容片段中,获取与所述查询语句匹配的目标内容片段之前,还包括:The method according to any one of claims 1 to 6, wherein before obtaining the target content fragment matching the query statement from a plurality of content fragments included in at least one document, it further includes:
    基于人工智能AI领域的光学字符识别OCR技术,对各所述文档进行识别,以获取各所述文档的识别结果;Based on the optical character recognition OCR technology in the field of artificial intelligence, identify each of the documents to obtain the recognition results of each of the documents;
    对各所述识别结果进行结构化处理,以得到各所述文档中包括的多个所述内容片段;Perform structured processing on each of the recognition results to obtain a plurality of content fragments included in each of the documents;
    将各所述内容片段与对应的内容字段对应保存。Each content segment is stored in correspondence with the corresponding content field.
  11. 根据权利要求10所述的方法,其中,所述基于人工智能AI领域的光学字符识别OCR技术,对各所述文档进行识别,以获取各所述文档的识别结果,包括:The method according to claim 10, wherein the optical character recognition (OCR) technology based on the field of artificial intelligence (AI) recognizes each of the documents to obtain the recognition results of each of the documents, including:
    调用RPA机器人将各所述文档上传至文档处理平台,以基于所述文档处理平台,采用所述光学字符识别OCR技术,对各所述文档进行识别;Call the RPA robot to upload each of the documents to the document processing platform, so as to identify each of the documents based on the document processing platform and using the optical character recognition OCR technology;
    获取所述文档处理平台返回的各所述文档的识别结果。Obtain the identification results of each document returned by the document processing platform.
  12. 一种答案生成装置,包括:An answer generating device including:
    第一获取模块,用于获取查询语句以及所述查询语句所属的问题类型;The first acquisition module is used to obtain the query statement and the question type to which the query statement belongs;
    第二获取模块,用于从至少一个文档包括的多个内容片段中,获取与所述查询语句匹配的目标内容片段;a second acquisition module, configured to acquire a target content segment that matches the query statement from a plurality of content segments included in at least one document;
    生成模块,用于按照所述问题类型对应的应答策略,基于所述目标内容片段,生成所述查询语句对应的目标答案。A generation module, configured to generate a target answer corresponding to the query statement based on the target content fragment according to the response strategy corresponding to the question type.
  13. 根据权利要求12所述的装置,其中,所述问题类型包括数字类、抽取类、判断类中的一个;所述目标内容片段的数量为多个;The device according to claim 12, wherein the question type includes one of a numerical type, an extraction type, and a judgment type; the number of the target content segments is multiple;
    所述生成模块,包括:The generation module includes:
    第一获取单元,用于对于每个所述目标内容片段,将所述查询语句与所述目标内容片段输入自然语言处理NLP领域的抽取模型,以从所述目标内容片段中抽取所述查询语句对应的候选答案片段,并获取对应的置信度;A first acquisition unit configured to input the query statement and the target content fragment into an extraction model in the field of natural language processing NLP for each target content fragment, so as to extract the query statement from the target content fragment. Corresponding candidate answer fragments, and obtain the corresponding confidence;
    第二获取单元,用于根据各所述候选答案片段对应的置信度,从各所述候选答案片段中获取目标答案片段;a second acquisition unit, configured to acquire a target answer segment from each of the candidate answer segments according to the confidence level corresponding to each of the candidate answer segments;
    生成单元,用于按照所述问题类型对应的应答策略,基于所述目标答案片段生成所述目标答案。A generating unit configured to generate the target answer based on the target answer fragment according to the response strategy corresponding to the question type.
  14. 一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时,实现如权利要求1-11中任一项所述的方法。An electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the implementation as described in any one of claims 1-11 is achieved. Methods.
  15. 一种计算机可读存储介质,其上存储有计算机程序,其中,所述计算机程序被处理器执行时实现如权利要求1-11中任一项所述的方法。A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the method according to any one of claims 1-11 is implemented.
  16. 一种计算机程序产品,其中,所述计算机程序产品中包括计算机程序,当所述计算机程序在在被处理器执行时,实现如权利要求1至11中任一项所述的方法。A computer program product, wherein the computer program product includes a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 11 is implemented.
  17. 一种计算机程序,其中,所述计算机程序包括计算机程序代码,当所述计算机程序代码在计算机上运行时,使得计算机执行如权利要求1至11中任一项所述的方法。A computer program, wherein the computer program includes computer program code, which when run on a computer causes the computer to perform the method according to any one of claims 1 to 11.
PCT/CN2022/100568 2022-06-07 2022-06-22 Answer generation method and apparatus, electronic device, and storage medium WO2023236252A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210635729.0A CN114936276A (en) 2022-06-07 2022-06-07 Answer generation method and device, electronic equipment and storage medium
CN202210635729.0 2022-06-07

Publications (1)

Publication Number Publication Date
WO2023236252A1 true WO2023236252A1 (en) 2023-12-14

Family

ID=82866825

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/100568 WO2023236252A1 (en) 2022-06-07 2022-06-22 Answer generation method and apparatus, electronic device, and storage medium

Country Status (2)

Country Link
CN (1) CN114936276A (en)
WO (1) WO2023236252A1 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117473069A (en) * 2023-12-26 2024-01-30 深圳市明源云客电子商务有限公司 Business corpus generation method, device and equipment and computer readable storage medium
CN117591547A (en) * 2024-01-18 2024-02-23 中昊芯英(杭州)科技有限公司 Database query method and device, terminal equipment and storage medium
CN117688164A (en) * 2024-02-03 2024-03-12 北京澜舟科技有限公司 Illusion detection method, system and storage medium based on large language model
CN118093849A (en) * 2024-04-26 2024-05-28 杭州数云信息技术有限公司 Dialogue method and device, storage medium, terminal and computer program product

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014190732A1 (en) * 2013-05-29 2014-12-04 Tencent Technology (Shenzhen) Company Limited Method and apparatus for building a language model
CN109033229A (en) * 2018-06-29 2018-12-18 北京百度网讯科技有限公司 Question and answer treating method and apparatus
CN113821612A (en) * 2021-07-14 2021-12-21 腾讯科技(深圳)有限公司 Information searching method and device
CN114281942A (en) * 2021-12-17 2022-04-05 科大讯飞股份有限公司 Question and answer processing method, related equipment and readable storage medium
CN114491023A (en) * 2021-12-31 2022-05-13 北京五八信息技术有限公司 Text processing method and device, electronic equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014190732A1 (en) * 2013-05-29 2014-12-04 Tencent Technology (Shenzhen) Company Limited Method and apparatus for building a language model
CN109033229A (en) * 2018-06-29 2018-12-18 北京百度网讯科技有限公司 Question and answer treating method and apparatus
CN113821612A (en) * 2021-07-14 2021-12-21 腾讯科技(深圳)有限公司 Information searching method and device
CN114281942A (en) * 2021-12-17 2022-04-05 科大讯飞股份有限公司 Question and answer processing method, related equipment and readable storage medium
CN114491023A (en) * 2021-12-31 2022-05-13 北京五八信息技术有限公司 Text processing method and device, electronic equipment and storage medium

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117473069A (en) * 2023-12-26 2024-01-30 深圳市明源云客电子商务有限公司 Business corpus generation method, device and equipment and computer readable storage medium
CN117473069B (en) * 2023-12-26 2024-04-12 深圳市明源云客电子商务有限公司 Business corpus generation method, device and equipment and computer readable storage medium
CN117591547A (en) * 2024-01-18 2024-02-23 中昊芯英(杭州)科技有限公司 Database query method and device, terminal equipment and storage medium
CN117688164A (en) * 2024-02-03 2024-03-12 北京澜舟科技有限公司 Illusion detection method, system and storage medium based on large language model
CN117688164B (en) * 2024-02-03 2024-05-17 北京澜舟科技有限公司 Illusion detection method, system and storage medium based on large language model
CN118093849A (en) * 2024-04-26 2024-05-28 杭州数云信息技术有限公司 Dialogue method and device, storage medium, terminal and computer program product

Also Published As

Publication number Publication date
CN114936276A (en) 2022-08-23

Similar Documents

Publication Publication Date Title
WO2023236252A1 (en) Answer generation method and apparatus, electronic device, and storage medium
WO2022142593A1 (en) Text classification method and apparatus, electronic device, and readable storage medium
WO2021121198A1 (en) Semantic similarity-based entity relation extraction method and apparatus, device and medium
WO2021218029A1 (en) Artificial intelligence-based interview method and apparatus, computer device, and storage medium
US11755661B2 (en) Text entry assistance and conversion to structured medical data
CN111930792B (en) Labeling method and device for data resources, storage medium and electronic equipment
WO2022188584A1 (en) Similar sentence generation method and apparatus based on pre-trained language model
CN112101010B (en) Telecom industry OA office automation manuscript auditing method based on BERT
CN107545044A (en) A kind of tables of data method for building up, electronic equipment and storage medium
WO2020232898A1 (en) Text classification method and apparatus, electronic device and computer non-volatile readable storage medium
WO2021169485A1 (en) Dialogue generation method and apparatus, and computer device
CN109359290A (en) The knowledge point of examination question text determines method, electronic equipment and storage medium
CN115099239B (en) Resource identification method, device, equipment and storage medium
WO2023065633A1 (en) Abnormal semantic truncation detection method and apparatus, and device and medium
CN114491034B (en) Text classification method and intelligent device
CN116151220A (en) Word segmentation model training method, word segmentation processing method and device
CN113806500B (en) Information processing method, device and computer equipment
WO2023236253A1 (en) Document retrieval method and apparatus, and electronic device
CN117873433A (en) Descriptive file acquisition method and device, electronic equipment and storage medium
CN117370190A (en) Test case generation method and device, electronic equipment and storage medium
Van Enschot et al. Taming our wild data: On intercoder reliability in discourse research
CN116629215A (en) Teaching document generation method and device, electronic equipment and storage medium
WO2022188585A1 (en) Annotation method and apparatus for use in text data, computer device, and storage medium
CN115617689A (en) Software defect positioning method based on CNN model and domain features
CN115017271A (en) Method and system for intelligently generating RPA flow component block

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22945391

Country of ref document: EP

Kind code of ref document: A1