CN113887244A - Text processing method and device - Google Patents

Text processing method and device Download PDF

Info

Publication number
CN113887244A
CN113887244A CN202111294843.3A CN202111294843A CN113887244A CN 113887244 A CN113887244 A CN 113887244A CN 202111294843 A CN202111294843 A CN 202111294843A CN 113887244 A CN113887244 A CN 113887244A
Authority
CN
China
Prior art keywords
text
answer
candidate
question
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111294843.3A
Other languages
Chinese (zh)
Inventor
白静
李长亮
李小龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Digital Entertainment Co Ltd
Original Assignee
Beijing Kingsoft Digital Entertainment Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Digital Entertainment Co Ltd filed Critical Beijing Kingsoft Digital Entertainment Co Ltd
Priority to CN202111294843.3A priority Critical patent/CN113887244A/en
Publication of CN113887244A publication Critical patent/CN113887244A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/258Heading extraction; Automatic titling; Numbering

Abstract

The application provides a text processing method and a text processing device, wherein the text processing method comprises the following steps: obtaining a question text and a target text containing a candidate answer corresponding to the question text; extracting candidate sentences containing the candidate answers from the target text; and constructing candidate answer characteristics according to the target text, the candidate sentences and the question text, and determining the target answer text corresponding to the question text based on the candidate answer characteristics. By considering the influence of the context semantic information on the answer of the question text, the accuracy of determining the target answer text is further improved.

Description

Text processing method and device
Technical Field
The application relates to the technical field of artificial intelligence, in particular to a text processing method. The application also relates to a text processing device, a computing device and a computer readable storage medium.
Background
With the development of internet technology, more and more question-answering systems are developed, and in order to accurately answer questions provided by users, before the answers are extracted from the question-answering systems, the questions provided by the users are generally required to be semantically understood and analyzed, and then the answers are queried and ranked according to semantically understood information, so that correct answers are screened out and fed back to the users. The current question system generally uses some features to sequence answers, the features at document paragraph level generally use cross-over ratio and the like to calculate the similarity between documents and questions, meanwhile, the types of the answers are combined to be used as feature vectors and the like, the features of the answers generally use a question-answering model to give answer confidence, and entity types, classification labels and the like contained in the answers are vectorized and then feature fusion is carried out, so that correct answers are obtained. However, the accuracy of the answer screening is limited, which is likely to cause wrong answers, and an effective solution is needed to solve the above problems.
Disclosure of Invention
In view of this, embodiments of the present application provide a text processing method to solve technical defects in the prior art. The embodiment of the application also provides a text processing device, a computing device and a computer readable storage medium.
According to a first aspect of embodiments of the present application, there is provided a text processing method, including:
acquiring a question text;
inputting the question text into a question-answering module for processing to obtain candidate answers output by the question-answering module, wherein the question-answering module is a question-answering system for carrying out preliminary answer on the question text, and the question-answering system is selected according to an actual application scene;
and extracting a target text containing the candidate answer from a text library corresponding to the question-answering module according to the candidate answer.
According to a second aspect of the embodiments of the present application, there is provided another text processing method, including:
obtaining a question text and a target text containing a candidate answer corresponding to the question text;
extracting candidate sentences containing the candidate answers from the target text;
and constructing candidate answer characteristics according to the target text, the candidate sentences and the question text, and determining the target answer text corresponding to the question text based on the candidate answer characteristics.
Optionally, the obtaining the question text and the target text containing the candidate answer corresponding to the question text includes:
acquiring the question text;
inputting the question text into a question-answering module for processing to obtain the candidate answer output by the question-answering module;
and extracting the target text containing the candidate answer from a text library corresponding to the question-answering module according to the candidate answer.
Optionally, the extracting, from the target text, a candidate sentence including the candidate answer includes:
determining answer positions of the candidate answers in the target text;
extracting the candidate sentence including the candidate answer in the target text based on the answer position.
Optionally, the determining answer positions of the candidate answers in the target text includes:
analyzing the candidate answer to obtain attribute information corresponding to the candidate answer;
and carrying out position location in the target text according to the attribute information, and determining the answer position of the candidate answer in the target text according to a location result.
Optionally, the extracting the candidate sentence containing the candidate answer in the target text based on the answer position includes:
identifying a first paragraph identifier and a second paragraph identifier in the target text based on the answer position, and extracting the candidate sentence containing the candidate answer according to the first paragraph identifier and the second paragraph identifier;
alternatively, the first and second electrodes may be,
and extracting a first paragraph text and a second paragraph text with the number of words set before and after the candidate answer from the target text, and generating the candidate sentence according to the first paragraph text, the candidate answer and the second paragraph text.
Optionally, the constructing a candidate answer feature according to the target text, the candidate sentence, and the question text includes:
extracting text features of the target text;
and splicing the text features, the candidate sentences and the question text to obtain the candidate answer features corresponding to the candidate answers.
Optionally, the determining, based on the candidate answer feature, a target answer text corresponding to the question text includes:
inputting the candidate answer features into a text processing module, and performing coding processing through a depth language model in the text processing module to obtain coding features;
inputting the coding features into a classification network in the text processing module for grading processing to obtain feature scores corresponding to the coding features;
determining answer scores corresponding to the candidate answers according to the feature scores, and screening the target answer texts from the candidate answers based on the answer scores;
and outputting the target answer text through the text processing module.
Optionally, the method further comprises:
acquiring an initial language model and a sample question text;
determining a sample answer text corresponding to the sample question text, and constructing a sample pair based on the sample question text and the sample answer text;
and training the initial language model based on the sample pair until the initial language model meets a training stop condition, and obtaining the depth language model.
Optionally, the screening out the target answer text from the candidate answers based on the answer scores includes:
sorting each sub-candidate answer in the candidate answers according to the answer scores to obtain a candidate answer sequence;
and screening the target answer text in the candidate answer sequence according to a preset screening rule.
Optionally, the text features include at least one of:
text title, text keyword, text semantic information.
Optionally, the splicing the text features, the candidate sentences and the question text to obtain the candidate answer features corresponding to the candidate answers includes:
and splicing the text features, the candidate sentences and the question text according to the input strategy of the text processing module, and obtaining the candidate answer features according to the splicing processing result.
According to a third aspect of embodiments of the present application, there is provided a text processing apparatus including:
a first obtaining module configured to obtain a question text;
the processing module is configured to input the question text into a question-answering module for processing, and obtain candidate answers output by the question-answering module, the question-answering module is a question-answering system for carrying out preliminary answers on the question text, and the question-answering system is selected according to an actual application scene;
and the first extraction module is configured to extract a target text containing the candidate answer from a text library corresponding to the question-answering module according to the candidate answer.
According to a fourth aspect of the embodiments of the present application, there is provided another text processing apparatus including:
the second acquisition module is configured to acquire a question text and a target text containing a candidate answer corresponding to the question text;
a second extraction module configured to extract candidate sentences containing the candidate answers in the target text;
the determining module is configured to construct candidate answer characteristics according to the target text, the candidate sentences and the question text, and determine the target answer text corresponding to the question text based on the candidate answer characteristics.
According to a fifth aspect of embodiments herein, there is provided a computing device comprising:
a memory and a processor;
the memory is for storing computer-executable instructions that when executed by the processor implement the steps of the text processing method.
According to a sixth aspect of embodiments herein, there is provided a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the text processing method.
According to the text processing method, after the question text is obtained, the question text is input to the question-answering module to be processed, the candidate answer output by the question-answering module is obtained, then the target text containing the candidate answer is extracted from the text base corresponding to the question-answering module according to the candidate answer, the question-answering module is a question-answering system for primarily answering the question text, and the question-answering system can be selected according to an actual application scene. The question-answering module is used for acquiring a target text containing candidate answers and extracting context information subsequently, so that the semantic information of the target text can be combined in the process of answering the question text, the accuracy of screening the target answer text is improved, and the target text is obtained by the question-answering module selected according to the actual application scene, so that the target text is more in line with the actual application scene, and the accuracy of question-answering is further improved.
According to the text processing method, after a question text is obtained, a candidate answer corresponding to the question text is determined, and a target text containing the candidate answer is obtained; candidate sentences containing candidate answers are then extracted from the target text, so that correct answers can be predicted subsequently by combining the context information of the candidate answers. And secondly, a candidate answer characteristic is constructed based on the target text, the candidate sentence and the question text, and finally the target answer text is determined based on the candidate answer characteristic, so that the influence of the context semantic information on the answer of the predicted question text is considered when the answer of the question text is screened, the accuracy of determining the target answer text is effectively improved, and the answer accuracy is further improved.
Drawings
Fig. 1 is a flowchart of a text processing method according to an embodiment of the present application;
FIG. 2 is a flowchart illustrating a text processing method applied to a question answering scenario according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a text processing apparatus according to an embodiment of the present application;
fig. 4 is a block diagram of a computing device according to an embodiment of the present application.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. This application is capable of implementation in many different ways than those herein set forth and of similar import by those skilled in the art without departing from the spirit of this application and is therefore not limited to the specific implementations disclosed below.
The terminology used in the one or more embodiments of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of the present application. As used in one or more embodiments of the present application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used in one or more embodiments of the present application refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It will be understood that, although the terms first, second, etc. may be used herein in one or more embodiments of the present application to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first aspect may be termed a second aspect, and, similarly, a second aspect may be termed a first aspect, without departing from the scope of one or more embodiments of the present application.
First, the noun terms to which one or more embodiments of the present invention relate are explained.
BERT model: (bidirectional encoder recurrents from Transformer), characterized by a transform-based bi-directional encoder, and the root of the BERT model is the transform, and is derived from the interpretation is all you need. Wherein the bidirectional meaning means that when processing a word, it can take into account the information of the words before and after the word, thereby obtaining the semantic meaning of the context.
Question answering System (QuestionAnswering System, QA): is a high-level form of information retrieval system that can answer questions posed by a user in natural language in accurate and concise natural language.
Confidence coefficient: the Confidence interval (Confidence interval) of a probability sample is an interval estimate for some overall parameter of this sample. The confidence interval exhibits the extent to which the true value of this parameter has a certain probability of falling around the measurement. The confidence interval gives the range of confidence levels of the measured parameter measurement, i.e. the "certain probability" required above. This probability is called the confidence level.
In the present application, a text processing method is provided. The present application relates to a text processing apparatus, a computing device, and a computer-readable storage medium, which are described in detail in the following embodiments one by one.
Fig. 1 shows a flowchart of a text processing method according to an embodiment of the present application, which specifically includes the following steps:
step S102, a question text and a target text containing a candidate answer corresponding to the question text are obtained.
Specifically, the question text specifically refers to a text corresponding to a question to be answered and submitted by a user; correspondingly, the candidate answers are determined after preliminary answer screening is performed on the question texts, and the number of the candidate answers is at least one, so that texts corresponding to correct answers matched with the question texts can be screened out from the candidate answers subsequently. The target text specifically refers to an article or a text paragraph containing the candidate answer, so that sentences (context information) containing the candidate answer can be extracted from the target text subsequently, and the accuracy of screening the target answer text is improved.
Based on this, in order to feed back a correct answer with high accuracy to a user, after the candidate answer is obtained, the target answer text is predicted by combining the influence of the context information on the accuracy of the screened answer, so that the target answer text can be determined more accurately. In this process, after the question text submitted by the user is acquired, the candidate answer corresponding to the question text is determined, so that the candidate target answer text can be screened, in this embodiment, the specific implementation manner is as follows:
acquiring the question text;
inputting the question text into a question-answering module for processing to obtain the candidate answer output by the question-answering module;
and extracting the target text containing the candidate answer from a text library corresponding to the question-answering module according to the candidate answer.
Specifically, the question-answering module is a question-answering system capable of initially answering the question text, that is, after the question text submitted by the user is input to the question-answering module, the question-answering module initially determines candidate answers for answering the question text, so that the candidate answers can be used in a subsequent text processing process. It should be noted that the text processing method provided by the present application is applied to a natural language processing scenario, that is, when a response needs to be made to a question text, answers need to be extracted from corresponding articles for feedback. Based on this, when the question answering module initially answers the question text, the question answering module is realized by combining a preset text library, and a large number of articles divided according to the field are stored in the text library so as to support answering of the question text in the same field.
On the basis, in order to enable correct answers to be screened out from candidate answers subsequently and feed back the correct answers to the question text, after the question text is obtained, the question-answering module carries out preliminary answer on the question text to obtain the candidate answers output by the question-answering module; since the number of the candidate answers may be large and the candidate answers are from different articles, at this time, a text library corresponding to the question-answering module needs to be determined, and then the article including the candidate answer is extracted from the text library as the target text for subsequently extracting context information, thereby implementing a process of performing response processing on the question text.
In practical application, the question-answering module may be created based on a question-answering System (QuestionAnswering System) to support preliminary answers to natural language questions of users and lay a foundation for subsequently screening correct answers, and in specific implementation, the question-answering System for constructing the question-answering module may be selected according to practical application scenarios, which is not limited herein.
To illustrate, in obtaining a question text "who is a first? "later, at this time, the question text is input to the question-answering system QA for preliminary processing, and the question-answering system QA is obtained for the question text" who is first? "three output candidate answers are respectively a candidate answer L1 [ a · a ], a candidate answer L2 [ a · B ], and a candidate answer L3 [ a · C ]. In order to be able to select the correct answer from the three candidate answers and feed the correct answer back to the user, at this time, the article including the three candidate answers needs to be extracted from the text library corresponding to the question-answering system QA for the subsequent screening process.
Based on this, at this time, an article a1[ … a. house edge/center, efficacy at Y football club … ] containing the candidate answer L1 was extracted from the text library; extracting an article A2[ … A & B is born in S place, professional football player, profession front … ] containing a candidate answer L2; extracting an article A3[ … A.C, male professional football players, field-top scene/edge/front waist … ] containing a candidate answer L3; so that correct answers can be screened and fed back to the user from the article content.
In summary, in order to effectively improve the accuracy of subsequently screening correct answers, after the question text is obtained, the target text of the candidate answer corresponding to the question text is obtained at the same time, so that the accuracy of screening the target answer text can be improved by subsequently combining the semantic information of the target text.
Step S104, extracting candidate sentences containing the candidate answers from the target text.
Specifically, on the basis of obtaining the question text and the target text containing the candidate answer, at this time, a candidate sentence containing the candidate answer may be extracted from the target text, so as to support the influence of the context semantic information in the target text on the correct answer in the subsequent prediction of the correct answer, thereby improving the screening accuracy of the correct answer. Based on this, the candidate sentence specifically refers to a short text containing a paragraph of the candidate answer or a set number of words. It should be noted that, since there may be a plurality of candidate answers, the obtained candidate sentences are also the same as the number of candidate answers, that is, the candidate answers are respectively from different target texts, and each target text has a candidate sentence containing the candidate answer.
Further, when extracting a candidate sentence including the candidate answer from the target text, since the content included in the target text may be more, that is, the target text may be a paper, a report, or a book, it is necessary to accurately locate the position of the candidate answer in the target text, so that the candidate sentence can be extracted from the target text, in this embodiment, the specific implementation manner is as follows:
step S1042: and determining the answer position of the candidate answer in the target text.
Specifically, the answer position specifically refers to a position of the candidate answer in the target text; based on this, since the target text may contain more content, the candidate sentence can be accurately extracted only by accurately locating the position of the candidate answer in the target text, so as to be used in the subsequent text processing process, in this embodiment, the process of determining the answer position is as follows:
analyzing the candidate answer to obtain attribute information corresponding to the candidate answer;
and carrying out position location in the target text according to the attribute information, and determining the answer position of the candidate answer in the target text according to a location result.
Specifically, the attribute information specifically refers to basic information of the candidate answer, including but not limited to word number, word unit, and arrangement order of word units of the candidate answer.
Based on this, in order to accurately locate the position of the candidate answer in the target text, the candidate answer may be analyzed to obtain attribute information of the candidate answer, then position location is performed in the target text based on the attribute information, and finally, the answer position of the candidate answer may be determined from the target text according to a location result.
In practical application, since the candidate answer may appear in the target text for multiple times, if the candidate answer is located again, multiple answer positions may appear, so as to avoid an influence caused by the question, after the candidate answer is located at multiple initial answer positions, a matching degree between a sentence to which each initial answer position belongs and the question text is calculated, that is, a semantic similarity between the sentence at each initial answer position and the question text is calculated, and by the matching degree between a semantic level mapping position and the text, the answer with the highest matching degree can be selected as the candidate answer, so that the position of the candidate answer in the target text is located more accurately, and the accuracy of subsequently screening correct answers is improved.
Step S1044, extracting the candidate sentence containing the candidate answer from the target text based on the answer position.
Specifically, after the answer position of the candidate answer in the target text is determined, the candidate sentence including the candidate answer can be extracted from the target text according to the answer position, and due to different requirements for determining the candidate sentence in different scenes, if the target text has more long sentences, if the candidate answer just falls into the long sentences, the extracted candidate sentence has more word units, and when the answer is subsequently screened, the screening accuracy may be affected; then, or there are many phrases in the target text, if the candidate answer exactly falls into a phrase, the word units included in the extracted candidate sentence are fewer, and when the answer is subsequently screened, the screening accuracy may also be affected, so that in order to meet the determination of the candidate sentence in different scenes, in this embodiment, the specific implementation manner is as follows:
identifying a first paragraph identifier and a second paragraph identifier in the target text based on the answer position, and extracting the candidate sentence containing the candidate answer according to the first paragraph identifier and the second paragraph identifier; or, extracting a first paragraph text and a second paragraph text with the number of words set before and after the candidate answer from the target text, and generating the candidate sentence according to the first paragraph text, the candidate answer and the second paragraph text.
Specifically, the first paragraph symbol refers to a paragraph symbol that is closest to the answer position forward in the target text, and the second paragraph symbol refers to a paragraph symbol that is closest to the answer position backward in the target text, where the paragraph symbol may be a comma, a period, an exclamation mark, a question mark, or the like (i.e., a symbol for a sentence break). In the case that the target text is determined to contain more short sentences, the candidate sentence can be determined in a manner of selecting an identification paragraph character, namely, the candidate sentence containing the candidate answer can be determined by selecting the content between the first paragraph character and the second paragraph character in the target text.
The first paragraph text is a paragraph interval formed by forward word number content in the target text based on the answer position, and the second paragraph text is a paragraph interval formed by backward word number content in the target text based on the answer position; in the case that the target text is determined to contain more long sentences, the candidate sentence can be determined by selecting a paragraph text with a set word number, namely, a first paragraph text with a set word number before an answer position is selected in the target text and a second paragraph text with a set word number, and combining the candidate answers of the answer position, the candidate sentence can be formed for a subsequent answer screening process aiming at correct answers.
Along the above example, on the basis of determining candidate answers L1 [ a · a ], L2 [ a · B ], and L3 [ a · C ], further, by analyzing each candidate answer, it is determined that the attribute information of the candidate answer L1 is { n1 words, and the word units are "a" "a" }; determining attribute information of the candidate answer L2 as n2 words, wherein word units are 'A' and 'B'; determining attribute information of the candidate answer L3 as n3 words, wherein word units are 'A' and 'C'; then the position of the candidate answer L1 in the article A1 is determined to be P1 according to the attribute information of the candidate answer L1, the position of the candidate answer L2 in the article A2 is determined to be P2 according to the attribute information of the candidate answer L2, and the position of the candidate answer L3 in the article A3 is determined to be P3 according to the attribute information of the candidate answer L3.
Further, based on the position P1, selecting [ a. mescenospen/mid ] in the article a1 as the candidate sentence CS1 corresponding to the candidate answer L1; selecting [ A.B is born at S place ] as a candidate sentence CS2 corresponding to the candidate answer L2 in the article A2 based on the position P2; selecting [ a.c male professional football player ] in the article A3 as a candidate sentence CS3 corresponding to the candidate answer L3 based on the position P3; after the candidate sentences corresponding to the candidate answers are determined, the correct answers can be screened subsequently by combining the context information of the candidate answers, so that the correct answer text can be fed back to the user.
In summary, in order to ensure that the correct answers can be accurately screened subsequently, at this time, the candidate sentences including the candidate answers are extracted from the target text in combination with the answer positions, so that the accurate prediction of the target correct answers can be accurately performed subsequently in combination with the context information of the candidate answers, and the accuracy of answering the question text is improved.
Step S106, constructing candidate answer characteristics according to the target text, the candidate sentences and the question text, and determining the target answer text corresponding to the question text based on the candidate answer characteristics.
Specifically, on the basis of extracting the candidate sentence including the candidate answer from the target text, in order to improve the accuracy of determining the target answer text, the candidate answer feature may be generated by combining the target text, the candidate sentence, and the question text, and used for subsequent correct answer prediction, so as to ensure the accuracy of determining the correct answer.
Further, in the process of constructing the candidate answer feature based on the target text, the candidate sentence, and the question text, considering that the feature of each dimension may be determined in the same expression form, and therefore, the splicing process needs to be performed, in this embodiment, a specific implementation manner is as follows:
extracting text features of the target text;
and splicing the text features, the candidate sentences and the question text to obtain the candidate answer features corresponding to the candidate answers.
Specifically, the text features specifically refer to features capable of expressing the central concept of the target text, including but not limited to a text title, a text keyword, text semantic information, and the like, where the text title refers to a title of the target text, the text keyword specifically refers to a key word in the target text, and the text semantic information specifically refers to related information capable of expressing an intention of the target text; correspondingly, the candidate answer features specifically refer to feature expressions obtained by splicing the text features, the candidate sentences and the question text, and are used for subsequent input to a text processing module to realize prediction of correct answers.
It should be noted that the text keywords and the text semantic information may be implemented by lda (text dirichletaltration), or may be determined according to the description information of the target text, that is, the keywords corresponding to the abstract of the target text may be used as the text keywords, and the text semantic information may be determined according to the abstract of the target text. In addition, the determination of the text keywords can be determined by calculating word unit probabilities, and the text semantic information can be determined by a syntax analyzer. In practical application, the determination manner of the text keyword and the text semantic information may be selected according to a practical application scenario, and this embodiment is not limited herein.
Further, since the text processing module is configured to select a candidate answer with the highest degree of correlation with the question text from the multiple candidate answers as the target answer text, before the text processing module processes the candidate answer, information combining three dimensions (text features, candidate sentences and question texts) needs to be spliced into a feature expression conforming to the module input, so as to support a subsequent screening processing operation, in this embodiment, a specific implementation manner is as follows:
and splicing the text features, the candidate sentences and the question text according to the input strategy of the text processing module, and obtaining the candidate answer features according to the splicing processing result.
Specifically, the input policy is a policy that needs to be followed when information of three dimensions is spliced, so as to implement that the text feature, the candidate sentence, and the question text can be spliced to the candidate answer feature that satisfies the input expression of the text processing module, that is, the text feature, the candidate sentence, and the question text need to be spliced according to the input policy, so as to obtain the candidate answer feature.
In specific implementation, the input strategy may be to convert the text features, the candidate sentences and the question text into three matrix expressions, and then to perform splicing processing on the three matrix expressions to obtain the candidate answer features in a matrix form for subsequent input to a text processing module for screening of correct answers; the text features, the candidate sentences and the question texts can be spliced firstly, that is, an expression of < text features > < candidate sentences > < question texts > is formed, and then the expression is converted into a matrix as the candidate answer features for being input into a text processing module for screening correct answers.
Following the above example, the text characteristic T1 of article a1 was determined to be < job >, the text characteristic T2 of article a2 was determined to be < brief >, and the text characteristic T3 of article A3 was determined to be < biography >; then, the text features T1 (employment), the candidate sentences CS1 (A. A employment frontier/center) and the question text S (who A is) are spliced to obtain candidate answer features AT 1[ < T1>, < CS1>, < S > ] corresponding to the candidate answers L1; splicing the text characteristics T2 (introduction), the candidate sentences CS2 (A and B are born AT S place) and the question text S (A is who), and obtaining candidate answer characteristics AT 2[ < T2>, < CS2>, < S > ] corresponding to the candidate answer L2; splicing the text characteristics T3 (biography), the candidate sentence CS3 (A. C man professional football players) and the question text S (who A is), and obtaining candidate answer characteristics AT 3[ < T3>, < CS3>, < S > ] corresponding to the candidate answer L3; for subsequent prediction of the correct answer.
In summary, by splicing the candidate answer features which are consistent with the input of the text processing module, the efficiency of answer prediction in the subsequent process can be further improved, so that the correct answer corresponding to the question text can be quickly fed back to the user.
On the basis of obtaining the candidate answer features, further, a target answer text corresponding to the question text can be determined according to the candidate answer features; in this process, in order to complete answer determination by fully combining context semantic information, the candidate answer features may be input to the text processing module for processing, so that a candidate answer with a high degree of correlation with the question text is accurately screened out from the candidate answers by the text processing module and is used as the target answer text, so as to implement correct answer to the question text.
Based on this, the text processing module can specifically encode the candidate answer features, and classify and score the results after the encoding, that is, a deep language model and a classification network are integrated in the text processing module, so that the encoding processing is completed through the deep language model, the two-classification scoring is completed through the classification network, the multiple candidate answers are sorted, and correct answers are screened out according to the sorting results and fed back as the target answer text. Correspondingly, the target answer text specifically refers to a text which is selected from the candidate answers and has a higher matching degree with the question text and can be used as a correct answer to the question text.
Furthermore, because the text features of the target text, the candidate sentences to which the candidate answers belong, and the question text are combined in the candidate answer features, encoding processing needs to be performed through a depth language model in the text processing module, after the encoding processing, the context semantic information of the candidate answers is combined, and then the grading processing is performed through a classification network, so that the target answer text is determined.
In practical application, the deep language model specifically refers to a model obtained by performing fine tuning on an existing initial language model through a question-and-answer task, and if the initial language model is a BERT model, when the deep language model is required to be applied to a natural language question-and-answer scene, the BERT model can be fine-tuned through the question-and-answer task to obtain the deep language model according to a fine tuning result, so that candidate answer features can be encoded for a subsequent scoring processing process, wherein the question-and-answer task specifically refers to a task created when a sample question text is used for training the BERT model, and encoding processing on the candidate answer features can be realized through the task, in the embodiment, the process of performing fine tuning on the initial language model through the question-and-answer task is as follows:
acquiring an initial language model and a sample question text;
determining a sample answer text corresponding to the sample question text, and constructing a sample pair based on the sample question text and the sample answer text;
and training the initial language model based on the sample pair until the initial language model meets a training stop condition, and obtaining the depth language model.
Specifically, the sample question text and the sample answer text specifically refer to sample data used when the initial language model is fine-tuned, and correspondingly, the initial language model specifically refers to a language model which is not fine-tuned by the question and answer task but has corresponding parameters set, and the initial language model may be a BERT model.
Based on this, after obtaining the initial language model and the sample question text, a plurality of sample candidate answers corresponding to the sample question text may be determined, a sample target text including each sample candidate answer may be extracted, then a sample candidate sentence including the sample candidate answer may be extracted from each sample target text, then the sample text features of the sample target text, the sample candidate sentence, and the sample question text may be spliced to obtain the sample candidate answer features, and then the sample candidate answer features may be output to the initial language model for training, a predicted answer text output by the model may be obtained according to a training result, at this time, a loss value may be calculated based on the predicted answer text and the sample answer text, whether the initial language model at the current stage satisfies a training stop condition may be determined according to the loss value, and if so, the loss value may be used as a depth language model for subsequent encoding processing, and if the condition is not met, selecting a new sample to train the sample continuously until the training stopping condition is met, and integrating the sample into the text processing module for use.
Furthermore, in this embodiment, a process of screening a target answer text by a text processing module integrating a deep language model and a classification network is specifically implemented as follows:
inputting the candidate answer features into a text processing module, and performing coding processing through a depth language model in the text processing module to obtain coding features;
inputting the coding features into a classification network in the text processing module for grading processing to obtain feature scores corresponding to the coding features;
determining answer scores corresponding to the candidate answers according to the feature scores, and screening the target answer texts from the candidate answers based on the answer scores;
and outputting the target answer text through the text processing module.
Specifically, the coding features specifically refer to feature expressions obtained after coding the candidate answer features, correspondingly, the feature scores specifically refer to scores obtained after grading the coding features corresponding to the candidate answers, correspondingly, the answer scores are scores corresponding to the candidate answers, the target answer text specifically refers to a text corresponding to the answers to the question text, and it should be noted that the target answer text is a result screened from the candidate answers.
In practical application, the classification network is specifically a network capable of scoring coding features, the classification network may be constructed by using an LGBM classifier, it needs to be stated that the feature score is a score for calculating whether a candidate answer can be used as the target answer text, and the higher the feature score is, the higher the matching degree between the candidate answer and the question text is, the higher the probability of being used as the target answer text is; on the contrary, the lower the feature score is, the lower the matching degree of the candidate answer and the question text is, and the lower the probability of the target answer text is; therefore, after the feature scores are calculated, the answer scores of all candidate answers can be analyzed, on the basis, the target answer text can be screened from the candidate answers, and the target answer text can be output and fed back through the text processing module.
Based on this, after the candidate answer features corresponding to each candidate answer are obtained, the candidate answer features can be input into a text processing module, the coding features corresponding to each candidate answer can be obtained by coding the candidate answer features through a deep language model in the text processing module, then the coding features corresponding to each candidate answer are input into a classification network in the text processing module to be subjected to grading processing, the feature scores of the coding features corresponding to each candidate answer can be obtained, the feature scores are used as answer scores of the candidate answers, the target answer text can be screened from the candidate answers based on the answer scores, and the target answer text can be output through the text processing module.
Furthermore, in the process of screening the target answer text from the candidate answers based on the answer score, because different scenes have different requirements, the target answer text may be determined according to a screening rule set by a scene requirement, and in this embodiment, a specific implementation manner is as follows:
sorting each sub-candidate answer in the candidate answers according to the answer scores to obtain a candidate answer sequence;
and screening the target answer text in the candidate answer sequence according to a preset screening rule.
Specifically, the sub-candidate answers are each candidate answer, and the candidate answer sequence is a sequence obtained by sorting the candidate answers according to the magnitude relation of the candidate scores.
Along the above example, after candidate answer features AT1, AT2 and AT3 are obtained, the candidate answer features AT1, AT2 and AT3 are respectively input to the BERT model after being subjected to the fine tuning by the question and answer task in the text processing module for encoding processing, and according to the processing result, an encoding feature ATcode1 corresponding to the candidate answer L1, an encoding feature ATcode2 corresponding to the candidate answer L2 and an encoding feature ATcode3 corresponding to the candidate answer L3 which are output by the BERT model are obtained.
Further, inputting each coding feature into a classification network for scoring, namely, performing classification scoring on each coding feature, determining a feature Score of the encode 1 as Score1 according to a scoring result, determining a feature Score of the encode 2 as Score2 according to the scoring result, determining a feature Score of the encode 3 as Score3 according to the scoring result, wherein the feature Score is Score2> the feature Score1> the feature Score3, then ranking candidate answers L1 [ a · a ], candidate answers L2 [ a · B ] and candidate answers L3 [ a · C ] based on the feature scores, determining that the Score of the candidate answers L2 [ a · B ] is the highest, and selecting the candidate answer L2 as a question text "a is who? "and feeding back to the user.
In summary, by using the fine-tuned language model for coding, the efficiency of predicting the target answer text can be effectively improved, meanwhile, the classification network is combined for scoring, and the scored candidate answers are ranked, so that the prediction accuracy can be further improved, and thus, the correct answer is determined for the question text.
According to the text processing method, after a question text is obtained, a candidate answer corresponding to the question text is determined, and a target text containing the candidate answer is obtained; candidate sentences containing candidate answers are then extracted from the target text, so that correct answers can be predicted subsequently by combining the context information of the candidate answers. And secondly, a candidate answer characteristic is constructed based on the target text, the candidate sentence and the question text, and finally the target answer text is determined based on the candidate answer characteristic, so that the influence of the context semantic information on the answer of the predicted question text is considered when the answer of the question text is screened, the accuracy of determining the target answer text is effectively improved, and the answer accuracy is further improved.
The text processing method provided by the present application is further described below with reference to fig. 2 by taking an example of application of the text processing method in a question answering scenario. Fig. 2 shows a processing flow chart of a text processing method applied in a question answering scenario according to an embodiment of the present application, which specifically includes the following steps:
step S202, the question text uploaded by the user is obtained.
The present embodiment takes the question text as "who the author is in the western song? "the text processing method is explained as an example.
Step S204, determining candidate answers of the question text in different articles based on a preset question system.
What is the author of the western song obtained in the question text? "thereafter, the system determines that the question text is irony in article A1[ … Western song, and the candidate answer L1 in the expression of emotional feeling unevenness … is expressed by song Western song [ Western song ]. The question text, which was attached to wu-wangfu-mau-kuai in article a2[ … girl west, is for a political purpose, but wangwei does not draw materials for political reasons, but rather is [ wuwang ] with a candidate answer L2 in gorgeous rabber … after she has reached work. Question text in article a3[ … western song is a poem created by the royal wife of poem in down dynasty. This poem, by western historical allusion from civilian to royal choiceness, revealed that the candidate answer L3 in the life's full-life-style of life, the cool-and-hot state … [ king wife ]. Problem text in article a4[ … Xiri together in women of the Yuexi racoon, can no longer be assigned to her co-vehicle for the same vehicle; the candidate answer L4 in the neighborhood of eastern kho in banlanga blind practice frame, which was optical frown and wanted to take pet was not easy … was [ eastern kho ].
It should be noted that, in practical applications, different articles have different lengths, and in order to facilitate description of a text processing process, part of contents in the articles are selected as representations of the articles.
Step S206, determining answer positions of the candidate answers in the articles, and extracting context information in the articles based on the answer positions.
After determining that the candidate answers are respectively: after the candidate answer L1 [ xishi ], the candidate answer L2 [ wuwang ], the candidate answer L3 [ wangwei ] and the candidate answer L4 [ east shi ], in order to improve the correctness of the subsequent answer to the question text, the accuracy of determining the correct answer is improved by combining the context information of the candidate answer.
Based on this, the answer position of each candidate answer in the article to which the candidate answer belongs is determined firstly, that is, the position of the candidate answer L1 [ xishi ] in the article a1 is determined to be P1 xs; determining the position of the candidate answer L2 [ wuwang ] in article a2 as P2 ww; determining the position of a candidate answer L3 [ Wangwei ] in the article A3 to be P3 ww; the candidate answer L4 [ shiese ] was determined to be P4ds at the position in article a 4.
Further, context information corresponding to each candidate answer is extracted from each article according to the answer position, that is, a sentence containing the candidate answer is selected from each article as the context information corresponding to each candidate answer, so that the correct answer is determined in the following process. That is, based on the answer position P1xs, the [ find the world feeling uneven by subscribing sitcom ] may be selected as the corresponding context information DP1 of the candidate answer L1 [ sitcom ] in the article a 1; based on the answer position P2ww, a candidate answer L2 [ wuwang ] corresponding to the context information DP2 can be selected from article a2[ wuwang difference is married to west girls); based on the answer position P3ww, a [ western song is a poem created by royal poetry of down poetry ] can be selected in the article A3 as the corresponding context information DP3 of the candidate answer L3 [ royal dimensional ]; based on the answer position P4ds, [ eastern scholar who is in the blind main frame ] can be selected in the article a4 as the corresponding context information DP4 of the candidate answer L4 [ eastern scholar ].
And S208, obtaining article characteristics of the article to which the candidate answer belongs, and splicing the article characteristics, the question text and the context information to obtain answer text characteristics.
In order to further improve the accuracy of determining the correct answer of the question text, the article characteristics of the article to which the candidate answer belongs can be combined, and then the article characteristics, the question text and the context information are spliced and used for subsequent correct answer prediction, so that the accuracy of determining the correct answer is ensured.
Further, keywords of an article to which the candidate answer belongs may be selected as the article features for subsequent splicing out the answer text features. Based on this, the keywords kw1 of article a1 were determined as < irony > and < lyric >; determining keywords kw2 of article a2 as < grafting > and < politics >; determining keywords kw3 of article a3 as < authored poetry > and < disclosure >; the keyword kw4 of article a4 was determined to be < raccoon > and < inner frame >.
Furthermore, after the article features of the article to which the candidate answers belong are obtained, the article features, the question text and the context information are spliced at this time to obtain the answer text features. Namely: concatenating the keywords kw1 (sarcasm and lyric) of the article a1, the question text S (who the author of the western song was), and the context information DP1 (which indicates the sense of anger is uneven by subscribing to the western song) corresponding to the candidate answer L1 (western song) to obtain answer text characteristics AT 1[ < kw1>, < S >, < DP1> ] corresponding to the candidate answer L1;
splicing keywords kw2 (marriage and politics), question texts S (who the author is the author of western application) and context information DP2 (difference between wuwangfu and western application) corresponding to candidate answers L2 (wuwang) of an article a2 to obtain answer text characteristics AT2 corresponding to the candidate answers L2 [ < kw2>, < S >, < DP2> ];
splicing keywords kw3 (creating poems and postings) of an article A3, a question text S (who the author of the Western application is) and context information DP3 (the Western application is a poem created by the King dimension of the Tang Dynasty) corresponding to a candidate answer L3 (the King dimension) to obtain answer text characteristics AT 3[ < kw3>, < S >, < DP3> ] corresponding to the candidate answer L3;
splicing keywords kw3 (raccoon yarn and sports frame) of an article A4, question texts S (who the author of western song is) and context information DP4 (eastern star) corresponding to candidate answers L4 (eastern star) to obtain answer text characteristics AT 4[ < kw4>, < S >, < DP4> ] corresponding to the candidate answers L4; for subsequent prediction of the correct answer.
Step S210, inputting the answer text characteristics into a text processing module, and performing coding processing through a depth language model which is subjected to fine tuning by a question and answer task in the text processing module to obtain answer text coding characteristics.
Specifically, the text processing module specifically refers to a module for integrating the fine-tuned deep language model and the classification network, wherein the deep language model fine-tuned by the question-answering task specifically refers to: and according to the initial language model corresponding to the preliminarily trained network parameters published by the publisher, combining the current question-answering scene, and finely adjusting the initial language model by adopting a question-answering task to obtain a deep language model in the text processing module. That is to say, in order to apply the initial language model to the current question-answering scenario, a question-answering task is adopted to perform fine adjustment on the initial language model in combination with the requirements of the scenario, wherein the question-answering task refers to a given set number of questions and articles related to the questions, and the articles contain statements of answers to the questions, and the statements are used for predicting the range of answer texts in the statements, so that the fine-adjusted deep language model can be used for encoding the features of the answer texts subsequently, and a basis is laid for the subsequent sorting task.
Based on the method, after the answer text features constructed by the article features, the context information and the question text are obtained, the answer text features can be input into the text processing module at the moment, coding processing is carried out through a depth language model which is subjected to fine tuning by a question and answer task in the text processing module, so that semantic coding feature expression of the answer text features corresponding to the candidate answers is obtained, and correct answers can be screened from a plurality of candidate answers in a grading and sorting mode and then fed back to the user.
Based on this, after answer text features AT 1[ < kw1>, < S >, < DP1> ] corresponding to the candidate answer L1, answer text features AT 2[ < kw2>, < S >, < DP2> ] corresponding to the candidate answer L2, answer text features AT 3[ < kw3>, < S >, < DP3> ] corresponding to the candidate answer L3, and answer text features AT 4[ < kw4>, < S >, < DP4> ] corresponding to the candidate answer L4 are obtained, the answer text characteristics AT 1-AT 4 can be respectively input into a text processing module to be encoded by the BERT model after being finely adjusted by the question-answering task, according to the processing result, answer text coding characteristics ATcode1 corresponding to candidate answers L1, answer text coding characteristics ATcode2 corresponding to candidate answers L2, answer text coding characteristics ATcode3 corresponding to candidate answers L3 and answer text coding characteristics ATcode4 corresponding to candidate answers L4 output by the BERT model are obtained.
Step S212, inputting the coding features of the answer text into a classification network in the text processing module for grading processing to obtain an answer score, and taking the answer score as a ranking score corresponding to the candidate answer.
And S214, sorting the candidate answers according to the sorting scores, selecting a target answer according to the sorting result, outputting the target answer by the text processing module, and feeding back the target answer to the user.
After the answer text coding features corresponding to the candidate answers are obtained, the answer text coding features can be input to a classification network in a text processing module for grading, so that the grading of each feature is realized, the score corresponding to the answer text coding features is obtained, and the higher the score is, the higher the similarity degree of the candidate answers and the question text is (the higher the probability that the candidate answers are correct answers is), the score of the answers obtained after grading can be used as the ranking score of each candidate answer for ranking the candidate answers in the following process, so that the candidate answer closest to the question text is obtained as the correct answer to be fed back to the user.
Further, after determining answer text coding feature ATcode1 corresponding to candidate answer L1, answer text coding feature ATcode2 corresponding to candidate answer L2, answer text coding feature ATcode3 corresponding to candidate answer L3 and answer text coding feature ATcode4 corresponding to candidate answer L4, inputting each answer text coding feature to a classification network for scoring, namely, performing classification scoring on each answer text coding feature, determining the Score of the answer text coding feature ATcode1 as Score1, the Score of the answer text coding feature ATcode2 as Score2, the Score of the answer text coding feature ATcode3 as Score3 and the Score of the answer text coding feature ATcode4 as Score4 according to scoring results.
Further, at this time, the answer Score1 may be used as the ranking Score of the candidate answer L1 [ xishi ], the answer Score2 may be used as the ranking Score of the candidate answer L2 [ wuwang ], the answer Score3 may be used as the ranking Score of the candidate answer L3 [ royal fibers ], and the answer Score4 may be used as the ranking Score of the candidate answer L1 [ east shi ]. Wherein answer Score3> answer Score2> answer Score1> answer Score 4.
And finally, sequencing the candidate answers according to the sequencing scores to obtain a sequencing result of [ Wangwei > Wuwang > Xishi > Dongshi ], determining that the score of the candidate answer L3 [ Wangwei ] is the highest according to the sequencing result, selecting the candidate answer L3 [ Wangwei ] as a correct answer corresponding to the question text, outputting the correct answer [ Wangwei ] from a text processing module, and feeding back the correct answer to the user to inform the user of who is the author of the Xishi idea? The answer to "is" Wangwei ".
In summary, in consideration of the influence of the context semantic information on the answer for determining the question text, in order to improve the accuracy for determining the correct answer of the question text, when the answer is screened for the question text, the characteristics of the context information, the article characteristics, the question text and the like are combined, the characteristics are fused by using the fine-tuned deep language model, and finally, the correct answer of the question text is selected by means of scoring, so that the answer accuracy is effectively improved, and the experience effect of the user is improved.
Corresponding to the above method embodiment, the present application further provides a text processing apparatus embodiment, and fig. 3 shows a schematic structural diagram of a text processing apparatus provided in an embodiment of the present application. As shown in fig. 3, the apparatus includes:
an obtaining module 302, configured to obtain a question text and a target text containing a candidate answer corresponding to the question text;
an extraction module 304 configured to extract candidate sentences containing the candidate answers in the target text;
a determining module 306 configured to construct candidate answer features according to the target text, the candidate sentences and the question text, and determine a target answer text corresponding to the question text based on the candidate answer features.
Optionally, the obtaining module 302 is further configured to:
acquiring the question text; inputting the question text into a question-answering module for processing to obtain the candidate answer output by the question-answering module; and extracting the target text containing the candidate answer from a text library corresponding to the question-answering module according to the candidate answer.
Optionally, the extraction module 304 is further configured to:
determining answer positions of the candidate answers in the target text; extracting the candidate sentence including the candidate answer in the target text based on the answer position.
Optionally, the extraction module 304 is further configured to:
analyzing the candidate answer to obtain attribute information corresponding to the candidate answer; and carrying out position location in the target text according to the attribute information, and determining the answer position of the candidate answer in the target text according to a location result.
Optionally, the extraction module 304 is further configured to:
identifying a first paragraph identifier and a second paragraph identifier in the target text based on the answer position, and extracting the candidate sentence containing the candidate answer according to the first paragraph identifier and the second paragraph identifier; or, extracting a first paragraph text and a second paragraph text with the number of words set before and after the candidate answer from the target text, and generating the candidate sentence according to the first paragraph text, the candidate answer and the second paragraph text.
Optionally, the determining module 306 is further configured to:
extracting text features of the target text; and splicing the text features, the candidate sentences and the question text to obtain the candidate answer features corresponding to the candidate answers.
Optionally, the determining module 306 is further configured to:
inputting the candidate answer features into a text processing module, and performing coding processing through a depth language model in the text processing module to obtain coding features; inputting the coding features into a classification network in the text processing module for grading processing to obtain feature scores corresponding to the coding features; determining answer scores corresponding to the candidate answers according to the feature scores, and screening the target answer texts from the candidate answers based on the answer scores; and outputting the target answer text through the text processing module.
Optionally, the determining module 306 is further configured to:
acquiring an initial language model and a sample question text; determining a sample answer text corresponding to the sample question text, and constructing a sample pair based on the sample question text and the sample answer text; and training the initial language model based on the sample pair until the initial language model meets a training stop condition, and obtaining the depth language model.
Optionally, the determining module 306 is further configured to:
sorting each sub-candidate answer in the candidate answers according to the answer scores to obtain a candidate answer sequence; and screening the target answer text in the candidate answer sequence according to a preset screening rule.
Optionally, the text features include at least one of:
text title, text keyword, text semantic information.
Optionally, the determining module 306 is further configured to:
and splicing the text features, the candidate sentences and the question text according to the input strategy of the text processing module, and obtaining the candidate answer features according to the splicing processing result.
After the text processing device provided by this embodiment obtains a question text, a candidate answer corresponding to the question text is determined, and a target text including the candidate answer is obtained at the same time; candidate sentences containing candidate answers are then extracted from the target text, so that correct answers can be predicted subsequently by combining the context information of the candidate answers. And secondly, a candidate answer characteristic is constructed based on the target text, the candidate sentence and the question text, and finally the target answer text is determined based on the candidate answer characteristic, so that the influence of the context semantic information on the answer of the predicted question text is considered when the answer of the question text is screened, the accuracy of determining the target answer text is effectively improved, and the answer accuracy is further improved.
The above is a schematic scheme of a text processing apparatus of the present embodiment. It should be noted that the technical solution of the text processing apparatus and the technical solution of the text processing method belong to the same concept, and details that are not described in detail in the technical solution of the text processing apparatus can be referred to the description of the technical solution of the text processing method. Further, the components in the device embodiment should be understood as functional blocks that must be created to implement the steps of the program flow or the steps of the method, and each functional block is not actually divided or separately defined. The device claims defined by such a set of functional modules are to be understood as a functional module framework for implementing the solution mainly by means of a computer program as described in the specification, and not as a physical device for implementing the solution mainly by means of hardware.
Fig. 4 shows a block diagram of a computing device 400 provided according to an embodiment of the present application. The components of the computing device 400 include, but are not limited to, a memory 410 and a processor 420. Processor 420 is coupled to memory 410 via bus 430 and database 450 is used to store data.
Computing device 400 also includes access device 440, access device 440 enabling computing device 400 to communicate via one or more networks 460. Examples of such networks include the Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the internet. The access device 440 may include one or more of any type of network interface (e.g., a Network Interface Card (NIC)) whether wired or wireless, such as an IEEE802.11 Wireless Local Area Network (WLAN) wireless interface, a worldwide interoperability for microwave access (Wi-MAX) interface, an ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a bluetooth interface, a Near Field Communication (NFC) interface, and so forth.
In one embodiment of the application, the above-described components of computing device 400 and other components not shown in FIG. 4 may also be connected to each other, such as by a bus. It should be understood that the block diagram of the computing device architecture shown in FIG. 4 is for purposes of example only and is not limiting as to the scope of the present application. Those skilled in the art may add or replace other components as desired.
Computing device 400 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., tablet, personal digital assistant, laptop, notebook, netbook, etc.), mobile phone (e.g., smartphone), wearable computing device (e.g., smartwatch, smartglasses, etc.), or other type of mobile device, or a stationary computing device such as a desktop computer or PC. Computing device 400 may also be a mobile or stationary server.
Wherein processor 420 is configured to execute the following computer-executable instructions:
obtaining a question text and a target text containing a candidate answer corresponding to the question text;
extracting candidate sentences containing the candidate answers from the target text;
and constructing candidate answer characteristics according to the target text, the candidate sentences and the question text, and determining the target answer text corresponding to the question text based on the candidate answer characteristics.
The above is an illustrative scheme of a computing device of the present embodiment. It should be noted that the technical solution of the computing device and the technical solution of the text processing method belong to the same concept, and details that are not described in detail in the technical solution of the computing device can be referred to the description of the technical solution of the text processing method.
An embodiment of the present application further provides a computer-readable storage medium storing computer instructions that, when executed by a processor, are configured to:
obtaining a question text and a target text containing a candidate answer corresponding to the question text;
extracting candidate sentences containing the candidate answers from the target text;
and constructing candidate answer characteristics according to the target text, the candidate sentences and the question text, and determining the target answer text corresponding to the question text based on the candidate answer characteristics.
The above is an illustrative scheme of a computer-readable storage medium of the present embodiment. It should be noted that the technical solution of the storage medium belongs to the same concept as the technical solution of the text processing method, and details that are not described in detail in the technical solution of the storage medium can be referred to the description of the technical solution of the text processing method.
The foregoing description of specific embodiments of the present application has been presented. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The computer instructions comprise computer program code which may be in the form of source code, object code, an executable file or some intermediate form, or the like. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, etc. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
It should be noted that, for the sake of simplicity, the above-mentioned method embodiments are described as a series of acts or combinations, but those skilled in the art should understand that the present application is not limited by the described order of acts, as some steps may be performed in other orders or simultaneously according to the present application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
The preferred embodiments of the present application disclosed above are intended only to aid in the explanation of the application. Alternative embodiments are not exhaustive and do not limit the invention to the precise embodiments described. Obviously, many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles of the application and its practical applications, to thereby enable others skilled in the art to best understand and utilize the application. The application is limited only by the claims and their full scope and equivalents.

Claims (30)

1. A method of text processing, comprising:
acquiring a question text;
inputting the question text into a question-answering module for processing to obtain candidate answers output by the question-answering module, wherein the question-answering module is a question-answering system for carrying out preliminary answer on the question text, and the question-answering system is selected according to an actual application scene;
and extracting a target text containing the candidate answer from a text library corresponding to the question-answering module according to the candidate answer.
2. The method according to claim 1, further comprising, after extracting a target text containing the candidate answer from a text library corresponding to the question-answering module according to the candidate answer, the steps of:
extracting candidate sentences containing the candidate answers from the target text;
and constructing candidate answer characteristics according to the target text, the candidate sentences and the question text, and determining the target answer text corresponding to the question text based on the candidate answer characteristics.
3. The method of claim 2, wherein constructing candidate answer features from the target text, the candidate sentences and the question text comprises:
extracting text features of a target text;
and splicing the text features, the candidate sentences and the question text to obtain candidate answer features corresponding to the candidate answers.
4. The method according to claim 2 or 3, wherein the determining the target answer text corresponding to the question text based on the candidate answer features comprises:
and inputting the candidate answer characteristics into a text processing module for processing, screening candidate answers with higher correlation degree with the question text from the candidate answers through the text processing module based on the candidate answer characteristics, and determining the candidate answers as target answer texts corresponding to the question text.
5. The method of claim 2 or 3, wherein the extracting candidate sentences containing the candidate answers in the target text comprises:
determining answer positions of the candidate answers in the target text;
extracting the candidate sentence including the candidate answer in the target text based on the answer position.
6. The method of claim 5, wherein the determining the answer position of the candidate answer in the target text comprises:
analyzing the candidate answer to obtain attribute information corresponding to the candidate answer;
and carrying out position location in the target text according to the attribute information, and determining the answer position of the candidate answer in the target text according to a location result.
7. The method according to claim 6, wherein the attribute information is basic information of the candidate answer, and includes at least word number, word unit, and arrangement order of word units of the candidate answer.
8. The method of claim 5, wherein if the candidate answer appears in the target text multiple times, the determining the answer position of the candidate answer in the target text comprises:
determining a plurality of initial answer positions of the candidate answer in the target text;
and calculating the matching degree between the sentence to which each initial answer position belongs and the question text, and determining the initial answer position with the highest matching degree as the answer position of the candidate answer.
9. The method of claim 5, wherein extracting the candidate sentence containing the candidate answer in the target text based on the answer position comprises:
identifying a first paragraph identifier and a second paragraph identifier in the target text based on the answer position, and extracting the candidate sentence containing the candidate answer according to the first paragraph identifier and the second paragraph identifier;
alternatively, the first and second electrodes may be,
and extracting a first paragraph text and a second paragraph text with the number of words set before and after the candidate answer from the target text, and generating the candidate sentence according to the first paragraph text, the candidate answer and the second paragraph text.
10. The method according to claim 9, wherein the first paragraph symbol is a paragraph symbol closest to the answer position forward in the target text, and the second paragraph symbol is a paragraph symbol closest to the answer position backward in the target text, wherein the paragraph symbol is a symbol for a sentence break in any one of commas, periods, exclamations or question marks.
11. The method of claim 9 or 10, wherein said extracting the candidate sentence containing the candidate answer from the first paragraph delimiter and the second paragraph delimiter comprises:
determining the content between the first paragraph identifier and the second paragraph identifier in the target text as the candidate sentence.
12. The method of claim 9, wherein generating the candidate sentence from the first paragraph text, the candidate answer, and the second paragraph text comprises:
and under the condition that the target text is determined to contain a preset number of long sentences, forming the candidate sentence by combining a first paragraph text with a set word number before an answer position and a second paragraph text with a set word number after the answer position in the target text.
13. The method of claim 3, wherein the textual features include at least one of: text title, text keyword, text semantic information.
14. The method of claim 13, further comprising:
determining the text keyword and the text semantic information through latent Dirichlet distribution (LDA);
alternatively, the first and second electrodes may be,
determining the text keywords and the text semantic information according to the description information of the target text;
alternatively, the first and second electrodes may be,
determining the text keywords by calculating the probability of word units and determining the text semantic information by a syntax analyzer.
15. The method of claim 14, wherein the determining the text keyword and the text semantic information according to the description information of the target text comprises:
determining keywords corresponding to the abstract of the target text as the text keywords, and determining the text semantic information according to the abstract of the target text.
16. The method according to any one of claims 3, 13, 14 or 15, wherein the splicing the text features, the candidate sentences and the question text to obtain candidate answer features corresponding to candidate answers comprises:
and splicing the text features, the candidate sentences and the question text according to the input strategy of the text processing module, and obtaining the candidate answer features according to the splicing processing result.
17. The method of claim 16, wherein the splicing the text feature, the candidate sentence, and the question text according to the input policy of the text processing module, and obtaining the candidate answer feature according to the splicing result comprises:
respectively converting the text features, the candidate sentences and the question text into respective corresponding matrix expressions, and splicing the respective corresponding matrix expressions to obtain the candidate answer features in a matrix form;
alternatively, the first and second electrodes may be,
and splicing the text features, the candidate sentences and the question text to obtain a spliced expression, converting the spliced expression into a matrix, and determining the matrix as the candidate answer features.
18. The method according to claim 4, wherein the inputting the candidate answer features into a text processing module for processing, and the selecting, by the text processing module, a candidate answer with a higher degree of relevance to the question text from the candidate answers based on the candidate answer features, and determining the candidate answer as the target answer text corresponding to the question text comprises:
inputting the candidate answer features into a text processing module, and performing coding processing through a depth language model in the text processing module to obtain coding features;
inputting the coding features into a classification network in the text processing module for grading processing to obtain feature scores corresponding to the coding features;
determining answer scores corresponding to the candidate answers according to the feature scores, and screening the target answer texts from the candidate answers based on the answer scores;
and outputting the target answer text through the text processing module.
19. The method of claim 18, wherein determining answer scores corresponding to the candidate answers based on the feature scores comprises:
determining the feature score as an answer score for the candidate answer.
20. The method of claim 18, wherein said screening out said target answer text from said candidate answers based on said answer scores comprises:
sorting each sub-candidate answer in the candidate answers according to the answer scores to obtain a candidate answer sequence;
and screening the target answer text in the candidate answer sequence according to a preset screening rule.
21. The method of claim 18, wherein the deep language model is a fine-tuned model of an existing initial language model by a question-and-answer task.
22. The method of claim 18 or 21, further comprising:
acquiring an initial language model and a sample question text;
determining a sample answer text corresponding to the sample question text, and constructing a sample pair based on the sample question text and the sample answer text;
and training the initial language model based on the sample pair until the initial language model meets a training stop condition, and obtaining the depth language model.
23. The method of claim 22, wherein the determining of the sample answer text corresponding to the sample question text and the constructing of the sample pair based on the sample question text and the sample answer text; training the initial language model based on the sample pair until the initial language model meets a training stop condition, and obtaining the deep language model, wherein the training stop condition comprises the following steps:
determining a plurality of sample candidate answers corresponding to the sample question text, and extracting a sample target text containing each sample candidate answer;
extracting sample candidate sentences containing sample candidate answers from each sample target text;
splicing the sample text features of the sample target text, the sample candidate sentences and the sample question text to obtain sample candidate answer features;
inputting the sample candidate answer features into an initial language model for training, and obtaining a predicted answer text output by the initial language model according to a training result;
calculating a loss value based on the predicted answer text and the sample answer text;
judging whether the initial language model at the current stage meets the training stopping condition or not according to the loss value;
if yes, determining the initial language model of the current stage as the depth language model;
and if not, selecting a new sample to continue training the initial language model until the initial language model meets the training stopping condition, and obtaining the deep language model.
24. The method of claim 22, wherein the initial language model is a BERT model.
25. The method according to claim 4, wherein the step of determining, by the text processing module, a target answer text corresponding to the question text by screening candidate answers with a higher degree of correlation with the question text from the candidate answers based on the candidate answer features comprises:
and screening out the candidate answer with the highest degree of correlation with the question text from the candidate answers as the target answer text by the text processing module based on the candidate answer characteristics.
26. The method of claim 18, wherein the classification network is a network that scores coding features.
27. The method of claim 18, the classification network constructed using an LGBM classifier.
28. A text processing apparatus, comprising:
a first obtaining module configured to obtain a question text;
the processing module is configured to input the question text into a question-answering module for processing, and obtain candidate answers output by the question-answering module, the question-answering module is a question-answering system for carrying out preliminary answers on the question text, and the question-answering system is selected according to an actual application scene;
and the first extraction module is configured to extract a target text containing the candidate answer from a text library corresponding to the question-answering module according to the candidate answer.
29. A computing device, comprising:
a memory and a processor;
the memory is configured to store computer-executable instructions, and the processor is configured to execute the computer-executable instructions to implement the steps of the text processing method of any one of claims 1 to 27.
30. A computer-readable storage medium storing computer instructions, which when executed by a processor, implement the steps of the text processing method of any one of claims 1 to 27.
CN202111294843.3A 2021-05-21 2021-05-21 Text processing method and device Pending CN113887244A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111294843.3A CN113887244A (en) 2021-05-21 2021-05-21 Text processing method and device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111294843.3A CN113887244A (en) 2021-05-21 2021-05-21 Text processing method and device
CN202110556481.4A CN113032531B (en) 2021-05-21 2021-05-21 Text processing method and device

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN202110556481.4A Division CN113032531B (en) 2021-05-21 2021-05-21 Text processing method and device

Publications (1)

Publication Number Publication Date
CN113887244A true CN113887244A (en) 2022-01-04

Family

ID=76455794

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202111294843.3A Pending CN113887244A (en) 2021-05-21 2021-05-21 Text processing method and device
CN202110556481.4A Active CN113032531B (en) 2021-05-21 2021-05-21 Text processing method and device

Family Applications After (1)

Application Number Title Priority Date Filing Date
CN202110556481.4A Active CN113032531B (en) 2021-05-21 2021-05-21 Text processing method and device

Country Status (1)

Country Link
CN (2) CN113887244A (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117371404B (en) * 2023-12-08 2024-02-27 城云科技(中国)有限公司 Text question-answer data pair generation method and device

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8275803B2 (en) * 2008-05-14 2012-09-25 International Business Machines Corporation System and method for providing answers to questions
CN106844741A (en) * 2017-02-13 2017-06-13 哈尔滨工业大学 A kind of answer method towards specific area
CN111125335B (en) * 2019-12-27 2021-04-06 北京百度网讯科技有限公司 Question and answer processing method and device, electronic equipment and storage medium
CN111460089B (en) * 2020-02-18 2023-08-25 北京邮电大学 Multi-segment reading understanding candidate answer sorting method and device
CN111524593B (en) * 2020-04-23 2022-08-16 厦门大学 Medical question-answering method and system based on context language model and knowledge embedding
CN112417105B (en) * 2020-10-16 2024-03-19 泰康保险集团股份有限公司 Question-answering processing method and device, storage medium and electronic equipment

Also Published As

Publication number Publication date
CN113032531B (en) 2021-11-30
CN113032531A (en) 2021-06-25

Similar Documents

Publication Publication Date Title
US20190243886A1 (en) Methods and systems for improving machine learning performance
CN111753060A (en) Information retrieval method, device, equipment and computer readable storage medium
CN108595708A (en) A kind of exception information file classification method of knowledge based collection of illustrative plates
CN112749326B (en) Information processing method, information processing device, computer equipment and storage medium
CN113177124A (en) Vertical domain knowledge graph construction method and system
CN113961685A (en) Information extraction method and device
CN110347790B (en) Text duplicate checking method, device and equipment based on attention mechanism and storage medium
CN113221545B (en) Text processing method, device, equipment, medium and program product
US20210056261A1 (en) Hybrid artificial intelligence system for semi-automatic patent pinfringement analysis
CN112860896A (en) Corpus generalization method and man-machine conversation emotion analysis method for industrial field
CN113392331A (en) Text processing method and equipment
CN114942994A (en) Text classification method, text classification device, electronic equipment and storage medium
CN111199151A (en) Data processing method and data processing device
CN110969005B (en) Method and device for determining similarity between entity corpora
CN113887244A (en) Text processing method and device
CN113486143A (en) User portrait generation method based on multi-level text representation and model fusion
CN113011126A (en) Text processing method and device, electronic equipment and computer readable storage medium
CN114528851B (en) Reply sentence determination method, reply sentence determination device, electronic equipment and storage medium
CN115718904A (en) Text processing method and device
CN116362331A (en) Knowledge point filling method based on man-machine cooperation construction knowledge graph
CN115329850A (en) Information comparison method and device, electronic equipment and storage medium
CN114818727A (en) Key sentence extraction method and device
CN114118087A (en) Entity determination method, entity determination device, electronic equipment and storage medium
CN113961686A (en) Question-answer model training method and device, question-answer method and device
CN113408287A (en) Entity identification method and device, electronic equipment and storage medium

Legal Events

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