WO2024164580A1 - 面向段落级文本的中英文语义相似度计算方法 - Google Patents
面向段落级文本的中英文语义相似度计算方法 Download PDFInfo
- Publication number
- WO2024164580A1 WO2024164580A1 PCT/CN2023/128479 CN2023128479W WO2024164580A1 WO 2024164580 A1 WO2024164580 A1 WO 2024164580A1 CN 2023128479 W CN2023128479 W CN 2023128479W WO 2024164580 A1 WO2024164580 A1 WO 2024164580A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- sentence
- paragraph
- english
- chinese
- node
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/22—Matching criteria, e.g. proximity measures
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/205—Parsing
- G06F40/211—Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/30—Semantic analysis
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Definitions
- the present invention relates to the field of information technology, and in particular to a Chinese-English semantic similarity calculation method for paragraph-level texts.
- cross-language paragraph semantic similarity calculation is an important research content. It studies how to calculate the semantic similarity of paragraph-level texts in different languages. This plays an important role in many cross-language processing applications and related fields, such as calculating the semantic similarity of abstracts of applications in different languages to complete the detection and selection of similar applications; calculating the semantic similarity of abstracts of papers in different languages, thereby realizing similar paper detection, completing cross-language paper recommendation and cross-language plagiarism detection.
- the current Chinese-English cross-language paragraph semantic similarity calculation method still needs to be improved in accuracy, and it mainly has the following three shortcomings:
- Negative samples in the alignment of Chinese and English sentence representations should be semantically dissimilar to the anchor samples.
- the alignment of Chinese and English sentence representations is trained using a Chinese-English parallel sentence pair dataset.
- For the Chinese-English parallel sentence pair dataset when the anchor sample is a Chinese sentence, its positive sample is an English sentence that is parallel to the Chinese sentence. Negative samples need to be constructed by our. Existing methods use English sentences in other parallel sentence pairs as negative samples, but the negative samples generated by this method may be semantically similar to the anchor samples. False negative samples. If the representation distance between anchor samples and false negative samples is widened, it will affect the alignment of sentence representations and damage the performance of the Chinese-English sentence representation model.
- paragraph text should consider the information at the three levels of words, sentences and paragraphs.
- the current methods of representing paragraphs either emphasize the representation of paragraphs through the information at the sentence level or the representation of paragraphs through the information at the word level.
- the present invention provides the following solutions:
- a method for calculating Chinese and English semantic similarity for paragraph-level texts comprising:
- paragraph representation vectors are extracted for Chinese paragraphs and English paragraphs respectively, including the following processes:
- the feature vectors of the topic word node and sentence node are average pooled respectively, and then the average pooled topic word node representation vector, sentence node representation vector and global paragraph node feature vector are concatenated and dimensionally reduced to obtain the paragraph representation vector of the Chinese paragraph/English paragraph;
- the distance between the paragraph representation vector of the Chinese paragraph and the paragraph representation vector of the English paragraph is calculated to obtain the semantic similarity between the Chinese paragraph and the English paragraph.
- a Chinese-English sentence representation alignment model is trained based on a Chinese-English parallel sentence pair dataset, which is used to extract initialization feature vectors of topic nodes, sentence nodes, and global paragraph nodes.
- the Chinese-English sentence representation alignment model obtained by training the Chinese-English parallel sentence pair dataset includes:
- Anchor samples are selected from the Chinese-English parallel sentence dataset. Sentences that are parallel to the anchor samples are positive samples, and sentences in other Chinese-English parallel sentence pairs that are different from the anchor samples in language are negative samples.
- the negative sample For each negative sample, if its semantic similarity with the anchor sample is greater than the set threshold, the negative sample is a false negative sample, and the weight of the false negative sample is assigned to 0; otherwise, the weight of the negative sample is assigned to 1;
- the Chinese-English sentence representation alignment model is trained using the training set obtained after removing false negative samples to obtain the trained Chinese-English sentence representation alignment model; wherein, the Chinese-English sentence representation alignment model includes two feature extraction branches, one of which includes a Chinese sentence encoder and an average pooling layer, and the other includes an English sentence encoder and an average pooling layer.
- the first semantic similarity between the parallel sentence of the negative sample and the anchor sample is calculated as the semantic similarity between the negative sample and the anchor sample;
- the maximum value of the first semantic similarity and the second semantic similarity is taken as the semantic similarity between the negative sample and the anchor sample.
- the objective function is expressed as follows: min L(x i , y i )+L(y i , xi )
- L( xi , yi ) and L( yi , xi ) represent the alignment loss functions when the anchor samples are Chinese sentences and English sentences, respectively, which are expressed as follows:
- d(x, y) represents the vector similarity between Chinese sentence x and English sentence y
- ⁇ represents the temperature hyperparameter
- ⁇ i,j represents the weight of the negative sample y j of the anchor sample xi
- the subscripts i and j represent the numbers of the Chinese-English parallel sentence pairs
- N is the total number of Chinese-English parallel sentence pairs in the training batch.
- constructing a subject word node for each subject word in a Chinese paragraph/English paragraph and constructing a sentence node for each sentence in a Chinese paragraph/English paragraph includes:
- the extraction of the initialization feature vectors of the topic word nodes, sentence nodes and global paragraph nodes includes:
- For each topic word node count the sentence number and word order in the sentence where the topic word appears, use the Chinese sentence encoder/English sentence encoder in the Chinese-English sentence representation alignment model to encode the sentence where the corresponding topic word appears, and obtain the feature vector of each word in the sentence. According to the word order of the topic word in the sentence, extract the feature vector of the topic word as the initialization feature vector of the topic word node; if the topic word appears multiple times in the Chinese paragraph/English paragraph, average pool the feature vectors of the topic word at each position to obtain the initialization feature vector of the topic word node;
- the Chinese sentence encoder/English sentence encoder in the Chinese-English sentence representation alignment model is used to encode the sentence to obtain the feature vector of each word, and then average pooling is performed to obtain the feature vector as the initialization feature vector of the sentence node;
- the initialized feature vectors of all topic nodes and sentence nodes are average pooled to obtain the initialized feature vector of the global paragraph node.
- edge relationship between nodes is determined by the following method:
- sentence A contains the keyword a
- an edge is established between the sentence node corresponding to sentence A and the keyword node corresponding to the keyword a to connect them;
- sentence A and sentence B have a contextual relationship in the Chinese paragraph/English paragraph, an edge is established between the sentence node corresponding to sentence A and the sentence node corresponding to sentence B to connect them;
- topic word a and topic word b co-occur in the sentences of the Chinese paragraph/English paragraph, an edge is established between their corresponding topic word nodes to connect them;
- the global paragraph node is connected to all sentence nodes and keyword nodes by an edge;
- Each node establishes an edge connecting to itself
- e pq represents the edge relationship between node p and node q.
- the initialized feature vectors of all nodes and the edge relationships between the nodes are input into the graph attention network, and the feature vectors of each node after information interaction are output, including:
- the node feature vector output by the previous layer of graph attention network is As the input of the graph attention network of this layer, the feature vector of each node after information interaction is output Where n is the total number of nodes; the input of the first layer of graph attention network is the initialization feature vector of all nodes and the edge relationship between nodes; the construction process of each layer of graph attention network is as follows:
- a pq represents the importance of node q to node p
- d( ⁇ ) represents the similarity function between two vectors
- the neighbor node information of each node is passed to the node, where the neighbor nodes include the node itself, and the weight of the edge relationship of the node's neighbor nodes is normalized using softmax:
- ⁇ represents the nonlinear transformation function
- the feature vector of each node finally output by each layer of graph attention network is input into the next layer of graph attention network.
- paragraph representation vector of the Chinese paragraph/English paragraph is obtained by the following method:
- h word and h sentence represent the node representation vector of the topic word and the node representation vector of the sentence respectively after average pooling;
- the present invention proposes a method for calculating the semantic similarity between Chinese and English for paragraph-level text.
- a multi-level paragraph representation method is proposed, which can model paragraph text from three levels: keywords, sentences and paragraphs, and interact information within and between information at each level based on the graph attention network. Then, the information at the three levels of keywords, sentences and paragraphs is integrated to obtain a high-quality paragraph representation vector.
- the semantic similarity between Chinese and English paragraphs is obtained by calculating the distance between the paragraph representation vectors.
- This method can realize high-precision calculation of semantic similarity between Chinese and English cross-language paragraphs, and can be applied to similarity calculation of abstracts of applications in different languages to complete the detection and selection of similar applications; it can also be applied to similarity calculation of abstracts of papers in different languages, thereby realizing similar paper detection and completing cross-language paper recommendation.
- FIG1 is an overall framework diagram of a method for calculating Chinese-English semantic similarity for paragraph-level texts provided by an embodiment of the present invention
- FIG2 is a flowchart of Chinese and English sentence representation alignment for removing false negative samples provided by an embodiment of the present invention
- FIG3 is a schematic diagram of a process for constructing positive and negative samples provided by an embodiment of the present invention.
- FIG4 is a schematic diagram of a Chinese-English sentence representation alignment model framework provided by an embodiment of the present invention, wherein (a) and (b) are schematic diagrams of a Chinese-English sentence representation alignment model framework with anchor samples being Chinese sentences and English sentences, respectively;
- FIG. 5 is a diagram showing the result of alignment of Chinese and English sentence representations provided by an embodiment of the present invention.
- the embodiment of the present invention provides a method for calculating the semantic similarity between Chinese and English for paragraph-level text.
- the sentence representation alignment method of Chinese and English sentences with false negative samples is used to align the sentences in different languages.
- Sub-representations are aligned to a common representation space.
- the similarity of sentences can be obtained by calculating the distance of sentence vectors, providing a representation basis at the word and sentence levels for the realization of Chinese and English paragraph representation.
- a multi-level paragraph representation method is proposed, which can model paragraph text from three levels: topic words, sentences, and paragraphs, and interact with information within and between each level based on the graph attention network. Then, the information at the three levels of topic words, sentences, and paragraphs is integrated to obtain a high-quality paragraph representation vector.
- the semantic similarity between Chinese and English paragraphs is obtained by calculating the distance of paragraph representation vectors.
- the Chinese-English semantic similarity calculation method for paragraph-level text includes three stages: alignment of Chinese and English sentence representations to remove false negative samples, multi-level Chinese and English paragraph representation based on graph attention network, and Chinese-English cross-language paragraph semantic similarity calculation.
- the Chinese-English sentence representation alignment method for removing false negative samples selects a Chinese-English parallel sentence pair dataset as training data. First, based on the Chinese-English parallel sentence pair dataset, anchor samples are selected and corresponding negative samples and positive samples are generated; then the negative samples are screened to remove false negative samples and retain true negative samples; after constructing the Chinese-English sentence representation alignment model, the anchor samples, positive samples and true negative samples can be used to train the Chinese-English sentence representation alignment model; after the training is completed, the Chinese-English sentence representation model is obtained, which can encode Chinese sentences and English sentences and represent them in a common semantic representation space. The semantic similarity between sentences can be obtained by calculating the distance between the representation vectors of Chinese sentences and English sentences.
- the semantic representations of sentences in different languages can be aligned into a common representation space through a supervised sentence representation alignment method.
- the similarity of sentences in the common representation space can be obtained by calculating the distance between sentence vectors, without the need to translate into a single language for calculation, thus avoiding the semantic loss that may be caused by translation bias in the machine translation process.
- the alignment of Chinese and English sentence representations to remove false negative samples includes the following steps.
- each Chinese-English parallel sentence pair consists of a pair of parallel Chinese sentences and English sentences.
- S12 Filter negative samples, remove false negative samples, and retain true negative samples.
- negative sample y j For negative sample y j , it needs to meet the condition of being semantically dissimilar to anchor sample xi . However, negative samples constructed from other Chinese-English parallel sentence pairs in the same training batch do not necessarily meet this condition, so negative samples need to be screened. For negative sample y j , if its semantic similarity sim( xi , y j ) with anchor sample xi is greater than the set threshold This means that the negative sample and the anchor sample are semantically similar and do not meet the requirements of negative samples, that is, this negative sample is a false negative sample. If the representation distance between the anchor sample and the false negative sample is increased, the alignment of the sentence representation will be affected, which will damage the performance of the Chinese-English sentence representation alignment model.
- the anchor sample x i and the negative sample y j are sentences in different languages, and the existing semantic similarity calculation technology for Chinese and English sentences is not mature (low precision), their similarity cannot be calculated directly.
- a method for calculating similarity indirectly is proposed.
- the anchor sample is a Chinese sentence x i
- sim zh ( ⁇ ) and sim en ( ⁇ ) represent the Chinese sentence similarity calculation and the English sentence similarity calculation, respectively.
- a mature single-language sentence semantic similarity calculation model is used to calculate the semantic similarity between the anchor sample and the negative sample.
- the Chinese sentence encoder RoBERTa-wwm-ext Choinese version
- the representation vector of the encoded word is averaged and pooled to obtain the feature vector of the Chinese sentence.
- the cosine similarity of the feature vectors of the two Chinese sentences is calculated to obtain the Chinese sentence similarity sim zh ( ⁇ );
- the English sentence encoder bert-base-uncased English version
- the encoded word representation vector is averaged and pooled to obtain the feature vector of the Chinese sentence.
- the obtained word representation vector is average pooled to obtain the feature vector of the English sentence, and then the English sentence similarity sim en ( ⁇ ) is obtained by calculating the cosine similarity of the feature vectors of two English sentences.
- ⁇ i,j represents the weight of the negative sample y j of the anchor sample x i .
- FIG3 shows a schematic diagram of the construction process of positive and negative samples.
- the above process of filtering out false negative samples is the same, and only corresponding adjustments need to be made to the processing object.
- Figure 4(a) is a schematic diagram of the anchor sample being a Chinese sentence
- Figure 4(b) is a schematic diagram of the anchor sample being an English sentence.
- the Chinese sentence enters the Chinese sentence encoder to obtain the representation vector of the word in the sentence, and the representation vector of the Chinese sentence is obtained after the average pooling layer.
- the English sentence enters the English sentence encoder to obtain the representation vector of the word in the sentence, and the representation vector of the English sentence is obtained after the average pooling layer.
- the English sentence encoder here uses bert-base-uncased (English version), which is a trained monolingual English sentence encoder that can perform semantic representation on English sentences;
- the Chinese sentence encoder uses RoBERTa-wwm-ext (Chinese version), which is a trained monolingual Chinese sentence encoder that can perform semantic representation on Chinese sentences.
- the Chinese and English sentence representation alignment model is trained using anchor samples, positive samples, and negative samples.
- the loss function uses a variant of the InfoNCE loss.
- the anchor sample is a Chinese sentence x i
- the positive The sample is an English sentence yi
- the alignment loss function L( xi , yi ) is:
- d(x, y) represents the vector similarity between Chinese sentence x and English sentence y
- ⁇ represents the temperature hyperparameter
- ⁇ i, j represents the weight of negative sample yi of anchor sample xi
- subscripts i and j represent the numbers of Chinese-English parallel sentence pairs
- N is the total number of Chinese-English parallel sentence pairs in the training batch.
- the alignment loss function is equivalent to an N-way softmax classification problem, in which the positive sample is correct and N-1 negative samples are wrong.
- the training goal of the model is to shorten the vector distance between the anchor sample and the positive sample and to increase the vector distance with the negative sample, so as to shorten the representation of semantically similar sentences in the common semantic space and increase the representation of semantically dissimilar sentences in the common semantic space, so as to achieve the purpose of aligning to the same representation space.
- ⁇ j ,i represents the weight of the negative sample xj of the anchor sample yi .
- the objective function of the Chinese-English sentence representation alignment model is expressed as follows: min L(x i , y i )+L(y i , xi ).
- the purpose of training is to minimize the distance between the vectors of semantically similar sentences and maximize the distance between the vectors of semantically dissimilar sentences, so as to achieve the alignment of the representation spaces of sentences in different languages.
- the objective function includes two alignment losses, which is equivalent to alignment from two directions (Chinese->English, English->Chinese). For example, there are four pairs of Chinese-English parallel sentences to train the model:
- Figure 5 shows the result of alignment of Chinese and English sentence representations (the alignment of Chinese and English sentence representations is shown with the anchor sample "English is the most widely used language.” as an example).
- the semantic representation space of English sentences and the semantic representation space of Chinese sentences are two independent representation spaces. At this time, the distance between the representation vectors of Chinese and English sentences cannot reflect their semantic similarity.
- the English sentence semantic representation space and the Chinese sentence semantic representation space are aligned to a common sentence semantic representation space by shortening the representation distance between the anchor sample and the positive sample and increasing the representation distance between the anchor sample and the true negative sample. In this way, in the common sentence semantic representation space, the distance between the representation vectors of Chinese and English sentences can reflect their semantic similarity.
- the Chinese sentence encoder and the English sentence encoder in the Chinese-English sentence representation alignment model can be used as Chinese-English sentence representation models to encode Chinese sentences and English sentences respectively to obtain corresponding vectors.
- the obtained Chinese sentence vectors and English sentence vectors are in a common sentence semantic representation space.
- the semantic similarity between sentences can be obtained by calculating the distance between vectors.
- S2 The second stage, multi-level Chinese and English paragraph representation based on graph attention network.
- the multi-level Chinese and English paragraph representation based on graph attention network specifically includes the following processes:
- S21 Model the Chinese paragraph/English paragraph from three levels: keyword, sentence and paragraph (multi-level information modeling of paragraph).
- the global paragraph node is connected to each topic word node and sentence node with an edge. In this way, the paragraph is modeled into a paragraph graph from the three levels of topic words, sentences and paragraphs, which serves as the input for the next step of Chinese and English paragraph representation.
- Keywords are words that can express the central content of a paragraph. Extract the top k most important keywords as the subject words of the paragraph and construct corresponding subject word nodes. Record the sentence numbers and word order of the k keywords in the sentences.
- S212 Segment the Chinese paragraph/English paragraph and construct a sentence node for each sentence in the paragraph, represented as c is the number of sentences in the Chinese paragraph/English paragraph.
- each topic word node h i it is necessary to count the position of the topic word in the paragraph (in which sentences it appeared and the position in the sentence, that is, the sentence number and the word order in the sentence).
- the feature vector of each word is obtained.
- the feature vector of the topic word is extracted according to the recorded word order as the initialization vector of the topic word node; if the topic word appears multiple times in the paragraph, first use the above method to obtain the feature vector of the topic word at each position, and then average pool these vectors to obtain the initialization feature of the topic word node.
- topic word nodes For k topic word nodes, feature vectors h 1 , h 2 ...h k can be obtained.
- the topic word features obtained in this way contain the context information of the sentence. Words in different sentences can have different semantics according to different context information, which can effectively solve the polysemy problem.
- the initialized feature vector of a sentence node is the feature vector obtained after encoding and average pooling the sentence through the Chinese and English sentence representation models. For c sentence nodes, we get h k+1 , h k+2 ...h k+c .
- the initialization feature vector of the global node is h k+c+1 obtained by averaging the initialization feature vectors of all other topic nodes and sentence nodes.
- S215 Establish edge relationships between nodes in the following manner:
- sentence A contains keyword a
- an edge is established between the sentence node corresponding to sentence A and the keyword node corresponding to keyword a.
- sentence A and sentence B have a contextual relationship in the Chinese paragraph or the English paragraph, an edge is established between the sentence node corresponding to sentence A and the sentence node corresponding to sentence B to connect them;
- Each node establishes an edge connecting to itself.
- the edge relationship between nodes is modeled as follows:
- e pq represents the edge relationship between node p and node q.
- the paragraph graph is processed through the graph attention network, information is transmitted between nodes, and finally the paragraph representation vector of the Chinese paragraph/English paragraph is generated by integrating the three levels of information: topic words, sentences and global paragraph information.
- the node feature vector output by the previous layer of graph attention network is As the input of the graph attention network of this layer, the feature vector of each node after information interaction is output Where n is the total number of nodes; the input of the first layer of the graph attention network is the initialization feature vector of all nodes and the edge relationship between nodes epq , p, q ⁇ 1, 2, ...n ⁇ .
- the construction process of each layer of the graph attention network is as follows:
- a shared linear transformation W is learned to transform the input features of the node into deeper features. Then self-attention is performed between the nodes to calculate the weight of the edge between the nodes. If there is an edge connection between node p and node q, the weight calculation formula of the edge relationship e pq is as follows:
- a pq represents the importance of node q to node p;
- d( ⁇ ) represents the similarity function between two vectors, and cosine similarity is used here; in the process of information transmission, the neighbor node information of each node will be transmitted to the node, where the neighbor node includes the node itself, and the weight of the edge relationship between the node and the neighbor node is normalized by softmax:
- ⁇ represents a nonlinear transformation function
- the feature vector of each node finally output by each layer of graph attention network is input into the next layer of graph attention network.
- the final feature vectors of each node are fused to obtain the paragraph representation vector of the Chinese paragraph/English paragraph.
- the feature vectors of the topic node and the sentence node are averaged and pooled, which is expressed as follows:
- h word and h sentence represent the average pooled topic word node representation vector and sentence node representation vector respectively. Then, the average pooled topic word node representation vector, sentence node representation vector and global paragraph node feature vector are concatenated and then compressed through two fully connected layers to obtain the Chinese paragraph/English paragraph representation vector h paragraph , which is expressed as follows:
- S3 The third stage is the calculation of semantic similarity between Chinese and English cross-language paragraphs.
- cos( ⁇ ) is the cosine similarity between calculated vectors.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Artificial Intelligence (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Health & Medical Sciences (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Data Mining & Analysis (AREA)
- Life Sciences & Earth Sciences (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Bioinformatics & Computational Biology (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Evolutionary Biology (AREA)
- Evolutionary Computation (AREA)
- Machine Translation (AREA)
Abstract
本发明公开了一种面向段落级文本的中英文语义相似度计算方法,其分别对中文段落和英文段落进行段落表征向量提取,从主题词、句子和段落三个层次对段落文本进行建模,并基于图注意力网络在各个层次内部和各个层次信息之间进行信息交互,然后融合主题词、句子和段落三个层次的信息得到段落表征向量,通过计算段落表征向量的距离得到中文段落和英文段落的语义相似度。该方法通过融合主题词、句子和段落三个层次的信息得到高质量的段落表征向量,能实现中英跨语言段落语义相似度的高精度计算。
Description
本申请要求于2023年02月09日提交中国专利局、申请号为202310085688.7、发明名称为“面向段落级文本的中英文语义相似度计算方法”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本发明涉及信息技术领域,特别是涉及一种面向段落级文本的中英文语义相似度计算方法。
现在,随着世界文化交流程度的加强以及各国跨语言之间的资源共享,跨语言场景变得越来越普遍,这导致了跨语言应用需求的越发迫切。为了解决由此带来的技术壁垒,实现跨语言之间的资源共享,学术界和工业界一直都在积极探索跨语言的自然语言处理技术。而其中,跨语言段落语义相似度计算就是一项重要的研究内容,它研究的是如何对不同语言的段落级文本进行语义相似度计算,这在许多跨语言处理应用及其相关领域中扮演着重要角色,如对不同语言申请书的摘要进行语义相似度计算,完成相似申请书的检测和遴选;对不同语言论文的摘要进行语义相似度计算,从而实现相似论文检测,完成跨语言论文推荐和跨语言抄袭检测。
现阶段的中英跨语言段落语义相似度计算方法精度还有待提高,其主要存在以下三点不足:
(1)跨语言段落语义相似度计算需要解决语言之间的障碍。但是,目前的大多数跨语言相似度检测使用翻译的技巧来解决语言之间的障碍,包括:基于字典、基于平行语料库、基于机器翻译的方法等。相当于把跨语言问题转换为单语或者中间语言之后,再来解决相似度度量的问题。然而,在转换的过程不管是字典、平行语料库、机器翻译都存在缺陷,极有可能丢失文本的一部分深层信息。
(2)中英句子表征对齐里的负样本应该与锚样本语义不相似。中英句子表征对齐使用中英平行句对数据集进行训练,对于中英平行句对数据集,当锚样本是中文句子的时候,那么它的正样本是与中文句子平行的英文句子,负样本则需要自己构造,现有方法把其它平行句子对里的英文句子作为负样本,但是这种方法生成的负样本有可能是语义与锚样本相似的
假负样本。如果拉开锚样本与假负样本的表征距离,会影响句子表征的对齐,损害中英句子表征模型的性能。
(3)段落文本的表征应该同时考虑词、句子和段落三个层次的信息。但是,现在对段落进行表征的方法或强调通过句子层面的信息对段落进行表征,或强调通过词层面的信息对段落进行表征,缺少对段落不同层次信息的信息交互和信息融合,不能有效地从词、句子和段落三个层次同时对段落文本进行完备的表征。
发明内容
基于此,有必要提供一种面向段落级文本的中英文语义相似度计算方法,以解决现有的中英跨语言段落语义相似度计算方法精度不高的问题。
为实现上述目的,本发明提供了如下方案:
一种面向段落级文本的中英文语义相似度计算方法,包括:
分别对中文段落和英文段落进行段落表征向量提取,包括如下过程:
为中文段落/英文段落中的每个主题词构建主题词节点,为中文段落/英文段落的每个句子构建一个句子节点,为中文段落/英文段落构建一个全局段落节点;
提取主题词节点、句子节点及全局段落节点的初始化特征向量;
根据句子是否含有主题词建立句子节点与主题词节点间的边关系,根据句子在对应段落里的上下文关系建立句子节点之间的边关系,根据主题词在句子里的共现关系建立主题词节点之间的边关系,全局段落节点与每一个主题词节点和句子节点都用一条边连接;每个节点建立一条与自身连接的边;对节点间的边关系进行建模;
将所有节点的初始化特征向量及节点间的边关系输入图注意力网络,输出信息交互后各节点的特征向量;
分别将主题词节点、句子节点的特征向量作平均池化,然后对平均池化后的主题词节点表征向量、句子节点表征向量与全局段落节点的特征向量进行拼接及降维,得到中文段落/英文段落的段落表征向量;
计算中文段落的段落表征向量与英文段落的段落表征向量之间的距离得到中文段落与英文段落的语义相似度。
进一步地,在分别对中文段落和英文段落进行段落表征向量提取之前
还包括:
基于中英平行句对数据集训练得到中英文句子表征对齐模型,该中英文句子表征对齐模型用于提取主题词节点、句子节点及全局段落节点的初始化特征向量。
进一步地,所述基于中英平行句对数据集训练得到中英文句子表征对齐模型,包括:
从中英文平行句数据集中选定锚样本,与锚样本平行的句子为正样本,其他中英文平行句对中与锚样本语言不同的句子为负样本;
对于每个负样本,若其与锚样本的语义相似度大于设定阈值,则该负样本为假负样本,将假负样本的权重赋值为0;否则,将负样本的权重赋值为1;
利用去假负样本后得到的训练集对中英文句子表征对齐模型进行训练,得到训练完成后的中英文句子表征对齐模型;其中,中英文句子表征对齐模型包括两个特征提取分支,其中一个分支包括中文句子编码器和平均池化层,另一个分支包括英文句子编码器和平均池化层。
进一步地,对于每个负样本,其与锚样本的语义相似度通过如下方法计算:
利用单语言句子语义相似度计算模型计算负样本平行的句子与锚样本之间的第一语义相似度作为负样本与锚样本的语义相似度;
或,利用单语言句子语义相似度计算模型计算负样本与锚样本平行的句子之间的第二语义相似度作为负样本与锚样本的语义相似度;
或,取第一语义相似度和第二语义相似度中的最大值作为负样本与锚样本的语义相似度。
进一步地,训练中英文句子表征对齐模型时,目标函数表示如下:
min L(xi,yi)+L(yi,xi)
min L(xi,yi)+L(yi,xi)
其中,L(xi,yi)和L(yi,xi)分别表示锚样本为中文句子和英文句子时的对齐损失函数,表示如下:
其中,d(x,y)表示中文句子x与英文句子y的向量相似度;τ表示温度超参数;αi,j表示锚样本xi的负样本yj的权重;下标i、j表示中英平行句对的编号,N为该训练批次中中英平行句对的总数。
进一步地,所述为中文段落/英文段落中的每个主题词构建主题词节点,为中文段落/英文段落的每个句子构建一个句子节点,包括:
利用TF-IDF算法提取中文段落/英文段落中的关键词,提取重要性最高的前k个关键词作为中文段落/英文段落的主题词并对应构建主题词节点分别记录这k个主题词出现的句子序号和在句子中的词序;
对中文段落/英文段落进行分句,为中文段落/英文段落的每个句子构建一个句子节点,表示为c为中文段落/英文段落的句子数。
进一步地,所述提取主题词节点、句子节点及全局段落节点的初始化特征向量,包括:
对于每个主题词节点,统计其出现的句子序号和在句子中的词序,利用中英文句子表征对齐模型中的中文句子编码器/英文句子编码器对出现对应主题词的句子进行编码,得到句子中每个词的特征向量,根据主题词在句子中的词序提取该主题词的特征向量作为该主题词节点的初始化特征向量;如果该主题词在中文段落/英文段落中出现多次,则将每个位置的主题词的特征向量进行平均池化得到该主题词节点的初始化特征向量;
对于每个句子节点,利用中英文句子表征对齐模型中的中文句子编码器/英文句子编码器对句子进行编码得到每个词的特征向量,然后进行平均池化得到特征向量作为该句子节点的初始化特征向量;
对所有主题词节点和句子节点的初始化特征向量进行平均池化,得到全局段落节点的初始化特征向量。
进一步地,各节点间的边关系通过如下方法确定:
如果句子A中含有主题词a,则句子A对应的句子节点与主题词a对应的主题词节点之间建立一条边进行连接;
如果句子A和句子B在中文段落/英文段落里有上下文关系,则句子A对应的句子节点与句子B对应的句子节点间建立一条边进行连接;
如果主题词a和主题词b在中文段落/英文段落的句子里存在共现关系,则在它们对应的主题词节点之间建立一条边进行连接;
全局段落节点与所有的句子节点和主题词节点都建立一条边进行连接;
每个节点建立一条与自身连接的边;
节点间的边关系建模表示如下:
其中,epq表示节点p与节点q之间的边关系。
进一步地,所述将所有节点的初始化特征向量及节点间的边关系输入图注意力网络,输出信息交互后各节点的特征向量,包括:
对于每一层图注意力网络,将上一层图注意力网络输出的节点特征向量作为该层图注意力网络的输入,输出信息交互后各节点的特征向量其中n为节点总数;第一层图注意力网络的输入为所有节点的初始化特征向量和节点间的边关系;其中,每层图注意力网络构建过程如下:
学习一个共享的线性转换W,在节点之间进行自注意力以计算节点之间边的权重,如果节点p和节点q之间有一条边连接的话,则边关系epq的权重计算公式如下:
其中,Apq表示节点q对节点p的重要性,d(·)表示两个向量之间的相似度函数;
每个节点的邻居节点信息都会传递到该节点身上,其中邻居节点包括该节点自身,对该节点的邻居节点的边关系的权重用softmax进行归一化:
其中,是节点p的邻居节点集,m表示节点m;
节点p更新后的特征向量表示如下:
其中,σ表示非线性变换函数;
将每层图注意力网络最终输出的各节点的特征向量输入到下一层图注意力网络,经过最后一层图注意力网络输出后,得到各节点最终的特征向量h′p,p=1,2…n。
进一步地,中文段落/英文段落的段落表征向量通过如下方法得到:
用h′p,p=1,2…k表示主题词节点的特征向量,用h′p,p=k+1,k+2…k+c表示句子节点的特征向量,用h′p,p=k+c+1表示全局段落节点的特征向量;其中,k为主题词节点总数,c为句子节点总数;
分别将主题词节点、句子节点的特征向量作平均池化,表示如下:
其中,hword、hsentence分别表示平均池化后的主题词节点表征向量、句子节点表征向量;
对平均池化后的主题词节点表征向量、句子节点表征向量与全局段落节点的特征向量进行拼接后,再经过两层全连接层进行维度压缩,得到中文段落/英文段落的段落表征向量hparagraph,表示如下:
其中,hglobal=h′k+c+1表示全局段落节点的特征向量,分别表示两层全连接层的权重矩阵,b1、b2分别表示两层全连接层的偏置系数。
本发明提出了一种面向段落级文本的中英文语义相似度计算方法,
提出了一种多层次的段落表征方法,能够从主题词、句子和段落三个层次对段落文本进行建模,并基于图注意力网络在各个层次内部和各个层次信息之间进行信息交互,然后融合主题词、句子和段落三个层次的信息得到高质量的段落表征向量,通过计算段落表征向量的距离得到中文段落和英文段落的语义相似度,该方法能实现中英跨语言段落语义相似度的高精度计算,可以应用于对不同语言申请书的摘要进行相似度计算,完成相似申请书的检测和遴选;还可以应用于对不同语言论文的摘要进行相似度计算,从而实现相似论文检测,完成跨语言的论文推荐。
说明书附图
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1是本发明实施例提供的面向段落级文本的中英文语义相似度计算方法整体框架图;
图2是本发明实施例提供的去假负样本的中英文句子表征对齐流程图;
图3是本发明实施例提供的正负样本的构建过程示意图;
图4是本发明实施例提供的中英文句子表征对齐模型框架示意图,其中,(a)和(b)分别为锚样本为中文句子和英文句子的中英文句子表征对齐模型框架示意图;
图5是本发明实施例提供的中英文句子表征对齐后的结果展示图。
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
本发明实施例提供了一种面向段落级文本的中英文语义相似度计算方法,首先通过去假负样本的中英文句子表征对齐方法,将不同语言的句
子表征对齐到公共的表征空间下,在公共表征空间下句子的相似度可以通过计算句子向量的距离得到,为实现中英文段落表征提供词和句子层面的表征基础。其次提出一种多层次的段落表征方法,能够从主题词、句子和段落三个层次对段落文本进行建模,并基于图注意力网络在各个层次内部和各个层次信息之间进行信息交互,然后融合主题词、句子和段落三个层次的信息得到高质量的段落表征向量,通过计算段落表征向量的距离得到中文段落和英文段落的语义相似度。
如图1所示,本实施例提供的面向段落级文本的中英文语义相似度计算方法包括三个阶段:去假负样本的中英文句子表征对齐,基于图注意力网络的多层次中英文段落表征,中英跨语言段落语义相似度计算。
S1:第一阶段,去假负样本的中英文句子表征对齐。
去假负样本的中英文句子表征对齐方法选取中英平行句对数据集作为训练数据,首先以中英平行句对数据集为基础,选取锚样本并生成对应的负样本与正样本;然后对负样本进行筛选,筛掉假负样本,保留真负样本;在构建中英文句子表征对齐模型后,就可以用锚样本、正样本和真负样本来训练中英文句子表征对齐模型;训练完成后就得了中英文句子表征模型,它能够对中文句子和英文句子进行编码,将它们表示在一个公共的语义表征空间下,通过计算中文句子和英文句子的表征向量间的距离就可以得到句子间的语义相似度。
本实施例中基于深度语义的特征提取方法,因为中文和英文之间有大量的中英平行句对语料作为监督信息,能够通过有监督的句子表征对齐方法将不同语言的句子语义表征对齐到一个公共的表征空间下,在公共表征空间下句子的相似度可以通过计算句子向量的距离得到,而不需要翻译成单语言再进行计算,避免了机器翻译过程的翻译偏差可能带来的语义丢失。
如图2所示,去假负样本的中英文句子表征对齐包括如下步骤。
S11:以中英平行句对数据集为基础,选取锚样本并生成对应的负样本与正样本。
对于一个中文句子的锚样本,它的正样本是与它语义相似的英文句子,而负样本是与它语义不相似的英文句子,正样本和负样本的质量会对中英文句子表征对齐模型训练有很大的影响,会使得模型的表征能力下降。目
前可用的训练数据集只有中英平行句对数据集,每个中英平行句对由一对平行的中文句子和英文句子组成,假设一个训练批次里有N对中英平行句对(xi,yi),i=1,2…N,则对于中文句子xi来说,它的一个正样本就是与之平行的英文句子yi,负样本是同一训练批次中其它平行句对里的英文句子yj,j=1,2…N∪j≠i。
同理,当英文句子yi作为锚样本的时候,正样本是与之平行的中文句子xi,负样本是同一训练批次中其它平行句对里的中文句子xj,j=1,2…N∪j≠i。
S12:对负样本进行筛选,筛掉假负样本,保留真负样本。
对于负样本yj,需要满足与锚样本xi语义不相似这一条件,但是通过同一训练批次下其它中英平行句对构造的负样本并不一定满足这个条件,需要对负样本进行筛选。对于负样本yj,如果它与锚样本xi的语义相似度sim(xi,yj)大于设定阈值则说明负样本与锚样本是语义相似的,不符合负样本的要求,即这个负样本是假负样本。如果拉开锚样本与假负样本的表征距离,会影响句子表征的对齐,损害中英文句子表征对齐模型的性能。
但是因为锚样本xi与负样本yj是不同语言的句子,而现有的中英文句子语义相似度计算技术并不成熟(精度不高),不能直接计算它们的相似度,这里提出一种间接计算相似度的方法。当锚样本是中文句子xi时,如果要与英文句子yj计算相似度,可以用中文句子xi的平行英文句子yj来与英文句子yj计算相似度得到simen(yi,yj),同理也可以利用英文句子yj的平行中文句子xj来和中文句子xi计算相似度得到simzh(xi,xj),这里simzh(·)和simen(·)分别表示中文句子相似度计算和英文句子相似度计算。具体实施时,利用成熟的单语言句子语义相似度计算模型来计算锚样本与负样本的语义相似度,在计算中文句子相似度时,可以利用中文句子编码器RoBERTa-wwm-ext(Chinese version)来对中文句子进行编码,然后将编码后得到的词的表征向量进行平均池化得到中文句子的特征向量,然后通过计算两个中文句子的特征向量的余弦相似度得到中文句子相似度simzh(·);在计算英文句子相似度时,可以利用英文句子编码器bert-base-uncased(English version)来对英文句子进行编码,然后将编码后
得到的词的表征向量进行平均池化得到英文句子的特征向量,然后通过计算两个英文句子的特征向量的余弦相似度得到英文句子相似度simen(·)。
因为负样本与锚样本的相似度越大则说明这个负样本是假负样本的可能性越大,为了提高判断假负样本的鲁棒性,在本发明一优选实施例中,中文句子xi和英文句子yj的语义相似度sim(xi,yj)取两者的最大值,其表示如下:
sim(xi,yj)=max(simzh(xi,xj),simen(yi,yj))。
sim(xi,yj)=max(simzh(xi,xj),simen(yi,yj))。
得到相似度后,需要设置一个阈值如果负样本与锚样本的相似度则说明这个负样本是假负样本,不能用来训练模型,需要通过给假负样本赋权重为0来去除它对模型训练的影响。负样本的权重赋值可表示如下:
其中,αi,j表示锚样本xi的负样本yj的权重。当然,需要说明的是,上述是以锚样本为中文句子xi为例的说明,图3所示为一个正负样本的构建过程示意图。同理,当以英文句子yj为锚样本时,上述筛选掉假负样本的过程原理相同,只需对处理对象作对应调整即可。
S13:构建中英文句子表征对齐模型。
中英文句子表征对齐模型如图4所示,其中图4(a)为锚样本为中文句子的示意图,图4(b)为锚样本为英文句子的示意图。中文句子进入中文句子编码器得到句子中词的表征向量,经过平均池化层得到中文句子的表征向量,英文句子进入英文句子编码器得到句子中词的表征向量,经过平均池化层得到英文句子的表征向量。这里的英文句子编码器采用bert-base-uncased(English version),它是已经训练好的单语言英语句子编码器,可以对英文句子进行语义表征;中文句子的编码器采用RoBERTa-wwm-ext(Chinese version),它是已经训练好的单语言中文句子编码器,可以对中文句子进行语义表征。
S14:训练中英文句子表征对齐模型。
用锚样本、正样本、负样本来训练中英文句子表征对齐模型,训练过程中,损失函数采用InfoNCE loss的变体,当锚样本是中文句子xi时,正
样本是英文句子yi,负样本是N-1个英文句子yj,j=1,2…N∪j≠i。对齐损失函数L(xi,yi)为:
其中,d(x,y)表示中文句子x与英文句子y的向量相似度;τ表示温度超参数;αi,j表示锚样本xi的负样本yi的权重;下标i、j表示中英平行句对的编号,N为该训练批次中中英平行句对的总数。对齐损失函数相当于一个N路的softmax分类问题,其中正样本是正确的,而N-1个负样本是错误的。模型的训练目标是拉近锚样本与正样本的向量距离,拉开与负样本的向量距离,从而能够在拉近语义相似的句子在公共语义空间中的表示,同时拉开语义不相似的句子在公共语义空间中的表示,实现对齐到同一表征空间的目的。
同理,当锚样本是英文句子yi时,对齐损失函数L(yi,xi)为:
其中,αj,i表示锚样本yi的负样本xj的权重。
则中英文句子表征对齐模型的目标函数表示如下:
min L(xi,yi)+L(yi,xi)。
min L(xi,yi)+L(yi,xi)。
总的来说训练的目的是使得语义相似的句子它们向量间的距离最小化,语义不相似的句子它们向量间的距离最大化,以此来实现不同语言句子表征空间的对齐。
目标函数包括两个对齐损失,相当于从两个方向进行对齐(中->英,英->中)。举个简单的例子,有下面四对中英平行句子对来训练模型:
①英语是使用最广泛的语言。English is the most widely spoken language.
②汉语是使用人数最多的语言。Chinese is the most spoken language.
③世界上现存的语言大约有6909种。There are about 6909 languages in existence in the world.
④英语的使用最广泛。English is the most widely used.
当以平行句[①英语是使用最广泛的语言。English is the most widely
spoken language.]来计算loss训练模型时有:
1、当把“英语是使用最广泛的语言。”作为锚样本时,正样本是“English is the most widely spoken language.”,负样本是“Chinese is the most spoken language.”、“There are about 6909 languages in existence in the world.”和“English is the most widely used.”。对负样本进行筛选可以判断出{“Chinese is the most spoken language.”,“There are about 6909 languages in existence in the world.”}是真负样本,而“English is the most widely used.”语义与“英语是使用最广泛的语言。”语义相似,所以是假负样本。要在公共表征空间把“英语是使用最广泛的语言。”与“English is the most widely spoken language.”拉近,同时把“英语是使用最广泛的语言。”和真负样本{“Chinese is the most spoken language.”,“There are about 6909 languages in existence in the world.”}这两个句子拉远,假负样本不进行拉远。
2、当把“English is the most widely spoken language.”作为锚样本时,正样本是“英语是使用最广泛的语言。”,负样本是“汉语是使用人数最多的语言。”、“世界上现存的语言大约有6909种。”和“英语的使用最广泛。”。对负样本进行筛选可以判断出{“汉语是使用人数最多的语言。”,“世界上现存的语言大约有6909种。”}是真负样本,而“英语的使用最广泛。”语义与“English is the most widely spoken language.”语义相似,所以是假负样本。要在公共表征空间把“English is the most widely spoken language.”与“英语是使用最广泛的语言。”拉近,同时把“English is the most widely spoken language.”和{“汉语是使用人数最多的语言。”,“世界上现存的语言大约有6909种。”}这两个句子拉远,假负样本不进行拉远。
这样双向训练后,对于句子“英语是使用最广泛的语言。”,句子“English is the most widely spoken language.”在表征空间中离它最近,对于句子“English is the most widely spoken language.”,句子“英语是使用最广泛的语言。”在表征空间中也离它最近。如果只训练一个方向,就可能导致这样一个情况:对于句子“英语是使用最广泛的语言。”,句子“English is the most widely spoken language.”在表征空间中离它最近,而
对于句子“English is the most widely spoken language.”,句子“英语是使用最广泛的语言。”在表征空间中并不是离它最近的,也就是可能有其它句子离句子“English is the most widely spoken language.”更近,这样达不到句子表征对齐的目的,所以需要双向对齐。
图5所示为中英文句子表征对齐后的结果展示图(中英句子表征对齐以锚样本为“英语是使用最广泛的语言。”作为例子进行展示),在中英句子表征对齐之前,英文句子语义表征空间和中文句子语义表征空间是两个独立的表征空间,这时中文句子和英文句子它们表征向量的距离是不能反映它们语义相似度的。在通过中英句子表征对齐后,通过拉近锚样本和正样本的表征距离,同时拉开锚样本和真负样本的表征距离,将英文句子语义表征空间和中文句子语义表征空间对齐到一个公共的句子语义表征空间下,这样在公共句子语义表征空间下,中文句子和英文句子它们表征向量的距离就能反映出它们的语义相似度。
S15:得到中英文句子表征模型。
中英文句子表征对齐模型训练完成后,中英文句子表征对齐模型中的中文句子编码器和英文句子编码器就可以作为中英句子表征模型,分别对中文句子和英文句子进行编码得到对应的向量,得到的中文句子向量和英文句子向量是在一个公共的句子语义表征空间下的,通过计算向量间的距离可以得到句子间的语义相似度。
S2:第二阶段,基于图注意力网络的多层次中英文段落表征。
基于图注意力网络的多层次中英文段落表征具体包括如下过程:
S21:从主题词、句子和段落三个层次对中文段落/英文段落进行建模(段落的多层次信息建模)。
首先根据段落的主题词和句子构建主题词节点和句子节点,并添加一个全局段落节点,其次根据句子是否含有主题词建立句子节点与主题词节点间的边关系,同时根据句子在段落里的上下文关系和主题词在句子里的共现关系分别建立句子节点之间的边关系和主题词节点之间的边关系,全局段落节点与每一个主题词节点和句子节点都用一条边连接。通过这样的方式从主题词、句子和段落三个层面把段落建模成一个段落图,以作为下一步中英段落表征的输入。具体步骤如下:
S211:利用TF-IDF算法提取中文段落/英文段落中的关键词,关键词是能够表达段落中心内容的词语,提取重要性最高的前k个关键词作为段落的主题词并对应构建主题词节点分别记录这k个主题词出现的句子序号和在句子中的词序。
S212:对中文段落/英文段落的进行分句,为段落里的每个句子构建一个句子节点,表示为c为中文段落/英文段落里的句子数。
S213:为中文段落/英文段落构建一个全局段落节点nodeglobal。
S214:利用中英文句子表征模型对节点的特征进行初始化。
假设所构建的段落图中有k个主题词节点,c个句子节点,1个全局节点,一共有n=k+c+1个节点,按照主题词节点、句子节点和全局节点的顺序对节点进行排序得到nodei,i=1,2…n,对这些节点进行特征初始化,方法如下:
对于每个主题词节点hi,需要统计主题词在段落里出现的位置(在哪些句子中出现过以及在句子里的位置,即句子序号和在句子中的词序),在对主题词进行编码时,首先将主题词出现的句子输入进中英文句子表征模型中,在经过中文/英文句子编码器对句子编码后,得到每个词的特征向量,根据记录的词序提取出该主题词的特征向量作为该主题词节点的初始化向量;如果主题词在段落里出现了多次,则先分别通过上面方法得到每个位置主题词的特征向量,然后对这些向量进行平均池化得到主题词节点的初始化特征。
对于k个主题词节点就可以得到特征向量h1,h2…hk。这样得到的主题词特征包含了句子的上下文信息,在不同句子里的词根据上下文信息的不同可以有着不同的语义,能够有效解决一词多义问题。
句子节点的初始化特征向量就是句子通过中英文句子表征模型进行编码和平均池化后得到的特征向量,对于c个句子节点得到hk+1,hk+2…hk+c。
全局节点的初始化特征向量是其它所有主题词节点和句子节点初始化特征向量进行平均池化后得到的hk+c+1。
S215:通过如下方式建立节点间的边关系:
(1)如果句子A中含有主题词a,则句子A对应的句子节点与主题词a对应的主题词节点之间建立一条边进行连接;
(2)如果句子A和句子B在中文段落/英文段落里有上下文关系,则句子A对应的句子节点与句子B对应的句子节点间建立一条边进行连接;
(3)如果主题词a和主题词b在中文段落/英文段落的句子里存在共现关系,则在它们对应的主题词节点之间建立一条边进行连接;
(4)全局段落节点与所有的句子节点和主题词节点都建立一条边进行连接;
(5)每个节点建立一条与自身连接的边。
S216:对节点间的边关系进行建模表示。
对于节点p和节点q,如果它们之间有一条边连接,则它们互为邻居节点(节点自己也算作自己的邻居节点)。如果节点p和节点q互为邻居节点则epq=1,否则epq=0。节点间的边关系建模表示如下:
其中,epq表示节点p与节点q之间的边关系。
S22:基于图注意力网络的信息交互和信息融合。
通过图注意力网络对段落图进行处理,在各个节点间进行信息传递,最后通过融合主题词、句子和全局段落信息三个层次的信息生成中文段落/英文段落的段落表征向量。
对于每一层图注意力网络,将上一层图注意力网络输出的节点特征向量作为该层图注意力网络的输入,输出信息交互后各节点的特征向量其中n为节点总数;第一层图注意力网络的输入为所有节点的初始化特征向量和节点间的边关系epq,p,q∈{1,2,…n}。每层图注意力网络构建过程如下:
为了获得足够的表达能力,学习一个共享的线性转换W,将节点的输入特征转换为更深层次的特征。然后在节点之间进行自注意力以计算节点之间边的权重,如果节点p和节点q之间有一条边连接的话,则边关系epq的权重计算公式如下:
其中,Apq表示节点q对节点p的重要性;d(·)表示两个向量之间的相似度函数,这里采用余弦相似度;在信息传递过程中,每个节点的邻居节点信息都会传递到该节点身上,其中邻居节点包括该节点自身,对该节点的邻居节点的边关系的权重用softmax进行归一化:
其中,是节点p的邻居节点集,m表示节点m。得到归一化的注意力权重后就可以用来更新节点p的特征,节点p更新后的特征向量表示如下:
其中,σ表示非线性变换函数。
将每层图注意力网络最终输出的各节点的特征向量输入到下一层图注意力网络,经过最后一层图注意力网络输出后,得到各节点最终的特征向量h′p,p=1,2…n。
对各节点最终的特征向量进行融合得到中文段落/英文段落的段落表征向量,首先分别将主题词节点、句子节点的特征向量作平均池化,表示如下:
其中,hword、hsentence分别表示平均池化后的主题词节点表征向量、句子节点表征向量。然后对平均池化后的主题词节点表征向量、句子节点表征向量与全局段落节点的特征向量进行拼接后,再经过两层全连接层进行维度压缩,得到中文段落/英文段落的段落表征向量hparagraph,表示如下:
其中,hglobal=h′k+c+1表示全局段落节点的特征向量,分别表示两层全连接层的权重矩阵,b1、b2分别表示两层全连接层的偏置系数。
S3:第三阶段,中英跨语言段落语义相似度计算。
计算中文段落的段落表征向量与英文段落的段落表征向量之间的距离得到中文段落与英文段落的语义相似度Similarity:
其中,cos(·)是计算向量间的余弦相似度。
本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处。综上所述,本说明书内容不应理解为对本发明的限制。
Claims (10)
- 一种面向段落级文本的中英文语义相似度计算方法,其特征在于,包括:分别对中文段落和英文段落进行段落表征向量提取,包括如下过程:为中文段落/英文段落中的每个主题词构建主题词节点,为中文段落/英文段落的每个句子构建一个句子节点,为中文段落/英文段落构建一个全局段落节点;提取主题词节点、句子节点及全局段落节点的初始化特征向量;根据句子是否含有主题词建立句子节点与主题词节点间的边关系,根据句子在对应段落里的上下文关系建立句子节点之间的边关系,根据主题词在句子里的共现关系建立主题词节点之间的边关系,全局段落节点与每一个主题词节点和句子节点都用一条边连接;每个节点建立一条与自身连接的边;对节点间的边关系进行建模;将所有节点的初始化特征向量及节点间的边关系输入图注意力网络,输出信息交互后各节点的特征向量;分别将主题词节点、句子节点的特征向量作平均池化,然后对平均池化后的主题词节点表征向量、句子节点表征向量与全局段落节点的特征向量进行拼接及降维,得到中文段落/英文段落的段落表征向量;计算中文段落的段落表征向量与英文段落的段落表征向量之间的距离得到中文段落与英文段落的语义相似度。
- 根据权利要求1所述的面向段落级文本的中英文语义相似度计算方法,其特征在于,在分别对中文段落和英文段落进行段落表征向量提取之前还包括:基于中英平行句对数据集训练得到中英文句子表征对齐模型,该中英文句子表征对齐模型用于提取主题词节点、句子节点及全局段落节点的初始化特征向量。
- 根据权利要求2所述的面向段落级文本的中英文语义相似度计算方法,其特征在于,所述基于中英平行句对数据集训练得到中英文句子表征对齐模型,包括:从中英文平行句数据集中选定锚样本,与锚样本平行的句子为正样本,其他中英文平行句对中与锚样本语言不同的句子为负样本;对于每个负样本,若其与锚样本的语义相似度大于设定阈值,则该负样本为假负样本,将假负样本的权重赋值为0;否则,将负样本的权重赋值为1;利用去假负样本后得到的训练集对中英文句子表征对齐模型进行训练,得到训练完成后的中英文句子表征对齐模型;其中,中英文句子表征对齐模型包括两个特征提取分支,其中一个分支包括中文句子编码器和平均池化层,另一个分支包括英文句子编码器和平均池化层。
- 根据权利要求3所述的面向段落级文本的中英文语义相似度计算方法,其特征在于,对于每个负样本,其与锚样本的语义相似度通过如下方法计算:利用单语言句子语义相似度计算模型计算负样本平行的句子与锚样本之间的第一语义相似度作为负样本与锚样本的语义相似度;或,利用单语言句子语义相似度计算模型计算负样本与锚样本平行的句子之间的第二语义相似度作为负样本与锚样本的语义相似度;或,取第一语义相似度和第二语义相似度中的最大值作为负样本与锚样本的语义相似度。
- 根据权利要求3所述的面向段落级文本的中英文语义相似度计算方法,其特征在于,训练中英文句子表征对齐模型时,目标函数表示如下:
min L(xi,yi)+L(yi,xi)其中,L(xi,yi)和L(yi,xi)分别表示锚样本为中文句子和英文句子时的对齐损失函数,表示如下:
其中,d(x,y)表示中文句子x与英文句子y的向量相似度;τ表示温度超参数;αi,j表示锚样本xi的负样本yj的权重;下标i、j表示中英平行句对的编号,N为该训练批次中中英平行句对的总数。 - 根据权利要求1至5任一项所述的面向段落级文本的中英文语义相似度计算方法,其特征在于,所述为中文段落/英文段落中的每个主题词 构建主题词节点,为中文段落/英文段落的每个句子构建一个句子节点,包括:利用TF-IDF算法提取中文段落/英文段落中的关键词,提取重要性最高的前k个关键词作为中文段落/英文段落的主题词并对应构建主题词节点分别记录这k个主题词出现的句子序号和在句子中的词序;对中文段落/英文段落进行分句,为中文段落/英文段落的每个句子构建一个句子节点,表示为c为中文段落/英文段落的句子数。
- 根据权利要求2至5任一项所述的面向段落级文本的中英文语义相似度计算方法,其特征在于,所述提取主题词节点、句子节点及全局段落节点的初始化特征向量,包括:对于每个主题词节点,统计其出现的句子序号和在句子中的词序,利用中英文句子表征对齐模型中的中文句子编码器/英文句子编码器对出现对应主题词的句子进行编码,得到句子中每个词的特征向量,根据主题词在句子中的词序提取该主题词的特征向量作为该主题词节点的初始化特征向量;如果该主题词在中文段落/英文段落中出现多次,则将每个位置的主题词的特征向量进行平均池化得到该主题词节点的初始化特征向量;对于每个句子节点,利用中英文句子表征对齐模型中的中文句子编码器/英文句子编码器对句子进行编码得到每个词的特征向量,然后进行平均池化得到特征向量作为该句子节点的初始化特征向量;对所有主题词节点和句子节点的初始化特征向量进行平均池化,得到全局段落节点的初始化特征向量。
- 根据权利要求1至5任一项所述的面向段落级文本的中英文语义相似度计算方法,其特征在于,各节点间的边关系通过如下方法确定:如果句子A中含有主题词a,则句子A对应的句子节点与主题词a对应的主题词节点之间建立一条边进行连接;如果句子A和句子B在中文段落/英文段落里有上下文关系,则句子A对应的句子节点与句子B对应的句子节点间建立一条边进行连接;如果主题词a和主题词b在中文段落/英文段落的句子里存在共现关 系,则在它们对应的主题词节点之间建立一条边进行连接;全局段落节点与所有的句子节点和主题词节点都建立一条边进行连接;每个节点建立一条与自身连接的边;节点间的边关系建模表示如下:
其中,epq表示节点p与节点q之间的边关系。 - 根据权利要求1至5任一项所述的面向段落级文本的中英文语义相似度计算方法,其特征在于,所述将所有节点的初始化特征向量及节点间的边关系输入图注意力网络,输出信息交互后各节点的特征向量,包括:对于每一层图注意力网络,将上一层图注意力网络输出的节点特征向量作为该层图注意力网络的输入,输出信息交互后各节点的特征向量其中n为节点总数;第一层图注意力网络的输入为所有节点的初始化特征向量和节点间的边关系;其中,每层图注意力网络构建过程如下:学习一个共享的线性转换W,在节点之间进行自注意力以计算节点之间边的权重,如果节点p和节点q之间有一条边连接的话,则边关系epq的权重计算公式如下:
其中,Apq表示节点q对节点p的重要性,d(·)表示两个向量之间的相似度函数;每个节点的邻居节点信息都会传递到该节点身上,其中邻居节点包括该节点自身,对该节点的邻居节点的边关系的权重用softmax进行归一化:
其中,是节点p的邻居节点集,m表示节点m;节点p更新后的特征向量表示如下:
其中,σ表示非线性变换函数;将每层图注意力网络最终输出的各节点的特征向量输入到下一层图注意力网络,经过最后一层图注意力网络输出后,得到各节点最终的特征向量h'p,p=1,2…n。 - 根据权利要求1至5任一项所述的面向段落级文本的中英文语义相似度计算方法,其特征在于,中文段落/英文段落的段落表征向量通过如下方法得到:用h'p,p=1,2…k表示主题词节点的特征向量,用h'p,p=k+1,k+2…k+c表示句子节点的特征向量,用h'p,p=k+c+1表示全局段落节点的特征向量;其中,k为主题词节点总数,c为句子节点总数;分别将主题词节点、句子节点的特征向量作平均池化,表示如下:
其中,hword、hsentence分别表示平均池化后的主题词节点表征向量、句子节点表征向量;对平均池化后的主题词节点表征向量、句子节点表征向量与全局段落节点的特征向量进行拼接后,再经过两层全连接层进行维度压缩,得到中文段落/英文段落的段落表征向量hparagraph,表示如下:
其中,hglobal=h'k+c+1表示全局段落节点的特征向量,分别表示两层全连接层的权重矩阵,b1、b2分别表示两层全连接层的偏置系数。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310085688.7A CN115828931B (zh) | 2023-02-09 | 2023-02-09 | 面向段落级文本的中英文语义相似度计算方法 |
| CN202310085688.7 | 2023-02-09 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2024164580A1 true WO2024164580A1 (zh) | 2024-08-15 |
Family
ID=85520932
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2023/128479 Ceased WO2024164580A1 (zh) | 2023-02-09 | 2023-10-31 | 面向段落级文本的中英文语义相似度计算方法 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN115828931B (zh) |
| WO (1) | WO2024164580A1 (zh) |
Cited By (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119476301A (zh) * | 2024-11-05 | 2025-02-18 | 南京邮电大学 | 基于递归卷积神经网络的中文句子语义相似度计算方法 |
| CN120012759A (zh) * | 2025-04-18 | 2025-05-16 | 北京市大数据中心 | 复杂文档的全局语境分析方法及系统 |
| CN120449885A (zh) * | 2025-04-24 | 2025-08-08 | 广州工程技术职业学院 | 多语言合同智能比对方法、系统、设备及存储介质 |
| CN121071115A (zh) * | 2025-08-25 | 2025-12-05 | 国网物资有限公司 | 一种基于人工智能的违约管理用文本分析方法 |
| CN121303304A (zh) * | 2025-09-26 | 2026-01-09 | 中国科学院文献情报中心 | 一种基于四维索引的科技文献知识自动标注方法及系统 |
| CN121301542A (zh) * | 2025-09-26 | 2026-01-09 | 中国科学院文献情报中心 | 基于大规模预训练模型的科技文献语义查新方法及系统 |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN115828931B (zh) * | 2023-02-09 | 2023-05-02 | 中南大学 | 面向段落级文本的中英文语义相似度计算方法 |
| CN117236330B (zh) * | 2023-11-16 | 2024-01-26 | 南京邮电大学 | 一种基于互信息和对抗神经网络的增强主题多样性方法 |
Citations (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| EP3249547A1 (en) * | 2016-05-27 | 2017-11-29 | Accenture Global Solutions Limited | Generating test data from samples using natural language processing and structure-based pattern determination |
| CN107862045A (zh) * | 2017-11-07 | 2018-03-30 | 哈尔滨工程大学 | 一种基于多特征的跨语言剽窃检测方法 |
| CN109213995A (zh) * | 2018-08-02 | 2019-01-15 | 哈尔滨工程大学 | 一种基于双语词嵌入的跨语言文本相似度评估技术 |
| CN112818121A (zh) * | 2021-01-27 | 2021-05-18 | 润联软件系统(深圳)有限公司 | 一种文本分类方法、装置、计算机设备及存储介质 |
| CN113836192A (zh) * | 2021-08-13 | 2021-12-24 | 深译信息科技(横琴)有限公司 | 平行语料的挖掘方法、装置、计算机设备及存储介质 |
| CN113901831A (zh) * | 2021-09-15 | 2022-01-07 | 昆明理工大学 | 基于预训练语言模型及双向交互注意力的平行句对抽取方法 |
| CN114821051A (zh) * | 2022-04-24 | 2022-07-29 | 江西省农业科学院土壤肥料与资源环境研究所 | 一种遥感图像的农用地语义分割方法 |
| CN115828931A (zh) * | 2023-02-09 | 2023-03-21 | 中南大学 | 面向段落级文本的中英文语义相似度计算方法 |
Family Cites Families (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7778817B1 (en) * | 2000-09-30 | 2010-08-17 | Intel Corporation | Method and apparatus for determining text passage similarity |
| CN104281692A (zh) * | 2014-10-13 | 2015-01-14 | 安徽华贞信息科技有限公司 | 一种实现段落维度化描述方法及系统 |
| CN108399165A (zh) * | 2018-03-28 | 2018-08-14 | 广东技术师范学院 | 一种基于位置加权的关键词抽取方法 |
| CN111967271B (zh) * | 2020-08-19 | 2025-04-25 | 北京大学 | 分析结果的生成方法、装置、设备及可读存储介质 |
-
2023
- 2023-02-09 CN CN202310085688.7A patent/CN115828931B/zh active Active
- 2023-10-31 WO PCT/CN2023/128479 patent/WO2024164580A1/zh not_active Ceased
Patent Citations (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| EP3249547A1 (en) * | 2016-05-27 | 2017-11-29 | Accenture Global Solutions Limited | Generating test data from samples using natural language processing and structure-based pattern determination |
| CN107862045A (zh) * | 2017-11-07 | 2018-03-30 | 哈尔滨工程大学 | 一种基于多特征的跨语言剽窃检测方法 |
| CN109213995A (zh) * | 2018-08-02 | 2019-01-15 | 哈尔滨工程大学 | 一种基于双语词嵌入的跨语言文本相似度评估技术 |
| CN112818121A (zh) * | 2021-01-27 | 2021-05-18 | 润联软件系统(深圳)有限公司 | 一种文本分类方法、装置、计算机设备及存储介质 |
| CN113836192A (zh) * | 2021-08-13 | 2021-12-24 | 深译信息科技(横琴)有限公司 | 平行语料的挖掘方法、装置、计算机设备及存储介质 |
| CN113901831A (zh) * | 2021-09-15 | 2022-01-07 | 昆明理工大学 | 基于预训练语言模型及双向交互注意力的平行句对抽取方法 |
| CN114821051A (zh) * | 2022-04-24 | 2022-07-29 | 江西省农业科学院土壤肥料与资源环境研究所 | 一种遥感图像的农用地语义分割方法 |
| CN115828931A (zh) * | 2023-02-09 | 2023-03-21 | 中南大学 | 面向段落级文本的中英文语义相似度计算方法 |
Cited By (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119476301A (zh) * | 2024-11-05 | 2025-02-18 | 南京邮电大学 | 基于递归卷积神经网络的中文句子语义相似度计算方法 |
| CN120012759A (zh) * | 2025-04-18 | 2025-05-16 | 北京市大数据中心 | 复杂文档的全局语境分析方法及系统 |
| CN120449885A (zh) * | 2025-04-24 | 2025-08-08 | 广州工程技术职业学院 | 多语言合同智能比对方法、系统、设备及存储介质 |
| CN121071115A (zh) * | 2025-08-25 | 2025-12-05 | 国网物资有限公司 | 一种基于人工智能的违约管理用文本分析方法 |
| CN121303304A (zh) * | 2025-09-26 | 2026-01-09 | 中国科学院文献情报中心 | 一种基于四维索引的科技文献知识自动标注方法及系统 |
| CN121301542A (zh) * | 2025-09-26 | 2026-01-09 | 中国科学院文献情报中心 | 基于大规模预训练模型的科技文献语义查新方法及系统 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN115828931B (zh) | 2023-05-02 |
| CN115828931A (zh) | 2023-03-21 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN115828931B (zh) | 面向段落级文本的中英文语义相似度计算方法 | |
| CN110390103B (zh) | 基于双编码器的短文本自动摘要方法及系统 | |
| CN116775922A (zh) | 基于语言与视觉细节特征融合的遥感图像跨模态检索方法 | |
| CN111611807B (zh) | 一种基于神经网络的关键词提取方法、装置及电子设备 | |
| CN109684648B (zh) | 一种多特征融合的古今汉语自动翻译方法 | |
| CN110532328B (zh) | 一种文本概念图构造方法 | |
| CN118133241B (zh) | 多模态预训练模型的训练方法、装置、设备和存储介质 | |
| WO2021243903A1 (zh) | 自然语言至结构化查询语言的转换方法及系统 | |
| CN113095087A (zh) | 一种基于图卷积神经网络的中文词义消歧方法 | |
| CN119990297B (zh) | 基于大模型生成和知识图谱集成的多模态关系抽取方法 | |
| CN114647730A (zh) | 一种融合图注意力和图卷积网络的事件检测方法 | |
| CN111832293A (zh) | 基于头实体预测的实体和关系联合抽取方法 | |
| CN112257460B (zh) | 基于枢轴的汉越联合训练神经机器翻译方法 | |
| CN116860960A (zh) | 一种基于知识图和bart语义的多文档摘要方法 | |
| CN119272772A (zh) | 融合多尺度特征及句法信息的社交媒体文本命名实体识别方法及系统 | |
| CN120873199A (zh) | 一种基于大语言模型的多模态自动化知识图谱构建方法 | |
| CN116822495B (zh) | 基于对比学习的汉-老、泰平行句对抽取方法及装置 | |
| CN116414988A (zh) | 基于依赖关系增强的图卷积方面级情感分类方法及系统 | |
| CN120336571A (zh) | 一种基于多模态检索增强生成的新闻图片描述方法 | |
| CN111831792B (zh) | 一种电力知识库构建方法及系统 | |
| CN109299442A (zh) | 汉语篇章主次关系识别方法和系统 | |
| CN118964625A (zh) | 结合标签关联图聚类和文本结构图注意力的合同分类方法 | |
| CN115146618B (zh) | 一种基于对比表示学习的复杂因果关系抽取方法 | |
| CN115688785B (zh) | 一种融合多源知识的航空装备型号命名实体识别方法 | |
| CN118504574A (zh) | 一种融合多粒度语义信息的中文文本蕴含识别方法 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 23920772 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 23920772 Country of ref document: EP Kind code of ref document: A1 |