Text processing apparatus, method, device and computer-readable recording medium

The text processing method integrates external information through encoding and decoding hidden states, enhancing the probability of its inclusion in text processing results, addressing the limitations of conventional methods.

JP7555701B2Active Publication Date: 2024-09-25NTT DOCOMO INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
JP2019209173
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2019-09-20
Filing Date
2019-11-19
Publication Date
2024-09-25
Estimated Expiration
2039-11-19

AI Technical Summary

Technical Problem

Conventional text processing methods fail to effectively incorporate external information specified by users or associated with the source text, leading to suboptimal processing results.

Method used

A text processing method and apparatus that encodes source text and determines decoding hidden states, utilizing an output unit to consider external information in determining output words based on encoding and decoding hidden states, and adjusting thresholds and attention distributions to prioritize external information inclusion.

Benefits of technology

Enhances the probability of external information appearing in text processing results by effectively integrating user-specified or associated information, improving the effectiveness of text generation processes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007555701000021
    Figure 0007555701000021
  • Figure 0007555701000022
    Figure 0007555701000022
  • Figure 0007555701000023
    Figure 0007555701000023
Patent Text Reader

Abstract

To provide a text processing apparatus, method, and device for displaying external information in a result of text processing, and a computer-readable recording medium.SOLUTION: A text processing apparatus 100 includes: an encoding unit which encodes a source text to acquire a source-text encoding hidden state; a decoding unit which determines a decoding hidden state; and an output unit which determines output word probability distribution on the basis of external information, the source-text encoding hidden state, and the decoding hidden state, for determining an output word.SELECTED DRAWING: Figure 1
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The present disclosure relates to the field of text processing, and more particularly to a text processing apparatus, method, device and computer readable medium. [Background technology]

[0002] In conventional text processing, in processes such as text conversion and text generation, a final text processing result can be obtained by processing an input source text.

[0003] In some cases, the user can specify some external information for the text processing process to obtain more ideal results. Such external information may be important information in the text specified by the user, or other text information associated with the source text. In order to increase the possibility that such external information will appear in the text processing result, a text processing method that fully considers the external information in the text processing process is required. Summary of the Invention [Means for solving the problem]

[0004] In order to fully take external information into account in the text processing process, the present disclosure provides a text processing method, an apparatus, a device and a computer-readable recording medium.

[0005] According to one aspect of the present disclosure, there is provided a text processing apparatus including: an encoding unit configured to encode a source text to obtain a source text encoded hidden state; a decoding unit configured to determine a decoded hidden state; and an output unit configured to determine an output word probability distribution based on external information, the source text encoded hidden state, and the decoded hidden state to determine output words.

[0006] In some embodiments, the output unit is configured to select, based on the external information, a candidate output word having a probability equal to or greater than an output probability threshold and having a probability corresponding to the external information. Included The word is configured to be determined as a candidate output word for the current time step.

[0007] In some embodiments, the output unit is further configured to determine candidate probabilities of the candidate output words based on a joint probability between a candidate output word of a current time step and a candidate sequence determined in a previous time step, and a similarity between the candidate sequence determined in the previous time step and the external information, and to determine a predetermined number of candidate output words with the highest candidate probabilities as output words.

[0008] In some embodiments, the encoding unit is further configured to encode the extrinsic information to obtain an extrinsic information encoded hidden state, and the output unit is configured to determine a similarity between the extrinsic information encoded hidden state and the decoded hidden state, and to output the extrinsic information as an output word if the similarity is greater than or equal to a similarity threshold for a current time step.

[0009] In some embodiments, the output unit is further configured to: determine a word with the highest probability in the output word probability distribution as an output word for a current time step if the similarity is less than the current similarity threshold; and adjust the similarity threshold for the current time step to determine an adjusted similarity threshold to be used as the similarity threshold for a next time step, the adjusted similarity threshold being less than the similarity threshold for the current time step.

[0010] In some embodiments, the text processing apparatus further includes an attention generation unit configured to determine an attention distribution for a current time step based on the external information, the source text encoding hidden state and the decoded hidden state, and the output unit configured to determine an output word probability distribution based on the attention distribution, the source text encoding hidden state and the decoded hidden state to determine output words.

[0011] In some embodiments, the encoder and decoder are trained by the steps of: encoding a training source text to obtain a training source text encoded hidden state; determining a training decoded hidden state; determining output words for a current time step based on the external information, the training source text encoded hidden state, and the training decoded hidden state; and adjusting parameters in the encoder and decoder so that differences between training output words and words included in the external information are minimized.

[0012] According to another aspect of the present disclosure, there is further provided a text processing method including the steps of encoding a source text to obtain a source text encoded hidden state, determining a decoded hidden state, and determining an output word probability distribution based on external information, the source text encoded hidden state, and the decoded hidden state to determine output words.

[0013] In some embodiments, the method further comprises: selecting, based on the external information, among the candidate output words, those having a probability equal to or greater than an output probability threshold and having a probability not greater than the external information. Included The method further includes determining the word as a candidate output word for the current time step.

[0014] In some embodiments, the method further includes determining candidate probabilities of the candidate output words based on a joint probability between a candidate output word of a current time step and a candidate sequence determined in a previous time step, and a similarity between the candidate sequence determined in the previous time step and the external information, and determining a predetermined number of candidate output words with the highest candidate probabilities as output words.

[0015] In some embodiments, the method further comprises the steps of encoding the extrinsic information to obtain an extrinsic information encoded hidden state; determining a similarity between the extrinsic information encoded hidden state and the decoded hidden state, and outputting the extrinsic information as an output word if the similarity is greater than or equal to a similarity threshold for a current time step.

[0016] In some embodiments, the method further comprises determining a most probable word in the output word probability distribution as the output word of the current time step if the similarity is less than the current similarity threshold, and adjusting the similarity threshold of the current time step to determine an adjusted similarity threshold to be used as the similarity threshold of the next time step, the adjusted similarity threshold being less than the similarity threshold of the current time step.

[0017] In some embodiments, the method further comprises determining an attention distribution for a current time step based on the extrinsic information, the source text encoding hidden state, and the decoded hidden state, and determining an output word probability distribution based on the extrinsic information, the source text encoding hidden state, and the decoded hidden state to determine output words comprises determining an output word probability distribution based on the attention distribution, the source text encoding hidden state, and the decoded hidden state to determine output words.

[0018] According to yet another aspect of the present disclosure, there is provided a text processing device including a processor and a memory having computer readable programming commands stored therein, the computer readable programming commands being configured to perform the text processing method as described above when executed by the processor.

[0019] According to yet another aspect of the present disclosure, there is provided a computer readable storage medium having computer readable instructions recorded thereon which, when executed by a computer, cause the computer to carry out a text processing method as described above. Effect of the Invention

[0020] By utilizing the text processing method, apparatus, device, and computer-readable recording medium disclosed herein, in the text generation process, external information is used to determine the attention distribution of the current time step, and / or the output words of the current time step are determined based on the external information, thereby effectively taking into account the content of the external information in the text processing process and improving the probability of generating external information in the text generation process, and when external information is taken into account, the effect of generating text can be improved. [Brief description of the drawings]

[0021] The embodiments of the present disclosure will be described in more detail with reference to the drawings. The above and other objects, features and advantages of the present disclosure will be more apparent. The drawings are for further understanding of the embodiments of the present disclosure, and are used to interpret the present disclosure together with the embodiments of the present disclosure as part of the specification, and are not intended to limit the present disclosure. In the drawings, the same reference numerals generally indicate the same parts or steps.

[0022] [Figure 1] 1 shows a schematic block diagram of a text processing device according to the present disclosure; [Figure 2A] 1 illustrates a schematic embodiment of determining candidate output words based on output probability distributions according to an embodiment of the present application; [Figure 2B] 1 illustrates a schematic embodiment of determining candidate output words based on output probability distributions according to an embodiment of the present application; [Figure 3A] 1 shows a schematic block diagram of an attention generation unit according to an embodiment of the present disclosure. [Figure 3B] 1 illustrates a schematic process of an attention generation unit according to an embodiment of the present application determining an attention distribution for a current time step. [Figure 4] FIG. 2 shows another schematic block diagram of an attention generation unit according to an embodiment of the present application. [Diagram 5] FIG. 2 shows another schematic block diagram of a text processing apparatus according to an embodiment of the present application. [Figure 6] 1 shows a schematic flow chart of a text processing method according to the present application; [Figure 7] 1 illustrates a schematic flow chart of determining attention distribution for a current time step based on external information according to an embodiment of the present application; [Figure 8] 13 illustrates another schematic flowchart of determining attention distribution for a current timestep based on external information according to an embodiment of the present application. [Figure 9] 4 shows a schematic flowchart of another text processing method according to an embodiment of the present application; [Figure 10] 4 illustrates an exemplary flowchart of another text processing method according to an embodiment of the present application. [Figure 11] FIG. 2 is a schematic diagram of a computing device according to an embodiment of the present disclosure. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0023] Hereinafter, the technical solutions of the embodiments of the present disclosure will be described clearly and comprehensively with reference to the drawings in the embodiments of the present disclosure. It is clear that the described embodiments are only some of the embodiments of the present disclosure, and not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative labor are included in the scope of protection of the present disclosure.

[0024] Unless otherwise defined, technical or scientific terms used herein have the ordinary meanings that are understood by those skilled in the art. The words "first", "second" and similar words used in this application do not indicate any order, number or importance, but are merely used to distinguish different components. Similarly, words such as "comprise" and "include" and similar words refer to the part or thing that appears before the word including the part or thing listed after the word and its equivalents, and do not exclude other parts or things. Words such as "connect" and "connect to each other" and similar words are not limited to physical or mechanical connection, but also include electrical connection, whether direct or indirect. Words such as "upper", "lower", "left", "right" and the like are used merely to indicate relative positional relationships, and after the absolute position of the described object is changed, the relative positions may be changed accordingly.

[0025] The principles of the present disclosure are described below by taking the generation of text summaries as an example, however, those skilled in the art can understand that the method provided by the present disclosure may also be applied to other text processing processes, such as text conversion processes, machine translation processes, etc., without departing from the principles of the present disclosure.

[0026] FIG. 1 shows a schematic block diagram of a text processing device according to the present disclosure. As shown in FIG. 1, the text processing device 100 may include an encoding unit 110, a decoding unit 120, an attention generating unit 130, and an output unit 140. The text processing device 100 may perform text processing on a source text I to generate a corresponding text processing result. For example, the text processing device 100 may be used to generate a summary for the source text I. The source text I may include at least one sentence, and each sentence includes at least one word.

[0027] The text processing device 100 provided by the present disclosure can receive external information and perform a text processing process on the source text based on the external information. In some embodiments, the external information refers to predefined text information expected as a processing result of the source text. In some examples, the external information is at least one word or sentence in the source text. In some other examples, the external information is a word or sentence at a predetermined position in the source text, for example, the first sentence, the last sentence, or any other specified position of the text information in the source text. In some other examples, the external information is additional text associated with the source text. For example, the title of the source text. In some implementations, the external information may be additional text determined based on a user's input. The present application is not limited to a method for determining the external information here. In fact, the external information used in the text processing process may be determined in any possible manner.

[0028] When processing source text using the text processing device 100, the probability that the external information will appear in the text processing result can be increased by considering external information at each stage of text processing. For example, if the title of a sentence in the source text is determined as external information, words and / or sentences in the sentence title will definitely appear or will very likely appear in the summary of the source text output from the text processing device 100 provided by the present application.

[0029] When performing a text processing method on a computer, the computer often cannot process text data directly, so when processing source text and / or external information, the source text needs to be converted into numerical data first.

[0030] In some embodiments, the source text I is implemented in the form of a natural language. In this case, the text processing apparatus 100 may further include a pre-processing unit (not shown). The pre-processing unit may be used to convert the source text into numerical data before the source text is input to the encoding unit. For example, a word segmentation process may be performed on each sentence in the source text I, thereby splitting each sentence into a plurality of words. Then, for example, the plurality of words obtained by the word segmentation process may be converted into a word vector of a certain dimension by a method of word embedding.

[0031] Similarly, the extrinsic information may be transformed to obtain at least one word vector corresponding to the extrinsic information for subsequent text processing.

[0032] In some embodiments, the source text I according to the present disclosure may be realized in the form of numerical data, for example, the source text I may be represented by at least one word vector. In this case, the encoding unit 110 may directly process the source text I. Alternatively, a preprocessing device provided independently of the text processing device 100 may perform preprocessing on the natural language.

[0033] In the following, no distinction will be made as to whether the external information and the source text are in the form of natural language or in the form of numerical data. When it is necessary to use a computer to process the external information and / or the source text in the form of natural language, those skilled in the art may convert the external information and / or the source text in the form of natural language into numerical data as necessary.

[0034] The encoding unit 110 may be configured to encode a source text I to be processed in order to obtain a source text encoded hidden state h.

[0035] In some embodiments, the encoding unit 110 may be implemented as an encoding network. An exemplary encoding network includes a long short-term memory (LSTM) network, and an LSTM network system may be applied to tasks such as machine translation, text summary generation, etc. Note that the encoding network may be implemented as any machine learning model capable of encoding word vectors.

[0036] For example, when at least one word vector corresponding to a source text I is input, the encoder may output source text coding hidden states h1, h2, h3... corresponding to each word vector x1, x2, x3... respectively. The number of source text coding hidden states and the number of source text word vectors may be the same or different. For example, when generating k word vectors based on a source text I, the encoder may process these k word vectors to generate k corresponding source text coding hidden states, where k is an integer greater than 1.

[0037] The decoder 120 may be used to determine the decoded hidden state s of the current time step. In some embodiments, the decoder 120 may determine the decoded hidden state s of the current time step. t To obtain the hidden state s t-1 , and the output word x obtained by the text processing device in the previous time step. t Receive s t-1 and x t In the processing of the first time step, s0 and x1 may be determined as default initial values. The decoded hidden state s may include multiple decoded hidden states s1, s2, s3, ... corresponding to the source text I.

[0038] In some embodiments, the decoding unit 120 may be implemented as a decoding network. Exemplary decoding networks include long-short-term memory networks. However, the decoding network may be implemented as any machine learning model capable of decoding the output of the encoding network.

[0039] In some embodiments, the encoding and decoding networks may be denoted as a sequence-to-sequence (Seq2Seq) model and may be used to realize the conversion of one input sequence, e.g., "WXYZ" (e.g., as input text), to another output sequence, e.g., "AXY" (e.g., as a text summary).

[0040] The attention generation unit 130 may be configured to determine an attention distribution A based on the source text encoding hidden state h and the decoded hidden state s, and output the attention distribution A for a subsequent text processing process of the current time step.

[0041] In some embodiments, the attention distribution A at the current time step t t may be the coded attention distribution of the source text.

[0042] In some implementations, at each time step t, the source text encoding hidden state h t and the decoded hidden state s t Using this, we estimate the coding attention distribution a of the source text at the current time step. t For example, we can use equations (1) and (2) to determine the coding attention distribution a t may be determined. a t = softmax(e t ) (1) t denotes the current time step, softmax denotes the regularized exponential function, and e t is determined by equation (2) as follows:

number

[0043] In some other embodiments, the attention generation unit 130 may generate an attention distribution a of the source text determined by the external information and Equation (1). t Based on the attention distribution A of the current time step including external information t Then, for each subsequent part processing process, attention distribution A t may be output.

[0044] In some implementations, the attention distribution A for the current time step includes external information. t uses external information to estimate the attention distribution a of the source text. t may be determined after adjusting for

[0045] In some other implementations, the attention distribution A of the current time step including external information is t is the attention distribution of the source text a t and the attention distribution a' of external information t It may include both.

[0046] Hereinafter, referring to Figs. 3A, 3B, and 4, attention distribution A including external information will be described. t The decision process will not be described in detail here.

[0047] The output unit 140 may be configured to determine an output word probability distribution based on the attention distribution A, the source text encoding hidden state h, and the decoded hidden state s to determine an output word O for the current timestep.

[0048] The output word probability distribution is the generation probability distribution P vocab The probability distribution P generated by equations (3) and (4) may be vocab may be determined.

number

number

[0049] In some embodiments, the output word probability distribution is the attention distribution A output from the attention generation unit 130. t may include:

[0050] For example, the output word probability distribution may be determined by weighting and adding the generated probability distribution and the attention distribution A.

[0051] In some implementations, the source text encoded hidden state of the current time step, the decoded hidden state, the attention distribution, and the input x t Based on the weighting coefficient P for the probability distribution and attention distribution gen may be determined.

[0052] For example, a weighting coefficient P for performing weighted addition on the generated probability distribution and the attention distribution genmay be represented by equation (5).

number

[0053] Attention Distribution A t The attention distribution of the source text a t and the attention distribution a' of external information t When both are included, the attention distribution of the source text a t and the attention distribution a' of external information t The weighting coefficient parameters of the generated probability distribution P vocab , the attention distribution of the source text a t and the attention distribution a' of external information t The method of determining each of the weighting coefficient parameters will be described below, and will not be described in detail here.

[0054] In some implementations, the output unit 140 may determine the word with the highest probability in the output word probability distribution to be the output word for the current timestep.

[0055] In some other embodiments, the output unit 140 may determine and output a word probability distribution based on external information to determine the output word for the current time step.

[0056] In some implementations, the output unit 140 selects, based on the external information, among the candidate output words, those having a probability equal to or greater than an output probability threshold and corresponding to the external information. Included In some examples, the output unit 140 may determine the candidate output words using the beam search principle.

[0057] For example, the output unit 140 may determine at least two words in each time step as candidate output words for the current time step, and then use the candidate output words in the text processing process of the next time step. Similarly, the output unit 140 may determine at least two candidate output words for the next time step.

[0058] Specifically, taking the number of candidate output words as an example, two candidate output words a, b can be output at time step t. Then, the candidate output words a, b can be used in the text processing process of the next time step to determine the candidate output words c, d at time step t+1.

[0059] 2A and 2B illustrate an example embodiment of determining candidate output words based on output probability distributions according to an embodiment of the present application.

[0060] In some embodiments, when determining candidate output words for each time step, a predetermined number M (in the above example, M is 2) of words with the highest output probability in the output probability distribution are determined as candidate output words, where M is an integer equal to or greater than 2.

[0061] In the output word probability distribution shown in FIG. 2A, the two words with the highest output probabilities are w3 and w11, so w3 and w11 are determined as the candidate output words.

[0062] In some other embodiments, when determining the candidate output words for each time step, N words with the highest output probability in the output probability distribution are selected and determined in a predefined manner, and M words among these N words are determined as the candidate output words, where N is an integer greater than M. In some implementations, the value of N may be specified in advance.

[0063] In some other implementations, an output probability threshold may be determined in advance, and M words among the N words whose output probabilities are greater than the output probability threshold may be determined as candidate output words.

[0064] Among the N words with the highest output probability, Included If the word is not present, the M words among these N words with the highest output probabilities may be determined as candidate output words.

[0065] Among the N words with the highest output probability, Included If a word exists, then it is present in these N words, and the external information Included If the number of words n is M or more, the word with the highest output probability and the lowest external information is selected. Included Determine M words as candidate output words, and consider the external information present in N words. Included If the number of words n is smaller than a predetermined number M, then among the N words, Included The word and the Mn words with the highest output probabilities among the remaining Nn words are determined as candidate output words.

[0066] As shown in Fig. 2B, the two highest words in the output word probability distribution are w3 and w11. The words with output probabilities greater than the preset output probability threshold include w3, w7, and w11. W2 and w7 are the words that are most likely to be affected by the external information. Included .

[0067] In this case, w7 is the external information. Included And because the output probability of w7 is greater than the output probability threshold, w7 and w11 are selected as candidate output words, rather than selecting w3, which has a higher output probability.

[0068] In this way, the probability that a word in the external information is determined as an output word can be increased.

[0069] At least four output candidate sequences ac, ad, bc, bd can be determined using the candidate output words a, b output at time step t and the candidate output words c, d at time step t+1, and the output probability of each output candidate sequence is determined by a joint probability method, and the two with the highest output probabilities among the four output sequence candidates ac, ad, bc, bd are determined as candidate texts after time step t+1.

[0070] For example, the output probability of candidate output words a, b, c, and d is P a , P b , P c and P d The output candidate sequences ac, ad, bc, and bd are each expressed as P ac =P a *P c , P ad =P a *P d , P bc =P b *P c , and P bd =P b *P d It can be shown that P ac >P ad >P bc >P bd If so, then the output sequence ac,ad at time step t+1 is used for subsequent text processing.

[0071] In some embodiments, the output candidate sequence may be determined based on external information. For example, the penalty value of the output candidate sequence may be determined using formula (6). The penalty value determined by formula (6) may adjust the joint output probability of the output candidate sequence.

number

[0072] In one implementation, any possible text similarity algorithm may be used to determine the similarity between the candidate text sequence generated before time step t and the external information. For example, a cosine similarity method may be used to determine the similarity between the candidate text sequence generated before time step t and the external information.

[0073] Using the above formula (6), the higher the similarity between the candidate text sequence generated before time step t and the external information, the more the penalty value is used to increase the output probability of the output candidate sequence. In some implementations, the penalty value s(x,y) can be multiplied or added to the output probability in the output candidate sequence to achieve the effect of determining the output candidate sequence based on the similarity between the candidate text sequence generated before time step t and the external information.

[0074] That is, by determining the penalty value to be used for the output candidate sequence based on extrinsic information, the probability that the extrinsic information will appear in the candidate text sequence can be increased, thereby increasing the probability that the extrinsic information will appear in the final output text processing result.

[0075] In another implementation, the output unit may be further configured to determine a similarity between external information and the source text encoding hidden state, and determine a word to be output at the current time step based on the similarity between the external information and the source text encoding hidden state.

[0076] For example, the encoding unit 110 may be used to encode the extrinsic information to obtain an extrinsic information encoded hidden state.

[0077] The output unit 140 may be configured to determine a similarity between the extrinsic information encoded hidden state and the decoded hidden state, and if the similarity between the extrinsic information encoded hidden state and the decoded hidden state is greater than or equal to a predefined similarity threshold, the output unit outputs the extrinsic information as the output of the current time step.

[0078] If the extrinsic information is a word, the extrinsic information may be output as the word of the current time step. If the extrinsic information is a sentence, the extrinsic information may be directly inserted after the text sequence generated before the current time step t.

[0079] It should be noted that the text sequence already generated before the current time step t may be generated based on the most probable word in the output probability distribution, or based on some candidate output words with the most probabilities in the output probability distribution. The process described in the implementation method above may be adopted to determine the candidate output words, and will not be described in detail here.

[0080] If the similarity between the external information encoded hidden state and the decoded hidden state is smaller than a predefined similarity threshold, the output unit determines an output word probability distribution for the current time step based on the results output from the decoding unit and the attention generation unit, and determines an output word for the current time step based on the output word probability distribution for the current time step.

[0081] Using the above method, if the similarity between the result output from the decoding unit and the external information is relatively high, the result output from the decoding unit may be directly replaced with the external information, i.e., in this case, the result of the text sequence determined after the output of the current time step is the result obtained by inserting the external information after the text sequence determined after the output of the previous time step.

[0082] Then, when processing the next time step, the decoder can use the extrinsic information to encode the extrinsic information to obtain the decoded hidden state of the next time step, so that the subsequent decoding process can use the results of the extrinsic information, thereby ensuring semantic consistency between the results obtained in the subsequent decoding and the inserted extrinsic information.

[0083] When the external information is a word, the decoded hidden state of the previous time step and the external information are used as input to the decoding unit for processing, and the decoded hidden state of the current time step can be obtained.

[0084] When the external information contains multiple words, the decoder performs several loop processes. The inputs to the decoder in the first loop are the decoded hidden state of the previous time step and the first word of the external information, and the inputs to the decoder in the subsequent loops are the decoded hidden state obtained in the previous loop and the next word of the external information. By performing several loops, it is possible to process each word in the external information, and a decoded hidden state containing all the external information is obtained and used as the decoded hidden state of the current time step.

[0085] In some implementations, after the extrinsic information has already replaced the result output by the decoder and inserted into the text processing result, no similarity comparison between the extrinsic information encoded hidden state and the decoded hidden state is performed.

[0086] In some examples, the similarity threshold may be implemented by a function with respect to a given time step t.

[0087] As described above, if the similarity between the external information encoded hidden state and the decoded hidden state is smaller than a predefined similarity threshold, the operation of replacing the decoder output with the external information to output it is not performed, and the output result is determined based on the output word probability distribution. In this case, in order to increase the probability that the external information appears in the final text processing result, the similarity threshold of the current time step is adjusted to determine an adjusted similarity threshold, the adjusted similarity threshold is smaller than the similarity threshold of the current time step, and the adjusted similarity threshold is used as the similarity threshold of the next time step.

[0088] For example, the similarity threshold is adjusted using equation (7).

number

number

[0089] By using the above method to perform a monotonically decreasing adjustment of the similarity threshold for each time step, the similarity between the external information and the output result of the decoding unit is reduced to a lower level in the text processing process, so that the probability that the similarity between the external information and the output result of the decoding unit will be greater than the similarity threshold of the current time step increases, i.e., the probability that the external information will appear in the final text processing result increases.

[0090] In the process of generating a text summary, the text processing device 100 provided by the present application uses external information to determine the attention distribution of the current time step, and / or determines the output words of the current time step based on the external information, thereby effectively taking the content of the external information into account in the text processing process, increasing the probability of generating external information in the text generation process, and improving the effect of text generation when external information is taken into account.

[0091] When implementing the text processing device 100 provided by the present application, a person skilled in the art may make any combination of the above technical solutions. For example, in the process of performing text processing on the source text in the text processing device 100, only the attention generation unit may be used to generate an attention distribution including external information based on external information, and the attention distribution may be used in subsequent text processing, and the external information may not be taken into consideration in the subsequent text processing process. For example, only the output unit may be used to determine the word to be output in the current time step based on external information, and the external information may not be taken into consideration in the previous encoding, decoding, and attention generation processes. Furthermore, the attention generation unit may consider external information in the process of generating the attention distribution for the current time step, and the output unit may consider external information in the process of determining the word to be output in the current time step, thereby further increasing the possibility that the text processing result includes external information.

[0092] FIG. 3A shows a schematic block diagram of an attention generation unit according to an embodiment of the present disclosure. The attention generation unit 300 shown in FIG. 3A is used to generate an attention distribution a of a source text based on external information. t We can determine the attention distribution A' by adjusting the focus vector A and including external information.

[0093] As shown in FIG. 3A, the attention generation unit 300 includes a source text attention determination unit 310 and a content selection unit 320.

[0094] The source text attention determination unit 310 determines an encoding attention distribution a of the source text based on the source text encoding hidden state and the decoded hidden state. t In some embodiments, the coded attention distribution a of the source text is determined using the above formula (1). t can be determined.

[0095] The content selector 320 may be used to determine a selection probability for each word in a source text. In some implementations, the content selector 320 may be used to determine a selection probability distribution for the source text based on external information, the selection probability distribution including a selection probability for each word for the source text.

[0096] In some implementations, content selector 220 may utilize a content selection network (eg, an LSTM network) to process source text I and determine a first selection probability for each word in the source text.

[0097] A reference text processing result ref (i.e., a text processing result of a predetermined training data) is used to train the content selection network to be used. In the training process of the content selection network, a tagging sequence generated based on a source text I and the reference text processing result ref is input to the content selection network for processing. The tagging sequence and the word sequence of the source text I have the same length, and the value of the i-th element of the tagging sequence is determined by the i-th word of the source text I in the reference text processing result ref. Included By using the above method to train a content selection network, the content selection network can process a source text I and output a first selection probability result for each word in the source text, where the first selection probability indicates the probability that this word in the source text I will be selected based on the content selection network and appear in the final text processing result.

[0098] In some embodiments, the source text includes: Included For at least one word, a selection probability of the at least one word may be determined to be at least a predefined probability value λ. For example, Included The second-choice probability of a word is determined to a predefined probability value λ, and the external information is Not included The second choice probability of other words is determined to be 0.

[0099] A selection probability for each word in the source text may be determined based on the first selection probability and the second selection probability. For example, the selection probability for each word in the source text may be determined as the sum of the first selection probability and the second selection probability. As can be seen from the above, Included For a word, its selection probability is greater than or equal to a predefined probability value λ.

[0100] Based on the selection probability distribution, the content selection unit 220 is used to determine, for each word in the source text, the attention of the word according to the selection probability of the word, to obtain an attention distribution A. In some embodiments, the content selection unit 220 may be configured to determine the attention used for the word in the attention distribution of the current time step as zero if the selection probability of the word is lower than a predetermined selection probability threshold ε. Also, the content selection unit 220 may determine the attention used for the word in the attention distribution of the current time step as zero if the selection probability of the word is equal to or greater than the predetermined selection probability threshold ε, to obtain an attention distribution A of the source text. t The attention of the word in the target region may be determined as the attention of the word in the target region.

[0101] By using the above attention generation unit, a selection probability can be generated for each word in the source text, that is, when determining the attention for each word, at least both the attention magnitude calculated using formula (1) and the selection probability of the word should be considered. If the selection probability of the word is lower than a predetermined selection threshold, it can be considered that the word has a low probability of appearing in the current time step, and therefore the attention of the word does not need to be considered in the subsequent text processing process.

[0102] Equation (9) may represent the result of the attention distribution determined using the content selection unit.

number

number

[0103] By setting the selection probability of a word included in the external information to at least a predefined probability value λ, if the predefined probability value is greater than a predetermined selection probability threshold ε, the word in the external information can be prevented from being filtered out in the content selection step, and the word in the external information can be guaranteed to enter the subsequent text processing process, thereby increasing the probability that the word in the external information appears in the text processing result. Note that in some implementations, the predefined probability value λ may be set to be equal to or less than the predetermined selection probability threshold ε. In this case, the selection probability of each word is determined to be the sum of the first selection probability and the second selection probability, thereby increasing the selection probability of the word in the external information and increasing the probability that the word in the external information appears in the text processing result.

[0104] FIG. 3B illustrates an exemplary process for determining the attention distribution for a current time step using the attention generator illustrated in FIG. 3A.

[0105] As shown in FIG. 3B, taking four words in the source text as an example, the content selection network is used to select the attention of the first and third words for use in the subsequent text processing process.

[0106] FIG. 4 shows another schematic block diagram of the attention generation unit of the embodiment of the present application. As shown in FIG. 4, the attention generation unit 400 may include a source text attention determination unit 410 and an external information attention determination unit 420. The attention distribution A determined by the attention generation unit shown in FIG. 4 is the attention distribution a of the source text. t and the attention distribution a' of external information t Includes both.

[0107] In some implementations, the source text attention determiner 410 uses equation (2) to determine an encoded attention parameter e for each word in the source text based on the source text encoded hidden state of the current time step and the decoded hidden state of the current time step. it Determine.

[0108] The external information attention determination unit 420 is used to determine an external attention parameter for each word in the source text, and determines the external information. Included The external attention parameter of the word is determined to be a predetermined first external attention parameter, and the external information is Not included The external attention parameter of the word is determined to be a predetermined second external attention parameter. In some implementations, the first external attention parameter may be set as λ′ and the second external attention parameter may be set to 0, where λ′ is a value greater than 0.

[0109] Determine the attention parameter for each word to be used in the source text based on the coded attention parameter and the external attention parameter. For example, calculate the sum of the coded attention parameter for each word and the external attention parameter to obtain the attention parameter e′ for that word. i t can be sought.

[0110] Then, the attention parameter e' i t Determine the attention distribution for the current time step of the source text based on the attention parameter e' i t By applying the softmax function to , we can obtain the attention for the current time step for each word used in the source text.

[0111] Using the above method, we focus on external information in the source text with predefined external attention parameters. Included The attention parameters for words can be adjusted, and external information can be used to IncludedAdjustment to word attention can be implemented. Note that when the first external attention parameter is a hyperparameter λ' greater than 0 and the second external attention parameter is set to 0, the attention distribution for each word in the source text is adjusted based on the external information, so that the external information can be used to adjust the attention distribution. Included Attention to words can be made more important.

[0112] In the above example, the first external attention parameter is set to λ' and the second external attention parameter is set to 0 to illustrate the principle of the present application, but the scope of the present application is not limited thereto. Those skilled in the art may set the external attention parameters for each word used in the source text according to the actual situation, and finally, the external information Included We only need to implement the effect that the attention of words becomes more important. For example, we set the first external attention wp parameter λ1', and the second external attention parameter λ2', where λ1' and λ2' are any real numbers, and only λ1'>λ2' needs to be satisfied.

[0113] In some embodiments, the source text attention determination unit 410 uses the above equations (1) and (2) to determine the coded attention distribution a of the source text. t The extrinsic information attention determination unit 420 may be used to determine the coded attention distribution a′ of the extrinsic information. t may be used to determine

[0114] In this case, the extrinsic information is encoded using the encoding unit 110 shown in Fig. 1 to obtain an extrinsic information encoded hidden state h'. The extrinsic information attention unit 420 determines an extrinsic information encoding attention distribution based on the extrinsic information encoded hidden state h' and the decoded hidden state s.

[0115] For example, we use the above formulas (1) and (2) to obtain the coded attention distribution a' of the external information. tand the source text coding hidden state h in equations (1) and (2) should be replaced with the extrinsic information coding hidden state h′.

[0116] In some implementations, each of the extrinsic information coding attention distributions a' t and the coding attention distribution a of the source text t When calculating, we use the share parameter formulas (1) and (2), that is, the coding attention distribution a' of the external information t and the coding attention distribution a of the source text t The parameter v used to calculate T , W h , W S , b attn In some other implementations, the coded attention distribution a' of the extrinsic information t and the coding attention distribution a of the source text t and the training parameters used to calculate the extrinsic information coding attention distribution a′ t and the coding attention distribution a of the source text t The parameter v used to calculate T , W h , W S , b attn may be different.

[0117] The attention generation unit 400 shown in FIG. 4 encodes the external information into attention distribution a′ t The output part of the system generates the coded attention distribution a' of the external information, as shown in Figure 1. t and the coding attention distribution a of the source text t Further processing is performed on to determine the output word probability distribution for the current time step.

[0118] Attention Distribution A t The attention distribution of the source text a t and the attention distribution a' of external information tWhen both are included, the output word probability distribution is the generation probability distribution, the attention distribution of the source text, a t and the attention distribution a' of external information t It may be expressed as a weighted average of

[0119] In some implementations, the output word probability distribution may be determined by equation (10).

number

number

number

[0120] In some implementations, P is calculated based on the coding hidden state of the source text at the current time step t, the decoding hidden state, the coding attention distribution of the external information, and the output of the output unit at the previous time step t-1. generator , P pointer , and P T may be determined.

[0121] For example, based on equation (11), P generator , P pointer , and P T can be determined.

number

number

[0122] In some embodiments, when the output unit determines the output word probability distribution, it may take into account the probability distribution result determined by other methods. For example, the importance of each word in the source text I may be determined by considering the correlation between multiple sentence vectors formed by the word vectors in the source text I. The output word probability distribution may further include a word probability distribution formed according to the importance. For those skilled in the art, the method of generating the output word probability distribution is not limited thereto, and the output word probability distribution may include various types of word probability distributions without departing from the principles of the present disclosure.

[0123] Using the above method, the attention generation unit 400 calculates the attention distribution a' at the current time step of the external information. t and determine the attention distribution a' at the current time step of the external information. tmay be used to determine the output probability distribution of the current time step. In the embodiment provided by the present disclosure, the attention distribution of the external information is used to determine the output probability distribution of the current time step, instead of the features of the external information, so that the influence of invalid information in the features of the external information on the output probability distribution of the current time step can be avoided.

[0124] FIG. 5 illustrates another exemplary embodiment of a text processing apparatus according to an embodiment of the present application.

[0125] 5, the text processing device 500 may include an encoding unit 510, a decoding unit 520, an attention generation unit 530, an output unit 540, and a post-processing unit 550. The encoding unit 510, the decoding unit 520, the attention generation unit 530, and the output unit 540 may be implemented by the encoding unit 110, the decoding unit 120, the attention generation unit 130, and the output unit 140 described in FIGS. 1 to 3, and will not be described in detail here.

[0126] The post-processing unit 550 may be configured to perform post-processing on the candidate text based on the external information to determine an output text including the external information.

[0127] As described above, the encoding unit 510, the decoding unit 520, the attention generation unit 530, and the output unit 540 can be implemented in accordance with the encoding unit 110, the decoding unit 120, the attention generation unit 130, and the output unit 140 described in Figures 1 to 3, so that the output unit 540 can output text processing results including external information.

[0128] When the result output from the output unit 540 already contains external information, the result output from the output unit 540 may be directly output as the result of text processing.

[0129] If the result output from the output unit 540 does not include external information, the result output from the output unit 540 is set as a candidate text, and the post-processing unit 550 performs post-processing on the candidate text based on the external information to determine an output text including the external information.

[0130] In some implementations, the external information may include pre-specified information, for example, the external information may be a pre-specified sentence, or a sentence in the source text that contains a pre-specified word.

[0131] If the pre-specified external information is a sentence, the post-processing unit 550 may be configured to determine a similarity between the sentence in the candidate text and the external information, and if the similarity is greater than a pre-defined candidate similarity threshold, replace the sentence in the candidate text with the external information.

[0132] If the pre-determined external information is a word, the post-processing unit 550 may be configured to determine a similarity between a sentence in the candidate text and the external information, and replace the sentence in the candidate text with the external information if the similarity is greater than a pre-defined candidate similarity threshold.

[0133] In some implementations, if the similarity is greater than a predefined candidate similarity threshold, the post-processing unit 550 may be configured to remove the sentence in the candidate text and replace it with the sentence as extrinsic information or the sentence in the removed candidate text containing the word as extrinsic information.

[0134] In some examples, the external information is inserted into the remaining information based on a correlation in the source text between the external information in the source text and the redundant information in the candidate text, for example, the external information is inserted into the redundant information of the candidate text based on the order in which the external information and the redundant information in the candidate text appear in the source text.

[0135] In some other implementations, if the similarity is less than a predetermined candidate similarity threshold, the post-processing unit 550 inserts external information into the candidate text based on the correlation in the source text between the external information and sentences in the candidate text.

[0136] The similarity between the external information and each sentence in the candidate text may be compared. If the similarity between the external information and each sentence in the candidate text is smaller than a predetermined candidate similarity threshold, it means that the generated text processing result does not contain information similar to the external information. In this case, the external information and the candidate text may be directly matched to determine the final text processing result.

[0137] For example, the final text processing result may be determined by inserting the external information into the candidate text according to the order in which the external information and sentences in the candidate text appear in the source text.

[0138] By using the above text processing device according to the present application, the contents of external information can be effectively added to the text processing result, and it is guaranteed that the expected contents of external information are added to the text processing result.

[0139] As described above, the encoding unit 110, the decoding unit 120, and the attention generation unit 130 in the text processing device shown with reference to Figures 1 to 3 all include parameters that need to be trained. Therefore, it is necessary to train at least one of the encoding unit 110, the decoding unit 120, and the attention generation unit 130 using machine learning.

[0140] In some embodiments, the encoding unit, the attention generating unit and the decoding unit are trained using a predefined source text training set, the source text training set including a plurality of training source texts.

[0141] The text processing device shown in FIG. 1 can be used to process the training source text to obtain a training text processing result for the training source text. For example, an encoding unit can be used to encode the training source text to obtain an encoded hidden state of the training source text. Then, a decoding unit can be used to determine a training decoded hidden state. Then, an attention generating unit can be used to determine a training attention distribution for a current time step based on the external information, the training source text encoded hidden state, and the training decoded hidden state. An output unit can be used to determine a training output word probability distribution based on the training attention distribution, the training source text encoded hidden state, and the training decoded hidden state to determine a training output word.

[0142] By adjusting parameters in the encoding unit, the attention generation unit, and the decoding unit, the loss function used in the training process is minimized, and training is implemented for the encoding unit, the attention generation unit, and the decoding unit.

[0143] In some examples, the loss function used in the training process may be implemented as the following equation (12):

number

[0144] In another example, the loss function loss used in the training process can be implemented by the following equations (13) and (14).

number

number

number

number

number

[0145] FIG. 6 illustrates an exemplary flow chart of the text processing method of the present application. As shown in FIG. 6, in step S602, the source text may be encoded to obtain a source text encoding hidden state. In some embodiments, an encoding network may be used to encode the source text. An exemplary encoding network includes a long short-term memory (LSTM) network, and an LSTM network-based system may be applied to tasks such as machine translation, text summary generation, etc. As can be seen, the encoding network may be implemented as any machine learning model that encodes word vectors.

[0146] For example, when at least one word vector corresponding to a source text I is input, the encoding network outputs source text encoded hidden states h1, h2, h3... corresponding to each word vector x1, x2, x3... respectively. The number of source text encoded hidden states and the number of source text word vectors may be the same or different. For example, when generating k word vectors based on a source text I, the encoding network processes the k word vectors to generate k corresponding source text encoded hidden states, where K is an integer greater than 1.

[0147] In step S604, a decoded hidden state may be determined. In some embodiments, the decoder 120 may determine the decoded hidden state s t-1 and the output word x obtained by the text processing device in the previous time step t Receive and s t-1 and x t By processing the current time step, the decoded hidden state s tIn the first time step, s0 and x1 are determined as default initial values. The decoding hidden state s may include multiple decoding hidden states s1, s2, s3, ... corresponding to the source text S. Exemplary decoding networks include long short-term memory networks. Note that the decoding network may be implemented by any machine learning model that performs decoding on the output of the encoding network.

[0148] In step S606, an attention distribution for the current time step may be determined based on external information, the source text encoded hidden state, and the decoded hidden state.

[0149] In some embodiments, the attention distribution A at the current time step t t is the coding attention distribution of the source text. For example, we use equations (1) and (2) to obtain the coding attention distribution a t can be determined.

[0150] In some other embodiments, the attention distribution a of the source text determined based on the external information and Equation (1) t The attention distribution A of the current time step including external information based on t Determine the attention distribution A that includes external information. t is output and used in subsequent text processing steps.

[0151] FIG. 7 illustrates an exemplary flowchart of determining attention distribution for a current time step based on external information according to an embodiment of the present application.

[0152] In step S702, a coding attention distribution of the source text is determined based on the source text coding hidden state and the decoded hidden state. In some embodiments, the coding attention distribution a of the source text is determined by using the formula (1): t can be determined.

[0153] In step S704, a selection probability distribution for the source text is determined based on external information, the selection probability distribution including a selection probability to be used for each word in the source text.

[0154] In some implementations, a content selection network (eg, an LSTM network) is used to operate on a source text I to determine a first selection probability for each word in the source text.

[0155] The content selection network processes a source text I and outputs a first selection probability result for each word in the source text, where the first selection probability indicates the probability that this word in source text I will be selected based on the content selection network and appear in the final text processing result.

[0156] In some embodiments, the source text includes: Included For at least one word, a selection probability of the at least one word is determined to be at least a predefined probability value λ. For example, Included The second-choice probability of a word is determined to a predefined probability value λ, and the external information is Included The second choice probability of other words is determined to be 0.

[0157] Based on the first and second selection probabilities, a selection probability for each word in the source text is determined. For example, the selection probability for each word in the source text can be determined as the sum of the first and second selection probabilities. As can be seen, the external information Included For a word, its selection probability is greater than or equal to a predefined probability value λ.

[0158] In step S706, the attention distribution can be obtained by determining the attention of each word in the source text based on the selection probability of the word.

[0159] Based on the selection probability distribution, step S706 may include, for each word in the source text, determining attention for the word based on the selection probability of the word to obtain an attention distribution A. In some embodiments, step S706 may include determining that when the selection probability of the word is less than a predetermined selection probability threshold ε, the attention used for the word in the attention distribution for the current time step is 0. Also, step S706 may include determining that when the selection probability of the word is equal to or greater than the predetermined selection probability threshold ε, the attention used for the word in the attention distribution for the current time step is equal to or greater than the encoded attention distribution a of the source text. t The method may include determining attention of the word in the sequence.

[0160] Using the above attention generation method, a selection probability can be generated for each word in the source text, that is, when determining the attention for each word, at least the attention magnitude calculated using formula (1) and the selection probability of the word should be considered. When the selection probability of the word is lower than a predetermined selection threshold, it can be determined that the probability of the word appearing in the current time step is very low, so the attention of the word does not need to be considered in the subsequent text processing process.

[0161] The selection probability of a word included in the external information is set to at least a predefined probability value λ, and if the predefined probability value is greater than a predetermined selection probability threshold ε, the word in the external information is guaranteed not to be filtered in the content selection step, thereby ensuring that the word in the external information is processed in the subsequent text processing process, thereby increasing the probability that the word in the external information appears in the text processing result. Note that in some implementations, the predefined probability value λ may be set to be equal to or less than the predetermined selection probability threshold ε. In this case, the selection probability of each word is determined to be the sum of the first selection probability and the second selection probability, thereby increasing the selection probability of the word in the external information, and thus the effect of increasing the probability that the word in the external information appears in the text processing result can be implemented.

[0162] FIG. 8 shows another exemplary flowchart of the steps of determining the attention distribution for the current time step based on external information according to an embodiment of the present application.

[0163] In step S802, the coding attention of the source text for the current time step can be determined.

[0164] In some embodiments, the coded attention parameter e for each word in the source text is calculated based on the source text coded hidden state of the current time step and the decoded hidden state of the current time step using Equation (2). i t Then, the coding attention distribution a of the source text can be determined by using the above equations (1) and (2). t Determine.

[0165] In step S804, the extrinsic information coding attention for the current time step can be determined.

[0166] In some embodiments, an external attention parameter for each word in the source text can be determined and the external information can be used to determine the attention parameter. Included The external attention parameter of the word is determined to be a predetermined first external attention parameter, and the external information is Not included The external attention parameter of the word is determined to be a predetermined second external attention parameter. In some implementations, the first external attention parameter is set to λ′ and the second external attention parameter is set to 0, where λ′ is a value greater than 0.

[0167] Based on the coded attention parameter determined in step S802 and the external attention parameter, the attention parameter to be used for each word in the source text can be determined. For example, the attention parameter e′ for a word can be calculated by summing the coded attention parameter and the external attention parameter for that word. i tmay be determined.

[0168] Then, the attention parameter e' i t For example, the attention distribution for the current time step of the source text may be determined based on the attention parameter e' i t By applying a softmax function to , we can determine the attention for the current timestep to be used for each word in the source text.

[0169] Using the above method, we focus on external information in the source text using predefined external attention parameters. Included The attention parameter for words can be adjusted, and external information can be used to Included It is possible to implement word attention adjustment. Note that when the first external attention parameter is set to a hyperparameter λ' greater than 0 and the second external attention parameter is set to 0, the attention distribution for each word in the source text is adjusted based on external information, and the attention distribution for each word in the source text is adjusted based on the external information. Included It allows words to be given more attention.

[0170] In some embodiments, the extrinsic information can be encoded to obtain an extrinsic information encoded hidden state h'. In addition, the extrinsic information encoded attention distribution a' can be obtained by using the above formulas (1) and (2). t can be determined, and the source text coding hidden state h in equations (1) and (2) should be replaced with the extrinsic information coding hidden state h′.

[0171] In some implementations, the extrinsic information coding attention distribution a' t and the coding attention distribution a of the source text t When calculating and , we use the share parameter to calculate equations (1) and (2), that is, we calculate the external information coding attention distribution a' t and the coding attention distribution a of the source text t The parameter v used to calculateT , W h , W S , b attn In some other implementations, the coded attention distribution a' of the extrinsic information t and the source text-wise coding attention distribution a t We train the training parameters for calculating the external information coding attention distribution a' t and the coding attention distribution a of the source text t The parameter v used to calculate T , W h , W S , b attn may be different.

[0172] Referring back to FIG. 6, in step S608, an output word probability distribution may be determined based on the attention distribution, the source text encoding hidden states, and the decoding hidden states.

[0173] The output word probability distribution is the generation probability distribution P vocab Using equations (3) and (4), the generated probability distribution P vocab can be determined.

[0174] In some embodiments, the output word probability distribution is the attention distribution A t may include:

[0175] For example, the output word probability distribution can be determined by performing a weighted addition of the generated probability distribution and the attention distribution A.

[0176] In some implementations, a weighting factor P for the generation probability distribution and the attention distribution is calculated based on the source text encoding hidden state of the current time step, the source text decoding hidden state, the attention distribution, and the output of the decoding network of the previous time step. gen Determine.

[0177] For example, a weighting coefficient P gen can be shown as equation (5).

[0178] Attention Distribution A t The attention distribution of the source text a t and the attention distribution a' of external information t When both are included, the attention distribution of the source text a t and the attention distribution a' of external information t The weighting coefficient parameters may be the same or different.

[0179] Attention Distribution A t The attention distribution of the source text a t and the attention distribution a' of external information t When both are included, the output word probability distribution is the generation probability distribution, the attention distribution of the source text, a t and the attention distribution a' of external information t This can be expressed as a weighted average of

[0180] In some implementations, equation (10) may be used to determine the output word probability distribution.

[0181] In some implementations, P is calculated based on the encoded hidden state of the source text at the current time step t, the decoded hidden state of the source text, the encoded attention distribution of the external information, and the output of the decoding network at the previous time step t-1. generator , P pointer , and P T For example, P may be determined using equation (11). generator , P pointer , and P T Determine.

[0182] In some implementations, step S608 may include determining the most probable word in the output word probability distribution to be the output word for the current timestep.

[0183] FIG. 9 shows an exemplary flow chart of a method for processing text according to an embodiment of the present application.

[0184] As shown in FIG. 9, in step S902, the source text can be encoded to obtain a source text encoding hidden state.

[0185] In step S904, a decoded hidden state can be determined. In some embodiments, the decoded hidden state can be determined using step S604 shown in FIG. 6, which will not be described again.

[0186] In step S906, an output word probability distribution is determined based on external information, the source text encoded hidden state, and the decoded hidden state to determine an output word.

[0187] In some other embodiments, step S906 may further determine and output a word probability distribution based on external information to determine the output words for the current timestep.

[0188] In one implementation, step S906 includes determining whether the candidate output word has a probability equal to or greater than an output probability threshold based on the external information and the external information is not affected by the candidate output word. Included This may include determining the word to be a candidate output word for the current time step.

[0189] For example, at least two words are determined as candidate output words for the current time step in each time step, and then the candidate output words are used in the text processing process of the next time step. Similarly, at least two candidate output words may be determined for the next time step.

[0190] Specifically, for example, when the number of candidate output words is two, two candidate output words a and b can be determined at time step t. Then, the candidate output words a and b can be used in the text processing process of the next time step to determine candidate output words c and d at time step t+1.

[0191] In some embodiments, when determining candidate output words for each time step, a predetermined number M (in the above example, M is 2) of words with the highest output probability in the output probability distribution are determined as candidate output words, where M is an integer equal to or greater than 2.

[0192] In some other embodiments, when determining candidate output words for each time step, N words with the highest selection output probability in the output probability distribution may be determined based on a predefined method, and M words among these N words may be determined as candidate output words, where N is an integer greater than M. In some implementations, the value of N may be specified in advance.

[0193] In some other implementations, an output probability threshold may be pre-determined, and M words from among the N words with output probabilities greater than the output probability threshold may be determined as candidate output words.

[0194] Among the N words with the highest output probability, Included If the word does not exist, the M words with the highest output probabilities among these N words are determined as candidate output words.

[0195] Among the N words with the highest output probability, Included If a word exists, then it is present in these N words, and the external information Included If the number of words n is M or more, the output probability of the N words with the highest probability and the external information is Included Determine M words as candidate output words. Included If the number of words n is smaller than a certain number M, the external information in these N words IncludedThe Mn words with the highest output probability among the word and the remaining Nn words are determined as candidate output words.

[0196] At least four output candidate sequences ac, ad, bc, and bd can be determined using the candidate output words a and b output at time step t and the candidate output words c and d at time step t+1. The output probability of each output candidate sequence is determined by a joint probability method, and the two with the highest output probabilities among the four output sequence candidates ac, ad, bc, and bd are determined as candidate texts after time step t+1.

[0197] For example, the output probability of candidate output words a, b, c, and d is P a , P b , P c and P d The output candidate sequences ac, ad, bc, and bd are each expressed as P ac =P a *P c , P ad =P a *P d , P bc =P b *P c , and P bd =P b *P d It can be shown that P ac >P ad >P bc >P bd If so, then the output sequence ac,ad at time step t+1 is used for subsequent text processing.

[0198] In some embodiments, the output candidate sequence may also be determined based on external information. For example, the penalty value of the output candidate sequence may be determined using equation (6).

[0199] In one implementation, any possible text similarity algorithm may be used to determine the similarity between the candidate text sequence generated before time step t and the external information. For example, a cosine similarity method may be used to determine the similarity between the candidate text sequence generated before time step t and the external information.

[0200] Using the above formula (6), the higher the similarity between the candidate text sequence generated before time step t and the external information, the more the penalty value is used to increase the output probability of the output candidate sequence. In some implementations, the penalty value s(x,y) can be multiplied or added to the output probability in the output candidate sequence to achieve the effect of determining the output candidate sequence based on the similarity between the candidate text sequence generated before time step t and the external information.

[0201] That is, by determining the penalty value to be used for the output candidate sequence based on extrinsic information, the probability that the extrinsic information will appear in the candidate text sequence can be increased, thereby increasing the probability that the extrinsic information will appear in the final output text processing result.

[0202] In another implementation, step S906 may include determining a similarity between external information and the source text coding hidden state, and determining a word to be output at the current time step based on the similarity between external information and the source text coding hidden state.

[0203] For example, a coding network may be used to code the extrinsic information to obtain an extrinsic information-coded hidden state.

[0204] Step S906 may include determining a similarity between the extrinsic information encoded hidden state and the decoded hidden state, and if the similarity between the extrinsic information encoded hidden state and the decoded hidden state is greater than or equal to a predefined similarity threshold, the extrinsic information may be output as the output of the current timestep.

[0205] If the extrinsic information is a word, the extrinsic information may be output as the word of the current time step. If the extrinsic information is a sentence, the extrinsic information may be directly inserted after the text sequence generated before the current time step t.

[0206] It should be noted that the text sequence already generated before the current time step t may be generated based on the most probable word in the output probability distribution, or may be generated based on some candidate output words with the most probabilities in the output probability distribution. The adopted candidate output words can be determined by the process described in the implementation method, and will not be described in detail here.

[0207] If the similarity between the extrinsic information encoded hidden state and the decoded hidden state is less than a predefined similarity threshold, determine an output word probability distribution for the current time step based on the result output from the decoding network, and determine an output word for the current time step based on the output word probability distribution for the current time step.

[0208] Using the above method, when the similarity between the result output from the decoding network and the extrinsic information is higher, the result output from the decoding network may be directly replaced with the extrinsic information, i.e., in this case, the result of the text sequence determined after the output of the current time step is the result obtained by inserting the extrinsic information after the text sequence determined after the output of the previous time step.

[0209] Then, when processing the next time step, the decoding network is used to encode the extrinsic information to obtain the decoded hidden state of the next time step, so that the later decoding process can use the results of the extrinsic information, thereby ensuring the semantic consistency between the results obtained in the later decoding and the inserted extrinsic information.

[0210] When the external information is a word, the decoded hidden state of the previous time step and the external information can be used as the input of the decoding network to obtain the decoded hidden state of the current time step.

[0211] When the external information contains multiple words, the decoding network performs several loop processes. The inputs to the decoding network in the first loop are the decoded hidden state of the previous time step and the first word of the external information, and the inputs to the decoding network in the subsequent loops are the decoded hidden state obtained in the previous loop and the next word of the external information. By performing several loops, it is possible to process each word in the external information, and a decoded hidden state containing all the external information is obtained and used as the decoded hidden state of the current time step.

[0212] In some implementations, after the extrinsic information has already been substituted into the result output from the decoding network and inserted into the text processing result, no similarity comparison is performed between the extrinsic information encoded hidden state and the decoded hidden state.

[0213] In some examples, the similarity threshold may be implemented by a function with respect to a given time step t.

[0214] As described above, if the similarity between the external information encoded hidden state and the decoded hidden state is less than a predefined similarity threshold, the operation of replacing the output of the decoding network with the external information is not performed, and the output result is determined based on the output word probability distribution. In this case, in order to increase the probability that the external information appears in the final text processing result, the similarity threshold of the current time step is adjusted to determine an adjusted similarity threshold, which is less than the similarity threshold of the current time step, and the adjusted similarity threshold is used as the similarity threshold of the next time step.

[0215] For example, the similarity threshold is adjusted using equation (7).

[0216] By performing a monotonically decreasing adjustment of the similarity threshold for each time step, the similarity between the external information and the output result of the decoding unit is reduced to a lower level in the text processing process, so that the probability that the similarity between the external information and the output result of the decoding network will be greater than the similarity threshold of the current time step increases, i.e., the probability that the external information will appear in the final text processing result increases.

[0217] FIG. 10 shows an exemplary flow chart of a method for processing text according to an embodiment of the present application.

[0218] In step S1002, the source text is encoded to obtain the source text encoded hidden state.

[0219] In step S1004, the decoded hidden state is determined.

[0220] In step S1006, an output word for each time step is determined based on the source text encoded hidden state and the decoded hidden state, and a candidate text is determined.

[0221] In step S1008, post-processing is performed on the candidate text based on the external information to determine an output text containing the external information.

[0222] If the result output from step S1006 does not include the external information, the result output from step S1006 is taken as a candidate text, and post-processing is performed on the candidate text based on the external information to determine an output text including the external information.

[0223] In some implementations, the external information may include pre-specified information, for example, the external information may be a pre-specified sentence, or a sentence in the source text that includes a pre-specified word.

[0224] If the pre-specified external information is a sentence, a similarity between the sentence in the candidate text and the external information may be determined, and if the similarity is greater than a pre-defined candidate similarity threshold, the sentence in the candidate text may be replaced with the external information.

[0225] If the predetermined external information is a word, a similarity between a sentence in the candidate text and the external information may be determined, and if the similarity is greater than a predetermined candidate similarity threshold, the sentence in the candidate text may be replaced with the external information.

[0226] In some implementations, if the similarity is greater than a predetermined candidate similarity threshold, the sentence in the candidate text may be deleted and replaced with an external sentence or a sentence in the deleted candidate text that contains the external word.

[0227] In some examples, the external information is inserted into the remaining information based on a correlation in the source text between the external information in the source text and the redundant information in the candidate text, for example, the external information is inserted into the redundant information of the candidate text based on the order in which the external information and the redundant information in the candidate text appear in the source text.

[0228] In some other implementations, if the similarity is less than a predefined candidate similarity threshold, external information is inserted into the candidate text based on correlations in the source text between the external information and sentences in the candidate text.

[0229] The similarity between the external information and each sentence in the candidate text may be compared. If the similarity between the external information and each sentence in the candidate text is smaller than a predetermined candidate similarity threshold, it means that the generated text processing result does not contain information similar to the external information. In this case, the external information and the candidate text may be directly matched to determine the final text processing result.

[0230] For example, the final text processing result may be determined by inserting the external information into the candidate text according to the order in which the external information and sentences in the candidate text appear in the source text.

[0231] By utilizing the above text processing method according to the present application, the content of external information can be effectively added to the text processing result, and it is guaranteed that the content of external information expected to be added to the text processing result can be added.

[0232] By using the text processing method of the present application, in the text generation process, external information can be used to determine the attention distribution of the current time step and / or the output words of the current time step based on the external information, so that the content of the external information can be effectively taken into account in the text processing process, the probability of generating external information in the text generation process can be increased, and the effect of generating text when external information is taken into account can be improved.

[0233] In addition, the method or apparatus according to the embodiment of the present application may be implemented by the structure of a computing device shown in FIG. 11. FIG. 11 shows the structure of the computing device. As shown in FIG. 11, the computing device 1100 may include a bus 1110, one or at least two CPUs 1120, a read only memory (ROM) 1130, a random access memory (RAM) 1140, a communication port 1150 connected to a network, an input / output component 1160, a hard disk 1170, etc. The memory device in the computing device 1100, such as the ROM 1130 or the hard disk 1170, may record various data or files used in the processing and / or communication of the method for detecting a target in a video provided by the present application and programming commands executed by the CPU. The computing device 1100 may include a user interface 1180. Of course, the structure shown in FIG. 11 is merely exemplary, and when implementing a different device, one or more components in the computing device shown in FIG. 11 may be omitted according to actual needs.

[0234] The embodiments of the present application may further be implemented by a computer-readable recording medium. The computer-readable recording medium of the embodiments of the present application has computer-readable commands recorded thereon. When the computer-readable commands are executed by a processor, they may be executed with reference to the methods of the embodiments of the present application described in the above drawings. The computer-readable recording medium may include, but is not limited to, volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache, etc. The non-volatile memory may include, for example, read-only memory (ROM), a hard disk, a flash memory, etc.

[0235] As will be understood by those skilled in the art, the contents described herein may be modified and improved in various ways. For example, the various devices or components described above may be implemented in hardware, software, firmware, or a combination of some or all of them.

[0236] Also, as shown in the present application and the claims, unless the context clearly indicates an exception case, words such as "a," "one," "a kind," and / or "the" do not refer to the singular but may include the plural. In general, "comprises" and "including" merely indicate the inclusion of steps and elements already clearly labeled, but these steps and elements are not exhaustive and the method or device may include other steps or elements.

[0237] Also, although various references are made herein to certain units in the systems according to the embodiments of the present invention, any number of different units may be used and implemented on the user side and / or server side, and the units are merely illustrative and different aspects of the systems and methods may use different units.

[0238] In the present application, the operations performed by the system according to the embodiment of the present application are described using flowcharts. Note that the previous or subsequent operations do not have to be performed in order. Conversely, each step may be processed in the reverse order or simultaneously. In addition, other operations may be added to these processes, or a step or multiple steps may be omitted from these processes.

[0239] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art, and unless otherwise defined, for example, terms normally defined by dictionaries have meanings consistent with their meaning in the context of their related art and are not to be construed in an idealized or formal sense.

[0240] The above is a description of the present invention, but is not intended to limit the present invention. Although several exemplary embodiments of the present invention have been described, those skilled in the art can understand that various modifications may be made to the exemplary embodiments without departing from the novel teachings and advantages of the present invention. Therefore, these modifications are intended to be included in the scope of the present invention, which is defined by the claims. It should be noted that the above is a description of the present invention, and is not limited to the specific embodiments disclosed, and modifications to the disclosed embodiments and other embodiments are also intended to be included in the scope of the appended claims. The present invention is limited to the claims and their equivalents.

Claims

1. A text processing device that processes word vectors of a source text based on a sequence-to-sequence model while taking into account external information, comprising: an encoding unit configured to encode word vectors of a source text using an encoding network to obtain a source text encoding hidden state; a decoder configured to decode an output of the encoder utilizing a decoding network to determine a decoded hidden state; an attention generating unit configured to calculate, in each time step, an encoding attention parameter for each word in the source text using the source text encoding hidden state and the decoded hidden state of the current time step, and to calculate an encoding attention distribution of the source text by applying a softmax function to the encoding attention parameter, as an attention distribution of the current time step; an output unit configured to obtain a context vector based on the attention distribution and the source text coding hidden state of a current time step, calculate a generation probability distribution based on the context vector and the decoded hidden state, calculate an output word probability distribution by performing a weighted addition of the generation probability distribution and the attention distribution, determine a word in the output word probability distribution whose output probability is equal to or greater than a preset output probability threshold and which is included in the external information as a candidate output word of a current time step, determine an output candidate sequence based on the candidate output word of the current time step and the candidate output word of a next time step, determine an output probability of the output candidate sequence based on a joint probability of an output probability of the candidate output word of the current time step and an output probability of the candidate output word of the next time step, determine a penalty value of the output candidate sequence based on a similarity between a candidate text sequence determined in a previous time step and the external information, adjust the output probability of the output candidate sequence using the penalty value such that the higher the similarity, the greater the penalty value increases the output probability of the output candidate sequence, and determine the candidate output word in a predetermined number of sequences having the highest output probability of the adjusted output candidate sequence as the output word of the current time step, A text processing device, wherein the external information is predefined text information expected as a result of processing a source text.

2. The encoding unit and the decoding unit In the encoding unit, encoding the training source text using an encoding network to obtain a training source text encoding hidden state; in said decoding unit, using a decoding network to decode the output of said encoding unit to determine training decoded hidden states; determining training output words for a current time step based on the extrinsic information, the training source text encoded hidden states, and the training decoded hidden states; 2. The text processing apparatus according to claim 1, wherein the training is performed by adjusting parameters in the encoding unit and the decoding unit so that a difference between the training output words and words included in the external information is minimized.

3. A text processing method for performing processing on word vectors of a source text based on a sequence-to-sequence model while taking into account external information, comprising: encoding word vectors of a source text using an encoding network to obtain source text encoding hidden states; using a decoding network to decode an output of the encoding network to determine a decoded hidden state; At each time step, calculating an encoding attention parameter for each word in the source text using the source text encoding hidden state and the decoded hidden state of the current time step, and calculating an encoding attention distribution of the source text by applying a softmax function to the encoding attention parameter, which is the attention distribution of the current time step; determining an output candidate sequence based on a joint probability of an output probability of the candidate output word of the current time step and an output probability of the candidate output word of the next time step; determining a penalty value of the output candidate sequence based on a similarity between a candidate text sequence determined in a previous time step and the external information; adjusting the output probability of the output candidate sequence using the penalty value such that the penalty value increases the output probability of the output candidate sequence as the similarity increases; and determining the candidate output word in a predetermined number of sequences having the highest output probability of the adjusted output candidate sequence as the output word of the current time step.

4. A processor; a memory having computer readable programming commands stored therein; A text processing device which performs the text processing method of claim 3 when the computer readable programming instructions are executed by the processor.

5. A computer readable recording medium having computer readable instructions recorded thereon which, when executed by a computer, cause the computer to carry out the text processing method of claim 3.