Text sentiment classification method based on quantum heuristic algorithm

By employing a quantum heuristic-based text sentiment classification method, utilizing the BERT pre-trained model and PCA technology for feature extraction, and constructing a quantum heuristic neural network model, this approach solves the problem of extracting high-level semantic features in existing technologies, achieving highly accurate text sentiment classification.

CN115495580BActive Publication Date: 2026-02-10CENT SOUTH UNIV +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211175447.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-26
Publication Date
2026-02-10
Estimated Expiration
2042-09-26

AI Technical Summary

Technical Problem

Existing quantum-heuristic word embedding methods struggle to extract high-level semantic features in text sentiment classification tasks, resulting in low sentiment classification accuracy.

Method used

A quantum heuristic-based text sentiment classification method is adopted. The amplitude embedding vector is extracted by the BERT pre-trained model, and PCA technology is combined for dimensionality reduction and feature extraction to construct a quantum heuristic neural network model. The amplitude and phase embedding vectors are used for text sentiment classification.

Benefits of technology

It achieves highly accurate and reliable text sentiment classification, improving the accuracy of classification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115495580B_ABST
    Figure CN115495580B_ABST
Patent Text Reader

Abstract

The application discloses a text sentiment classification method based on a quantum heuristic algorithm, which comprises the following steps: obtaining original training texts with classification labels and processing the original training texts to obtain training texts; loading a pre-training model and corresponding parameters and training to obtain amplitude embedding vectors; performing dimension reduction and feature extraction on high-dimensional sentences after word segmentation to obtain phase embedding vectors; constructing a quantum heuristic neural network model; and performing actual text sentiment classification by using the quantum heuristic neural network model. The text sentiment classification method based on the quantum heuristic algorithm has the advantages that: by means of double-feature extraction and compound word embedding, and in combination with the quantum heuristic algorithm, the classification of text sentiment is realized; and the method has high accuracy and good reliability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of natural language processing, specifically relating to a text sentiment classification method based on a quantum heuristic algorithm. Background Technology

[0002] With the development of economy and technology and the improvement of people's living standards, Natural Language Processing (NLP) technology has been widely applied in people's production and life, bringing endless convenience. Therefore, the accuracy of NLP has become the top priority of NLP technology research.

[0003] In Natural Language Processing (NLP), embedding techniques are an indispensable part. Embedding uses vectors to represent human language and allows computers to process these vectors containing human language information. Embedding itself is constantly evolving, extending and expanding from initial static embedding methods such as one-hot and word2vec to dynamic embedding. Currently, quantum-inspired word embedding methods have achieved good results in NLP tasks.

[0004] However, current quantum-heuristic word embedding methods generally cannot extract high-level semantic features, such as polarity and sentiment. Therefore, in text sentiment classification tasks, the lack of semantic features in current methods leads to sentiment classification errors, ultimately affecting the accuracy of classification. Summary of the Invention

[0005] The purpose of this invention is to provide a text sentiment classification method based on a quantum heuristic algorithm that is highly accurate and reliable.

[0006] The text sentiment classification method based on quantum heuristic algorithm provided by this invention includes the following steps:

[0007] S1. Obtain the original training text with classification labels;

[0008] S2. Process the original training text obtained in step S1 to obtain the training text;

[0009] S3. Load the pre-trained model and its corresponding parameters, and train the pre-trained model using the training text obtained in step S2 to obtain the amplitude embedding vector;

[0010] S4. Perform dimensionality reduction and feature extraction on the high-dimensional sentences after word segmentation to obtain the phase embedding vector;

[0011] S5. Construct a quantum-inspired neural network model based on amplitude embedding vector, phase embedding vector, and quantum computing and deep learning theories;

[0012] S6. Using the quantum heuristic neural network model obtained in step S5, perform actual text sentiment classification.

[0013] Step S2 involves processing the original training text obtained in step S1 to obtain the training text, specifically including the following steps:

[0014] The original training text is processed by converting each sentence into an index; an identifier is added before each sentence for feature extraction after text pre-training.

[0015] Step S3, which involves loading the pre-trained model and its corresponding parameters, and training the pre-trained model using the training text obtained in step S2 to obtain the amplitude embedding vector, specifically includes the following steps:

[0016] The pre-trained model is a BERT pre-trained model;

[0017] The segmented sentences in the training text are input into the BERT pre-trained model for training.

[0018] Extract the vector from the first position in the output sequence of the BERT pre-trained model to obtain the training identifier;

[0019] The obtained training identifier vector is mapped to the Hilbert space of the corresponding quantum state, and then an amplitude embedding layer is used for mapping to obtain the amplitude embedding vector.

[0020] Step S4, which involves reducing the dimensionality and extracting features from the segmented high-dimensional sentence to obtain the phase embedding vector, specifically includes the following steps:

[0021] PCA technique is used for dimensionality reduction and feature extraction;

[0022] Each batch of text sentences is segmented into words, and the resulting single word and its corresponding index are combined into a two-dimensional matrix X1.

[0023] The obtained two-dimensional matrix X1 is subjected to mean value processing to obtain a new two-dimensional matrix X2;

[0024] Calculate the covariance matrix X3 of the new two-dimensional matrix X2;

[0025] Calculate the eigenvalues ​​and eigenvectors of the covariance matrix X3, and sort the eigenvalues ​​in ascending order;

[0026] Retain the eigenvectors corresponding to the top N largest eigenvalues ​​after sorting, where N is a set natural number;

[0027] The original features are mapped to a new space constructed from N retained feature vectors, thus forming low-dimensional feature vectors;

[0028] The low-dimensional eigenvectors are mapped to the Hilbert space of the corresponding quantum state, and a phase embedding layer is used for mapping to obtain the phase embedding vector.

[0029] The process of averaging the obtained two-dimensional matrix X1 to obtain a new two-dimensional matrix X2 involves calculating the average value of each dimension of the obtained two-dimensional matrix X1, and then subtracting the average value of the corresponding dimension from each feature in the current dimension to obtain the new two-dimensional matrix X2.

[0030] Step S5, which involves constructing a quantum heuristic neural network model based on amplitude embedding vectors, phase embedding vectors, and quantum computing and deep learning theories, specifically includes the following steps:

[0031] The obtained amplitude embedding vector and phase embedding vector are used to construct the quantum state representation of the sentence:

[0032] αe βi =αcos(β) + iαsin(β)

[0033] In the formula, αcos(β) is the real part; αsin(β) is the imaginary part; i is the imaginary unit; the amplitude embedding vector corresponds to the real part, and the phase embedding vector corresponds to the imaginary part;

[0034] After the measurement operation, the real part matrix and the imaginary part matrix are obtained, which are used to represent the quantum state after the measurement.

[0035] Maxpooling is then performed on the obtained real and imaginary matrices to extract the features from them.

[0036] The vectors after Maxpooling are concatenated to obtain a new set of vectors;

[0037] A binary classifier is constructed using a multilayer sensing mechanism;

[0038] The new vector is then input into the constructed binary classifier to obtain the final classification label.

[0039] The text sentiment classification method based on quantum heuristic algorithm provided by this invention achieves text sentiment classification by extracting complex words through dual features and combining them with quantum heuristic algorithm; moreover, the method of this invention has high accuracy and good reliability. Attached Figure Description

[0040] Figure 1 This is a schematic diagram of the method flow of the present invention. Detailed Implementation

[0041] like Figure 1 The diagram shown illustrates the method flow of this invention: This text sentiment classification method based on quantum heuristics provided by the present invention includes the following steps:

[0042] S1. Obtain the original training text with classification labels;

[0043] S2. Process the original training text obtained in step S1 to obtain the training text; specifically, this includes the following steps:

[0044] The original training text is processed by converting each sentence into an index; an identifier is added before each sentence for feature extraction after text pre-training.

[0045] S3. Load the pre-trained model and its corresponding parameters, and train the pre-trained model using the training text obtained in step S2 to obtain the amplitude embedding vector; specifically, this includes the following steps:

[0046] The pre-trained model is a BERT pre-trained model;

[0047] The segmented sentences in the training text are input into the BERT pre-trained model for training.

[0048] Extract the vector from the first position in the output sequence of the BERT pre-trained model to obtain the training identifier; this vector should be more representative than other positions, containing information about the entire sentence.

[0049] The obtained training identifier vector is mapped to the Hilbert space of the corresponding quantum state, and then an amplitude embedding layer is used for mapping to obtain the amplitude embedding vector.

[0050] S4. Perform dimensionality reduction and feature extraction on the segmented high-dimensional sentence to obtain the phase embedding vector; specifically including the following steps:

[0051] PCA technique is used for dimensionality reduction and feature extraction;

[0052] Each batch of text sentences is segmented into words, and the resulting single word and its corresponding index are combined into a two-dimensional matrix X1.

[0053] The obtained two-dimensional matrix X1 is subjected to mean value processing to obtain a new two-dimensional matrix X2; specifically, for the obtained two-dimensional matrix X1, the mean value of each dimension of the matrix is ​​calculated, and then the mean value of the corresponding dimension is subtracted from each feature in the current dimension to obtain the new two-dimensional matrix X2.

[0054] Calculate the covariance matrix X3 of the new two-dimensional matrix X2;

[0055] Calculate the eigenvalues ​​and eigenvectors of the covariance matrix X3, and sort the eigenvalues ​​in ascending order;

[0056] Retain the eigenvectors corresponding to the top N largest eigenvalues ​​after sorting, where N is a set natural number;

[0057] The original features are mapped to a new space constructed by N retained feature vectors, thus forming a low-dimensional feature vector (this step achieves feature compression); that is, the original data is mapped to a low-dimensional space composed of N vectors, and feature extraction of the data is achieved.

[0058] The low-dimensional eigenvectors are mapped to the Hilbert space of the corresponding quantum state, and a phase embedding layer is used for mapping to obtain the phase embedding vector.

[0059] S5. Based on amplitude embedding vectors, phase embedding vectors, and quantum computing and deep learning theories, construct a quantum heuristic neural network model; specifically including the following steps:

[0060] The obtained amplitude embedding vector and phase embedding vector are used to construct the quantum state representation of the sentence:

[0061] αe βi =αcos(β) + iαsin(β)

[0062] In the formula, αcos(β) is the real part; αsin(β) is the imaginary part; i is the imaginary unit; the amplitude embedding vector corresponds to the real part, and the phase embedding vector corresponds to the imaginary part;

[0063] After the measurement operation, the real part matrix and the imaginary part matrix are obtained, which are used to represent the quantum state after the measurement.

[0064] Maxpooling is then performed on the obtained real and imaginary matrices to extract the features from them.

[0065] The vectors after Maxpooling are concatenated to obtain a new set of vectors;

[0066] A binary classifier is constructed using a multilayer sensing mechanism;

[0067] The new vector is then input into the constructed binary classifier to obtain the final classification label.

[0068] S6. Using the quantum heuristic neural network model obtained in step S5, perform actual text sentiment classification.

Claims

1. A text sentiment classification method based on a quantum heuristic algorithm, comprising the following steps: S1. Obtain the original training text with classification labels; S2. Process the original training text obtained in step S1 to obtain the training text; S3. Load the pre-trained model and its corresponding parameters, and train the pre-trained model using the training text obtained in step S2 to obtain the amplitude embedding vector; S4. Perform dimensionality reduction and feature extraction on the high-dimensional sentences after word segmentation to obtain the phase embedding vector; S5. Based on amplitude embedding vectors, phase embedding vectors, and quantum computing and deep learning theories, construct a quantum heuristic neural network model; specifically including the following steps: The obtained amplitude embedding vector and phase embedding vector are used to construct the quantum state representation of the sentence: ae βi =αcos(β)+iαsin(β) In the formula, αcos(β) is the real part; αsin(β) is the imaginary part; and i is the imaginary unit. The amplitude embedding vector corresponds to the real part, and the phase embedding vector corresponds to the imaginary part; After the measurement operation, the real part matrix and the imaginary part matrix are obtained, which are used to represent the quantum state after the measurement. Maxpooling is then performed on the obtained real and imaginary matrices to extract the features from them. The vectors after Maxpooling are concatenated to obtain a new set of vectors; A binary classifier is constructed using a multilayer sensing mechanism; The new vector is then input into the constructed binary classifier to obtain the final classification label. S6. Using the quantum heuristic neural network model obtained in step S5, perform actual text sentiment classification.

2. The text sentiment classification method based on quantum heuristic algorithm according to claim 1, characterized in that... Step S2 involves processing the original training text obtained in step S1 to obtain the training text, specifically including the following steps: The original training text is processed by converting each sentence into an index; an identifier is added before each sentence for feature extraction after text pre-training.

3. The text sentiment classification method based on quantum heuristic algorithm according to claim 2, characterized in that... Step S3, which involves loading the pre-trained model and its corresponding parameters, and training the pre-trained model using the training text obtained in step S2 to obtain the amplitude embedding vector, specifically includes the following steps: The pre-trained model is a BERT pre-trained model; The segmented sentences in the training text are input into the BERT pre-trained model for training. Extract the vector from the first position in the output sequence of the BERT pre-trained model to obtain the training identifier; The obtained training identifier vector is mapped to the Hilbert space of the corresponding quantum state, and then an amplitude embedding layer is used for mapping to obtain the amplitude embedding vector.

4. The text sentiment classification method based on quantum heuristic algorithm according to claim 3, characterized in that... Step S4, which involves reducing the dimensionality and extracting features from the segmented high-dimensional sentence to obtain the phase embedding vector, specifically includes the following steps: PCA technique is used for dimensionality reduction and feature extraction; Each batch of text sentences is segmented into words, and the resulting single word and its corresponding index are combined into a two-dimensional matrix X1. The obtained two-dimensional matrix X1 is subjected to mean value processing to obtain a new two-dimensional matrix X2; Calculate the covariance matrix X3 of the new two-dimensional matrix X2; Calculate the eigenvalues ​​and eigenvectors of the covariance matrix X3, and sort the eigenvalues ​​in ascending order; Retain the eigenvectors corresponding to the top N largest eigenvalues ​​after sorting, where N is a set natural number; The original features are mapped to a new space constructed from N retained feature vectors, thus forming low-dimensional feature vectors; The low-dimensional eigenvectors are mapped to the Hilbert space of the corresponding quantum state, and a phase embedding layer is used for mapping to obtain the phase embedding vector.

5. The text sentiment classification method based on quantum heuristic algorithm according to claim 4, characterized in that... The process of averaging the obtained two-dimensional matrix X1 to obtain a new two-dimensional matrix X2 involves calculating the average value of each dimension of the obtained two-dimensional matrix X1, and then subtracting the average value of the corresponding dimension from each feature in the current dimension to obtain the new two-dimensional matrix X2.

Citation Information

Patent Citations

  • Methods and systems for multi-label classification of text data

    CA3085033A1

  • Automating solving NP problems in annealer systems

    CN112116093A