Sentiment tuple extraction method and system based on syntactic semantic fusion
By employing a syntactic-semantic fusion method, utilizing a structure-aware syntactic encoder and bidirectional cross-attention fusion technology, the problem of low accuracy in sentiment tuple extraction in large language models is solved, achieving higher-precision structured prediction and improving the effectiveness of business intelligence and user experience optimization.
Patent Information
- Application Number
- CN202511476916.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-16
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2045-10-16
AI Technical Summary
Large language models have low accuracy in sentiment tuple extraction in scenarios with few or no samples, especially in structured prediction tasks such as sentiment triple extraction, nested entity recognition, and multi-hop relation extraction, which leads to reduced output accuracy.
We employ a syntactic-semantic fusion approach, which computes the encoded embedding data of the input text through a structure-aware syntactic encoder and fuses the syntactic and semantic representations through bidirectional cross-attention. We then optimize the distribution of the fused representations using a dual similarity contrastive learning framework, integrating syntactic and semantic information to improve the accuracy of sentiment tuple extraction.
It improves the output accuracy of large language models in the process of sentiment tuple extraction, enabling more accurate identification of complete sentiment tuples and enhancing the ability to process complex structured information, making it suitable for business intelligence and user experience optimization.
Smart Images

Figure CN120952009B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of large language model technology, and in particular to a method and system for extracting sentiment tuples based on syntactic-semantic fusion. Background Technology
[0002] A Large Language Model (LLM) is an artificial intelligence model built using deep learning techniques for Natural Language Processing (NLP) and natural language generation. To improve the output accuracy of LLMs, structured prediction techniques can be applied. The structured data obtained through structured prediction can provide clearer and more systematic knowledge representations for LLMs, enhancing their ability to process complex structured information.
[0003] For example, structured prediction can extract fine-grained sentiment information from e-commerce reviews, enabling business intelligence and user experience optimization. It is evident that structured prediction in large language models relies on a large amount of sample data, and insufficient or low-quality sample data will lead to a decrease in the accuracy of the large language model's output.
[0004] To improve output accuracy, large language models can leverage context learning in scenarios with few or no samples, thereby enhancing their natural language processing capabilities. However, they still perform poorly in structured prediction tasks, such as aspect-based sentiment triplet extraction (ASTE), nested entity recognition, and multi-hop relation extraction. This reduces the accuracy of sentiment triplet extraction methods and negatively impacts the natural language processing results of large language models. Summary of the Invention
[0005] In view of this, embodiments of this application provide a sentiment tuple extraction method and system based on syntactic-semantic fusion to solve the problem of low output accuracy in sentiment tuple extraction methods.
[0006] According to a first aspect of this application, a method for extracting sentiment tuples based on syntactic-semantic fusion is provided, the method comprising:
[0007] Get the input text;
[0008] The structure-aware syntactic encoder is used to compute the encoded embedding data of the input text, which includes the syntactic representation and semantic representation of the input text; the structure-aware syntactic encoder is an encoder obtained by supervised training based on graph converter through multi-dimensional syntactic similarity; the structure-aware syntactic encoder is used to inject dependency syntactic tree bias into the multi-head attention mechanism;
[0009] By employing bidirectional cross-attention fusion, the syntactic representation and the semantic representation are deeply interacted to obtain a fused representation;
[0010] The unified representation of the fusion representation is computed based on a dual similarity comparison learning framework. The unified representation is obtained by optimizing the distribution of the fusion representation in the similarity space and by aligning semantic and syntactic similarities through training on pre-constructed positive and negative sample pairs.
[0011] Candidate examples are retrieved based on the unified representation, and the candidate examples are determined based on cosine similarity; the cosine similarity is used to characterize the similarity between the unified representation and the fused vectors of all examples in the example library.
[0012] According to a second aspect of this application, a sentiment tuple extraction system based on syntactic-semantic fusion is provided, the system comprising:
[0013] The text acquisition module is used to acquire input text;
[0014] A syntax encoding module is used to compute encoded embedding data of the input text using a structure-aware syntax encoder. The encoded embedding data includes the syntactic representation and semantic representation of the input text. The structure-aware syntax encoder is an encoder obtained by supervised training based on graph converter through multi-dimensional syntactic similarity. The structure-aware syntax encoder is used to inject dependency syntax tree bias into a multi-head attention mechanism.
[0015] A bidirectional cross-attention fusion module is used to deeply interact the syntactic representation and the semantic representation through bidirectional cross-attention fusion to obtain a fused representation;
[0016] A dual similarity comparison learning module is used to compute a unified representation of the fused representation based on a dual similarity comparison learning framework. The unified representation is obtained by optimizing the distribution of the fused representation in the similarity space and by aligning semantic and syntactic similarities through training on pre-constructed positive and negative sample pairs.
[0017] The retrieval module is used to retrieve candidate examples based on the unified representation, wherein the candidate examples are determined based on cosine similarity; the cosine similarity is used to characterize the similarity between the unified representation and the fused vectors of all examples in the example library.
[0018] According to a third aspect of this application, a computer device is provided, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor executes the program to implement the above-described sentiment tuple extraction method based on syntactic-semantic fusion.
[0019] According to a fourth aspect of this application, a storage medium is provided on which a computer program is stored, which, when executed by a processor, implements the above-described sentiment tuple extraction method based on syntactic-semantic fusion.
[0020] By employing the above technical solutions, embodiments of this application provide a method and system for extracting sentiment tuples based on syntactic-semantic fusion. The method, after acquiring input text, uses a structure-aware syntactic encoder to calculate the encoded embedding data of the input text, and then uses bidirectional cross-attention fusion to deeply interact with syntactic and semantic representations to obtain a fused representation. A unified representation of the fused representation is then calculated based on a dual similarity comparison learning framework, and candidate examples are retrieved based on the unified representation. This method can generate encoded embedding data based on a dependency tree-encoded structure-aware graph converter, and achieve syntactic and semantic fusion through a bidirectional cross-attention mechanism, as well as perform dual similarity comparison learning. This provides explicit syntactic guidance for structured tasks in large language models, simultaneously integrating syntactic and semantic information, correctly identifying complete sentiment tuples, and improving the output accuracy of sentiment tuple extraction results.
[0021] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0022] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0023] Figure 1 A schematic diagram of the SynSem-ICL architecture provided in the embodiments of this application;
[0024] Figure 2 A schematic diagram of the sentiment tuple extraction method based on syntactic-semantic fusion provided in the embodiments of this application;
[0025] Figure 3 A schematic diagram of the syntactic encoding process from raw text to representation space provided for embodiments of this application;
[0026] Figure 4A schematic diagram illustrating the bidirectional cross-attention fusion process between semantic and syntactic representations provided in this application embodiment;
[0027] Figure 5 A schematic diagram of the structure of the sentiment tuple extraction system based on syntactic-semantic fusion provided in the embodiments of this application. Detailed Implementation
[0028] The present application will be described in detail below with reference to the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in the embodiments of the present application can be combined with each other.
[0029] In the embodiments of this application, the sentiment tuple extraction method and system based on syntactic-semantic fusion can be applied to the natural language processing of large language models to achieve structured prediction of sentiment tuples. Structured prediction is a data processing technique; the structured data obtained through structured prediction can provide clearer and more systematic knowledge representations for large language models, improving their ability to process complex structured information.
[0030] For example, structured prediction can be used to extract fine-grained sentiment information from e-commerce reviews. In business systems, structured prediction techniques can also be relied upon to achieve business intelligence and user experience optimization.
[0031] Large language models demonstrate significant capabilities in few-shot and zero-shot scenarios through context learning, but they still perform poorly in structured prediction tasks, such as aspect-based sentiment triple extraction, nested entity recognition, and multi-hop relation extraction. These complex problems require not only deep semantic understanding but also accurate syntactic dependency modeling to generate well-structured output.
[0032] In some embodiments, improving example selection can enhance the learning performance of large language models (MLMs) on contextual information. The selection of contextual examples is a key factor affecting the few-shot performance of LLMs. The quality of the selected examples plays a decisive role in the performance of large language models. Therefore, appropriate example selection can significantly improve the structured prediction results of large language models, while inappropriate selection often leads to severe degradation. However, the retrieval strategy of large language models relies solely on the semantic similarity of pre-trained embeddings, making them significantly inadequate in scenarios where syntactic structure plays a central role.
[0033] For example, for the phrase "the service is prompt friendly", a semantically based retrieval method would incorrectly separate the multi-word opinion "prompt friendly", while a syntactically based method would completely ignore "friendly".
[0034] The few-shot learning performance of LLMs is highly dependent on the quality of the selected context examples. For example, given a query instance q and a pool of examples... D ={( x i , y i )} N i=1 ,in, x i This indicates the input text. y i This represents the corresponding structured output, namely the triplet of aspect, opinion, and sentiment. The large language model can then select top results based on semantic similarity during retrieval. k The most relevant example is:
[0035] ;
[0036] in, R k Indicates the preceding k The most relevant examples; TopK() is a function that takes the top k examples; sim sem ( ) indicates semantic similarity; x i Indicates the input text; y i express x i The corresponding structured output; D Indicates the sample pool; q This indicates a query instance.
[0037] However, relying solely on semantic similarity cannot capture subtle structural differences that are crucial for accurate prediction. For example, for sentences... x 1 and sentences x 2:
[0038] x 1: “The ambience is very pleasant but the price is high.”
[0039] x 2: “The atmosphere here is cozy and relaxing.”
[0040] Although the sentence x 1 and sentences x 2. While semantically similar and both used to describe the atmosphere of a restaurant, their parallel structures in dependency parsing trees differ significantly. In sentences...x In sentence 1, "pleasant" and "high" each preside over two clauses, connected by the coordinating conjunction "but." In dependency parsing, "but" is marked as a conjunction (cc) and depends on "pleasant," while "high" is marked as an adjective (conj) and also depends on "pleasant." Each clause has its own independent subject, namely "ambience" and "price," clearly conveying a polarity shift. In contrast, in sentence... x In section 2, "cozy" and "relaxing" are parallel adjectives within the same copular structure, connected by "and," forming a phrase-level parallelism with consistent sentiment. Therefore, [the following is a possible interpretation:] x 2 is used as x Contextual examples of 1 may mislead the model, causing it to ignore clause-level comparisons, making it difficult for large language models to accurately extract information and reducing the output accuracy of the sentiment tuple extraction process.
[0041] To address the issue of low output accuracy in sentiment tuple extraction methods, some embodiments of this application provide a sentiment tuple extraction method based on syntactic-semantic fusion. This method can simultaneously integrate syntactic and semantic information through Syntactic-Semantic In-Context Learning (SynSem-ICL) to correctly identify complete sentiment tuples.
[0042] To address this, the SynSem-ICL framework can be constructed to improve the output accuracy of the sentiment tuple extraction process by unifying syntactic and semantic signals during retrieval. The retrieval objective can be reformulated as:
[0043] ;
[0044] in, R k Indicates the preceding k The most relevant examples; TopK() is a function that takes the top k examples; x i Indicates the input text; y i express x i The corresponding structured output; D Indicates the sample pool; q Indicates a query instance; h fused This represents a unified representation that integrates both semantic and syntactic information. h q fused This represents the unified representation corresponding to the query instance; h xi fusedThis represents a unified representation of the input text.
[0045] The SynSem-ICL framework effectively bridges the performance gap between context learning and supervised methods by combining syntactic structure and semantic representation without requiring model fine-tuning. SynSem-ICL utilizes a structure-aware graph transformer to encode syntactic structure through tree distance and dependency type bias mechanisms; it aligns and fuses word-level syntactic representations and sub-word-level semantic representations through a bidirectional cross-attention mechanism; and it optimizes the fused representation space using hard negative samples at both the semantic and syntactic levels through a dual similarity comparison learning objective.
[0046] Therefore, the SynSem-ICL framework overcomes the inherent limitations of pure semantic retrieval by introducing syntactic structures to enrich the selection of few-shot examples. Correspondingly, such as Figure 1 As shown, the SynSem-ICL framework includes a graph Transformer-based syntactic encoder that injects dependency syntactic tree biases into a multi-head attention mechanism; it also includes a bidirectional cross-attention fusion module to achieve deep interaction between syntactic embeddings and semantic embeddings; and a dual similarity comparison learning module to optimize the fused representation space. This design simultaneously ensures semantic relevance and structural alignment, thereby achieving more accurate LLM retrieval.
[0047] The sentiment tuple extraction method based on syntactic-semantic fusion can be applied to electronic devices with data processing capabilities. These electronic devices include, but are not limited to, computers, servers, mobile terminals, smart wearable devices, and industrial control machines. For ease of description, electronic devices are used as the execution subject of the method in this embodiment. It should be understood that the method can also be applied to other types of execution subjects, which are not illustrated in this embodiment. Figure 2 As shown, the method includes:
[0048] S101. Obtain the input text.
[0049] To extract sentiment tuples, input text is required before performing sentiment tuple extraction based on syntactic-semantic fusion. The input text serves as the extraction baseline for the ASTE task and can originate from data sources relevant to the application domain.
[0050] For example, when the ASTE task is applied to extract sentiment tuples from product review text, the input text can be obtained from user comment text on the product review page in order to extract sentiment data in triplets of aspect, opinion, and sentiment from the product review text.
[0051] In some embodiments, after acquiring the input text, preprocessing can be performed on the input text to convert the original text into a format suitable for model processing, while removing noise and redundant information, thereby improving the processing performance of the large language model. Preprocessing may include text cleaning, text standardization, word segmentation, vocabulary construction, and serialization format conversion, etc.
[0052] After obtaining the input text, text cleaning can be performed first, such as removing HTML tags, special characters and punctuation marks, and redundant spaces. Then, text standardization is applied to the cleaned text, such as case conversion, stemming, or lemmatization. Next, tokenization is performed, dividing the input text into multiple keywords or subwords and removing stop words. Based on the tokenization results, a vocabulary is built, assigning a unique index to each word, and using pre-trained word embedding tools such as Word2Vec, GloVe, or BERT to represent the words. Finally, the text is converted into a sequence format that the model can process, and the sequence is padded to the same length to meet the input requirements of large language models.
[0053] S102. Calculate the encoded embedding data of the input text using a structure-aware syntactic encoder.
[0054] After acquiring the input text, the electronic device can use a structure-aware syntactic encoder to compute the encoded embedding data of the input text. The encoded embedding data includes the syntactic and semantic representations of the input text. Furthermore, the structure-aware syntactic encoder is an encoder obtained through supervised training using a graph transformer (Transformer) based on multi-dimensional syntactic similarity. This structure-aware syntactic encoder is used to inject dependency syntactic tree biases into a multi-head attention mechanism.
[0055] By introducing a graph Transformer-based structure-aware syntactic encoder, tree distance and dependency type bias can be combined into the attention mechanism. This allows the structure-aware syntactic encoder to be trained under supervision using multi-dimensional syntactic similarity, generating fine-grained syntactic representations that are aligned with the semantic embedding space, thus providing a robust foundation for subsequent syntactic and semantic fusion.
[0056] For example, a syntactic graph Transformer can be constructed by embedding tree distance bias and dependency type bias into a multi-head attention mechanism. Graph Transformers enable large language models to capture both local and global structural information in dependency trees simultaneously.
[0057] Structure-aware syntactic encoders can inject the syntactic tree structure into attention computation through two types of structural biases, namely tree distance bias and dependency type bias, based on a structural bias mechanism.
[0058] For tree distance bias, in some embodiments, when an electronic device performs encoded embedding data computation of input text using a structure-aware syntactic encoder, it may first extract word pairs from the input text, wherein the word pairs include any two keywords in the input text. For example, a word pair may include a first keyword i and a second keyword j.
[0059] Next, for the extracted word pairs, calculate the tree distance between them. For example, the tree distance T... ij This represents the tree distance between the first keyword i and the second keyword j. Then, based on the learnable vector index table, the shortest path length of the word pair on the dependency tree is calculated according to the tree distance and the corpus word pair set. The shortest path length is then mapped to the tree distance bias. That is, the tree distance bias is a learnable bias used to set the attention weights of syntactically closer word pairs.
[0060] Tree distance bias is used to encode the syntactic distance between word pairs in a dependency tree. Based on linguistic intuition, nodes that are closer in distance tend to have stronger syntactic relationships. For example, there is a strong correlation between the subject and the predicate. Therefore, when performing the ASTE task, the electronic device can calculate the shortest path length of the word pair in the dependency tree and map it to a learnable bias, i.e.:
[0061] ;
[0062] in, T ij Keywords i With keywords j tree distance; D max This indicates word pairs that cover a predetermined proportion of the corpus, such as D max =20 indicates that 99% of the word pairs in the corpus are covered; b ij tree This is a table of learnable vector indices.
[0063] Based on tree distance bias, word pairs that are syntactically closer will receive higher attention weights than weakly related word pairs. For example... Figure 3As shown, taking the sentence "Ambience is very pleasant but price is high" as an example, the standard Transformer treats the input as a linear sequence, while the syntactic graph Transformer reconstructs local patterns through dependency parsing. Specifically, "ambience" and "pleasant" form a subject-verb relationship; "but" connects two contrasting clauses; and "pleasant" and "high" form a parallel relationship, reflecting parallel sentiments. By determining the tree distance bias, the tree distance between "ambience" and "pleasant" is set to 1, while the tree distance between "ambience" and "price" is set to 3. Therefore, the word pair "ambience" and "pleasant" can receive higher attention weights. Thus, by setting the tree distance bias, large language models can capture key structural features that are difficult to recognize in sequence encoding.
[0064] Regarding dependency type bias, in some embodiments, when an electronic device performs encoded embedding data computation of input text using a structure-aware syntactic encoder, it can first obtain dependency tags for word pairs, where the dependency tags are used to represent the dependency relationship between a first keyword and a second keyword in the word pair. For example, through deprel... i→j This represents a dependency tag pointing from the first keyword i to the second keyword j.
[0065] Next, query the edge information of the word pair. If the edge information exists, calculate the dependency type bias based on the learnable lookup table and dependency labels; if the edge information does not exist, the dependency type bias can be set to zero. Dependency type bias is used to reflect the functional importance of different syntactic relations. For example, subject-verb relations (nsubj) are more informative than determiner relations (det), and contrastive conjunctions (cc) may indicate a shift in sentiment; therefore, the dependency type bias can be calculated as follows:
[0066] ;
[0067] in, deprel i→j Indicates starting from the first keyword i Pointing to the second keyword j Dependency tags; b dep For a learnable lookup table, each dependency type corresponds to a bias parameter. If the first keyword... i With the second keyword j If there is no direct dependency between them, the bias is set to 0. These bias terms are directly added to the attention logarithm before softmax, thus affecting the final weights and enabling the model to adaptively measure the functional role of different dependencies.
[0068] After calculating the tree distance bias and dependency type bias, a syntactic graph Transformer can be constructed by embedding these biases into a multi-head attention mechanism. Therefore, in some embodiments, when calculating the encoded embedding data of the input text using a structure-aware syntactic encoder, a graph transformer can be constructed first based on the tree distance bias and dependency type bias. Specifically, the node features of the graph transformer are initialized so that the initial representation of each keyword is formed by concatenating part-of-speech embeddings and dependency relation embeddings. Furthermore, in each layer of the graph transformer, the tree distance bias and dependency type bias are incorporated into the calculation of the attention score. Additionally, the number of layers in the graph transformer is dynamically adjusted based on the dependency tree depth.
[0069] A graph converter is trained using multi-dimensional syntactic similarity to generate syntactic representations with syntactic awareness. This multi-dimensional syntactic similarity includes several complementary measures, such as tree edit distance, tree kernel method, graph-based metrics, probability distribution divergence, and average dependency path length. For example, syntactic similarity is composed of five complementary measures: tree edit distance, tree kernel method, graph-based metrics, Jensen-Shannon divergence, and average dependency path length. Tree edit distance captures differences in the global structure of the parse tree; tree kernel method identifies recurring substructures across sentences; graph-based metrics evaluate the topological correspondence of the dependency network; Jensen-Shannon divergence quantifies changes in the distribution of grammatical functions; and average dependency path length reflects combinatorial complexity. These five complementary measures collectively cover multi-dimensional linguistic features, ranging from macroscopic tree structure configurations to microscopic dependency patterns.
[0070] For example, based on the aforementioned bias mechanism, a graph Transformer for structure awareness can be constructed. This graph Transformer can initialize node features. Specifically, the initial representation of each word is formed by concatenating part-of-speech embeddings and dependency relation embeddings.
[0071] ;
[0072] in, H i (0) Indicates the first i The initial representation of each keyword; e i pos This indicates part-of-speech tag embedding, belonging to R 384 gather; e i dep This indicates the dependency relationship between the word and its parent node, and also belongs to... R 384The initial representation design of this graph Transformer can be consistent with the dimensions of multilingual semantic encoders such as paraphrase-multilingual-mpnet-base-v2, thus ensuring compatibility with subsequent fusion.
[0073] After initial representation setup, structure-aware attention computation can be performed based on the graph Transformer. In each Transformer layer, structural biases are incorporated into the attention score calculation, i.e.:
[0074] ;
[0075] in, S ij (l,h) Indicates attention score; q i (l,h) The first keyword i The query vector; k j (l,h) Indicates the second keyword j The key vector; both the query vector and the key vector come from the first... l The first layer h One's attention, d head For each dimension of attention head, b ij tree With b ij dep These are the corresponding structural biases.
[0076] Structure-aware attention mechanisms can ensure that syntactically related word pairs, such as "ambience" and "pleasant," receive higher attention weights even if they have low semantic similarity. Therefore, large language models can capture structurally meaningful patterns.
[0077] To accommodate varying levels of syntactic complexity, the Graph Transformer can also dynamically adjust the number of layers based on the dependency tree depth d, using an adaptive depth strategy.
[0078] ;
[0079] in, N Indicates the number of Transformer layers in the graph; α This represents the tuning coefficient, used to tune the validation set, such as α=1.5; d Indicates the depth of the dependency tree.
[0080] For shallow dependency trees such as those for simple sentences, large language models require fewer layers, while for deep dependency trees such as those for complex sentences, more layers can achieve better results. Furthermore, to alleviate the vanishing gradient problem, residual connections can be introduced, i.e., the final output... H syn belong R L×768 As a sentence-level syntactic representation.
[0081] For the constructed graph Transformer, syntactic similarity-supervised learning can be performed, that is, the graph Transformer can be trained by supervising learning based on structural similarity so that it can generate representations with syntactic awareness and thus capture potential linguistic patterns.
[0082] The weights of each metric can be determined based on the Criteria Importance Through Intercriteria Correlation (CRITIC) method, which can perform large-scale feature importance analysis based on the following formula:
[0083] ;
[0084] in, s i and s j This indicates that the input sentence pair is... f k ( s i , s j ) indicates the first k Syntactic similarity components w k These are the weights corresponding to the similarity components. A similarity threshold can then be set, such as... θ syn =0.68, which is used to identify approximately 10% of sentence pairs as syntactically similar.
[0085] During training, sentence pairs from the dataset can be used as input. The model determines the mean squared error between the predicted value and the calculated syntactic similarity score by minimizing the cosine similarity between their syntactic representations.
[0086] ;
[0087] in, L syn Mean squared error; B For batches of sentence pairs; hs syn This indicates sentence-level syntactic embedding, belonging to R 768 gather; cos ( ) represents cosine similarity; sim syn ( ) represents syntactic similarity.
[0088] After training to obtain a structure-aware syntax encoder, the input text can be fed into the graph converter in the structure-aware syntax encoder to capture the underlying linguistic patterns, thereby generating encoded embedding data.
[0089] S103. By using bidirectional cross-attention fusion, syntactic representation and semantic representation interact deeply to obtain a fused representation.
[0090] After obtaining the encoded embedding data of the input text using a structure-aware syntactic encoder, deep fusion of syntax and semantics can be performed based on the syntactic and semantic representations in the encoded embedding data. By introducing a bidirectional cross-attention mechanism, deep interaction between syntactic and semantic representations can be achieved, enabling them to interact dynamically and thus allowing the model to gain a more structured and integrated understanding.
[0091] To achieve deep fusion, in some embodiments, bidirectional cross-attention fusion is used to deeply interact syntactic and semantic representations to obtain the fused representation. Text alignment can be performed first; that is, to bridge the differences in word segmentation granularity, a character offset-based alignment strategy can be adopted to map sub-word units to corresponding words. Therefore, during text alignment, the sub-word embeddings of the input text can be obtained first. These sub-word embeddings are obtained by performing semantic encoding on the input text using a semantic encoder.
[0092] For example, such as Figure 4 As shown, word-level representations, i.e., word embeddings H, can be generated through a semantic encoder. sem Subword embedding H sem It belongs to R Lsub×768 The set is a vector, while the syntactic encoder works at the word level to obtain the syntactic representation, i.e., the syntactic representation H. syn Syntactic representation H syn It is a member of R Lwd×768 A vector of a set.
[0093] Next, the character span is calculated, and an alignment matrix is constructed based on the character span. The character span represents the number of characters separating any two keywords in the input text, and the alignment matrix represents the proportion of keywords covered by sub-words.
[0094] For example, let [ o mwd , e m wd )and[ o n sub , e n sub () represent keywords respectively m With your words n Given the character span, the alignment matrix is:
[0095] ;
[0096] in, A mn Indicates the first m The first keyword n The weight of each subword, i.e., the weight of each subword n Covering keywords m The proportion is used as the matrix element of the alignment matrix. A mn The value range of is [0, 1]; o m wd and e m wd Each represents a keyword m The start and end positions; o n sub and e n sub Representing sub-words n The start and end positions; o m wd , e m wd )and[ o n sub , e n sub () represent keywords respectively m With your words n Character span;
[0097] An alignment matrix is constructed, and the electronic device can apply normalization constraints to the alignment matrix to generate semantic representations of keywords. These semantic representations are obtained through weighted aggregation of sub-word embeddings. For example, normalization constraints can be applied based on the alignment matrix described above. Based on this, word-level semantic representations can be obtained through weighted aggregation:
[0098] ;
[0099] in, H' sem,m Let m be the aligned semantic representation of the m-th word, and let R be the semantic representation of the m-th word. 768 A vector of a set, m = 1, 2, ..., L wd L wd It is the total number of words in the sentence; L sub It is the number of sub-words of the m-th keyword; A mn Indicates the first m The first keyword n The weight of each sub-word; H sem,m This represents the semantic representation of the m-th subword.
[0100] Alignment semantic representation H' sem,m Subword embeddings can be obtained from the output of the aggregate semantic encoder. H sem,n Obtain, subword embedding H sem,n Too R 768 The vector; the weights of the aggregate semantic encoder are... A mn The decision has been made. It is evident that text alignment allows the model output to be independent of the tokenizer, making it applicable to different languages and model architectures, and providing a robust foundation for subsequent fusion.
[0101] After generating semantic representations of keywords through text alignment, the semantic and syntactic representations can be fused based on a bidirectional cross-attention fusion mechanism. Specifically, in some embodiments, when obtaining a fused representation by deeply interacting the syntactic and semantic representations through bidirectional cross-attention fusion, a first output projection matrix can be calculated based on the semantic representation, and a second output projection matrix can be calculated based on the syntactic representation. The first output projection matrix enables the semantic representation's lexical units to adjust their contextual representation according to syntactic relationships; the second output projection matrix enables the syntactic representation's lexical units to be interpreted based on semantic context refinement.
[0102] For example, based on a bidirectional cross-attention mechanism, aligned representations can interact through this mechanism, allowing syntactic and semantic representations to play different roles in the fusion process in different directions. For the semantic-to-syntactic direction (Sem→Syn), which enables semantic representation to perceive syntactic structure, a forward attention path can be utilized, employing a "query-key-value" attention mechanism to obtain the following attention calculation results:
[0103] ;
[0104] in, Attn sem←syn This represents the attention output from syntax (syn) to semantics (sem); softmax This represents a function that transforms a real vector into a probability distribution; Q sem This represents a query vector from the semantic feature space. Q sem =H' sem W Q sem ; K syn T This represents the transpose of the key vector from the syntactic feature space. K syn =H syn W K syn ; d head Dimensions representing the attention head; V syn This represents a value vector from the syntactic feature space. V syn =H syn W V syn ; W Q sem , W K syn , W V syn The learnable projection matrix is R 768×64 ; H' sem For alignment semantic representation.
[0105] It is evident that, in the semantic-syntactic direction of the bidirectional cross-attention mechanism, semantic lexical units can adjust their contextual representations according to syntactic relations. For example, the opinion word "pleasant" can focus on the corresponding syntactic subject "ambience," thereby bringing the two closer in the embedding space, which helps in the identification of "aspect-opinion pairs" and facilitates the modeling of long-distance dependencies.
[0106] For the syntax-to-semantics direction (Syn→Sem), this direction can inject semantic content into the syntactic structure through a reverse attention path, resulting in the following attention calculation results:
[0107] ;
[0108] in, Attn syn←sem This represents the attention output from semantics (sem) to syntax (syn); softmax This represents a function that transforms a real vector into a probability distribution; Q syn This represents a query vector from the syntactic feature space. Q syn = H syn W Q syn ; K T sem This represents the transpose of the key vector from the semantic feature space. K sem =H' sem W K sem ; V sem This represents a value vector from the semantic feature space. V sem =H' sem W V sem ; d head Dimensions representing the attention head; W Q syn , W K sem , W V sem The learnable projection matrix is R 768×64 ; H' sem For alignment semantic representation.
[0109] In the syntactic-to-semantic direction of the bidirectional cross-attention mechanism, syntactic lexical units can have their functional interpretations refined based on semantic context. For example, the contrastive conjunction "but" initially only encodes its structural function, but after focusing on the semantic contrast between the preceding and following clauses, such as "pleasant" and "high," its representation can be dynamically adjusted to reflect polarity shifts at the discourse level. Therefore, semantically enhanced syntactic representations can achieve accurate interpretation of complex sentence structures.
[0110] After generating the first and second output projection matrices based on the bidirectional cross-attention mechanism, residual connections and layer normalization can be performed on these matrices. Then, based on the first and second output projection matrices, a multi-granularity pooling strategy is used to concatenate features to generate a fused representation.
[0111] For example, residual connections and layer normalization are used to ensure training stability and avoid information loss, namely:
[0112] ;
[0113] ;
[0114] in, and They are respectively after layer normalization and Dropout The processed semantic and syntactic representations; LayerNorm Representation layer normalization; H' sem For alignment semantic representation; H syn This represents syntactic representation; W O sem , W O syn The output projection matrix, representing the output weight matrix of semantic and syntactic features, can be... R 768×768 Matrix of form; Attn sem←syn This represents the attention output from syntax to semantics; Attn syn←sem This represents the attention output from semantics to syntax; Dropout The regularization rate can be set to 0.1. Residual connections can preserve input information, while normalization can stabilize the inter-layer activation distribution.
[0115] Then output H based on the bidirectional attention module sem With H synGenerate a fused representation, which encodes contextual information from both semantic and syntactic perspectives. To construct a unified sentence-level representation, a multi-granularity pooling strategy can be adopted, namely:
[0116] ;
[0117] in, h fused The fused representation represents the fused feature vector; LayerNorm Representation layer normalization; W fuse Let be the learnable projection matrix, representing the weight matrix used for feature fusion, which can be... R 768×3072 The form is a matrix, which can compress the concatenated features into a 768-dimensional vector; MeanPool Indicates average pooling; MaxPool This indicates max pooling; and They are respectively after layer normalization and Dropout The processed semantic and syntactic representations.
[0118] As can be seen, parallel pooling can achieve a balanced integration of semantic and syntactic features; and by combining mean pooling and max pooling, it takes into account both global trends and local salient features; while maintaining compatibility with the standard embedding dimensions required by downstream modules. The final fused representation... h fused Simultaneously encoding semantic and structural information enables the retrieval module to distinguish between sentences that are semantically similar but syntactically different. For example, it can distinguish between the contrastive structure in "pleasant but high" and the coordinate structure in "cozy and relaxing," even though they are semantically similar but have significant differences in syntactic form.
[0119] S104. A unified representation for computing fusion representations based on a dual similarity comparison learning framework.
[0120] After obtaining the fused representation, a unified representation can be computed based on contrastive learning using dual similarity. To this end, a contrastive learning framework based on dual similarity can be used to optimize the distribution of the fused representation in the similarity space. Then, training is performed on pre-constructed positive and negative sample pairs, enabling the dual similarity-based contrastive learning framework to simultaneously align semantic and syntactic similarities. In other words, the unified representation is obtained by optimizing the distribution of the fused representation in the similarity space and by aligning semantic and syntactic similarities through training on pre-constructed positive and negative sample pairs.
[0121] To achieve contrastive learning based on dual similarity, in some embodiments, when computing the unified representation of the fused representation using the dual similarity-based contrastive learning framework, the semantic similarity of sentence pairs in the sample dataset can first be calculated using a pre-trained encoder. The semantic similarity is calculated based on a weighted combination of multiple complementary metrics.
[0122] For example, for any pair of sentences ( s i , s j In similarity calculation and threshold determination, semantic similarity can be obtained through a pre-trained encoder, i.e.:
[0123] ;
[0124] in, sim sem ( s i , s j () represents semantic features s i and semantic features s j The similarity between them; h i sem and h j sem They represent semantic features respectively s i and semantic features s j The corresponding vector representation; cos() represents cosine similarity.
[0125] Syntactic similarity is calculated using a weighted combination of five complementary feature measures. Semantic threshold. θ sem With syntactic threshold θ syn This can be determined using the 90th quantile method. Sentence pairs falling within the top 10% of the similarity distribution are considered highly similar. In practical applications, this can be set... θ sem =0.82, θ syn =0.68. This setting ensures that only about 10% of sentence pairs are selected, thus reflecting the sparsity of semantic and syntactic similarity in the data.
[0126] After calculating the semantic similarity of sentence pairs in the sample dataset, a training dataset is constructed based on the semantic similarity. The training dataset includes a positive sample set and a negative sample set. The negative sample set includes semantically difficult negative samples, syntactically difficult negative samples, and random negative samples. Semantically difficult negative samples include sentence pairs that are semantically similar but syntactically different; syntactically difficult negative samples include sentence pairs that are syntactically similar but semantically different; random negative samples are used to provide basic contrast signals.
[0127] Then, training samples are extracted from the training dataset according to a preset sample ratio. The preset sample ratio represents the ratio of positive sample set to negative sample set as 1:2, and the ratio of semantically difficult negative samples, syntactically difficult negative samples, and random negative samples in the negative sample set is 3:1:1.
[0128] For example, in contrastive learning based on dual similarity, sample construction can begin. Since the success of contrastive learning largely depends on the strategic nature of sample selection, four classes of samples can be constructed based on the interaction between semantic and syntactic similarity, each optimized for different aspects of the representation space.
[0129] Based on the aforementioned dual thresholds, the definitions and functions of the four sample types can be used to construct the following four types of sample pairs: Positive samples include sentence pairs that are semantically and syntactically similar, serving as ideal anchor points in the target similarity space. Semantically difficult negative samples include sentence pairs that are semantically similar but syntactically different, used to guide the model to learn more discriminative syntactic features. Syntactically difficult negative samples include sentence pairs that are syntactically similar but semantically different, preventing the model from over-relying on structural patterns and ignoring content differences. Random negative samples are used to provide basic contrast signals, helping the model establish a general similarity boundary.
[0130] To achieve efficient and stable training, a dynamic sampling strategy can be used during model training to initially maintain a 1:2 ratio of positive to negative samples to balance convergence speed and discriminative ability. Within the negative samples, a 3:1:1 ratio of semantically difficult to negative: syntactically difficult to negative: random samples can be maintained, thus emphasizing the more challenging semantically difficult negative samples during training.
[0131] After extracting training samples, the learning model can be trained using these samples. In each training epoch, similarity can be recalculated and samples can be resampled to adapt to the dynamic evolution of the model representation. Therefore, in some embodiments, when training the learning model using training samples, the training samples can first be input into the learning model to obtain the training results output by the learning model. Then, the training loss can be calculated based on the training results. The model parameters of the learning model can then be set according to the training loss. Furthermore, semantic similarity can be recalculated in each training epoch, and samples can be resampled based on the recalculated semantic similarity.
[0132] For example, by setting a contrastive learning objective function and using InfoNCE loss to optimize the distribution of the fused representation in the similarity space, that is:
[0133] ;
[0134] in, L contrast Indicates comparative loss; B Indicates batch size; log Represents the natural logarithm function; exp Represents an exponential function; h ai fused The fused representation of the anchor point; h pi fused The fusion represents the corresponding positive sample; sim ( ) represents the similarity function; N i Represents the set of negative samples; h n fused Indicates a negative sample; τ This represents the temperature parameter, which can be set. τ =0.05 was determined through a grid search of the validation set.
[0135] This loss function reshapes the representation space through an "attraction-repulsion" mechanism between sample pairs. By introducing semantically hard negative samples, it ensures that the model can distinguish between sentences that are "semantically similar but syntactically different," thus improving output accuracy.
[0136] In some embodiments, to optimize the model training process, the graph converter can be pre-trained with multiple complete traversal rounds using syntactic similarity targets, and dual contrastive learning can be performed based on a multi-stage curriculum mechanism. This multi-stage curriculum mechanism includes a first stage, a second stage, and a third stage. The first stage uses random negative samples to establish basic discriminative boundaries; the second stage introduces syntactically difficult negative samples to guide the learning model to focus on structural differences while maintaining semantic similarity; and the third stage introduces semantically difficult negative samples to enhance syntactic discriminative ability.
[0137] For example, to ensure training stability, a progressive learning strategy can be adopted. That is, before end-to-end training begins, the graph Transformer is pre-trained for 3 epochs using syntactic similarity targets, making its output more sensitive and reliable to structural information. After the pre-training, a complete training framework based on dual contrastive learning is adopted, employing a three-stage learning mechanism. In epochs 1–5, only random negative samples are used to establish basic discriminative boundaries; in epochs 6–15, syntactically difficult negative samples are introduced to guide the model to pay attention to structural differences while maintaining semantic similarity; from the 16th epoch onwards, semantically difficult negative samples are further introduced to strengthen syntactic discriminative ability.
[0138] You can also set differentiated learning rates and perform iterative training on the learning model based on these differentiated learning rates. Differentiated learning rates are used for different modules. For example, the pre-trained encoder can be set to 5×102. -6 To prevent catastrophic amnesia, the fusion layer is set to 1×10. -4 To allow for quick adaptation to new tasks. The projection head is set to 5×10. -4 This allows for flexible shaping of the feature space. All learning rates use a 10% linear warmup and cosine decay scheduling in subsequent stages.
[0139] Then, according to the preset stopping conditions, the model parameters of the learning model are output. The preset stopping conditions include an early stopping metric and a training loss. The early stopping metric includes the area under the ROC curve; the training loss includes the InfoNCE loss.
[0140] Pre-defined stopping criteria can effectively avoid gradient instability caused by introducing overly difficult samples too early. Therefore, early stopping uses the area under the ROC curve (ROC-AUC) as the primary stopping metric, supplemented by InfoNCE loss to prevent overfitting. The early stopping mechanism is triggered when the ROC-AUC on the validation set does not improve over N consecutive epochs, and the InfoNCE loss does not decrease significantly (or even increases).
[0141] As can be seen, through the above comparative learning process, the final fusion representation h is obtained. fused It possesses both rich semantic information and fine-grained syntactic discriminative capabilities, thus significantly improving the retrieval performance of high-quality samples. After training to obtain a learning model, a unified representation of the fused representation can be calculated based on the learned model. The learning model includes an encoder based on a dual similarity comparison learning framework.
[0142] S105. Retrieve candidate examples based on the unified representation.
[0143] After computing the unified representation of the fused representation, the large language model can perform example retrieval and reasoning, that is, retrieve candidate examples based on the unified representation. The candidate examples are determined based on cosine similarity; cosine similarity is used to characterize the similarity between the unified representation and the fused vectors of all examples in the example library.
[0144] For example, in the reasoning phase, test sentences are encoded to obtain a unified representation. h fused Then, the cosine similarity between the vector and all example fused vectors in the example library D is calculated, and the Top-K are selected as candidate examples. For example, if K=5, the top 5 search results are selected as candidate examples.
[0145] To improve retrieval efficiency, Faiss's HNSW index can be used, which reduces retrieval complexity from O(N) to O(logN). Simultaneously, batch processing with a batch size of 64 further enhances throughput. To accelerate repeated queries, an LRU-based caching mechanism can be used to store the results of the most recent 1000 queries, thereby improving response speed. Retrieved examples are sorted by similarity from highest to lowest and uniformly organized into a JSON array format for input suggestions.
[0146] By applying the technical solutions of the above embodiments, the sentiment tuple extraction method based on syntactic-semantic fusion provided in the above embodiments can utilize the SynSem-ICL framework to solve the problem of semantic and syntactic signal mismatch in small-sample structured prediction. The method can be based on a dependency tree-encoded structure-aware Graph Transformer, syntactic-semantic fusion achieved through a bidirectional cross-attention mechanism, and dual-similarity comparison learning. Through synergistic effects, it provides explicit syntactic guidance for structured tasks. Using only five examples, SynSem-ICL enables a general large language model to achieve performance close to 4–8% of the F1 score of a fully supervised model on ASTE-Data-V2. Simultaneously, it achieves an SF1 improvement of up to 8.1% on languages with high morphological diversity.
[0147] The explicit syntactic anchors provided by the SynSem-ICL framework enable large language models to better distinguish between transition and parallel structures and improve boundary detection, thus overcoming the fundamental limitations of relying solely on semantic retrieval. From an application perspective, near-supervised model performance can be achieved without fine-tuning, making it applicable to dynamic decision support systems such as customer feedback analysis, social media monitoring, and domain-specific scenarios where labeled data is scarce but accuracy is crucial. By bridging the gap between language structure and semantic understanding, syntactic-semantic fusion can enhance structured prediction capabilities and interpretability.
[0148] In some embodiments, as a specific implementation of the sentiment tuple extraction method based on syntactic-semantic fusion described in the above embodiments, some embodiments of this application also provide a sentiment tuple extraction system based on syntactic-semantic fusion, such as... Figure 5 As shown, the system includes:
[0149] The text acquisition module is used to acquire input text;
[0150] A syntax encoding module is used to compute encoded embedding data of the input text using a structure-aware syntax encoder. The encoded embedding data includes the syntactic representation and semantic representation of the input text. The structure-aware syntax encoder is an encoder obtained by supervised training based on graph converter through multi-dimensional syntactic similarity. The structure-aware syntax encoder is used to inject dependency syntax tree bias into a multi-head attention mechanism.
[0151] A bidirectional cross-attention fusion module is used to deeply interact the syntactic representation and the semantic representation through bidirectional cross-attention fusion to obtain a fused representation;
[0152] A dual similarity comparison learning module is used to compute a unified representation of the fused representation based on a dual similarity comparison learning framework. The unified representation is obtained by optimizing the distribution of the fused representation in the similarity space and by aligning semantic and syntactic similarities through training on pre-constructed positive and negative sample pairs.
[0153] The retrieval module is used to retrieve candidate examples based on the unified representation, wherein the candidate examples are determined based on cosine similarity; the cosine similarity is used to characterize the similarity between the unified representation and the fused vectors of all examples in the example library.
[0154] By applying the technical solutions of the above embodiments, the sentiment tuple extraction system based on syntactic-semantic fusion provided in the above embodiments can perform context-learned retrieval, encode the dependency syntactic tree through a graph Transformer, and deeply fuse it with bidirectional cross-attention and semantic representation. Without fine-tuning, it can achieve performance comparable to the supervised baseline simply through example selection. Through the system's collaborative architecture combining graph Transformer, bidirectional fusion module, and dual similarity comparison loss, it effectively solves the problems of syntactic encoding, cross-granularity alignment, and discriminative learning.
[0155] For example, through experiments on the ASTE-Data-V2 dataset, the system can achieve an F1 score that differs from the fully supervised model by only 4–8% using only 5 retrieval examples. On the SemEval-2022 multilingual benchmark, our model achieved a maximum SF1 improvement of 8.1%, demonstrating robustness to morphologically rich languages.
[0156] By applying the technical solutions of the above embodiments, the sentiment tuple extraction system based on syntactic-semantic fusion provided in the above embodiments, after the text acquisition module acquires the input text, the syntactic encoding module uses a structure-aware syntactic encoder to calculate the encoded embedding data of the input text. The bidirectional cross-attention fusion module then uses bidirectional cross-attention fusion to deeply interact the syntactic and semantic representations to obtain a fused representation. The dual similarity comparison learning module then calculates the unified representation of the fused representation based on the dual similarity comparison learning framework, and the retrieval module retrieves candidate examples based on the unified representation. The system can generate encoded embedding data based on a dependency tree-encoded structure-aware graph converter, and through syntactic and semantic fusion achieved by the bidirectional cross-attention mechanism, as well as dual similarity comparison learning, it provides explicit syntactic guidance for structured tasks of large language models, can simultaneously integrate syntactic and semantic information, correctly identify complete sentiment tuples, and improve the output accuracy of sentiment tuple extraction results.
[0157] It should be noted that other corresponding descriptions of the functional units involved in the sentiment tuple extraction system based on syntactic-semantic fusion provided in the embodiments of this application can be found in the corresponding descriptions in the sentiment tuple extraction method based on syntactic-semantic fusion provided in the above embodiments, and will not be repeated here.
[0158] This application also provides a computer device, specifically a personal computer, server, network device, etc. The computer device includes a bus, processor, memory, and communication interface, and may also include input / output interfaces and a display device. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database of the computer device stores location information. The network interface of the computer device is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements the steps in the various method embodiments.
[0159] Those skilled in the art will understand that the structure of the computer device described above is only a partial structure related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. A specific computer device may include more or fewer components, or combine certain components, or have different component arrangements.
[0160] In one embodiment, a computer-readable storage medium is also provided, which may be non-volatile or volatile, having stored thereon a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0161] In one embodiment, a computer program product is also provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0162] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0163] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods.
[0164] Any references to memory, database, or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc.
[0165] Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can take many forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0166] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchain. The processors involved in the embodiments provided in this application may be, but are not limited to, general-purpose processors, graphics processors, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc.
[0167] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0168] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A sentiment tuple extraction method based on syntactic-semantic fusion, characterized in that, The method includes: Get the input text; The structure-aware syntactic encoder is used to compute the encoded embedding data of the input text, which includes the syntactic representation and semantic representation of the input text; the structure-aware syntactic encoder is an encoder obtained by supervised training based on graph converter through multi-dimensional syntactic similarity; the structure-aware syntactic encoder is used to inject dependency syntactic tree bias into the multi-head attention mechanism; By employing bidirectional cross-attention fusion, the syntactic representation and the semantic representation are deeply interacted to obtain a fused representation; The unified representation of the fusion representation is computed based on a dual similarity comparison learning framework. The unified representation is obtained by optimizing the distribution of the fusion representation in the similarity space and by aligning semantic and syntactic similarities through training on pre-constructed positive and negative sample pairs. Candidate examples are retrieved based on the unified representation, and the candidate examples are determined based on cosine similarity; the cosine similarity is used to characterize the similarity between the unified representation and the fused vectors of all examples in the example library.
2. The method according to claim 1, characterized in that, The input text is computed using a structure-aware syntactic encoder, including: Extract word pairs from the input text, wherein the word pairs include any two keywords from the input text; Calculate the tree distance of the word pairs; Based on the learnable vector index table, the shortest path length of the word pair on the dependency tree is calculated according to the tree distance and the corpus word pair set; The shortest path length is mapped to a tree distance bias, which is a learnable bias; the tree distance bias is used to set the attention weights for syntactically closer word pairs.
3. The method according to claim 2, characterized in that, The method of computing encoded embedding data of the input text using a structure-aware syntactic encoder further includes: Obtain the dependency tags of the word pairs, wherein the dependency tags are used to represent the dependency relationship between the first keyword and the second keyword in the word pairs; Query the edge information of the given word pair; If the edge information exists, calculate the dependency type bias based on the learnable lookup table and the dependency label; If the edge information does not exist, set the dependency type bias to zero.
4. The method according to claim 3, characterized in that, The method of computing encoded embedding data of the input text using a structure-aware syntactic encoder further includes: A graph converter is constructed based on the tree distance bias and the dependency type bias. The node features of the graph converter are initialized so that the initial representation of each keyword is formed by concatenating part-of-speech embeddings and dependency relation embeddings. In each layer of the graph converter, the tree distance bias and the dependency type bias are incorporated into the calculation of the attention score. The number of layers of the graph converter is dynamically adjusted according to the depth of the dependency tree. The graph converter is trained using multi-dimensional syntactic similarity to generate syntactic representations with syntactic awareness capabilities. The multi-dimensional syntactic similarity includes multiple complementary measures, including tree edit distance, tree kernel method, graph-based metrics, probability distribution divergence, and average dependency path length. The input text is input into the graph converter to capture potential linguistic patterns in the input text and generate the encoded embedding data.
5. The method according to claim 1, characterized in that, Through bidirectional cross-attention fusion, the syntactic representation and the semantic representation are deeply interacted to obtain a fused representation, including: Obtain the word embeddings of the input text, which are obtained by performing semantic encoding on the input text using a semantic encoder; The character span is used to represent the number of characters between any two keywords in the input text. An alignment matrix is constructed based on the character span, and the alignment matrix is used to represent the proportion of subwords covering keywords; A normalization constraint is applied to the alignment matrix to generate a semantic representation of the keyword, which is obtained by weighted aggregation of the sub-word embeddings.
6. The method according to claim 5, characterized in that, The method further includes obtaining a fused representation by deeply interacting the syntactic representation and the semantic representation through bidirectional cross-attention fusion, thereby achieving the following: A first output projection matrix is calculated based on the semantic representation. The first output projection matrix is used to enable the lexical units of the semantic representation to adjust the context representation according to the syntactic representation relations. The second output projection matrix is calculated based on the syntactic representation. The second output projection matrix is used to enable the lexical units of the syntactic representation to be interpreted based on the semantic context refinement function. Perform residual connection and layer normalization processing based on the first output projection matrix and the second output projection matrix; Based on the first output projection matrix and the second output projection matrix, a multi-granularity pooling strategy is used to concatenate features to generate the fused representation.
7. The method according to claim 1, characterized in that, The unified representation of the fused representation is computed based on a dual similarity comparison learning framework, including: The semantic similarity of sentence pairs in the sample dataset is calculated by a pre-trained encoder, and the semantic similarity is obtained by a weighted combination of multiple complementary measures. A training dataset is constructed based on the semantic similarity, and the training dataset includes a positive sample set and a negative sample set; the negative sample set includes semantically difficult negative samples, syntactically difficult negative samples, and random negative samples. Training samples are extracted from the training dataset according to a preset sample ratio; the preset sample ratio is used to characterize that the ratio of the positive sample set to the negative sample set is 1:2, and the ratio of the semantically difficult negative samples, the syntactically difficult negative samples and the random negative samples in the negative sample set is 3:1:
1. The training samples are used to train a learning model, which includes an encoder based on a dual similarity comparison learning framework; The unified representation of the fusion representation is calculated based on the learning model.
8. The method according to claim 7, characterized in that, Training a learning model using the training samples includes: The training samples are input into the learning model to obtain the training results output by the learning model; Calculate the training loss based on the training results; The model parameters of the learning model are set according to the training loss; The semantic similarity is recalculated in each training round, and samples are resampled based on the recalculated semantic similarity.
9. The method according to claim 8, characterized in that, The method further includes: The graph converter is warmed up by multiple complete traversal rounds using syntactic similarity targets; Dual contrastive learning is performed based on a multi-stage curriculum mechanism, which includes a first stage, a second stage, and a third stage. The first stage is used to establish basic discriminative boundaries using random negative samples; the second stage is used to introduce syntactically difficult negative samples to guide the learning model to pay attention to structural differences while maintaining semantic similarity; and the third stage is used to introduce semantically difficult negative samples to enhance syntactic discriminative ability. Set a differentiated learning rate, and perform iterative training on the learning model based on the differentiated learning rate; According to the preset stopping conditions, the model parameters of the learning model are output. The preset stopping conditions include an early stopping metric and a training loss. The early stopping metric includes the area under the ROC curve; the training loss includes the InfoNCE loss.
10. A sentiment tuple extraction system based on syntactic-semantic fusion, characterized in that, The system includes: The text acquisition module is used to acquire input text; A syntax encoding module is used to compute encoded embedding data of the input text using a structure-aware syntax encoder. The encoded embedding data includes the syntactic representation and semantic representation of the input text. The structure-aware syntax encoder is an encoder obtained by supervised training based on graph converter through multi-dimensional syntactic similarity. The structure-aware syntax encoder is used to inject dependency syntax tree bias into a multi-head attention mechanism. A bidirectional cross-attention fusion module is used to deeply interact the syntactic representation and the semantic representation through bidirectional cross-attention fusion to obtain a fused representation; A dual similarity comparison learning module is used to compute a unified representation of the fused representation based on a dual similarity comparison learning framework. The unified representation is obtained by optimizing the distribution of the fused representation in the similarity space and by aligning semantic and syntactic similarities through training on pre-constructed positive and negative sample pairs. The retrieval module is used to retrieve candidate examples based on the unified representation, wherein the candidate examples are determined based on cosine similarity; the cosine similarity is used to characterize the similarity between the unified representation and the fused vectors of all examples in the example library.
Citation Information
Patent Citations
Relationship extraction method for Chinese financial text
CN115688776A
Aspect-level emotion triple extraction method and system based on semantic enhancement double encoders
CN116663567A