CN112613322B - Text processing method, device, equipment and storage medium - Google Patents

Text processing method, device, equipment and storage medium Download PDF

Info

Publication number
CN112613322B
CN112613322B CN202011501996.6A CN202011501996A CN112613322B CN 112613322 B CN112613322 B CN 112613322B CN 202011501996 A CN202011501996 A CN 202011501996A CN 112613322 B CN112613322 B CN 112613322B
Authority
CN
China
Prior art keywords
understood
question
text
character
answer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011501996.6A
Other languages
Chinese (zh)
Other versions
CN112613322A (en
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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202011501996.6A priority Critical patent/CN112613322B/en
Publication of CN112613322A publication Critical patent/CN112613322A/en
Priority to PCT/CN2021/097086 priority patent/WO2022127040A1/en
Application granted granted Critical
Publication of CN112613322B publication Critical patent/CN112613322B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N5/00Computing arrangements using knowledge-based models
    • G06N5/04Inference or reasoning models
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Computational Linguistics (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Machine Translation (AREA)

Abstract

The embodiment of the application discloses a text processing method, a device, equipment and a storage medium, comprising the following steps: acquiring a text to be understood, wherein the text to be understood comprises a question to be understood and a plurality of article fragments to be understood; inputting the text to be understood into a reading and understanding model, determining a question type label to which the question to be understood belongs through a semantic analysis layer of the reading and understanding model, and marking the question type label of the question answered by each article fragment to be understood, wherein the characteristic label of each character in the text to be understood and the position label of each character; and determining the initial character position and the end character position of the answer text of the question to be understood through the semantic matching layer of the reading and understanding model, and determining the answer text of the question to be understood. By adopting the embodiment of the application, the reading and understanding efficiency and the accuracy of the machine can be improved.

Description

Text processing method, device, equipment and storage medium
Technical Field
The present application relates to the field of natural language processing, and in particular, to a text processing method, apparatus, device, and storage medium.
Background
Currently, with the development of artificial intelligence technology, more and more inference models are used for natural language processing. The reading and understanding model with natural language processing technology as the core can help people to read and understand and answer questions. Fragment extraction type reading understanding is a task in natural language processing, and can well extract target information from a large amount of text materials, and ensure that an output result is a sentence in the text materials. Currently, the construction of fragment extraction class reading understanding models is mainly based on bi-directional coded representation translation (Bidirectional Encoder Representations from Transformers, bert) class techniques. The Bert model, as the currently mainstream training language model, can show a better result in most language training tasks. However, in the reading and understanding task, the problem and the article are semantically encoded based on vocabulary in the Bert model, and the Bert model cannot reasonably analyze the meaning of the problem through vocabulary encoding due to mismatching of the information quantity of the problem and the article. And because the length of the questions is limited, the Bert model is difficult to find the association among the questions through vocabulary coding, so that the answer pertinence of reading and understanding the model is poor, and the reading and understanding efficiency is low.
Disclosure of Invention
The embodiment of the application provides a text processing method, a device, equipment and a storage medium, which can be used for marking the problem type of a text to be understood so as to obtain the association between the problem to be understood and an article to be understood in the problem type, can improve the reading and understanding efficiency and the accuracy, and has high applicability.
In a first aspect, an embodiment of the present application provides a text processing method, including:
acquiring a text to be understood, wherein the text to be understood comprises a problem to be understood and a plurality of article fragments to be understood;
inputting the text to be understood into a reading and understanding model, and determining the question type label of the question to be understood and the question type label of the question answered by each article fragment to be understood through a semantic analysis layer of the reading and understanding model;
determining the feature labels of the characters in the text to be understood and the position labels of the characters through a semantic analysis layer of the reading understanding model;
determining the initial character position and the end character position of the answer text of the to-be-understood question based on the question type label of the to-be-understood question, the question type label of the question answered by the to-be-understood article fragment, the characteristic label of each character in the to-be-understood text and the position label of each character through the semantic matching layer of the reading and understanding model;
And determining the answer text of the to-be-understood question from the to-be-understood text according to the initial character position and the termination character position.
In the embodiment of the application, the semantic relevance of the to-be-understood problem and the to-be-understood article can be enhanced in the dimension of the problem type by marking the problem type of the to-be-understood problem in the to-be-understood text and the problem type answered by each to-be-understood article fragment; and marking the characteristics and the positions of the characters in the text to be understood after the type of the question is determined, and inputting the characters into a semantic matching layer, so that the semantic matching layer can read and understand the text to be understood at the character level, and the initial character position and the end character position of the answer text of the question to be understood are obtained in the article to be understood, thereby obtaining the answer text of the question to be understood, and improving the accuracy of reading and understanding.
With reference to the first aspect, in a possible implementation manner, before the text to be understood is input into the reading understanding model, the method further includes:
collecting a plurality of sample fragments of reading and understanding texts, wherein the sample fragments comprise question fragments and answer fragments corresponding to the question fragments;
Determining a question type label of each question segment in each sample segment and a question type label of a question answered by each answer segment;
determining the feature labels of the characters in the sample fragments and the position labels of the characters;
and training the semantic analysis layer and the semantic matching layer of the reading and understanding model based on the question type label of each question segment, the question type label of the questions answered by each answer segment, the characteristic label of each character in the sample segment and the position label of each character.
In the embodiment of the application, the relevance of the question segment and the answer segment in the question type dimension in the semantic analysis layer can be enhanced by marking the question type to which the question segment belongs in the sample segment and the question type to which the answer segment answers and training the semantic analysis layer. By means of semantic annotation of the sample fragments after the classification annotation and training of the semantic matching layer, the semantic matching layer can read and understand the text to be understood at the character level, and the initial character position and the end character position of the answer text of the question to be understood are obtained in the article to be understood, so that the answer text of the question to be understood is obtained, and the accuracy of reading and understanding is further improved.
With reference to the first aspect, in one possible implementation manner, the training the semantic analysis layer and the semantic matching layer of the reading understanding model based on the question type label to which each question segment belongs, the question type label to which each answer segment answers, the feature label of each character in the sample segment, and the position label of each character includes:
acquiring a first semantic matching layer network parameter obtained after training a semantic matching layer of the reading and understanding model based on a question type label which is included in any sample segment and to which a question segment belongs, a question type label which is corresponding to the question segment and to which a question is answered by an answer segment, a feature label of each character in any sample segment and a position label of each character;
determining the scores of the first semantic matching layer network parameters through a gating circulating layer of the reading understanding model;
when the score of the first semantic matching layer network parameter is greater than or equal to a threshold value, determining the network parameter of the semantic matching layer as the first semantic matching layer network parameter through the gating circulating layer;
when the score of the first semantic matching layer network parameter is smaller than a threshold value, determining the network parameter of the semantic matching layer as a second semantic matching layer network parameter through the gating circulating layer;
The second semantic matching layer network parameters are semantic matching layer network parameters obtained after training the semantic matching layer of the reading and understanding model based on a question type label of a question segment included in a previous sample segment, a question type label of a question answered by an answer segment corresponding to the question segment, a feature label of each character in the previous sample segment and a position label of each character, and the previous sample segment is a sample segment input into the reading and understanding model before any sample segment.
In the embodiment of the application, the score of the network parameter of the first semantic matching layer is determined through the gate control circulation layer of the reading and understanding model, so that sample fragments with lower quality can be removed, and sample fragments with low contribution to the semantic matching layer training are removed, so that the network parameter of the semantic matching layer is more accurate, the training efficiency of the semantic matching layer is improved, and the accuracy of reading and understanding is further improved.
With reference to the first aspect, in one possible implementation manner, the determining, by the semantic matching layer of the reading understanding model, a start character position and an end character position of the answer text of the to-be-understood question based on the question type label to which the to-be-understood question belongs, the question type label of the question answered by each to-be-understood article fragment, the feature label of each character in the to-be-understood text, and the position label of each character includes:
Determining a plurality of preselected initial character positions and a plurality of preselected termination character positions from the text to be understood through a semantic matching layer of the reading and understanding model based on the question type label to which the question to be understood belongs, the question type label of the question answered by each article fragment to be understood, the characteristic label of each character in the text to be understood and the position label of each character so as to obtain a plurality of preselected answer texts;
determining the score of each pre-selected answer text for answering the question to be understood based on the matching degree of each pre-selected answer text and the question to be understood through the semantic matching layer;
and taking the preselected initial character position and the preselected final character position of the preselected answer text with the highest score in the preselected answer texts as the initial character position and the final character position of the answer text of the question to be understood so as to obtain the answer text of the question to be understood.
With reference to the first aspect, in one possible implementation manner, the determining, from the text to be understood, the answer text of the question to be understood according to the start character position and the end character position includes:
If the character distance between the initial character position and the final character position of the answer text of the question to be understood is within the threshold value interval, determining the text between the initial character position and the final character position from the text to be understood as the answer text of the question to be understood, and outputting the answer text of the question to be understood.
In the embodiment of the application, the answer text can be further screened based on the length of the characters between the initial character position and the final character position of the answer text of the question to be understood, the length of the answer text can be further limited, and the information irrelevant to the question to be understood in the answer text is removed, so that the redundancy of the answer text is reduced, and the reading and understanding efficiency is improved.
With reference to the first aspect, in one possible implementation manner, the collecting a plurality of sample segments of reading comprehension text includes:
collecting a plurality of sample fragments of reading understanding texts from the Internet; and/or
Collecting a plurality of sample fragments of reading understanding texts from a target field database, wherein the target field database at least comprises a medical field database generated based on diagnosis and treatment data and pathology data of the medical field;
The sample fragments of each reading and understanding text comprise question fragments and answer fragments corresponding to the question fragments.
In a second aspect, an embodiment of the present application provides a text processing apparatus, including:
the text acquisition module is used for acquiring a text to be understood, wherein the text to be understood comprises a question to be understood and a plurality of article fragments to be understood;
the classification labeling module is used for inputting the text to be understood into a reading understanding model, and determining the question type label of the question to be understood and the question type label of the question answered by each article fragment to be understood through a semantic analysis layer of the reading understanding model;
the semantic annotation module is used for determining the feature annotation of each character in the text to be understood and the position annotation of each character through the semantic analysis layer of the reading and understanding model;
the semantic matching module is used for determining a starting character position and a termination character position of the answer text of the question to be understood through the semantic matching layer of the reading understanding model based on the question type label of the question to be understood, the question type label of the question answered by each article fragment to be understood, the characteristic label of each character in the text to be understood and the position label of each character, and determining the answer text of the question to be understood from the text to be understood according to the starting character position and the termination character position.
With reference to the second aspect, in one possible implementation manner, the semantic matching module includes:
the text confirming unit is used for determining a plurality of preselected initial character positions and a plurality of preselected terminal character positions from the text to be understood through the semantic matching layer of the reading and understanding model based on the question type label of the question to be understood, the question type label of the question answered by each article fragment to be understood, the characteristic label of each character in the text to be understood and the position label of each character so as to obtain a plurality of preselected answer texts;
an answer scoring unit, configured to determine, through the semantic matching layer, a score of each of the pre-selected answer texts for answering the question to be understood based on a matching degree between the pre-selected answer texts and the question to be understood;
and the answer confirming unit is used for taking the preselected initial character position and the preselected final character position of the preselected answer text with the highest score in the preselected answer texts as the initial character position and the final character position of the answer text of the question to be understood so as to obtain the answer text of the question to be understood.
With reference to the second aspect, in one possible implementation manner, the semantic matching module further includes:
And the answer output unit is used for determining the text between the initial character position and the terminal character position from the text to be understood as the answer text of the question to be understood and outputting the answer text of the question to be understood if the character distance between the initial character position and the terminal character position of the answer text of the question to be understood is within a threshold value interval.
In a third aspect, an embodiment of the present application provides a terminal device, where the terminal device includes a processor and a memory, and the processor and the memory are connected to each other. The memory is configured to store a computer program supporting the terminal device to perform the method provided by the first aspect and/or any of the possible implementation manners of the first aspect, the computer program comprising program instructions, the processor being configured to invoke the program instructions to perform the method provided by the first aspect and/or any of the possible implementation manners of the first aspect.
In a fourth aspect, embodiments of the present application provide a computer readable storage medium storing a computer program comprising program instructions which, when executed by a processor, cause the processor to perform the method provided by the first aspect and/or any one of the possible implementations of the first aspect.
In the embodiment of the application, the semantic relevance of the to-be-understood problem and the to-be-understood article can be enhanced in the dimension of the problem type by marking the problem type of the to-be-understood problem in the to-be-understood text and the problem type answered by each to-be-understood article fragment; and marking the characteristics and the positions of the characters in the text to be understood after the type of the question is determined, and inputting the characters into a semantic matching layer, so that the semantic matching layer can read and understand the text to be understood at the character level, and the initial character position and the end character position of the answer text of the question to be understood are obtained in the article to be understood, thereby obtaining the answer text of the question to be understood, and improving the accuracy of reading and understanding.
Drawings
In order to more clearly illustrate the embodiments of the application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a text processing method according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a process for training a reading understanding model according to an embodiment of the present application;
FIG. 3 is another flow chart of a text processing method according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a text processing device according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of a terminal device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
Natural language processing is an important direction in the fields of computer science and artificial intelligence, and is mainly researched to realize various theories and methods for effectively communicating between people and computers by natural language. However, it is very difficult to implement natural language processing, and the root cause of the difficulty is the wide variety of ambiguities or ambiguities at various levels of natural language text and dialog. Thus, natural language processing must be disambiguated, i.e., potentially ambiguous natural language input needs to be converted into some unambiguous computer internal representation. Many machine learning algorithms have been applied to perform natural language processing tasks, but these algorithms are typically implemented by means of hard rule-like matching. Therefore, more and more research is focused on natural language processing models, which give different weights to various reasoning elements, and decision is made according to the probability obtained by final calculation. Such models can yield many possible answers, rather than just one relative certainty, resulting in more reliable results, improving the applicability and compatibility of natural language processing models. Among them, the Bert model, as a currently mainstream natural language processing model, can show a better result in most language training tasks (e.g., machine reading understanding (Machine Reading Comprehension, MRC) tasks). Therefore, the Bert model can be used as a reading understanding model to answer questions according to given contexts, and the understanding degree of the reading understanding model to the natural language text can be tested. Common MRC tasks can be divided into four types: complete filling, multiple choice, segment extraction, free answer. The fragment extraction type reading understanding model can well extract target information which a user wants to pay attention to from a large amount of text materials, and can ensure that an output result is a material original sentence, and compared with a method requiring manual maintenance of a regular expression, the method greatly reduces the operation cost of the reading understanding model. Generally, a reading understanding model consists of the following parts: embedding (Embedding), feature extraction (Feature Extraction), context interaction (Context-Question Interaction), answer prediction (Answer Prediction). Wherein, embedding is used for mapping words into corresponding word vectors; extracting context information for extracting questions and articles by the features; contextual interactions are used to extract the relevance between articles and questions, often introducing an attention mechanism to facilitate adequate extraction of the relevance between articles and questions; the answer prediction is used to output a final answer (in a reading understanding model for performing a segment extraction type task, the final answer is an answer text) based on the information obtained in the above-described several portions. The method provided by the embodiment of the application can be executed by a system or terminal equipment loaded with a text processing function based on a reading understanding model, and for convenience of description, the method for text processing provided by the embodiment of the application will be described below with the terminal equipment as an execution subject.
Taking the example of constructing a reading understanding model (i.e. reading understanding model) in the medical field to perform fragment extraction reading understanding on the medical problem, the terminal device can improve or reconstruct a common reading understanding model (for example, a Bert model), and the method can be specifically determined according to the actual application scenario without limitation. In the application, the reading and understanding model comprises a semantic analysis layer and a semantic matching layer, the medical problems belong to a plurality of diseases such as pneumonia, bronchitis, upper respiratory tract infection, tuberculosis, asthma and the like, and the medical problems comprise a plurality of categories such as location problems, time problems, character problems, event problems, cause problems, method problems and the like. The terminal device builds the reading understanding model, including but not limited to, collecting a plurality of sample fragments of the reading understanding text from the internet or the target field database, and building the reading understanding model by using the plurality of sample fragments. Wherein the target area database may include: a medical field database generated based on medical field diagnosis and treatment data and pathology data, or a medical device field database generated based on existing device data and geographical position data of a medical institution. The sample segments may include a question segment (e.g., question segment 1, question segment 2, etc.), and an answer segment (e.g., answer segment 1, answer segment 2, etc.) corresponding to the question segment in the article segment. And the terminal equipment marks the problem category of each sample segment to obtain the sample segment after classification marking. The terminal equipment marks the question category of each sample segment, wherein the marking of the question category comprises marking the question type of the question segment in each sample segment, and marking the question type of one question segment as the question type answered by the answer segment corresponding to the question segment. For example, the terminal device labels the question types of question segment 1 (e.g., how cold is treated) as "upper respiratory tract infection" and "method question", and the question types of answer segment 1 (e.g., suggesting that the patient is bedridden, light diet) corresponding to question segment 1 as "upper respiratory tract infection" and "method question". The terminal device labels the question types of the question segment 2 (for example, what cause is the lung inflammation. The terminal equipment performs semantic annotation on the sample fragments subjected to the classification annotation to obtain sample fragments, including but not limited to performing feature annotation on each character in the sample fragments and labeling the positions of each character. For example, the terminal device performs pinyin labeling, stroke number labeling, and character position labeling on each character in the sample segment. The terminal device semantically labels problem segment 1 (how is the cold treated: feel (gan, 13, [ 1 ]) like (ru, 6, [ 3 ]) (he, 7, [ 4 ]) treatment (zhi, 8, [ 5 ]) treatment (liao, 7, [ 6 ]? (#, #, [ 7 ]). The terminal device adds a separator between the question segment 1 and the answer segment 1 (the position is [ 8 ]), and simultaneously, semantically marks the answer segment 1 (suggesting that the patient is bedridden and the diet is light) corresponding to the question segment 1 as follows: build (jian, 8, [ 9 ]) to (yi, 5, [ 10 ]) to (huan, 11, [ 11 ], [ 12 ], (zhe, 8, [ 12 ]) to lie (wo, 8, [ 13 ]) to (chuang, 7, [ 14 ]) to (xiu, 6, [ 15 ]) to (xi, 10, [ 16 ]) to (qi, 11, [ 17 ], (dan, 12, [ 18 ]) to (yin, 7, [ 19 ]) to eat (shi, 9, [ 20 ]. Further, the terminal device can train a semantic analysis layer and a semantic matching layer of the reading and understanding model by using the sample fragments after classification labeling, so that the trained reading and understanding model can output the question type labels of the questions to be understood and the questions answered by the article fragments to be understood and included in the text based on any input text.
In some possible embodiments, the terminal device obtains the text to be understood, and performs question type labeling and semantic labeling on the text to be understood through the trained reading understanding model. For example, the question types to be understood for question 1 (how cold is treated. The types of questions answered by the article fragment 2 to be understood (suggesting patient bed rest, light diet) can be labeled "upper respiratory tract infection" and "method questions" by reading the understanding model. And the reading understanding model can be used for marking the characteristics of each character in the text to be understood and marking the positions of each character. For example, by marking each character of the problem to be understood in the text to be understood by reading the understanding model and marking the position of each character (the position in the text to be understood), the problem 1 to be understood can be obtained: feel (gan, 13, [ 1 ]) like (ru, 6, [ 3 ]) (he, 7, [ 4 ]) treatment (zhi, 8, [ 5 ]) treatment (liao, 7, [ 6 ]? (#, #, [ 7 ]). A separator is added between question 1 to be understood and article segment 1 to be understood (position [ 8 ]). The semantic analysis layer of the reading and understanding model can obtain the article fragment 1 to be understood after semantic annotation: the infection (gan, 13, [ 9 ]) is (shi, 9, [ 11 ]) one (yi, 1, [ 12 ]) (zhong, 9, [ 13 ] ", see (jian, 11, [ 14 ]") for (jian, 4, [ 15 ] "), acute (ji, 9, [ 17 ]") for (xing, 8, [ 18 ] ", (hand, 3, [ 19 ]) for (hu, 8, [ 20 ]", [ xi,6, [ 21 ] ") for (dao, 11, [ 22 ]") for (bing, 9, [ 23 ] ", 9, [ 24 ]") for (xin, 8, [ 25 ] ", [ 14 ]", [ 26 ] "(29, 10,", [ 10 ] ", and (ng, 8, [ 25 ]). A separator (position 31) is added between the article fragment 1 to be understood and the article fragment 2 to be understood, for distinguishing the article fragment 1 to be understood from the article fragment 2 to be understood. The semantic analysis layer of the reading and understanding model can obtain the article fragment 2 to be understood after semantic annotation: build (jian, 8, [ 32 ]) to (yi, 5, [ 33 ]) to (huan, 11, [ 34 ]) to (zhe, 8, [ 35 ]) to (wo, 8, [ 36 ]) to (chuang, 7, [ 37 ]) to (xiu, 6, [ 38 ]) to (xi, 10, [ 39 ]) to (qin, 11, [ 40 ]) to (light (dan, 12, [ 41 ]) to (yin, 7, [ 42 ]) to (shi, 9, [ 43 ]). Inputting the marked questions to be understood and the sections of each article to be understood into a reading understanding model for semantic matching, and determining the initial character position (32) and the final character position (43) of the answer text of the questions to be understood in the articles to be understood through the reading understanding model so as to obtain the answer text of the questions to be understood (suggesting the bedridden rest of the patient and light diet).
Referring to fig. 1 specifically, fig. 1 is a flow chart of a text processing method according to an embodiment of the application. The method provided by the embodiment of the application can comprise the steps of obtaining a text to be understood, wherein the text to be understood comprises a problem to be understood (such as a problem 1 to be understood and the like) and a plurality of article fragments to be understood (such as an article fragment 1 to be understood, an article fragment 2 to be understood and the like). The terminal equipment inputs the text to be understood into a semantic analysis layer of the reading and understanding model, and carries out question type labeling and semantic labeling on the text to be understood through the semantic analysis layer so as to obtain labeled questions to be understood and article fragments to be understood. And the terminal equipment inputs the marked questions to be understood and the text fragments to be understood into a semantic matching layer for semantic matching, and determines the initial character position and the termination character position of the answer text of the questions to be understood in the text to be understood through the semantic matching layer so as to obtain the answer text of the questions to be understood. For convenience of description, the method provided by the embodiment of the application will be described below by taking the reading understanding model constructed in the medical field to take the reading understanding of the fragment extraction of the medical problem as an example. The method provided by the embodiment of the application can comprise the following steps:
S101: and the terminal equipment acquires the text to be understood.
In some possible embodiments, the terminal device obtains the text to be understood, where the text to be understood includes a question to be understood (e.g., question to be understood 1, etc.) and a plurality of article segments to be understood (e.g., article segment to be understood 1, article segment to be understood 2, etc.). For example, the terminal device may obtain the text to be understood including the question to be understood 1 (e.g., how to treat the cold. In some application scenarios, the length of the article to be understood may be longer than the length range limited by the reading and understanding model, and the terminal device may divide the article to be understood into a plurality of article segments to be understood, combine each article segment to be understood with the problem to be understood, and sequentially input the article segments to be understood into the reading and understanding model for reading and understanding. The specific determination may be determined according to the actual application scenario, and is not limited herein.
S102: and the terminal equipment inputs the text to be understood into a reading and understanding model, and determines the question type label of the question to be understood and the question type label of the question answered by each article fragment to be understood through a semantic analysis layer of the reading and understanding model.
In some possible embodiments, the terminal device may input the text to be understood into a trained reading understanding model, and perform question type labeling and semantic labeling on the text to be understood through a semantic analysis layer of the reading understanding model. For example, the semantic analysis layer of the understanding model may label the question types of questions answered by the question 1 to be understood (how to treat cold.
S103: and determining the feature labels of the characters in the text to be understood and the position labels of the characters through a semantic analysis layer of the reading and understanding model.
In some possible embodiments, the semantic analysis layer of the reading understanding model can simultaneously label the features of each character in the text to be understood and label the positions of each character, so as to obtain the labeled problem to be understood and each article fragment to be understood. The semantic annotation includes, but is not limited to, feature annotation of each character in the sample segment, and annotation of the location of each character. For example, the to-be-understood problem 1 after semantic annotation can be obtained by marking the features of each character of the to-be-understood problem in the to-be-understood text and marking the positions of each character (the positions in the to-be-understood text) through a reading understanding model: feel (gan, 13, [ 1 ]) like (ru, 6, [ 3 ]) (he, 7, [ 4 ]) treatment (zhi, 8, [ 5 ]) treatment (liao, 7, [ 6 ]? (#, #, [ 7 ]). A separator is added between question 1 to be understood and article segment 1 to be understood (position [ 8 ]). The semantic analysis layer of the reading and understanding model can obtain the article fragment 1 to be understood after semantic annotation: the infection (gan, 13, [ 9 ]) is (shi, 9, [ 11 ]) one (yi, 1, [ 12 ]) (zhong, 9, [ 13 ] ", see (jian, 11, [ 14 ]") for (jian, 4, [ 15 ] "), acute (ji, 9, [ 17 ]") for (xing, 8, [ 18 ] ", (hand, 3, [ 19 ]) for (hu, 8, [ 20 ]", [ xi,6, [ 21 ] ") for (dao, 11, [ 22 ]") for (bing, 9, [ 23 ] ", 9, [ 24 ]") for (xin, 8, [ 25 ] ", [ 14 ]", [ 26 ] "(29, 10,", [ 10 ] ", and (ng, 8, [ 25 ]). A separator (position 31) is added between the article fragment 1 to be understood and the article fragment 2 to be understood, for distinguishing the article fragment 1 to be understood from the article fragment 2 to be understood. The semantic analysis layer of the reading and understanding model can obtain the article fragment 2 to be understood after semantic annotation: build (jian, 8, [ 32 ]) to (yi, 5, [ 33 ]) to (huan, 11, [ 34 ]) to (zhe, 8, [ 35 ]) to (wo, 8, [ 36 ]) to (chuang, 7, [ 37 ]) to (xiu, 6, [ 38 ]) to (xi, 10, [ 39 ]) to (qin, 11, [ 40 ]) to (light (dan, 12, [ 41 ]) to (yin, 7, [ 42 ]) to (shi, 9, [ 43 ]).
In some possible implementations, please refer to fig. 2, fig. 2 is a schematic diagram of a flow chart for training a reading understanding model according to an embodiment of the present application. The above method for training the reading understanding model may include the implementation provided by each of the following steps S201 to S208.
S201: the terminal device collects a plurality of sample fragments of reading comprehension text.
In some possible embodiments, the method for collecting a plurality of sample segments of reading comprehension text by the terminal device may include, but is not limited to, collecting a plurality of sample segments of reading comprehension text from the internet by the terminal device, where the sample segments include a question segment (e.g., question segment 1, question segment 2, etc.), and an answer segment (e.g., answer segment 1, answer segment 2, etc.) corresponding to the question segment in the article segment.
S202: the terminal equipment determines the question type label of each question segment in each sample segment and the question type label of the questions answered by each answer segment.
In some possible embodiments, the terminal device may label each sample segment with a problem category, so as to obtain a sample segment after classification labeling. The terminal device may label the question category of each sample segment, including labeling the question type to which the question segment in each sample segment belongs, and labeling the question type to which one question segment belongs as the question type to which the answer segment corresponding to the question segment is answered. The question types of question segment 1 (how to treat cold. The terminal device may label the question types of the question segment 2 (what cause is the lung inflammation.
S203: and the terminal equipment determines the characteristic label of each character in each sample fragment and the position label of each character.
In some possible embodiments, the terminal device may perform semantic labeling on the sample fragments after the classification labeling, so as to obtain the sample fragments after the semantic labeling. The terminal equipment can label the characteristics of each character in each sample segment after classification labeling and label the positions of each character. For example, by labeling each character in the sample segment after classification, labeling the number of strokes, and labeling the character positions, the problem segment 1 (how cold is treated: feel (gan, 13, [ 1 ]) like (ru, 6, [ 3 ]) (he, 7, [ 4 ]) treatment (zhi, 8, [ 5 ]) treatment (liao, 7, [ 6 ]? (#, #, [ 7 ]). Adding a separator between the question segment 1 and the answer segment 1 (at the position of [ 8 ]), and simultaneously, semantically marking the answer segment 1 (suggesting that the patient is bedridden and the diet is light) corresponding to the question segment 1 as follows: build (jian, 8, [ 9 ]) to (yi, 5, [ 10 ]) to (huan, 11, [ 11 ], [ 12 ], (zhe, 8, [ 12 ]) to lie (wo, 8, [ 13 ]) to (chuang, 7, [ 14 ]) to (xiu, 6, [ 15 ]) to (xi, 10, [ 16 ]) to (qi, 11, [ 17 ], (dan, 12, [ 18 ]) to (yin, 7, [ 19 ]) to eat (shi, 9, [ 20 ].
S204: the terminal equipment inputs the question type label of each question segment, the question type label of the questions answered by each answer segment, the characteristic label of each character in the sample segment and the position label of each character into a semantic analysis layer and a semantic matching layer.
S205: and the gating circulation layer acquires first semantic matching layer network parameters obtained after training the semantic matching layer of the reading and understanding model based on any sample segment.
S206: the gating loop layer determines the scores of the first semantic matching layer network parameters.
S207: and when the score of the first semantic matching layer network parameters is greater than or equal to a threshold value, determining the network parameters of the semantic matching layer as the first semantic matching layer network parameters by a gating circulating layer.
S208: and when the score of the first semantic matching layer network parameters is smaller than a threshold value, determining the network parameters of the semantic matching layer as second semantic matching layer network parameters by a gating circulation layer.
In some possible embodiments, after the semantic matching layer is input into a sample segment and the semantic matching is trained by the sample segment, the gating loop layer may obtain the semantic matching layer network parameters of the semantic matching layer (assuming the first semantic matching layer network parameters). And determining the scores of the semantic matching layer network parameters through a gating circulating layer, and judging the scores of the semantic matching layer network parameters. And when the score of the semantic matching layer network parameters is greater than or equal to a threshold value, determining the network parameters of the semantic matching layer as the first semantic matching layer network parameters by a gating circulation layer through an updating gate of the gating circulation layer. And when the score of the network parameters of the semantic matching layer is smaller than a threshold value, determining the network parameters of the semantic matching layer as second semantic matching layer network parameters by the gating circulation layer through a reset gate. The second semantic matching layer network parameters are semantic matching layer network parameters obtained after training the semantic matching layer of the reading and understanding model based on the question type labels of the question fragments included in the previous sample fragments, the question type labels of the questions answered by the answer fragments corresponding to the question fragments, the feature labels of the characters in the previous sample fragments and the position labels of the characters. Here, the preceding sample segment is a sample segment for training the semantic matching layer by inputting the reading understanding model before any of the sample segments.
In some possible embodiments, after a sample segment is input into the semantic matching layer, the gating loop layer may acquire the semantic matching layer network parameters of the semantic matching layer (assumed to be the first semantic matching layer network parameters) and store the parameters in the gating loop layer, perform comprehensive scoring on the semantic matching layer network parameters after the sample segment stored in the gating loop layer is input into the semantic matching layer (n is a positive integer greater than 1 and can be freely set by a user), and determine the comprehensive score of the semantic matching layer network parameters. And when the comprehensive score of the semantic matching layer network parameters is greater than or equal to a threshold value, determining the network parameters of the semantic matching layer as the first semantic matching layer network parameters by a gating circulation layer through an updating gate. And when the comprehensive score of the semantic matching layer network parameters is smaller than a threshold value, determining the network parameters of the semantic matching layer as second semantic matching layer network parameters by the gating circulation layer through a reset gate. The second semantic matching layer network parameters are semantic matching layer network parameters obtained after training the semantic matching layer of the reading and understanding model based on a question type label of a question segment included in a previous sample segment, a question type label of a question answered by an answer segment corresponding to the question segment, a feature label of each character in the previous sample segment and a position label of each character, and the previous sample segment is a sample segment input into the reading and understanding model before the n sample segments.
Specifically, the semantic matching layer network parameters of the semantic matching layer after the i (i is a positive integer) sample fragment is input are obtained, a gating circulating layer determines scores of the semantic matching layer network parameters, and the semantic matching layer network parameters are restored or updated to obtain i-th group of semantic matching layer network parameters. When the (i+1) th sample fragment is input into the semantic matching layer, training the semantic matching layer by utilizing the (i) th group of semantic matching layer network parameters, so that the semantic matching layer network parameters controlled by the gating circulating layer at the (i) th moment can be ensured to be applied to training the semantic matching layer at the (i+1) th moment.
S104: and determining the initial character position and the end character position of the answer text of the question to be understood based on the marked text to be understood through the semantic matching layer of the reading understanding model, and determining the answer text of the question to be understood.
In some possible embodiments, the noted questions to be understood and the segments of each article to be understood are input into a reading understanding model for semantic matching, and the starting character position (32) and the ending character position (43) of the answer text of the questions to be understood are determined in the articles to be understood through the reading understanding model so as to obtain the answer text of the questions to be understood (suggesting that the patient is bedridden and is light diet).
In the embodiment of the application, the semantic relevance of the to-be-understood problem and the to-be-understood article can be enhanced in the dimension of the problem type by marking the problem type of the to-be-understood problem in the to-be-understood text and the problem type answered by each to-be-understood article fragment; and marking the characteristics and the positions of the characters in the text to be understood after the type of the question is determined, and inputting the characters into a semantic matching layer, so that the semantic matching layer can read and understand the text to be understood at the character level, and the initial character position and the end character position of the answer text of the question to be understood are obtained in the article to be understood, thereby obtaining the answer text of the question to be understood, and improving the accuracy of reading and understanding.
Referring to fig. 3, fig. 3 is another flow chart of a text processing method according to an embodiment of the application.
S301: and the terminal equipment acquires the text to be understood.
In some possible embodiments, the terminal device obtains the text to be understood, where the text to be understood includes a question to be understood (e.g., question to be understood 1, etc.) and a plurality of article segments to be understood (e.g., article segment to be understood 1, article segment to be understood 2, etc.). For example, the terminal device may obtain the text to be understood including question 1 to be understood (how is the cold treated. In some application scenarios, the length of the article to be understood may be longer than the length range limited by the reading and understanding model, and then the article to be understood may be divided into a plurality of article segments to be understood, each article segment to be understood and the problem to be understood are combined, and the combined article segments to be understood and the problem to be understood are sequentially input into the reading and understanding model for reading and understanding. The specific determination may be determined according to the actual application scenario, and is not limited herein.
S302: and the terminal equipment inputs the text to be understood into a reading and understanding model, and determines the question type label of the question to be understood and the question type label of the question answered by each article fragment to be understood through a semantic analysis layer of the reading and understanding model.
In some possible embodiments, the terminal device may input the text to be understood into a trained reading understanding model, and perform question type labeling and semantic labeling on the text to be understood through a semantic analysis layer of the reading understanding model. For example, the semantic analysis layer of the understanding model may label the question types of the question 1 to be understood (how to treat the cold.
S303: and determining the feature labels of the characters in the text to be understood and the position labels of the characters through a semantic analysis layer of the reading and understanding model.
In some possible embodiments, the semantic analysis layer of the reading understanding model can simultaneously label the features of each character in the text to be understood and label the positions of each character, so as to obtain the labeled problem to be understood and each article fragment to be understood. The semantic annotation includes, but is not limited to, feature annotation of each character in the sample segment, and annotation of the location of each character. For example, the to-be-understood problem 1 after semantic annotation can be obtained by marking the features of each character of the to-be-understood problem in the to-be-understood text and marking the positions of each character (the positions in the to-be-understood text) through a reading understanding model: feel (gan, 13, [ 1 ]) like (ru, 6, [ 3 ]) (he, 7, [ 4 ]) treatment (zhi, 8, [ 5 ]) treatment (liao, 7, [ 6 ]? (#, #, [ 7 ]). A separator is added between question 1 to be understood and article segment 1 to be understood (position [ 8 ]). The semantic analysis layer of the reading and understanding model can obtain the article fragment 1 to be understood after semantic annotation: the infection (gan, 13, [ 9 ]) is (shi, 9, [ 11 ]) one (yi, 1, [ 12 ]) (zhong, 9, [ 13 ] ", see (jian, 11, [ 14 ]") for (jian, 4, [ 15 ] "), acute (ji, 9, [ 17 ]") for (xing, 8, [ 18 ] ", (hand, 3, [ 19 ]) for (hu, 8, [ 20 ]", [ xi,6, [ 21 ] ") for (dao, 11, [ 22 ]") for (bing, 9, [ 23 ] ", 9, [ 24 ]") for (xin, 8, [ 25 ] ", [ 14 ]", [ 26 ] "(29, 10,", [ 10 ] ", and (ng, 8, [ 25 ]). A separator (position 31) is added between the article fragment 1 to be understood and the article fragment 2 to be understood, for distinguishing the article fragment 1 to be understood from the article fragment 2 to be understood. The semantic analysis layer of the reading and understanding model can obtain the article fragment 2 to be understood after semantic annotation: build (jian, 8, [ 32 ]) to (yi, 5, [ 33 ]) to (huan, 11, [ 34 ]) to (zhe, 8, [ 35 ]) to (wo, 8, [ 36 ]) to (chuang, 7, [ 37 ]) to (xiu, 6, [ 38 ]) to (xi, 10, [ 39 ]) to (qin, 11, [ 40 ]) to (light (dan, 12, [ 41 ]) to (yin, 7, [ 42 ]) to (shi, 9, [ 43 ]).
S304: and determining a plurality of preselected initial character positions and a plurality of preselected termination character positions from the text to be understood by the semantic matching layer of the reading and understanding model based on the question type label to which the question to be understood belongs, the question type label of the question answered by each article fragment to be understood, the characteristic label of each character in the text to be understood and the position label of each character so as to obtain a plurality of preselected answer texts.
S305: and determining the scores of the pre-selected answer texts for answering the questions to be understood based on the matching degree of the pre-selected answer texts and the questions to be understood through the semantic matching layer.
In some possible embodiments, the pre-selected answer text and the question to be understood may be matrix-vectorized, and the similarity of the two matrices may be calculated as the matching degree of the pre-selected answer text and the question to be understood.
Specifically, the pre-selected answer text and the question to be understood can be subjected to matrix vectorization, the feature matrix of the question to be understood is calculated, the meaning represented by the feature matrix can be the keyword in the question to be understood, and the similarity between the pre-selected answer text matrix and the feature matrix of the question to be understood is calculated and used as the matching degree between the pre-selected answer text and the question to be understood.
S306: and taking the preselected initial character position and the preselected final character position of the preselected answer text with the highest score in the preselected answer texts as the initial character position and the final character position of the answer text of the question to be understood so as to obtain the answer text of the question to be understood.
In some possible embodiments, it may be determined whether a character distance between a start character position and a stop character position of the answer text of the question to be understood is within a threshold interval, if so, determining the answer text of the question to be understood from the answer text according to the start character position and the stop character position, and outputting the answer text of the question to be understood; if not, the output answer text does not exist. The length of the answer text can be further limited, and information irrelevant to the questions to be understood in the answer text is removed, so that redundancy of the answer text is reduced, and reading and understanding efficiency is further improved.
In the embodiment of the application, the semantic relevance of the to-be-understood problem and the to-be-understood article can be enhanced in the dimension of the problem type by marking the problem type of the to-be-understood problem in the to-be-understood text and the problem type answered by each to-be-understood article fragment; and marking the characteristics and the positions of the characters in the text to be understood after the type of the question is determined, and inputting the characters into a semantic matching layer, so that the semantic matching layer can read and understand the text to be understood at the character level, and the initial character position and the end character position of the answer text of the question to be understood are obtained in the article to be understood, thereby obtaining the answer text of the question to be understood, and improving the accuracy of reading and understanding.
Referring to fig. 4, fig. 4 is a schematic structural diagram of a text processing device according to an embodiment of the application.
The text obtaining module 401 is configured to obtain a text to be understood, where the text to be understood includes a question to be understood and a plurality of article segments to be understood.
In some possible embodiments, the text to be understood is obtained by the text obtaining module 401, where the text to be understood includes a question to be understood and a plurality of article segments to be understood. For example, the text acquisition module 401 acquires the text to be understood including the question to be understood 1 (how is the cold treated. In some application scenarios, the length of the article to be understood may be longer than the length range limited by the reading and understanding model, and then the article to be understood may be divided into a plurality of article segments to be understood, each article segment to be understood and the problem to be understood are combined, and the combined article segments to be understood and the problem to be understood are sequentially input into the reading and understanding model for reading and understanding. The specific determination may be determined according to the actual application scenario, and is not limited herein.
The classification labeling module 402 is configured to input the text to be understood into the semantic analysis layer, label the text to be understood with question types and label the semantics to obtain labeled questions to be understood and each article fragment to be understood, where the question types label includes labeling the question types to which the questions to be understood belong, and labeling the question types answered by each article fragment to be understood, and the semantic labels include labeling the characters in the text to be understood and labeling the positions of the characters.
In some possible implementations, the text to be understood may be question-type-annotated and semantically-annotated by the classification annotation module 402. The types of questions to be understood for question 1 (how cold is treated) are labeled "upper respiratory tract infection" and "method questions", the types of questions to be understood for questions answered by article segment 1 (cold is a common acute upper respiratory viral infectious disease) are labeled "upper respiratory tract infection" and "other questions", and the types of questions to be understood for questions answered by article segment 2 (patient bedridden advice, light diet) are labeled "upper respiratory tract infection" and "method questions".
The semantic annotation module 403 is configured to determine, through the semantic analysis layer of the reading understanding model, a feature annotation of each character in the text to be understood and a position annotation of each character.
In some possible embodiments, the semantic labeling module 403 may label the features of each character in the text to be understood and label the positions of each character simultaneously, so as to obtain the labeled problem to be understood and each article fragment to be understood. The semantic annotation includes, but is not limited to, feature annotation of each character in the sample segment, and annotation of the location of each character. For example, the semantic annotation module 403 performs feature annotation on each character of the problem to be understood in the text to be understood and marks the position of each character (the position in the text to be understood), so as to obtain the problem 1 to be understood after semantic annotation: feel (gan, 13, [ 1 ]) like (ru, 6, [ 3 ]) (he, 7, [ 4 ]) treatment (zhi, 8, [ 5 ]) treatment (liao, 7, [ 6 ]? (#, #, [ 7 ]). A separator is added between question 1 to be understood and article segment 1 to be understood (position [ 8 ]). Obtaining a semantic tagged article fragment 1 to be understood: the infection (gan, 13, [ 9 ]) is (shi, 9, [ 11 ]) one (yi, 1, [ 12 ]) (zhong, 9, [ 13 ] ", see (jian, 11, [ 14 ]") for (jian, 4, [ 15 ] "), acute (ji, 9, [ 17 ]") for (xing, 8, [ 18 ] ", (hand, 3, [ 19 ]) for (hu, 8, [ 20 ]", [ xi,6, [ 21 ] ") for (dao, 11, [ 22 ]") for (bing, 9, [ 23 ] ", 9, [ 24 ]") for (xin, 8, [ 25 ] ", [ 14 ]", [ 26 ] "(29, 10,", [ 10 ] ", and (ng, 8, [ 25 ]). A separator (position 31) is added between the article fragment 1 to be understood and the article fragment 2 to be understood, for distinguishing the article fragment 1 to be understood from the article fragment 2 to be understood. The semantic analysis layer of the reading and understanding model can obtain the article fragment 2 to be understood after semantic annotation: build (jian, 8, [ 32 ]) to (yi, 5, [ 33 ]) to (huan, 11, [ 34 ]) to (zhe, 8, [ 35 ]) to (wo, 8, [ 36 ]) to (chuang, 7, [ 37 ]) to (xiu, 6, [ 38 ]) to (xi, 10, [ 39 ]) to (qin, 11, [ 40 ]) to (light (dan, 12, [ 41 ]) to (yin, 7, [ 42 ]) to (shi, 9, [ 43 ]).
The semantic matching module 404 is configured to determine, by using the semantic matching layer of the reading understanding model, a start character position and an end character position of the answer text of the question to be understood based on the question type label to which the question to be understood belongs, the question type label of the question answered by the article segments to be understood, the feature label of each character in the text to be understood, and the position label of each character, and determine the answer text of the question to be understood from the text to be understood according to the start character position and the end character position.
In some possible implementations, the semantic matching module 404 may matrix vector the pre-selected answer text and the question to be understood and calculate the similarity of the two matrices as the match of the pre-selected answer text and the question to be understood.
In particular, the semantic matching module 404 may also perform matrix vectorization on the pre-selected answer text and the question to be understood, calculate a feature matrix of the question to be understood, and the meaning represented by the feature matrix may be a keyword in the question to be understood, and calculate the similarity between the pre-selected answer text matrix and the feature matrix of the question to be understood, as the matching degree between the pre-selected answer text and the question to be understood. And the preselected initial character position and the preselected end character position of the preselected answer text with the highest scores can be used as the initial character position and the end character position of the answer text of the question to be understood so as to obtain the answer text of the question to be understood, and at the moment, the matching degree of the answer text and the question to be understood is the highest.
In some possible embodiments, the semantic matching module 404 includes:
the text confirming unit is used for determining a plurality of preselected initial character positions and a plurality of preselected ending character positions from the text to be understood through the semantic matching layer of the reading and understanding model based on the question type label of the question to be understood, the question type label of the question answered by each article fragment to be understood, the characteristic label of each character in the text to be understood and the position label of each character so as to obtain a plurality of preselected answer texts.
And the answer scoring unit is used for determining the scores of the preselected answer texts for answering the questions to be understood based on the matching degree of the preselected answer texts and the questions to be understood through the semantic matching layer.
And the answer confirming unit is used for taking the preselected initial character position and the preselected final character position of the preselected answer text with the highest score in the preselected answer texts as the initial character position and the final character position of the answer text of the question to be understood so as to obtain the answer text of the question to be understood.
In some possible embodiments, the semantic matching module 404 further includes:
And the answer output unit is used for determining the text between the initial character position and the terminal character position from the text to be understood as the answer text of the question to be understood and outputting the answer text of the question to be understood if the character distance between the initial character position and the terminal character position of the answer text of the question to be understood is within a threshold value interval.
In the embodiment of the application, the semantic relevance of the to-be-understood problem and the to-be-understood article can be enhanced in the dimension of the problem type by marking the problem type of the to-be-understood problem in the to-be-understood text and the problem type answered by each to-be-understood article fragment; and marking the characteristics and the positions of the characters in the text to be understood after the type of the question is determined, and inputting the characters into a semantic matching layer, so that the semantic matching layer can read and understand the text to be understood at the character level, and the initial character position and the end character position of the answer text of the question to be understood are obtained in the article to be understood, thereby obtaining the answer text of the question to be understood, and improving the accuracy of reading and understanding.
Referring to fig. 5, fig. 5 is a schematic structural diagram of a terminal device according to an embodiment of the present application. As shown in fig. 5, the terminal device in this embodiment may include: one or more processors 501 and a memory 502. The processor 501 and the memory 502 are connected via a bus 503. The memory 502 is used for storing a computer program comprising program instructions, and the processor 501 is used for executing the program instructions stored in the memory 502 for performing the following operations:
Acquiring a text to be understood, wherein the text to be understood comprises a problem to be understood and a plurality of article fragments to be understood;
inputting the text to be understood into a reading and understanding model, and determining the question type label of the question to be understood and the question type label of the question answered by each article fragment to be understood through a semantic analysis layer of the reading and understanding model;
determining the feature labels of the characters in the text to be understood and the position labels of the characters through a semantic analysis layer of the reading understanding model;
determining the initial character position and the end character position of the answer text of the to-be-understood question based on the question type label of the to-be-understood question, the question type label of the question answered by the to-be-understood article fragment, the characteristic label of each character in the to-be-understood text and the position label of each character through the semantic matching layer of the reading and understanding model;
and determining the answer text of the to-be-understood question from the to-be-understood text according to the initial character position and the termination character position.
In some possible embodiments, the above processor 501 is further configured to:
collecting a plurality of sample fragments of reading and understanding texts, wherein the sample fragments comprise question fragments and answer fragments corresponding to the question fragments;
Determining a question type label of each question segment in each sample segment and a question type label of a question answered by each answer segment;
determining the feature labels of the characters in the sample fragments and the position labels of the characters;
and training the semantic analysis layer and the semantic matching layer of the reading and understanding model based on the question type label of each question segment, the question type label of the questions answered by each answer segment, the characteristic label of each character in the sample segment and the position label of each character.
In some possible embodiments, the processor 501 is configured to:
acquiring a first semantic matching layer network parameter obtained after training a semantic matching layer of the reading and understanding model based on a question type label which is included in any sample segment and to which a question segment belongs, a question type label which is corresponding to the question segment and to which a question is answered by an answer segment, a feature label of each character in any sample segment and a position label of each character;
determining the scores of the first semantic matching layer network parameters through a gating circulating layer of the reading understanding model;
When the score of the first semantic matching layer network parameter is greater than or equal to a threshold value, determining the network parameter of the semantic matching layer as the first semantic matching layer network parameter through the gating circulating layer;
when the score of the first semantic matching layer network parameter is smaller than a threshold value, determining the network parameter of the semantic matching layer as a second semantic matching layer network parameter through the gating circulating layer;
the second semantic matching layer network parameters are semantic matching layer network parameters obtained after training the semantic matching layer of the reading and understanding model based on a question type label of a question segment included in a previous sample segment, a question type label of a question answered by an answer segment corresponding to the question segment, a feature label of each character in the previous sample segment and a position label of each character, and the previous sample segment is a sample segment input into the reading and understanding model before any sample segment.
In some possible embodiments, the processor 501 is configured to:
determining a plurality of preselected initial character positions and a plurality of preselected termination character positions from the text to be understood through a semantic matching layer of the reading and understanding model based on the question type label to which the question to be understood belongs, the question type label of the question answered by each article fragment to be understood, the characteristic label of each character in the text to be understood and the position label of each character so as to obtain a plurality of preselected answer texts;
Determining the score of each pre-selected answer text for answering the question to be understood based on the matching degree of each pre-selected answer text and the question to be understood through the semantic matching layer;
and taking the preselected initial character position and the preselected final character position of the preselected answer text with the highest score in the preselected answer texts as the initial character position and the final character position of the answer text of the question to be understood so as to obtain the answer text of the question to be understood.
In some possible embodiments, the processor 501 is configured to:
if the character distance between the initial character position and the final character position of the answer text of the question to be understood is within the threshold value interval, determining the text between the initial character position and the final character position from the text to be understood as the answer text of the question to be understood, and outputting the answer text of the question to be understood.
In some possible embodiments, the processor 501 is configured to:
collecting a plurality of sample fragments of reading understanding texts from the Internet; and/or
Collecting a plurality of sample fragments of reading understanding texts from a target field database, wherein the target field database at least comprises a medical field database generated based on diagnosis and treatment data and pathology data of the medical field;
The sample fragments of each reading and understanding text comprise question fragments and answer fragments corresponding to the question fragments.
In some possible embodiments, the processor 501 may be a central processing unit (central processing unit, CPU), which may also be other general purpose processors, digital signal processors (digital signal processor, DSP), application specific integrated circuits (application specific integrated circuit, ASIC), off-the-shelf programmable gate arrays (field-programmable gate array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 502 may include read only memory and random access memory and provide instructions and data to the processor 501. A portion of memory 502 may also include non-volatile random access memory. For example, the memory 502 may also store information of device type.
In a specific implementation, the terminal device may execute, through each functional module built in the terminal device, an implementation manner provided by each step in fig. 1 to 3, and specifically, the implementation manner provided by each step may refer to an implementation manner provided by each step, which is not described herein again.
In the embodiment of the application, the semantic relevance of the to-be-understood problem and the to-be-understood article can be enhanced in the dimension of the problem type by marking the problem type of the to-be-understood problem in the to-be-understood text and the problem type answered by each to-be-understood article fragment; and marking the characteristics and the positions of the characters in the text to be understood after the type of the question is determined, and inputting the characters into a semantic matching layer, so that the semantic matching layer can read and understand the text to be understood at the character level, and the initial character position and the end character position of the answer text of the question to be understood are obtained in the article to be understood, thereby obtaining the answer text of the question to be understood, and improving the accuracy of reading and understanding.
The embodiment of the present application further provides a computer readable storage medium, where a computer program is stored, where the computer program includes program instructions, and when executed by a processor, implement the methods provided by the steps in fig. 1 to 3, and specifically refer to the implementation manners provided by the steps, which are not described herein.
The computer readable storage medium may be the prediction model-based user behavior recognition apparatus provided in any one of the foregoing embodiments or an internal storage unit of the terminal device, for example, a hard disk or a memory of an electronic device. The computer readable storage medium may also be an external storage device of the electronic device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a flash card (flash card) or the like, which are provided on the electronic device. Further, the computer-readable storage medium may also include both an internal storage unit and an external storage device of the electronic device. The computer-readable storage medium is used to store the computer program and other programs and data required by the electronic device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
The terms "first," "second," "third," "fourth" and the like in the claims and in the description and drawings of the present application are used for distinguishing between different objects and not for describing a particular sequential order. Furthermore, the terms "comprise" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus. Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments. The term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps described in connection with the embodiments disclosed herein may be embodied in electronic hardware, in computer software, or in a combination of the two, and that the elements and steps of the examples have been generally described in terms of function in the foregoing description to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The method and related apparatus provided in the embodiments of the present application are described with reference to the flowchart and/or schematic structural diagrams of the method provided in the embodiments of the present application, and each flow and/or block of the flowchart and/or schematic structural diagrams of the method may be implemented by computer program instructions, and combinations of flows and/or blocks in the flowchart and/or block diagrams. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks. These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or structural diagram block or blocks. These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or structures.

Claims (8)

1. A method of text processing, the method comprising:
acquiring a text to be understood, wherein the text to be understood comprises a question to be understood and a plurality of article fragments to be understood;
collecting a plurality of sample fragments of reading and understanding texts, wherein the sample fragments comprise question fragments and answer fragments corresponding to the question fragments;
determining a question type label of each question segment in each sample segment and a question type label of a question answered by each answer segment;
determining the feature labels of the characters in the sample fragments and the position labels of the characters;
acquiring a first semantic matching layer network parameter obtained after training a semantic matching layer of a reading and understanding model based on a question type label to which a question segment included in any sample segment belongs, a question type label of a question answered by an answer segment corresponding to the question segment, a feature label of each character in any sample segment and a position label of each character;
determining the scores of the first semantic matching layer network parameters through a gating circulating layer of the reading understanding model;
when the score of the first semantic matching layer network parameter is greater than or equal to a threshold value, determining the network parameter of the semantic matching layer as the first semantic matching layer network parameter through the gating circulating layer;
When the score of the first semantic matching layer network parameter is smaller than a threshold value, determining the network parameter of the semantic matching layer as a second semantic matching layer network parameter through the gating circulating layer;
the second semantic matching layer network parameters are semantic matching layer network parameters obtained after training the semantic matching layer of the reading and understanding model based on a question type label of a question segment included in a previous sample segment, a question type label of a question answered by an answer segment corresponding to the question segment, a feature label of each character in the previous sample segment and a position label of each character, and the previous sample segment is a sample segment input to the reading and understanding model before any sample segment;
inputting the text to be understood into a reading and understanding model, and determining the question type label of the question to be understood and the question type label of the question answered by each article fragment to be understood through a semantic analysis layer of the reading and understanding model;
determining the feature labels of the characters in the text to be understood and the position labels of the characters through a semantic analysis layer of the reading understanding model;
Determining the initial character position and the end character position of the answer text of the to-be-understood question based on the question type label of the to-be-understood question, the question type label of the question answered by the to-be-understood article fragment, the feature label of each character in the to-be-understood text and the position label of each character through the semantic matching layer of the reading and understanding model;
and determining the answer text of the to-be-understood question from the to-be-understood text according to the initial character position and the termination character position.
2. The method of claim 1, wherein the determining, by the semantic matching layer of the reading understanding model, a start character position and an end character position of the answer text of the question to be understood based on the question type label to which the question to be understood belongs, the question type label of the question answered by the article segments to be understood, the feature label of each character in the text to be understood, and the position label of each character comprises:
determining a plurality of preselected initial character positions and a plurality of preselected termination character positions from the text to be understood through a semantic matching layer of the reading and understanding model based on the question type label to which the question to be understood belongs, the question type label of the question answered by each article fragment to be understood, the characteristic label of each character in the text to be understood and the position label of each character so as to obtain a plurality of preselected answer texts;
Determining scores of the pre-selected answer texts for answering the questions to be understood based on the matching degree of the pre-selected answer texts and the questions to be understood through the semantic matching layer;
and taking the preselected initial character position and the preselected final character position of the preselected answer text with the highest score in the preselected answer texts as the initial character position and the final character position of the answer text of the questions to be understood.
3. The method of claim 2, wherein the determining the answer text of the question to be understood from the text to be understood based on the start character position and the end character position comprises:
and if the character distance between the initial character position and the end character position of the answer text of the question to be understood is within a threshold value interval, determining the text between the initial character position and the end character position from the text to be understood as the answer text of the question to be understood, and outputting the answer text of the question to be understood.
4. The method of claim 1, wherein collecting a plurality of sample segments of reading comprehension text comprises:
collecting a plurality of sample fragments of reading understanding texts from the Internet; and/or
Collecting a plurality of sample fragments of reading understanding texts from a target field database, wherein the target field database at least comprises a medical field database generated based on diagnosis and treatment data and pathology data of the medical field;
the sample fragments of each reading and understanding text comprise question fragments and answer fragments corresponding to the question fragments.
5. A text processing apparatus, the apparatus comprising:
the text acquisition module is used for acquiring a text to be understood, wherein the text to be understood comprises a question to be understood and a plurality of article fragments to be understood;
the model training module is used for collecting a plurality of sample fragments of reading and understanding texts, wherein the sample fragments comprise question fragments and answer fragments corresponding to the question fragments; determining a question type label of each question segment in each sample segment and a question type label of a question answered by each answer segment; determining the feature labels of the characters in the sample fragments and the position labels of the characters; acquiring a first semantic matching layer network parameter obtained after training a semantic matching layer of a reading and understanding model based on a question type label to which a question segment included in any sample segment belongs, a question type label of a question answered by an answer segment corresponding to the question segment, a feature label of each character in any sample segment and a position label of each character; determining the scores of the first semantic matching layer network parameters through a gating circulating layer of the reading understanding model; when the score of the first semantic matching layer network parameter is greater than or equal to a threshold value, determining the network parameter of the semantic matching layer as the first semantic matching layer network parameter through the gating circulating layer; when the score of the first semantic matching layer network parameter is smaller than a threshold value, determining the network parameter of the semantic matching layer as a second semantic matching layer network parameter through the gating circulating layer; the second semantic matching layer network parameters are semantic matching layer network parameters obtained after training the semantic matching layer of the reading and understanding model based on a question type label of a question segment included in a previous sample segment, a question type label of a question answered by an answer segment corresponding to the question segment, a feature label of each character in the previous sample segment and a position label of each character, and the previous sample segment is a sample segment input to the reading and understanding model before any sample segment;
The classification labeling module is used for inputting the text to be understood into a reading understanding model, and determining the question type label of the question to be understood and the question type label of the question answered by each article fragment to be understood through a semantic analysis layer of the reading understanding model;
the semantic annotation module is used for determining the feature annotation of each character in the text to be understood and the position annotation of each character through the semantic analysis layer of the reading and understanding model;
the semantic matching module is used for determining the initial character position and the end character position of the answer text of the question to be understood through the semantic matching layer of the reading understanding model based on the question type label to which the question to be understood belongs, the question type label of the question answered by each article fragment to be understood, the characteristic label of each character in the text to be understood and the position label of each character, and determining the answer text of the question to be understood from the text to be understood according to the initial character position and the end character position.
6. The apparatus of claim 5, wherein the semantic matching module comprises:
The text confirming unit is used for determining a plurality of preselected initial character positions and a plurality of preselected terminal character positions from the text to be understood through the semantic matching layer of the reading and understanding model based on the question type label of the question to be understood, the question type label of the question answered by each article fragment to be understood, the characteristic label of each character in the text to be understood and the position label of each character so as to obtain a plurality of preselected answer texts;
the answer scoring unit is used for determining the score of each pre-selected answer text for answering the question to be understood based on the matching degree of each pre-selected answer text and the question to be understood through the semantic matching layer;
and the answer confirming unit is used for taking the preselected initial character position and the preselected final character position of the preselected answer text with the highest score in the preselected answer texts as the initial character position and the final character position of the answer text of the questions to be understood.
7. A terminal device comprising a processor and a memory, the processor and the memory being interconnected, wherein the memory is adapted to store a computer program comprising program instructions, the processor being configured to invoke the program instructions to perform the method of any of claims 1-4.
8. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program comprising program instructions which, when executed by a processor, cause the processor to perform the method of any of claims 1-4.
CN202011501996.6A 2020-12-17 2020-12-17 Text processing method, device, equipment and storage medium Active CN112613322B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202011501996.6A CN112613322B (en) 2020-12-17 2020-12-17 Text processing method, device, equipment and storage medium
PCT/CN2021/097086 WO2022127040A1 (en) 2020-12-17 2021-05-31 Text processing method and apparatus, and device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011501996.6A CN112613322B (en) 2020-12-17 2020-12-17 Text processing method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112613322A CN112613322A (en) 2021-04-06
CN112613322B true CN112613322B (en) 2023-10-24

Family

ID=75241022

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011501996.6A Active CN112613322B (en) 2020-12-17 2020-12-17 Text processing method, device, equipment and storage medium

Country Status (2)

Country Link
CN (1) CN112613322B (en)
WO (1) WO2022127040A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112613322B (en) * 2020-12-17 2023-10-24 平安科技(深圳)有限公司 Text processing method, device, equipment and storage medium
CN113139033B (en) * 2021-05-13 2024-07-09 平安国际智慧城市科技股份有限公司 Text processing method, device, equipment and storage medium
CN117992600B (en) * 2024-04-07 2024-06-11 之江实验室 Service execution method and device, storage medium and electronic equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6615172B1 (en) * 1999-11-12 2003-09-02 Phoenix Solutions, Inc. Intelligent query engine for processing voice based queries
CN110309305A (en) * 2019-06-14 2019-10-08 中国电子科技集团公司第二十八研究所 Machine based on multitask joint training reads understanding method and computer storage medium
CN110609886A (en) * 2019-09-18 2019-12-24 北京金山数字娱乐科技有限公司 Text analysis method and device
CN111027327A (en) * 2019-10-29 2020-04-17 平安科技(深圳)有限公司 Machine reading understanding method, device, storage medium and device
CN111046158A (en) * 2019-12-13 2020-04-21 腾讯科技(深圳)有限公司 Question-answer matching method, model training method, device, equipment and storage medium
CN111046674A (en) * 2019-12-20 2020-04-21 科大讯飞股份有限公司 Semantic understanding method and device, electronic equipment and storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8275803B2 (en) * 2008-05-14 2012-09-25 International Business Machines Corporation System and method for providing answers to questions
US10424288B2 (en) * 2017-03-31 2019-09-24 Wipro Limited System and method for rendering textual messages using customized natural voice
CN109992665A (en) * 2019-03-14 2019-07-09 广州智语信息科技有限公司 A kind of classification method based on the extension of problem target signature
CN112613322B (en) * 2020-12-17 2023-10-24 平安科技(深圳)有限公司 Text processing method, device, equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6615172B1 (en) * 1999-11-12 2003-09-02 Phoenix Solutions, Inc. Intelligent query engine for processing voice based queries
CN110309305A (en) * 2019-06-14 2019-10-08 中国电子科技集团公司第二十八研究所 Machine based on multitask joint training reads understanding method and computer storage medium
CN110609886A (en) * 2019-09-18 2019-12-24 北京金山数字娱乐科技有限公司 Text analysis method and device
CN111027327A (en) * 2019-10-29 2020-04-17 平安科技(深圳)有限公司 Machine reading understanding method, device, storage medium and device
CN111046158A (en) * 2019-12-13 2020-04-21 腾讯科技(深圳)有限公司 Question-answer matching method, model training method, device, equipment and storage medium
CN111046674A (en) * 2019-12-20 2020-04-21 科大讯飞股份有限公司 Semantic understanding method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
WO2022127040A1 (en) 2022-06-23
CN112613322A (en) 2021-04-06

Similar Documents

Publication Publication Date Title
CN111738004B (en) Named entity recognition model training method and named entity recognition method
CN112613322B (en) Text processing method, device, equipment and storage medium
CN109033068B (en) Method and device for reading and understanding based on attention mechanism and electronic equipment
WO2021072852A1 (en) Sequence labeling method and system, and computer device
CN109840287A (en) A kind of cross-module state information retrieval method neural network based and device
WO2021139229A1 (en) Text rhetorical sentence generation method, apparatus and device, and readable storage medium
CN111191002A (en) Neural code searching method and device based on hierarchical embedding
CN115599901B (en) Machine question-answering method, device, equipment and storage medium based on semantic prompt
CN112420205B (en) Entity recognition model generation method, entity recognition model generation device and computer readable storage medium
CN112599213B (en) Classification code determining method, device, equipment and storage medium
CN111694937A (en) Interviewing method and device based on artificial intelligence, computer equipment and storage medium
CN113707299A (en) Auxiliary diagnosis method and device based on inquiry session and computer equipment
CN112507061A (en) Multi-relation medical knowledge extraction method, device, equipment and storage medium
CN110688450A (en) Keyword generation method based on Monte Carlo tree search, keyword generation model based on reinforcement learning and electronic equipment
CN111145914A (en) Method and device for determining lung cancer clinical disease library text entity
CN113657105A (en) Medical entity extraction method, device, equipment and medium based on vocabulary enhancement
CN114708976A (en) Method, device, equipment and storage medium for assisting diagnosis technology
CN115238026A (en) Medical text subject segmentation method and device based on deep learning
CN113704481B (en) Text processing method, device, equipment and storage medium
CN113688207A (en) Modeling processing method and device for reading and understanding structure based on network
CN115081452B (en) Method for extracting entity relationship
CN116595994A (en) Contradictory information prediction method, device, equipment and medium based on prompt learning
CN114372467A (en) Named entity extraction method and device, electronic equipment and storage medium
CN111562943A (en) Code clone detection method and device based on event embedded tree and GAT network
CN115238700B (en) Biomedical entity extraction method based on multitask learning

Legal Events

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