Method and apparatus for generating text
Abstract
A method and apparatus for generating text. The method comprises: receiving original text and an element tag ( 201 ); generating an encoded text feature vector, and an encoded sentence feature vector of each sentence in the original text; executing decoding steps comprising: determining a word attention weight of each word in the original text at the current moment on the basis of a hidden state vector of the decoder at the current moment and the encoded text feature vector ( 2031 ); determining a sentence attention weight of each sentence in the original text; determining a normalized word attention weight of each word in the original text at the current moment; and estimating a target word at the current moment; and generating target text on the basis of the target word output by the decoder at each moment ( 204 ).
Interactive Citation Constellation Global Citation Ranking
Interactive SVG Citation Constellation renders in Rust/WebAssembly. Prior art cited: 18 · Forward citations: 0.
Claims (15 — 3 Independent, 12 Dependent)
- Claim 1Independent Claim
A method for generating a text, comprising: receiving an original text and an element tag; generating, based on the original text, an encoded text feature vector and an encoded sentence feature vector of each sentence in the original text using a pre-trained encoder; and performing, using a decoder that is pre-trained, following decoding steps: determining, based on a hidden state vector of the decoder at a current moment and the encoded text feature vector, a word attention weight of each word in the original text at the current moment; determining a sentence attention weight of each sentence in the original text at the current moment, based on the hidden state vector of the decoder at the current moment, the encoded sentence feature vector and the element tag; determining a normalized word attention weight of each word in the original text at the current moment based on the sentence attention weight and the word attention weight; and estimating a target word at the current moment based on the encoded text feature vector and normalized word attention weights of words in the original text at the current moment, wherein the method further comprises: generating a target text based on target words outputted by the decoder at moments.
- Claim 2Depends on #1
The method according to claim 1, wherein the generating, based on the original text, an encoded text feature vector and an encoded sentence feature vector of each sentence in the original text using a pre-trained encoder comprises: generating a text feature matrix based on the original text; inputting the text feature matrix into a pre-trained first encoder to obtain the encoded text feature vector; inputting the text feature matrix into a pre-trained second encoder to obtain an encoded word feature vector of each word in the original text; determining a sentence feature vector of a sentence in the original text based on encoded word feature vectors of words in the sentence in the original text; and inputting sentence feature vector of each sentence in the original text into a pre-trained third encoder to obtain the encoded sentence feature vector of each sentence in the original text.
- Claim 3Depends on #1
The method according to claim 1, wherein the estimating a target word at the current moment based on the encoded text feature vector and the normalized word attention weights of words in the original text at the current moment comprises: generating a context feature vector at the current moment based on the encoded text feature vector and the normalized word attention weights of the words in the original text at the current moment; and estimating the target word at the current moment based on the context feature vector and the encoded text feature vector.
- Claim 4Depends on #1
The method according to claim 1, wherein the element tag is generated by: performing clustering on the original text to obtain a cluster tag set; determining a target cluster tag from the cluster tag set; and determining the target cluster tag as the element tag.
- Claim 5Depends on #4
The method according to claim 4, wherein the performing clustering on the original text to obtain a cluster tag set comprises: segmenting the original text with a preset punctuation mark as a segmentation boundary, to obtain a short sentence set; deleting, from the short sentence set, a short sentence not meeting a preset condition to obtain an updated short sentence set; extracting, based on the updated short sentence set, word features of words in a short sentence using a pre-trained feature extraction model, and determining a sentence feature of the short sentence based on the word features; and determining, based on sentence features of short sentences in the updated short sentence set, cluster tags of the short sentences in the updated short sentence set using a pre-trained clustering model, to obtain the cluster tag set.
- Claim 6Independent Claim
An apparatus for generating a text, comprising: one or more processors; and a memory storing one or more programs; wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform operations, the operations comprising: receiving an original text and an element tag; generating, based on the original text, an encoded text feature vector and an encoded sentence feature vector of each sentence in the original text using a pre-trained encoder; and performing, using a decoder that is pre-trained, following decoding steps: determining, based on a hidden state vector of the decoder at a current moment and the encoded text feature vector, a word attention weight of each word in the original text at the current moment; determining a sentence attention weight of each sentence in the original text at the current moment, based on the hidden state vector of the decoder at the current moment, the encoded sentence feature vector and the element tag; determining a normalized word attention weight of each word in the original text at the current moment based on the sentence attention weight and the word attention weight; and estimating a target word at the current moment based on the encoded text feature vector and normalized word attention weights of words in the original text at the current moment; and generating a target text based on target words outputted by the decoder at moments.
- Claim 7Depends on #6
The apparatus according to claim 6, wherein the generating, based on the original text, an encoded text feature vector and an encoded sentence feature vector of each sentence in the original text using a pre-trained encoder comprises: generating a text feature matrix based on the original text; inputting the text feature matrix into a pre-trained first encoder to obtain the encoded text feature vector; inputting the text feature matrix into a pre-trained second encoder to obtain an encoded word feature vector of each word in the original text; determining a sentence feature vector of a sentence in the original text based on encoded word feature vectors of words in the sentence in the original text; and inputting sentence feature vector of each sentence in the original text into a pre-trained third encoder to obtain the encoded sentence feature vector of each sentence in the original text.
- Claim 8Depends on #6
The apparatus according to claim 6, wherein the estimating a target word at the current moment based on the encoded text feature vector and the normalized word attention weights of words in the original text at the current moment comprises: generating a context feature vector at the current moment based on the encoded text feature vector and the normalized word attention weights of the words in the original text at the current moment; and estimating the target word at the current moment based on the context feature vector and the encoded text feature vector.
- Claim 9Depends on #6
The apparatus according to claim 6, wherein the element tag is generated by: performing clustering on the original text to obtain a cluster tag set; determining a target cluster tag from the cluster tag set; and determining the target cluster tag as the element tag.
- Claim 10Depends on #9
The apparatus according to claim 9, wherein the performing clustering on the original text to obtain a cluster tag set comprises: segmenting the original text with a preset punctuation mark as a segmentation boundary, to obtain a short sentence set; deleting, from the short sentence set, a short sentence not meeting a preset condition to obtain an updated short sentence set; extracting, based on the updated short sentence set, word features of words in a short sentence using a pre-trained feature extraction model, and determining a sentence feature of the short sentence based on the word features; and determining, based on sentence features of short sentences in the updated short sentence set, cluster tags of the short sentences in the updated short sentence set using a pre-trained clustering model, to obtain the cluster tag set.
- Claim 11Independent Claim
A non-transitory computer readable medium, storing a computer program, wherein the program, when executed by a processor, implements operations comprising: receiving an original text and an element tag; generating, based on the original text, an encoded text feature vector and an encoded sentence feature vector of each sentence in the original text using a pre-trained encoder; and performing, using a decoder that is pre-trained, following decoding steps: determining, based on a hidden state vector of the decoder at a current moment and the encoded text feature vector, a word attention weight of each word in the original text at the current moment; determining a sentence attention weight of each sentence in the original text at the current moment, based on the hidden state vector of the decoder at the current moment, the encoded sentence feature vector and the element tag: determining a normalized word attention weight of each word in the original text at the current moment based on the sentence attention weight and the word attention weight; and estimating a target word at the current moment based on the encoded text feature vector and normalized word attention weights of words in the original text at the current moment, wherein the method further comprises: generating a target text based on target words outputted by the decoder at moments.
- Claim 12Depends on #11
The non-transitory computer readable medium according to claim 11, wherein the generating, based on the original text, an encoded text feature vector and an encoded sentence feature vector of each sentence in the original text using a pre-trained encoder comprises: generating a text feature matrix based on the original text; inputting the text feature matrix into a pre-trained first encoder to obtain the encoded text feature vector; inputting the text feature matrix into a pre-trained second encoder to obtain an encoded word feature vector of each word in the original text; determining a sentence feature vector of a sentence in the original text based on encoded word feature vectors of words in the sentence in the original text; and inputting sentence feature vector of each sentence in the original text into a pre-trained third encoder to obtain the encoded sentence feature vector of each sentence in the original text.
- Claim 13Depends on #11
The non-transitory computer readable medium according to claim 11, wherein the estimating a target word at the current moment based on the encoded text feature vector and the normalized word attention weights of words in the original text at the current moment comprises: generating a context feature vector at the current moment based on the encoded text feature vector and the normalized word attention weights of the words in the original text at the current moment; and estimating the target word at the current moment based on the context feature vector and the encoded text feature vector.
- Claim 14Depends on #11
The non-transitory computer readable medium according to claim 11, wherein the element tag is generated by: performing clustering on the original text to obtain a cluster tag set; determining a target cluster tag from the cluster tag set; and determining the target cluster tag as the element tag.
- Claim 15Depends on #14
The non-transitory computer readable medium according to claim 14, wherein the performing clustering on the original text to obtain a cluster tag set comprises: segmenting the original text with a preset punctuation mark as a segmentation boundary, to obtain a short sentence set; deleting, from the short sentence set, a short sentence not meeting a preset condition to obtain an updated short sentence set; extracting, based on the updated short sentence set, word features of words in a short sentence using a pre-trained feature extraction model, and determining a sentence feature of the short sentence based on the word features; and determining, based on sentence features of short sentences in the updated short sentence set, cluster tags of the short sentences in the updated short sentence set using a pre-trained clustering model, to obtain the cluster tag set.
Technical Overview & Description
CROSS-REFERENCE TO RELATED APPLICATIONS This patent application is a national stage of International Application No. PCT/CN2021/138296, filed on Dec. 15, 2021, which claims the priority from Chinese Patent Application No. 202110085890.0, filed on Jan. 22, 2021. Both of the aforementioned applications are hereby incorporated by reference in their entireties. TECHNICAL FIELD Embodiments of the present disclosure relate to the field of computer technology, particularly to the field of deep learning, and more particularly to a method and apparatus for generating a text. BACKGROUND A text summarization refers to a conversion from an original text into a refined text containing only key information, and mainly includes an extractive summarization and an abstractive summarization. The extractive summarization is mainly to extract a key word or short sentence from a source document through an algorithm such as a clustering or sequence labeling algorithm. The abstractive summarization is mainly to adopt a deep learning method to and use the frame of a Sequence2Sequence (sea2seq), to first encode the source document as a hidden vector of a fixed dimension by using an encoder and then input the hidden vector into a decoder side to perform word generation step by step. In the related art, on the basis of a seq2seq model, a pointer generator network introduces a copying mechanism and a coverage mechanism. The copying mechanism calculates the attention weights of all words in the source document at every decoding step, and can selectively copy a part of an original text to a summary, and thus can generate a word that has never been appeared in a vocabulary. The coverage mechanism accumulates the attention weights in the current step and all the previous steps at every decoding step, preventing the part that has a high weight in the original text being continuously copied. SUMMARY Embodiments of the present disclosure propose a method and apparatus for generating a text, and a com
Cited By — Indexed Forward Citations (0 of 0 total)
No indexed citing patents in this generation yet. Ingest USPTO/PatentsView bulk citation tables via patents-ingest to expand the local forward citation graph.
References Cited — Backward Prior Art (18)
| Patent | Title | Year | Citations |
|---|
Non-Patent Literature (4)
- Research on Chinese Automatic Text Summarization Based on Seq2Seq Model, 59 pages including pp. 1-53, 2018, with English Abstract.
- Bo-han Li et al., Multi-task Learning for Abstractive Text Summarization, Computer Knowledge and Technology, vol. 16, No. 31, pp. 20-25, 48, Nov. 2020, with English Abstract.
- International Search Report for PCT/CN2021/138296, dated Mar. 9, 2022, 2 pgs.
- Kimura Fukuda et al, Enhancing query-oriented abstract model with statement encoder, DEIM Forum 2019 A2-4, 21 Pages.