CN114138947A - Text processing method and device - Google Patents

Text processing method and device Download PDF

Info

Publication number
CN114138947A
CN114138947A CN202010916581.9A CN202010916581A CN114138947A CN 114138947 A CN114138947 A CN 114138947A CN 202010916581 A CN202010916581 A CN 202010916581A CN 114138947 A CN114138947 A CN 114138947A
Authority
CN
China
Prior art keywords
text
answer
question
question text
processed
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
CN202010916581.9A
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 CN202010916581.9A priority Critical patent/CN114138947A/en
Publication of CN114138947A publication Critical patent/CN114138947A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3346Query execution using probabilistic model
    • 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/3347Query execution using vector based model

Abstract

The application provides a text processing method and a text processing device, wherein the text processing method comprises the following steps: acquiring a text to be processed and a question text, wherein the question text is related to the text to be processed; extracting a plurality of candidate answers corresponding to the question text from the text to be processed; inputting the candidate answers and the question text into a semantic matching model for processing to obtain a predicted answer matched with the question text; and determining a reply result of the question text according to the predicted answer, the sentence of the predicted answer in the text to be processed and the question text.

Description

Text processing method and device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a text processing method and apparatus.
Background
Natural Language Processing (NLP) is an important direction in the fields of computer science and artificial intelligence, and it is studying various theories and methods that enable efficient communication between humans and computers using Natural Language. The application of natural language processing in the field of machine reading understanding is the most extensive, when answering a question according to chapters through machine reading understanding, a candidate answer is usually generated through a reader, and whether to answer the question is determined according to the output of the reader, but only one candidate answer is generated, so that the improvement of model performance is not limited, and correct judgment on the candidate answer cannot be effectively carried out, and an effective scheme is urgently needed to solve the problem.
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 text to be processed and a question text, wherein the question text is related to the text to be processed;
extracting a plurality of candidate answers corresponding to the question text from the text to be processed;
inputting the candidate answers and the question text into a semantic matching model for processing to obtain a predicted answer matched with the question text;
and determining a reply result of the question text according to the predicted answer, the sentence of the predicted answer in the text to be processed and the question text.
Optionally, the extracting multiple candidate answers corresponding to the question text from the text to be processed includes:
performing word segmentation on the text to be processed and the problem text, and forming a word unit set according to word segmentation processing results;
and inputting each word unit contained in the word unit set into a text processing model for processing to obtain a plurality of candidate answers corresponding to the question text.
Optionally, the inputting each word unit included in the word unit set to a text processing model for processing to obtain a plurality of candidate answers corresponding to the question text includes:
inputting each word unit contained in the word unit set into the text processing model, and calculating a first probability of each word unit as an initial character of an answer and a second probability of each word unit as an end character of the answer through a prediction module in the text processing model;
generating a starting probability distribution according to the first probability and generating an end probability distribution according to the second probability;
and inputting the initial probability distribution and the terminal probability distribution to a screening module in the text processing model for answer screening processing to obtain a plurality of candidate answers corresponding to the question text.
Optionally, the inputting the multiple candidate answers and the question text into a semantic matching model for processing to obtain a predicted answer matched with the question text includes:
inputting the plurality of candidate answers and the question text to the semantic matching model;
extracting features of the candidate answers and the question text through a feature extraction module in the semantic matching model to obtain a first feature vector corresponding to each candidate answer and a second feature vector corresponding to the question text;
respectively calculating the matching degree of the first feature vector and the second feature vector through a semantic matching module in the semantic matching model to obtain the matching degree of each candidate answer and the question text;
and selecting the candidate answer with the highest matching degree as the predicted answer, and outputting the predicted answer matched with the question text through an output module of the semantic matching model.
Optionally, the determining a response result of the question text according to the predicted answer, the sentence to which the predicted answer belongs in the text to be processed, and the question text includes:
determining the sentence to which the predicted answer belongs in the text to be processed;
generating a text group to be verified according to the statement, the question text and the predicted answer, inputting the text group to be verified into a verification model for predicted answer verification, and obtaining the correct rate of the predicted answer, wherein the correct rate represents the probability that the predicted answer is used as an answer matched with the question text;
and determining the answer result of the question text according to the accuracy.
Optionally, the determining the answer result of the question text according to the accuracy includes:
judging whether the accuracy is greater than a preset accuracy threshold value or not;
if yes, determining the predicted answer as a target answer of the question text, and generating a reply result of the question text according to the target answer;
if not, generating reminding information according to the predicted answer, and generating a reply result of the question text based on the reminding information.
Optionally, after the step of obtaining the text to be processed and the question text is executed, the method further includes:
performing word segmentation on the text to be processed to obtain a first word unit set, and performing word segmentation on the problem text to obtain a second word unit set;
respectively adding sentence beginning mark symbols and sentence division mark symbols aiming at the first word unit set and the second word unit set to obtain a third word unit set and a fourth word unit set;
and inputting the third word unit set and the fourth word unit set into a text processing model for feature extraction to obtain a text feature vector and a problem feature vector.
Optionally, the method further includes:
calculating the similarity of the problem feature vector and the feature vector of the text feature vector;
and under the condition that the similarity of the feature vectors is greater than a similarity threshold, determining the matching rate of the question text and the text to be processed according to the similarity of the feature vectors.
Optionally, after the step of inputting the multiple candidate answers and the question text into a semantic matching model for processing to obtain the predicted answer matched with the question text is executed, the method further includes:
determining the correct rate of the predicted answer according to the predicted answer, the sentence of the predicted answer in the text to be processed and the question text;
weighting and calculating based on the correct rate and the weight corresponding to the matching rate and the matching rate to obtain a response rate for responding to the question text;
and in the case that the answer rate is greater than a preset answer rate threshold value, taking the predicted answer as an answer result of the question text.
Optionally, the semantic matching model is trained in the following manner:
acquiring a training text and a training problem text corresponding to the training text;
extracting a plurality of training candidate answers from the training text, and performing score labeling on the plurality of training candidate answers;
and forming a sample set based on the training candidate answers after the score labeling and the training text, and inputting the sample set to an initial semantic matching model for training to obtain the semantic matching model.
Optionally, the score labeling the multiple training candidate answers includes:
and performing score labeling on the multiple candidate answers according to the evaluation indexes, or performing score labeling on the multiple candidate answers according to the evaluation indexes.
Optionally, the text processing model and the pre-training model of the semantic matching model have the same model type.
According to a second aspect of embodiments of the present application, there is provided a text processing apparatus including:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is configured to acquire a text to be processed and a question text, and the question text is related to the text to be processed;
the extraction module is configured to extract a plurality of candidate answers corresponding to the question text from the text to be processed;
the prediction module is configured to input the candidate answers and the question text into a semantic matching model for processing to obtain a predicted answer matched with the question text;
a determination module configured to determine a reply result of the question text according to the predicted answer, the sentence to which the predicted answer belongs in the text to be processed, and the question text.
According to a third 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 fourth 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 problem text and the question text to be processed are obtained, the candidate answers corresponding to the question text are extracted from the problem text to be processed, the candidate answers and the question text are simultaneously input into the semantic matching model, the predicted answer matched with the question text is obtained, and finally the answer result of the question text is determined according to the predicted answer, the sentence to which the predicted answer belongs and the question text.
Drawings
Fig. 1 is a flowchart of a text processing method according to an embodiment of the present application;
fig. 2 is a schematic diagram of a text processing method according to an embodiment of the present application;
FIG. 3 is a processing flow diagram of a text processing method applied in a reading understanding scenario according to an embodiment of the present application;
FIG. 4 is a schematic structural diagram of a text processing apparatus according to an embodiment of the present application;
fig. 5 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.
A semantic matching model: matching the similarity, correlation model of the two sentences.
Answer span: the reading comprehension model generally takes the head and tail positions of the answers as labels, and the span represents the whole answer.
Pre-training the model: the model pre-trained on the public corpus has strong generalization capability and can be used for various NLP tasks.
NLP: natural Language Processing (Natural Language Processing) is an important direction in the fields of computer science and artificial intelligence, and studies various theories and methods that enable efficient communication between a person and a computer using Natural Language.
Word segmentation: the process of recombining continuous word sequences into word sequences according to a certain specification.
Loss function: the (loss function) is a function that maps the value of a random event or its associated random variable to a non-negative real number to represent the loss of the random event. In application, the loss function is usually associated with the optimization problem as a learning criterion, i.e. the model is solved and evaluated by minimizing the loss function; for example, in statistics and machine learning, are used for parameter estimation (parametric estimation) of models.
Iteration: (iteration) is the activity of a repetitive feedback process, usually with the aim of approximating a desired goal or result. Each iteration of the process is referred to as an iteration, and the result of each iteration is used as the initial value for the next iteration.
And (3) encoding: is the process by which information is converted from one form or format to another.
And (3) weighting: (weight) means the importance of a certain factor or index relative to a certain event, which is different from the general specific gravity, and is represented by the percentage of the certain factor or index, and the relative importance of the factor or index is emphasized, and the contribution or importance is prone to be realized.
Attention: (attention), a means of dealing with overload information, in particular how to distinguish between different regions of an image or words in a sentence that are related to each other, often assigns a lot of attention to the part of interest.
And (3) text to be processed: the text to be analyzed may be an article, a text segment, a sentence, or the like.
Question text: the question is a question which is proposed according to the text to be processed and can be used for obtaining an answer through reading the text to be processed or analyzing the answer.
Candidate answers: refers to text that is screened out of the text to be processed that may be the target answer to the question text.
And (3) predicting an answer: the answer selected from the multiple candidate answers for the question text is the answer which is required to be explained, wherein the answer may be the final correct answer or the incorrect answer, and is the answer which is screened from the multiple candidate answers and has higher possibility.
Correct rate of predicted answer: refers to the probability of the predicted answer being the rationality of the target answer to the question text.
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 text to be processed and a question text are obtained, wherein the question text is related to the text to be processed.
In practical application, with the continuous development of the field of machine learning, the prediction of answers in the reading and understanding problem through a model becomes a trend, and the reading and understanding problem is solved through the model, so that not only can the answers of the reading and understanding problem be rapidly obtained, but also the correction of test questions can be realized, and the requirements of users can be better met; however, in the prior art, in the process of reading, understanding, solving and answering through the model, a candidate answer is generally generated through the reader, which causes the model to not fully function, greatly limits the capability of the model for extracting the answer, and causes the output answer to be too single, and the problem that the problem cannot be correctly solved may occur.
In the text processing method provided by the application, in order to improve the accuracy of answer extraction and improve the answer extraction capability of a model, as shown in fig. 2, after a question and a document (text to be processed) are obtained, the candidate answers are input to a reader to be determined, after a plurality of candidate answers are obtained, a predicted answer is obtained through semantic matching (a semantic matching model), and finally, the predicted answer is determined reasonably through a verifier, so that the answer result of the question text is determined; the method and the device have the advantages that the predicted answers are screened from the multiple candidate answers, and the correct rate of the predicted answers is determined, so that a more accurate answer result can be generated aiming at the question text, the problem that the answer of the question text is inaccurate due to a single answer is solved, the performance of a model can be fully utilized, and the accuracy of predicting the correct answers aiming at the question text is improved.
In a specific implementation, the text to be processed may be an article, a piece of text, a sentence, and the like, where the question text specifically refers to a question raised based on the text to be processed, and it should be noted that the question text may obtain an answer by reading and analyzing the text to be processed, or directly find an answer from the text to be processed, for example, the text to be processed is "a night mountain temple" with white li, a critical building with a hundred feet, a hand with a star, a dare with a high voice, and a surprise in the sky ", that is, the question text may be" who is an author of a night mountain temple? "or" what is the next sentence of a hundred feet high in a crisis building? "and the like.
Based on this, as the requirement of the user increases, many times, the user cannot analyze the text to be processed by himself to answer the question text, and the user usually selects the "problem solving software" to answer the question, however, the "problem solving software" in the prior art is usually implemented by using a model, only a single answer can be generated, and the interpretability of the answer is not strong, so that in order to avoid the question, the text processing method provided by the embodiment can be used to accurately answer the question text, and the interpretability of the answer is improved.
In this embodiment, the text processing method will be described by taking the text to be processed as a chinese reading comprehension question as an example, where the problem text is also provided based on the chinese reading comprehension question, and the text processing method provided in this embodiment may also be applied to english reading comprehension questions or reading comprehension questions of other languages.
Step S104, extracting a plurality of candidate answers corresponding to the question text from the text to be processed.
Specifically, on the basis of obtaining the text to be processed and the question text, it is further determined that the question text needs to be answered, and since the text to be processed is a reading and understanding question, an answer to the question text may be found in the text to be processed, and in order to improve the accuracy of answering the question text and select an answer that meets the question text in the text to be processed, a plurality of candidate answers may be preferentially screened from the text to be processed, so as to determine whether a correct answer that meets the question text can be separated from the plurality of candidate answers subsequently; the candidate answer is particularly an answer which can be used as a correct answer of the question text; it should be noted that, in order to be able to screen out answers with higher interpretability, in this embodiment, after a plurality of candidate answers are screened out, correct answers can be screened out from the plurality of candidate answers, so as to improve the accuracy of answering a question text.
In addition, in the case that the number of the candidate answers is large, a candidate answer set may be formed based on the candidate answers, so as to facilitate processing, and it may be determined whether the candidate answers need to form the candidate set, and the determination may be performed according to the number of the candidate answers or according to the total word number of the candidate answers, and when the number of the candidate answers is greater than a preset number threshold or the total word number of the candidate answers is greater than a preset word number threshold, the candidate answer set may be formed based on the candidate answers, so as to perform determination of a subsequent answer result.
Further, in the process of screening the multiple candidate answers, in order to meet the requirement of obtaining answers with higher rationality subsequently and improve the performance utilization rate of the model, the answer of the question text can be extracted from the text to be processed through the text processing model, in this embodiment, the specific implementation manner is as follows:
performing word segmentation on the text to be processed and the problem text, and forming a word unit set according to word segmentation processing results;
and inputting each word unit contained in the word unit set into a text processing model for processing to obtain a plurality of candidate answers corresponding to the question text.
Specifically, the word unit set specifically refers to a set composed of word units in the text to be processed, and the word unit specifically refers to a minimum unit composing the text to be processed; based on this, in the process of generating the multiple candidate answers, in order to improve the rationality and accuracy of candidate answer screening, word segmentation processing is performed on the text to be processed, then the word units are determined according to the word segmentation processing results (in specific implementation, the word segmentation processing results can be split so as to obtain a word unit set formed by multiple word units), and finally, each word unit included in the word unit set is input to the text processing model for processing, so that multiple candidate answers corresponding to the question text output by the text processing model can be obtained.
The model to be processed can select a pre-training model, such as a BERT model, an ELECTRA model or an ALBERT model, and the model has strong feature extraction capability, so that semantic information of a question and a text can be well extracted, and an answer close to the question text is analyzed to be used as a candidate answer for selecting a correct answer for the question text subsequently.
Furthermore, in the process of predicting candidate answers through the text processing model, the content of the text processing model is actually obtained by calculating the probability that each word is used as an initial word and a terminal word of an answer, so as to analyze the length of the word that can be used as the answer, and the word between the lengths of the text can be used as a candidate answer of the question text, in this embodiment, the specific implementation manner is as follows:
inputting each word unit contained in the word unit set into the text processing model, and calculating a first probability of each word unit as an initial character of an answer and a second probability of each word unit as an end character of the answer through a prediction module in the text processing model;
generating a starting probability distribution according to the first probability and generating an end probability distribution according to the second probability;
and inputting the initial probability distribution and the terminal probability distribution to a screening module in the text processing model for answer screening processing to obtain a plurality of candidate answers corresponding to the question text.
Specifically, in the process of predicting multiple candidate answers through a text processing model, each word unit included in the word unit set is firstly input into the text processing model, and a first probability that each word unit is used as a starting word of the question text candidate answer and a second probability that each word unit is used as an end word of the question text candidate answer are calculated through a prediction module in the text processing model.
Secondly, determining the initial probability distribution of the candidate answer according to the first probability corresponding to each word unit, and determining the terminal probability distribution of the candidate answer according to the second probability corresponding to each word unit; the initial probability distribution specifically refers to a distribution result generated according to the probability that each word unit serves as an initial word, and the terminal probability distribution specifically refers to a distribution result generated according to the probability that each subunit serves as a terminal word.
And finally, inputting the initial probability distribution and the terminal probability distribution into a screening module in the text processing model for answer screening processing, so that a plurality of candidate answers which accord with the question text are screened from the text to be processed through the screening module and are output for subsequently judging the rationality and correctness of each candidate answer.
The prediction module is used for calculating the probability of each word unit, the screening module is used for determining candidate answers according to the probability distribution of each word unit, the text processing model is used for analyzing whether the answer of the question text exists in the text to be processed according to the question text and the semantic information of the text to be processed, if yes, subsequent processing is carried out, if not, the subsequent processing process can be directly stopped, and reminding information that the correct answer cannot be obtained is fed back.
In the process of predicting whether the candidate answer of the question text exists in the text to be processed or not, the candidate answer is predicted by means of a mark of a 'CLS' of a text processing model, and the prediction of answer existence probability is realized by means of a vector corresponding to the mark; it should be noted that, in the process of determining a plurality of candidate answers corresponding to the question text by the prediction module and the screening module in cooperation, although the prediction module implements the probability of the predicted word, and the screening module implements the screening answer, the prediction module and the screening module are not necessarily in a completely separated state, that is, the prediction module and the screening module may implement a processing procedure alone or in cooperation, and may be set according to an actual application scenario in an actual application, which is not limited herein.
Following the above example, the text to be processed, namely Lebai in the night sky temple, hundred feet in the crisis, star in the hand, dare not for loud words, and the surprise-time shang, and the question text, which is the next sentence in hundred feet in the crisis, are obtained? After that, the text to be processed and the question text are simultaneously participled and participled, and the obtained first character unit set is { night, mountain, temple, plum, white, dangerous, building, high, hundred, ruler, hand, college, star, day, don, dare, high, sound, speech, terrorism, fright, day, up and person }, and the second character unit set is { danger, building, high, hundred, ruler, down, one, sentence, yes, assorted and how } ";
further, the first word unit set and the second word unit set are input into a text processing model for candidate answer screening, firstly, a text to be processed is processed through [ CLS ] sentence head mark symbols and [ SEP ] sentence division mark symbols, so that { CLS, night, mountain, temple SEP plum, white SEP … … terrorism, surprise, day, top and person SEP } is obtained, then, the probability prediction of answers existing in reading understanding is carried out on vector representations corresponding to [ CLS ] sentence head mark symbols through the text processing model, and the answers of the text to be processed with problems are determined.
Furthermore, candidate answer prediction is carried out on a text to be processed through a prediction model in a text processing model, the probability that each character is used as a candidate answer initial character and the probability that each character is used as a candidate answer terminal character are calculated, the probability that night is used as the answer initial character is 1%, the probability that a character is used as the answer terminal character is 2%, the probability that host is used as the answer initial character is 0.1%, the probability that a character is used as the answer terminal character is 0.2% … …%, the probability that human is used as the answer initial character is 0.5%, and the probability that a character is used as the answer terminal character is 5%; then generating initial probability distribution P according to probability of each character as initial character of answerstart∈RnAnd generating an end probability distribution P based on the probability of each word as an end word of the answerend∈RnWhere n represents the document length.
Finally according to the initial probability distribution Pstart∈RnAnd end probability distribution Pend∈RnScreening answers by determining the probability of each character as the initial character and the terminal character of the answer, and obtaining the probability P of all initial characters of the answerstartI and probability of all answer end words PendJ are respectively multiplied (i, j all represent the characters in the document), and a plurality of answers in a plurality of intervals [ i, j ] are determined according to the calculation result]Then through the initial probability distribution Pstart∈RnAnd end probability distribution Pend∈RnA matrix of n x n can be determined, where each element in the matrix of n x n represents an answer in the interval i, j]The probability of (d);
in addition, in order to meet the rationality of the selected answers, it is necessary to consider that the probability of the initial word in the answer is less than or equal to the probability of the final word, that is, the initial word of the answer is before the final word, that is, i is equal to or less than j, at this time, each element in the n × n matrix is selected according to the condition that i is equal to or less than j, so that a plurality of answers to be selected can be mapped, in order to accelerate the subsequent processing process, the largest first k answers to be selected can be selected according to a preset rule as candidate answers, the value of k can be set according to actual requirements, the k in this embodiment is 3, and the obtained plurality of candidate answers are "hand-extractable stars", "dare-high words", "startle-terrorist people", so as to perform the prediction and correctness judgment of the answer rationality subsequently.
In summary, in the process of determining the candidate answers, in order to fully utilize the model performance of the text processing model, a plurality of candidate answers are determined, and a problem that a correct answer cannot be accurately extracted due to outputting of one candidate answer can be avoided, thereby further improving the interpretability of subsequently screened correct answers.
And step S106, inputting the candidate answers and the question text into a semantic matching model for processing to obtain a predicted answer matched with the question text.
Specifically, on the basis of the determination of the multiple candidate answers, in order to accurately screen answers meeting the question text from the candidate answers, secondary answer screening is performed through a semantic matching model again, answer prediction is performed by inputting the multiple candidate answers and the question text into the semantic matching model, so that matching between the semantics of each candidate answer and the semantics of the question text is calculated, and therefore a predicted answer matched with the question text is screened, the predicted answer is the answer screened from the multiple candidate answers, and the predicted answer is specifically the answer screened from the text to be processed, which has the highest semantic matching degree with the question text.
It should be noted that, at this time, the predicted answer cannot be used as correct answer data, and subsequently, the rationality and correctness of the predicted answer need to be determined; in addition, in order to improve the fitting degree between the models, the text processing model and the semantic matching model in the embodiment may be selected from pre-training models of the same type, the models have the same bottom layer architecture, share a set of parameters, and only need to train separately and adjust corresponding parameters as required, so that time consumed by model preparation in the early stage is avoided being wasted by constructing a plurality of models of different types, and the fitting degree between the models is also improved.
Further, in the process of screening the predicted answer from the multiple candidate answers, the semantic matching degree between the semantics of each candidate answer and the question text is calculated through a semantic matching model, so that the candidate answer with the highest semantic matching degree with the question text is screened out as the predicted answer, and in this embodiment, the specific implementation manner is as follows:
inputting the plurality of candidate answers and the question text to the semantic matching model;
extracting features of the candidate answers and the question text through a feature extraction module in the semantic matching model to obtain a first feature vector corresponding to each candidate answer and a second feature vector corresponding to the question text;
respectively calculating the matching degree of the first feature vector and the second feature vector through a semantic matching module in the semantic matching model to obtain the matching degree of each candidate answer and the question text;
and selecting the candidate answer with the highest matching degree as the predicted answer, and outputting the predicted answer matched with the question text through an output module of the semantic matching model.
Specifically, the first feature vector specifically represents a semantic expression form of each candidate answer, and the second feature vector specifically represents a semantic expression form of the question text; based on this, after the candidate answers and the question text are input into the semantic matching model, feature extraction is performed on the candidate answers and the question text through a feature extraction module in the semantic matching model, so that a first feature vector corresponding to the candidate answers and a second feature vector corresponding to the question text are obtained.
And then respectively calculating the matching degrees of the first feature vector and the second feature vector through a semantic matching module in the semantic matching model so as to obtain the matching degrees with the same number as the plurality of candidate answers, selecting the candidate answer with the highest matching degree as the predicted answer of the question text in order to accurately determine the predicted answer of the question text, and outputting the predicted answer matched with the question text through an output module of the semantic matching model so as to be used for analyzing the rationality and the correctness of the predicted answer subsequently.
It should be noted that, in the process of cooperatively determining the predicted answer of the question text matching, although the feature extraction module implements feature extraction, and the semantic matching module implements calculating the matching degree of the feature vector, the feature extraction module and the semantic matching module are not necessarily in a completely separated state, that is, the feature extraction module and the semantic matching module may implement a processing process independently or cooperatively, and may be set according to an actual application scenario in an actual application, which is not limited herein.
According to the above example, after obtaining the candidate answers "stars are abstractable by hands", "desperate words", "people on startle day" of the question text, the multiple candidate answers and the question text are simultaneously input into the semantic matching model to determine the predicted answer, firstly, the feature extraction module in the semantic matching model is used to extract the features of the multiple candidate answers and the question text to obtain the feature vector S1 of the candidate answer "stars are abstractable by hands", the feature vector S2 of the candidate answer "desperate words", the feature vector S3 of the candidate answer "people on startle day", and the feature vector P of the question text "what the next sentence is in hundred feet in the crisis", then the semantic matching module in the semantic matching model is used to calculate the matching degree of the feature vector of each candidate answer and the feature vector of the question text respectively, and the matching degree of S1 and P is 85%, the matching degree of S2 and P is 75%, and the matching degree of S3 and P is 25%, so that the highest matching degree of S1 and P is determined, then the candidate answer 'hand can pick stars' is used as a prediction answer for matching the question text and is output, and then the subsequent analysis 'hand can pick stars' is performed to be used as the answer rationality of the question text 'what the next sentence of the high hundred feet of the crisis is' is.
In conclusion, the candidate answer with the highest matching degree with the question text is screened from the multiple candidate answers through the semantic matching model to serve as the predicted answer, so that the interpretability of the predicted answer is further improved, the semantic matching degree of the predicted answer is high, and the probability that the predicted answer can serve as the correct answer can be fully reflected.
Further, in order to improve the prediction accuracy of the semantic matching model, before performing answer prediction, the semantic matching model needs to be trained sufficiently, and in this embodiment, the specific implementation manner is as follows:
acquiring a training text and a training problem text corresponding to the training text;
extracting a plurality of training candidate answers from the training text, and performing score labeling on the plurality of training candidate answers;
and forming a sample set based on the training candidate answers after the score labeling and the training text, and inputting the sample set to an initial semantic matching model for training to obtain the semantic matching model.
Specifically, the training text and the training question text refer to texts for which correct answers are known, after the training text and the training question text corresponding to the training text are obtained, a plurality of training candidate answers are extracted from the training text, score labeling is performed on the plurality of training candidate answers, finally, a sample set is formed based on the plurality of training candidate answers after the score labeling and the training text, and the sample set is input to an initial semantic matching model for training, so that the semantic matching model can be obtained.
In practical applications, in the process of performing score labeling on the multiple training candidate answers, the multiple candidate answers may be subjected to score labeling according to evaluation indexes, or the multiple candidate answers may be subjected to score labeling according to evaluation indexes.
For example, the training text is "news report, yesterday afternoon of a major traffic accident, causing 20 people to be injured and no one fortunate to die. "the given training question text is" what was the accident in yesterday afternoon? "at this time, it is determined that the candidate answers to the question are" traffic "," major traffic accident "," 20 persons are injured "," major traffic "," major occurrence ", and the respective answers are scored, and the scoring result is" major traffic accident "1 score," traffic "0.9 score," 20 persons are injured "0 score; and finally, performing model training based on the scored candidate answers and the question texts to obtain a usable semantic matching model.
The training of the semantic matching model is realized in a scoring mode, so that the accuracy of the semantic matching model can be improved, the accuracy of the predicted answer is further improved, and the correct answer of the question text can be analyzed and output subsequently.
Step S108, determining the answer result of the question text according to the predicted answer, the sentence of the predicted answer in the text to be processed and the question text.
Specifically, after obtaining the predicted answer, in order to determine whether the predicted answer can be reasonably used as the answer to the question text, whether the predicted answer is feasible as the question text may be analyzed simultaneously according to the predicted answer, the sentence to which the predicted answer belongs in the text to be processed, and the question text, if so, it is determined that the predicted answer is reasonable as the answer to the question text, the predicted answer is used as the answer to the question text, and if not, it is determined that the predicted answer is unreasonable as the answer to the question text, and then the answer is determined as the information that a correct answer cannot be obtained for the question text.
Further, in order to improve the efficiency of predicting the rationality of the predicted answer, the rationality prediction process may be implemented by using a verification model, and in this embodiment, the specific implementation manner is as follows:
determining the sentence to which the predicted answer belongs in the text to be processed;
generating a text group to be verified according to the statement, the question text and the predicted answer, inputting the text group to be verified into a verification model for predicted answer verification, and obtaining the correct rate of the predicted answer, wherein the correct rate represents the probability that the predicted answer is used as an answer matched with the question text;
and determining the answer result of the question text according to the accuracy.
Specifically, in the process of determining the answer result, the correct rate of the predicted answer may be calculated according to the sentence to which the predicted answer belongs in the text to be processed, the question text and the predicted answer, and determining a reply result of the question text according to the accuracy, wherein the accuracy specifically refers to the probability of reflecting the reasonability of the predicted answer as the question text, the reply result is specifically a result of determining whether to output the predicted answer according to the correctness, and if the correctness is higher, the predicted answer is used as the answer of the question text to be reasonable, the predicted answer is used as the answer result of the question text, if the accuracy is low, it is determined that the answer is information that a correct answer cannot be obtained for the question text if the predicted answer is not reasonable as the answer to the question text.
Based on the above, firstly, the sentence to which the predicted answer belongs in the text to be processed is determined, secondly, the text group to be verified is generated according to the sentence, the question text and the predicted answer, secondly, the text group to be verified is input into a verification model for verification of the predicted answer, the correct rate of the predicted answer is obtained, and finally, whether the predicted answer can be output aiming at the question text or not is analyzed through the correct rate, so that the processing meeting the requirement of answering the question text is obtained. In practical application, the verification model can also be constructed by adopting a model with the same type as the semantic matching model, so as to improve the degree of fit between the models.
In addition, after the accuracy is obtained, an audit result of the question text may be determined in a judging manner, and in this embodiment, a specific implementation manner is as follows:
judging whether the accuracy is greater than a preset accuracy threshold value or not;
if yes, determining the predicted answer as a target answer of the question text, and generating a reply result of the question text according to the target answer;
if not, generating reminding information according to the predicted answer, and generating a reply result of the question text based on the reminding information.
According to the above example, after the prediction answer 'hand-extractable stars' is obtained, a text group to be verified is constructed according to the sentence to which the prediction answer belongs and what the next sentence of the question text 'the high hundred feet of the crisis' and is input into a verification model for verification of the answer, the degree of reasonability of 'hand-extractable stars' obtained as the correct answer is 95%, and at the moment, the degree of reasonability is compared with a preset threshold value to determine that the degree of reasonability of 'hand-extractable stars' is higher and the degree of reasonability of 'hand-extractable stars' can be output as the correct answer of the question text.
The text processing method provided by the application extracts a plurality of candidate answers corresponding to the question text from the to-be-processed text after the to-be-processed question text and the question text are obtained, and simultaneously inputting a plurality of candidate answers and the question text into the semantic matching model to obtain a predicted answer matched with the question text, and finally according to the predicted answer, and the sentence and the question text to which the predicted answer belongs determine the answer result of the question text, so that the predicted answer is screened from a plurality of candidate answers, the correct rate of the predicted answer is determined, thereby achieving the purposes of generating more accurate response results aiming at the question texts, solving the problem of inaccurate answer of the question texts caused by single answers, and the performance of the model can be fully utilized, and the accuracy of predicting correct answers aiming at the question text is improved.
The following description further explains the text processing method with reference to fig. 3 by taking an application of the text processing method provided in the present application in a reading and understanding scenario as an example. Fig. 3 shows a processing flow chart of a text processing method applied in a reading understanding scene according to an embodiment of the present application, which specifically includes the following steps:
step S302, reading comprehension documents and questions to be answered uploaded by the user through the client are obtained.
In practical application, in order to obtain correct answers of questions to be answered, a user takes pictures of reading understanding documents and the questions to be answered through a client, and uploads the pictures to a server for answering, at the moment, after the server receives the pictures, the reading understanding documents and the questions to be answered are obtained by extracting characters in the pictures, wherein the questions to be answered are provided based on the reading understanding questions, and the answers of the questions to be answered can be obtained through analyzing the reading understanding questions.
Reading understands the document as "according to news reports, major traffic accidents occurred in the afternoon of yesterday, causing 20 people to be injured and no one fortunately died", and the question to be answered is "what the accidents in the afternoon of yesterday? ", based on which the question to be answered is to be solved.
Step S304, inputting the reading comprehension document and the question to be answered into a reader for text processing, and obtaining the probability of answers existing in the reading comprehension document and a plurality of candidate answers screened aiming at the question to be answered.
Specifically, the reader understands that a document "reported according to news, a major traffic accident occurred yesterday afternoon, 20 people are injured and fortunate and nobody dies" through reading, and the obtained first word unit set comprises: { data, news, smell, newspaper … … no, people, death }, and performing word segmentation processing on the question to be answered to obtain a second word unit set { yesterday, day, next, noon, fact, yes, shit, how };
further, the word unit set is processed through [ CLS ] statement head mark symbols and [ SEP ] clause mark symbols to obtain { CLS, date, news, newspaper, no SEP … …, people, death and death SEP }, and { CLS yesterday, day, next, noon, accident, yes, sh and no SEP }, and then answers of the questions to be answered in the reading comprehension document are determined by predicting the probability of the answers existing in the reading comprehension document through vector representation corresponding to the [ CLS ] statement head mark symbols of the reader.
Furthermore, the reading comprehension document is subjected to candidate answer prediction processing through the reader, specifically: calculating, by a candidate answer generation module in a reader, a probability of reading and understanding each word in a document as an answer start word and a probability of each word as an answer end word, determining that wherein a probability of "data" as a start word of a start answer is 1%, a probability of "end word of an answer is 2%," new "as a start word of a start answer is 0.5%, a probability of" end word of an answer is 0.9% … … "heavy" as a start word of a start answer is 75%, a probability of "end word of an answer is 3%," large "as a start word of a start answer is 35%, a probability of" death "as a start word of a start answer is 0.1%, and a probability of" end word of an answer is 33%; then generating initial probability distribution P according to probability of each character as initial character of answerstart∈RnAnd generating an end probability distribution P based on the probability of each word as an end word of the answerend∈RnWhere n identifies the document length.
Then according to the starting probability distribution Pstart∈RnAnd end probability distribution Pend∈RnScreening answers by determining the probability of each character as the initial character and the terminal character of the answer, and obtaining the probability P of all initial characters of the answerstartI and probability of all answer end words PendJ are respectively multiplied (i, j all represent the characters in the document), and a plurality of answers in a plurality of intervals [ i, j ] are determined according to the calculation result]Then through the initial probability distribution Pstart∈RnAnd end of the sameRate distribution Pend∈RnA matrix of n x n can be determined, where each element in the matrix of n x n represents an answer in the interval i, j]The probability of (d);
in addition, in order to meet the rationality of the screened answers, it is necessary to consider that the probability of the initial word in the answer is less than or equal to the probability of the terminal word, that is, the initial word of the answer is before the terminal word, that is, i is equal to or less than j, at this time, each element in the n × n matrix is screened according to the condition that i is equal to or less than j, so that multiple answers to be selected can be mapped, in order to accelerate the subsequent processing process, the largest first k answers to be selected can be selected as candidate answers according to a preset rule, and the value of k can be set according to actual requirements, which is not limited herein.
Wherein, the plurality of candidate answers are respectively ' traffic ', ' major traffic accident ', ' 20 persons injured ', ' major traffic ', ' and ' occurrence of major '.
Step S306, inputting the multiple candidate answers and the question to be answered into a semantic matching model for answer prediction, and obtaining a predicted answer of the question to be answered.
Specifically, after obtaining a plurality of candidate answers "traffic", "major traffic accident", "20 persons are injured", "major traffic", "occurrence of major", a plurality of candidate answers and a question to be answered "what was an accident in the afternoon yesterday? And inputting the candidate answers and the text to be processed into a semantic matching model together for semantic matching, and calculating the semantic matching degree of each candidate answer and the text to be processed.
Further, it is determined by the calculate semantic match module in the semantic matching model what are "traffic" and "what was the accident in yesterday afternoon? "semantic matching degree is 70%," major traffic accident ", and" what was the accident in the afternoon of yesterday? "semantic match is 86%," 20 injured ", and" what was an accident in the afternoon of yesterday? "semantic match is 36%," major traffic "and" what was the accident in yesterday afternoon? "semantic match is 80%," significant "and" what was the accident in yesterday afternoon? "the semantic matching degree is 50%.
What are the candidate answers "major traffic accidents" and the question to be answered "yesterday afternoon accidents? "semantic matching degree is highest, and then" major traffic accident "is taken as a question to be answered" what was the accident in yesterday afternoon? "is predicted answer.
At this time, although the answer which may satisfy the question to be answered is screened out through the semantic matching model, if the answer is directly fed back to the client of the client, if the answer is incorrect, the answer thinking of the user is influenced, misleading can be caused to the user, the experience effect of the user is influenced to a great extent, and in order to avoid the question, the rationality verification is carried out on the predicted answer.
Step S308, determining the sentence to which the predicted answer belongs in the reading comprehension document, and forming a text set to be verified based on the sentence, the predicted answer and the question to be answered.
In practical application, there may be a case that the predicted answer is not in accordance with the question to be answered, if the question to be answered is fed back to the user, the experience effect of the user is greatly affected, so the predicted answer needs to be verified, and in order to improve the verification accuracy, in addition to considering the predicted answer and the question to be answered, the sentence to which the predicted answer belongs needs to be considered, so that a response result satisfying the question to be answered can be output through the verifier,
step S310, inputting the text set to be verified into a verifier to verify the predicted answer, and obtaining the predicted answer as the unreasonable rate of the question to be answered.
Specifically, when the text set to be verified is input to the verifier for verification of the predicted answer, the verifier generates an unreasonable rate (unreasonable probability that the predicted answer is used as an answer to the question to be answered) of the predicted answer according to the predicted answer, the sentence to which the predicted answer belongs and the question to be answered, and it should be noted that the higher the unreasonable rate is, the lower the rationality that the predicted answer is used as a correct answer to the question to be answered is, and otherwise, the lower the unreasonable rate is, the higher the rationality that the predicted answer is used as a correct answer to the question to be answered is.
After the predicted answer is determined to be used as the unreasonable rate of the question to be answered, in order to more accurately determine whether to feed the predicted answer back to the user as the answer result aiming at the question to be answered, the calculation can be carried out according to the probability and the unreasonable rate of reading and understanding the answer existing in the document, and therefore the result of determining whether to answer the question to be answered is obtained.
Step S312, weighting and calculating according to the probability of reading and understanding the answer in the document and the unreasonable rate of taking the predicted answer as the question to be answered, and obtaining the answer rate.
Step S314, judging whether the response rate is greater than a preset response rate threshold value; if yes, go to step S316; if not, go to step S318.
And step S316, taking the predicted answer as a reply result of the question to be answered, and sending the reply result to the client.
Step S318, generating a reply result that the question to be answered cannot be answered, and sending the reply result to the client.
Specifically, the response rate specifically indicates whether a response is made to the question to be answered, and if the response rate is greater than a preset response rate threshold, it indicates that the predicted answer is reasonable for the question to be answered, so that "major traffic accident" is taken as the question to be answered, "what is the accident in yesterday afternoon? "the answer is sent to the client and informs the user; the response rate is not greater than the preset response rate threshold, indicating that the predicted answer is unreasonable for the question to be answered, so a question to be answered "what was the accident in yesterday afternoon? "there is no correct answer in reading and understanding the document, and a reply result that the question to be answered cannot be answered is sent to the client.
The text processing method provided by the application extracts a plurality of candidate answers corresponding to the question text from the to-be-processed text after the to-be-processed question text and the question text are obtained, and simultaneously inputting a plurality of candidate answers and the question text into the semantic matching model to obtain a predicted answer matched with the question text, and finally according to the predicted answer, and the sentence and the question text to which the predicted answer belongs determine the answer result of the question text, so that the predicted answer is screened from a plurality of candidate answers, the correct rate of the predicted answer is determined, thereby achieving the purposes of generating more accurate response results aiming at the question texts, solving the problem of inaccurate answer of the question texts caused by single answers, and the performance of the model can be fully utilized, and the accuracy of predicting correct answers aiming at the question text is improved.
Corresponding to the above method embodiment, the present application further provides a text processing apparatus embodiment, and fig. 4 shows a schematic structural diagram of a text processing apparatus provided in an embodiment of the present application. As shown in fig. 4, the apparatus includes:
an obtaining module 402 configured to obtain a to-be-processed text and a question text, wherein the question text is related to the to-be-processed text;
an extracting module 404 configured to extract a plurality of candidate answers corresponding to the question text from the text to be processed;
a prediction module 406, configured to input the plurality of candidate answers and the question text into a semantic matching model for processing, so as to obtain a predicted answer matched with the question text;
a determining module 408 configured to determine a reply result of the question text according to the predicted answer, the sentence to which the predicted answer belongs in the text to be processed, and the question text.
In an optional embodiment, the extracting module 404 includes:
the word segmentation processing unit is configured to perform word segmentation processing on the text to be processed and the problem text and form a word unit set according to word segmentation processing results;
and the text processing unit is configured to input each word unit contained in the word unit set into a processing model for text processing, and obtain a plurality of candidate answers corresponding to the question text.
In an optional embodiment, the text processing unit includes:
a probability calculation subunit configured to input each word unit included in the word unit set to the text processing model, calculate a first probability that each word unit is an answer start word and a second probability that each word unit is an answer end word through a prediction module in the text processing model;
a generating probability distribution subunit configured to generate a starting probability distribution according to the first probability and an end probability distribution according to the second probability;
and the answer screening subunit is configured to input the initial probability distribution and the terminal probability distribution to a screening module in the text processing model for answer screening processing, so as to obtain a plurality of candidate answers corresponding to the question text.
In an alternative embodiment, the prediction module 406 includes:
an input model unit configured to input the plurality of candidate answers and the question text to the semantic matching model;
the feature extraction unit is configured to perform feature extraction on the multiple candidate answers and the question text through a feature extraction module in the semantic matching model to obtain a first feature vector corresponding to each candidate answer and a second feature vector corresponding to the question text;
a matching degree calculating unit configured to calculate matching degrees of the first feature vector and the second feature vector respectively through a semantic matching module in the semantic matching model, so as to obtain matching degrees of the candidate answers and the question text;
and the predicted answer output unit is configured to select the candidate answer with the highest matching degree as the predicted answer and output the predicted answer matched with the question text through an output module of the semantic matching model.
In an optional embodiment, the determining module 408 includes:
a sentence determining unit configured to determine the sentence to which the predicted answer belongs in the text to be processed;
the answer verification unit is configured to generate a text group to be verified according to the sentence, the question text and the predicted answer, input the text group to be verified into a verification model for predicted answer verification, and obtain the correct rate of the predicted answer, wherein the correct rate represents the probability that the predicted answer is used as an answer matched with the question text;
a determination reply result unit configured to determine the reply result of the question text according to the correct rate.
In an optional embodiment, the unit for determining a response result includes:
a judging subunit configured to judge whether the accuracy is greater than a preset accuracy threshold;
if yes, a target answer determining subunit is operated, wherein the target answer determining subunit is configured to determine the predicted answer as a target answer of the question text and generate a reply result of the question text according to the target answer;
and if not, operating a reminding subunit, wherein the reminding subunit is configured to generate reminding information according to the predicted answer and generate a reply result of the question text based on the reminding information.
In an optional embodiment, the text processing apparatus further includes:
the word segmentation processing module is configured to perform word segmentation processing on the text to be processed to obtain a first word unit set, and perform word segmentation processing on the problem text to obtain a second word unit set;
a mark adding module configured to add a sentence start mark and a sentence division mark to the first word unit set and the second word unit set, respectively, to obtain a third word unit set and a fourth word unit set;
and the feature extraction module is configured to input the third word unit set and the fourth word unit set into a text processing model for feature extraction, so as to obtain a text feature vector and a question feature vector.
In an optional embodiment, the text processing apparatus further includes:
a similarity calculation module configured to calculate a feature vector similarity of the question feature vector and the text feature vector;
and the matching rate determining module is configured to determine the matching rate of the question text and the text to be processed according to the similarity of the feature vectors under the condition that the similarity of the feature vectors is greater than a similarity threshold.
In an optional embodiment, the text processing apparatus further includes:
a correct rate determining module configured to determine a correct rate of the predicted answer according to the predicted answer, the sentence to which the predicted answer belongs in the text to be processed, and the question text;
a reply rate calculation module configured to perform weighting and calculation based on the correct rate and the weight corresponding to the correct rate, and the matching rate and the weight corresponding to the matching rate, so as to obtain a reply rate for replying to the question text;
and the answer determining module is configured to take the predicted answer as an answer result of the question text if the answer rate is greater than a preset answer rate threshold.
In an optional embodiment, the semantic matching model is trained in the following manner:
acquiring a training text and a training problem text corresponding to the training text;
extracting a plurality of training candidate answers from the training text, and performing score labeling on the plurality of training candidate answers;
and forming a sample set based on the training candidate answers after the score labeling and the training text, and inputting the sample set to an initial semantic matching model for training to obtain the semantic matching model.
In an optional embodiment, the score-labeling the plurality of training candidate answers includes:
and performing score labeling on the multiple candidate answers according to the evaluation indexes, or performing score labeling on the multiple candidate answers according to the evaluation indexes.
In an alternative embodiment, the text processing model is of the same model type as the pre-trained model of the semantic matching model.
The text processing device provided by the application extracts a plurality of candidate answers corresponding to the question text from the to-be-processed text after the to-be-processed question text and the question text are obtained, and simultaneously inputting a plurality of candidate answers and the question text into the semantic matching model to obtain a predicted answer matched with the question text, and finally according to the predicted answer, and the sentence and the question text to which the predicted answer belongs determine the answer result of the question text, so that the predicted answer is screened from a plurality of candidate answers, the correct rate of the predicted answer is determined, thereby achieving the purposes of generating more accurate response results aiming at the question texts, solving the problem of inaccurate answer of the question texts caused by single answers, and the performance of the model can be fully utilized, and the accuracy of predicting correct answers aiming at the question text is 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. 5 illustrates a block diagram of a computing device 500 provided according to an embodiment of the present application. The components of the computing device 500 include, but are not limited to, a memory 510 and a processor 520. Processor 520 is coupled to memory 510 via bus 530, and database 550 is used to store data.
Computing device 500 also includes access device 540, access device 540 enabling computing device 500 to communicate via one or more networks 560. 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 540 may include one or more of any type of network interface, e.g., a Network Interface Card (NIC), 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 500 and other components not shown in FIG. 5 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. 5 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 500 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 500 may also be a mobile or stationary server.
Wherein processor 520 is configured to execute the following computer-executable instructions:
acquiring a text to be processed and a question text, wherein the question text is related to the text to be processed;
extracting a plurality of candidate answers corresponding to the question text from the text to be processed;
inputting the candidate answers and the question text into a semantic matching model for processing to obtain a predicted answer matched with the question text;
and determining a reply result of the question text according to the predicted answer, the sentence of the predicted answer in the text to be processed and the question text.
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:
acquiring a text to be processed and a question text, wherein the question text is related to the text to be processed;
extracting a plurality of candidate answers corresponding to the question text from the text to be processed;
inputting the candidate answers and the question text into a semantic matching model for processing to obtain a predicted answer matched with the question text;
and determining a reply result of the question text according to the predicted answer, the sentence of the predicted answer in the text to be processed and the question text.
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, and the like. 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 (15)

1. A method of text processing, comprising:
acquiring a text to be processed and a question text, wherein the question text is related to the text to be processed;
extracting a plurality of candidate answers corresponding to the question text from the text to be processed;
inputting the candidate answers and the question text into a semantic matching model for processing to obtain a predicted answer matched with the question text;
and determining a reply result of the question text according to the predicted answer, the sentence of the predicted answer in the text to be processed and the question text.
2. The method according to claim 1, wherein the extracting a plurality of candidate answers corresponding to the question text from the text to be processed comprises:
performing word segmentation on the text to be processed and the problem text, and forming a word unit set according to word segmentation processing results;
and inputting each word unit contained in the word unit set into a text processing model for processing to obtain a plurality of candidate answers corresponding to the question text.
3. The method according to claim 2, wherein the inputting each word unit included in the word unit set into a text processing model for processing to obtain a plurality of candidate answers corresponding to the question text comprises:
inputting each word unit contained in the word unit set into the text processing model, and calculating a first probability of each word unit as an initial character of an answer and a second probability of each word unit as an end character of the answer through a prediction module in the text processing model;
generating a starting probability distribution according to the first probability and generating an end probability distribution according to the second probability;
and inputting the initial probability distribution and the terminal probability distribution to a screening module in the text processing model for answer screening processing to obtain a plurality of candidate answers corresponding to the question text.
4. The method of claim 1, wherein the inputting the candidate answers and the question text into a semantic matching model for processing to obtain a predicted answer for the question text matching comprises:
inputting the plurality of candidate answers and the question text to the semantic matching model;
extracting features of the candidate answers and the question text through a feature extraction module in the semantic matching model to obtain a first feature vector corresponding to each candidate answer and a second feature vector corresponding to the question text;
respectively calculating the matching degree of the first feature vector and the second feature vector through a semantic matching module in the semantic matching model to obtain the matching degree of each candidate answer and the question text;
and selecting the candidate answer with the highest matching degree as the predicted answer, and outputting the predicted answer matched with the question text through an output module of the semantic matching model.
5. The text processing method according to claim 1, wherein the determining a response result of the question text from the predicted answer, the sentence to which the predicted answer belongs in the text to be processed, and the question text comprises:
determining the sentence to which the predicted answer belongs in the text to be processed;
generating a text group to be verified according to the statement, the question text and the predicted answer, inputting the text group to be verified into a verification model for predicted answer verification, and obtaining the correct rate of the predicted answer, wherein the correct rate represents the probability that the predicted answer is used as an answer matched with the question text;
and determining the answer result of the question text according to the accuracy.
6. The text processing method according to claim 5, wherein said determining the answer result of the question text based on the correctness includes:
judging whether the accuracy is greater than a preset accuracy threshold value or not;
if yes, determining the predicted answer as a target answer of the question text, and generating a reply result of the question text according to the target answer;
if not, generating reminding information according to the predicted answer, and generating a reply result of the question text based on the reminding information.
7. The text processing method according to claim 1, wherein after the step of obtaining the text to be processed and the question text is executed, the method further comprises:
performing word segmentation on the text to be processed to obtain a first word unit set, and performing word segmentation on the problem text to obtain a second word unit set;
respectively adding sentence beginning mark symbols and sentence division mark symbols aiming at the first word unit set and the second word unit set to obtain a third word unit set and a fourth word unit set;
and inputting the third word unit set and the fourth word unit set into a text processing model for feature extraction to obtain a text feature vector and a problem feature vector.
8. The text processing method according to claim 7, further comprising:
calculating the similarity of the problem feature vector and the feature vector of the text feature vector;
and under the condition that the similarity of the feature vectors is greater than a similarity threshold, determining the matching rate of the question text and the text to be processed according to the similarity of the feature vectors.
9. The method according to claim 8, wherein after the step of inputting the candidate answers and the question text into a semantic matching model for processing to obtain the predicted answer for the question text matching is performed, the method further comprises:
determining the correct rate of the predicted answer according to the predicted answer, the sentence of the predicted answer in the text to be processed and the question text;
weighting and calculating based on the correct rate and the weight corresponding to the matching rate and the matching rate to obtain a response rate for responding to the question text;
and in the case that the answer rate is greater than a preset answer rate threshold value, taking the predicted answer as an answer result of the question text.
10. The text processing method of claim 1, wherein the semantic matching model is trained as follows:
acquiring a training text and a training problem text corresponding to the training text;
extracting a plurality of training candidate answers from the training text, and performing score labeling on the plurality of training candidate answers;
and forming a sample set based on the training candidate answers after the score labeling and the training text, and inputting the sample set to an initial semantic matching model for training to obtain the semantic matching model.
11. The method of claim 10, wherein the score labeling the plurality of training candidate answers comprises:
and performing score labeling on the multiple candidate answers according to the evaluation indexes, or performing score labeling on the multiple candidate answers according to the evaluation indexes.
12. The method of claim 9, wherein the text processing model is of the same model type as a pre-trained model of the semantic matching model.
13. A text processing apparatus, comprising:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is configured to acquire a text to be processed and a question text, and the question text is related to the text to be processed;
the extraction module is configured to extract a plurality of candidate answers corresponding to the question text from the text to be processed;
the prediction module is configured to input the candidate answers and the question text into a semantic matching model for processing to obtain a predicted answer matched with the question text;
a determination module configured to determine a reply result of the question text according to the predicted answer, the sentence to which the predicted answer belongs in the text to be processed, and the question text.
14. 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 according to any one of claims 1 to 12.
15. 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 12.
CN202010916581.9A 2020-09-03 2020-09-03 Text processing method and device Pending CN114138947A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010916581.9A CN114138947A (en) 2020-09-03 2020-09-03 Text processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010916581.9A CN114138947A (en) 2020-09-03 2020-09-03 Text processing method and device

Publications (1)

Publication Number Publication Date
CN114138947A true CN114138947A (en) 2022-03-04

Family

ID=80438302

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010916581.9A Pending CN114138947A (en) 2020-09-03 2020-09-03 Text processing method and device

Country Status (1)

Country Link
CN (1) CN114138947A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116089589A (en) * 2023-02-10 2023-05-09 阿里巴巴达摩院(杭州)科技有限公司 Question generation method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116089589A (en) * 2023-02-10 2023-05-09 阿里巴巴达摩院(杭州)科技有限公司 Question generation method and device
CN116089589B (en) * 2023-02-10 2023-08-29 阿里巴巴达摩院(杭州)科技有限公司 Question generation method and device

Similar Documents

Publication Publication Date Title
CN113127624B (en) Question-answer model training method and device
CN110781663A (en) Training method and device of text analysis model and text analysis method and device
CN110895559A (en) Model training method, text processing method, device and equipment
CN110347802B (en) Text analysis method and device
CN110555440B (en) Event extraction method and device
CN113536801A (en) Reading understanding model training method and device and reading understanding method and device
CN112860896A (en) Corpus generalization method and man-machine conversation emotion analysis method for industrial field
CN111695591A (en) AI-based interview corpus classification method, device, computer equipment and medium
CN115759001A (en) Language model training method, text prediction method and device
CN111242710A (en) Business classification processing method and device, service platform and storage medium
CN113486174B (en) Model training, reading understanding method and device, electronic equipment and storage medium
CN114077655A (en) Method and device for training answer extraction model
CN114138947A (en) Text processing method and device
KR20190023722A (en) Apparatus and method for sentiment analysis keyword expansion
CN115934904A (en) Text processing method and device
CN115795007A (en) Intelligent question-answering method, intelligent question-answering device, electronic equipment and storage medium
CN115757723A (en) Text processing method and device
CN115292492A (en) Method, device and equipment for training intention classification model and storage medium
CN114139545A (en) Information extraction method and device
CN114417863A (en) Word weight generation model training method and device and word weight generation method and device
CN113961686A (en) Question-answer model training method and device, question-answer method and device
CN114492410A (en) Contract information extraction method and device
CN114239565A (en) Deep learning-based emotion reason identification method and system
CN113657112A (en) Method and device for reading article
CN112328777A (en) Answer detection method and device

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