Few-shot text classification method and device, system, and storage medium
By constructing a word co-occurrence graph and generating continuous soft cue vectors through graph network encoding, the problems of overfitting and training instability in few-shot text classification are solved, the generalization ability and robustness of the model are improved, the training process is simplified, and it is applicable to a variety of low-resource classification tasks such as news, comments, social media and biomedical short texts.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XINJIANG UNIVERSITY
- Filing Date
- 2026-05-12
- Publication Date
- 2026-07-31
AI Technical Summary
Existing technologies suffer from overfitting, insufficient generalization, and sensitivity to random partitioning in few-sample text classification. Especially when annotation resources are limited, traditional methods struggle to fully model deep semantics, pre-trained language models are unstable in training scenarios with very few annotations, and graph neural network methods are complex to implement and have long training processes.
By constructing a word co-occurrence graph and graph network encoding, continuous soft cue vectors are generated. End-to-end optimization is performed using a pre-trained language model, and the graph structure is used to guide the soft cue enhancement encoding to output text category results.
It achieves a more stable mitigation of semantic sparsity under conditions with few samples, improves the generalization ability and robustness of classification models, simplifies the training process, balances performance and efficiency, and is suitable for a variety of low-resource classification task scenarios.
Smart Images

Figure CN122489767A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of natural language processing technology, specifically relating to a method, apparatus, system, and storage medium for few-sample text classification. Background Technology
[0002] Short text classification is one of the fundamental tasks in natural language processing, widely used in scenarios such as news topic identification, user comment sentiment analysis, social media content recognition, question intent determination, and biomedical literature indexing. Compared to long texts, short texts typically exhibit characteristics such as shorter length, weaker context, implicit entity relationships, and sparse semantic expression. With limited annotation resources, these problems are further amplified, leading to overfitting, undergeneralization, and sensitivity to random partitioning in classification models.
[0003] Existing text classification methods can be broadly categorized into three types. The first type consists of traditional methods such as TF-IDF and SVM, which are simple to implement but struggle to fully model deep semantics. The second type is pre-trained language model fine-tuning methods, such as BERT, which possess strong contextual representation capabilities but may still experience training instability in scenarios with very few annotations. The third type is graph neural network methods, which propagate structural information by constructing word graphs, document graphs, or heterogeneous graphs to alleviate the semantic sparsity problem of short texts. However, these methods often require constructing complex graph structures or additionally superimposing multi-stage training objectives, resulting in a long training process and complex system implementation.
[0004] In recent years, soft cue fine-tuning has gained attention as a parameter-efficient method for adapting pre-trained language models, due to its requirement to learn only a small number of consecutive cue parameters. However, traditional soft cueing typically learns directly in the form of free parameters, relying mainly on a small number of labeled samples for optimization, making it difficult to explicitly absorb the word co-occurrence structure patterns in the corpus. For few-sample text classification, this cue learning method based solely on sequence representation is insufficient to effectively characterize the latent structural priors in short text scenarios. Summary of the Invention
[0005] To address the problems existing in the prior art, the present invention provides a method, apparatus, system, and storage medium for few-sample text classification.
[0006] To achieve the above objectives, the present invention provides the following solution: A few-shot text classification method includes: Step S1: Perform standardization preprocessing on the original text to construct a unified vocabulary; Step S2: Based on the unified vocabulary, obtain the normalized graph structure moments by constructing a word co-occurrence graph; Step S3: Based on the normalized graph structure moments, obtain the document-level graph embedding through graph network encoding and document-level structural representation; Step S4: The document-level graph embedding is mapped into a continuous soft cue vector of fixed length using a two-layer multilayer perceptron. Step S5: Insert continuous soft cues after the classification labels in the input sequence of the pre-trained language model to form a cue-enhanced input representation; take the hidden states corresponding to the classification labels, output the class probabilities through a linear classification layer, and train the model using the cross-entropy loss function.
[0007] As a preferred option, in step S1, the original text is standardized, lowercaseed, segmented, and low-frequency words are filtered to establish a unified vocabulary.
[0008] As a preferred embodiment, in step S2, without using label information, the co-occurrence relationship of terms is statistically analyzed based on the sliding window of the original text, the point mutual information value is calculated, a PMI weighted word co-occurrence graph is constructed, and after adding self-loops, symmetric normalization is performed to obtain a normalized graph structure matrix.
[0009] As a preferred embodiment, in step S3, a two-layer word graph convolutional coding network is used to encode the standardized word graph to obtain a word node graph representation; at the same time, the word node representation is weighted and pooled by combining the document-to-word TF-IDF sparse mapping to form a document-level graph embedding.
[0010] The present invention also provides a few-sample text classification device, comprising: The first processing module is used to perform standardized preprocessing on the original text and build a unified vocabulary; The second processing module is used to obtain normalized graph structure moments by constructing a word co-occurrence graph based on a unified vocabulary. The third processing module is used to obtain document-level graph embeddings based on normalized graph structure moments through graph network encoding and document-level structure representation; The fourth processing module is used to embed and map the document-level graph into a fixed-length continuous soft cue vector through two layers of multilayer perceptrons; The fifth processing module is used to insert continuous soft cues after the classification labels in the input sequence of the pre-trained language model to form a cue-enhanced input representation; the hidden states corresponding to the classification labels are taken and the class probabilities are output by the linear classification layer, and then trained using the cross-entropy loss function.
[0011] As a preferred option, the first processing module performs character standardization, lowercase conversion, word segmentation, and low-frequency word filtering on the original text to establish a unified vocabulary.
[0012] As a preferred embodiment, the second processing module is used to calculate the point mutual information value, construct the PMI weighted word co-occurrence graph, and perform symmetric normalization after adding self-loops to obtain the normalized graph structure matrix, without using label information, based on the sliding window statistical word co-occurrence relationship of the original text.
[0013] As a preferred embodiment, the third processing module uses a two-layer word graph convolutional coding network to encode the standardized word graph to obtain the word node graph representation; at the same time, it combines the document-to-word TF-IDF sparse mapping to perform weighted pooling on the word node representation to form a document-level graph embedding.
[0014] The present invention also provides a few-shot text classification system, comprising: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program performs a few-shot text classification method when executed by the processor.
[0015] The present invention also provides a storage medium storing a computer program that executes a few-sample text classification method when running.
[0016] This invention first performs standardized preprocessing on the original text to construct a unified vocabulary; then, based on statistical word co-occurrence relationships of the entire corpus, it constructs a PMI-weighted word co-occurrence graph and obtains a normalized graph structure matrix by adding self-loops and symmetric normalization; further, it uses a two-layer word graph convolutional coding network to extract word node structure representations, and performs weighted pooling on the word node representations through document-to-word TF-IDF sparse mapping to form document-level graph embeddings; subsequently, it uses a multilayer perceptron to map the document-level graph embeddings into continuous soft cue vectors, and inserts these soft cue vectors after the classification labels in the input sequence of the pre-trained language model, thereby realizing graph structure-guided soft cue enhancement encoding; finally, it performs end-to-end optimization of the model through classification loss and outputs the text category results; this invention has the following beneficial effects: (1) Structural information injection is more direct. This invention does not learn soft cues as isolated free parameters, but generates continuous soft cues by graph network, so that the cue vectors naturally carry the prior knowledge of corpus-level word co-occurrence structure.
[0017] (2) The training process is simpler. This invention does not rely on document-level large images, nor does it require multi-stage graph comparison training objectives. Instead, end-to-end optimization can be completed within the standard supervised classification process.
[0018] (3) Stronger robustness with fewer samples. Word co-occurrence graphs provide stable corpus statistical priors, which can alleviate the semantic sparsity problem caused by short texts and improve the generalization ability in low-labeling scenarios.
[0019] (4) Balancing performance and efficiency. Compared with traditional pure graph models, this invention makes full use of the contextual modeling capabilities of pre-trained language models; compared with traditional soft hints, this invention only increases computational overhead, but can achieve more stable structural enhancement effects.
[0020] (5) Wide range of applications. This invention can be applied to various low-resource classification task scenarios such as news, comments, social media, and biomedical short texts, and has good engineering application potential. Attached Figure Description
[0021] To more clearly illustrate the technical solution of the present invention, the drawings used in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 This is a flowchart of a few-sample text classification method according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the word co-occurrence graph construction based on PMI in this invention; Figure 3 This is a schematic diagram of word graph convolutional coding and TF-IDF weighted pooling to generate document-level graph embeddings in this invention; Figure 4 This is a schematic diagram illustrating the generation and insertion of a pre-trained language model input sequence guided by the graph in this invention. Figure 5 This is a schematic diagram of the length sensitivity curve (Macro-F1). Detailed Implementation
[0023] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0024] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0025] Example 1 like Figure 1 As shown, the present invention provides a few-shot text classification method, including: Step S1, Corpus Preparation and Preprocessing Stage: Standardize characters, lowercase them, segment words, and filter low-frequency words in the input text to establish a unified vocabulary and construct training, validation, and test sample sets.
[0026] Step S2, Word Co-occurrence Graph Construction Stage: Without using label information, the co-occurrence relationship of words is statistically analyzed based on the sliding window of all original texts, the point mutual information value is calculated, a PMI weighted word co-occurrence graph is constructed, and after adding self-loops, symmetric normalization is performed to obtain the normalized graph structure matrix.
[0027] Step S3, Graph Network Encoding and Document-Level Structure Representation Generation Stage: The standardized word graph is encoded using a two-layer word graph convolutional coding network to obtain the word node graph representation; further, the word node representation is weighted and pooled by combining the document-word TF-IDF sparse mapping to form a document-level graph embedding.
[0028] Step S4, Graph-guided soft cue generation stage: The document-level graph embedding is mapped into a fixed-length continuous soft cue vector through a two-layer multilayer perceptron, so that the soft cues are no longer learned solely by free parameters, but are generated driven by corpus-level structural information.
[0029] Step S5, Cue Enhancement Classification Stage: Insert continuous soft cues after the classification labels in the input sequence of the pre-trained language model to form a cue-enhanced input representation; take the hidden states corresponding to the classification labels and output the class probabilities through a linear classification layer, and train the model using the cross-entropy loss function.
[0030] In one embodiment of the present invention, in step S1, a text classification corpus is first obtained. ,in This represents the i-th text sample. This indicates the corresponding category label. The text undergoes unified preprocessing, including character standardization, lowercase conversion, word segmentation, and low-frequency word filtering, retaining valid terms appearing in the unified thesaurus.
[0031] Furthermore, in scenarios with few samples for training, a small number of samples can be randomly selected for each category as the training and validation sets, with the remaining samples constituting the test set. A unified protocol of 20 training samples, 20 validation samples, and the rest as test samples is adopted, and multiple random seeds are used for repeated partitioning to reduce the randomness brought about by a single partition.
[0032] As one embodiment of the present invention, in step S2, as follows: Figure 2 As shown, without using label information, the PMI value is calculated and a sparse weighted word co-occurrence map is constructed based on the co-occurrence relationships of all original text statistical terms within the sliding window. The PMI calculation formula is as follows: ,in, Indicator With words The number of co-occurrences within the sliding window. and Respectively represent words Harmony The number of times it appears, Indicates the total amount of data in the corpus. and To prevent division by zero or extremely small positive numbers with abnormal logarithms, the PMI value is used to measure the statistical strength of the association between two words in the corpus; a higher PMI value indicates a stronger contextual association between the two words. This is then incorporated into the identity matrix. Forming a matrix with self-loops: and through the degree matrix After completing the symmetric normalization, the normalized graph structure matrix is obtained: ,in, This represents the adjacency matrix after adding self-loops. express The corresponding degree matrix, This represents the normalized word graph structure matrix. This processing allows word nodes to retain their own features while aggregating neighbor information, and reduces the impact of highly connected nodes on the graph convolution propagation process.
[0033] As one embodiment of the present invention, in step S3, as follows: Figure 3 As shown, a word vector is initialized for each word in the vocabulary. Stack all word vectors to form a matrix A two-layer word graph convolutional coding network is used to normalize the word graph. Encode. (Number) Layer graph convolution can be represented as: ,in, Indicates the first Layer input word node representation, Indicates the first Layer trainable weight matrix, Represents residual mapping, Representation layer normalization operation. This step enables each word node to aggregate neighbor word node information based on the PMI word graph, ultimately obtaining the word node representation matrix. .
[0034] As one embodiment of the present invention, in step S4, as follows: Figure 3 As shown, for any text Read its TF-IDF non-zero word index set and corresponding weights The word node representation after graph encoding By performing a weighted summation, we obtain the document-level graph embedding: ,in, Representing text Document-level graph embedding, The graph embedding dimension is represented by this. This document-level graph embedding simultaneously incorporates corpus-level word co-occurrence relationships and the distribution of important terms in the current text, and can serve as a structural condition vector for generating continuous soft cues.
[0035] like Figure 3As shown, embedding document-level graphs Inputting a two-layer multilayer perceptron, a fixed-length continuous soft cue vector is obtained through a tanh nonlinear mapping: ,in, and This indicates the trainable parameters in the generative network. Indicates the length of consecutive soft prompts. This represents the input embedding dimension of the pre-trained language model. This step is used to convert document-level graph structure information into a continuous cue representation that the pre-trained language model can accept.
[0036] As one embodiment of the present invention, in step S5, as follows: Figure 4 As shown, let the input text be... After word segmentation, a token ID sequence is obtained. First, the original token embedding is obtained through the embedding layer of a pre-trained language model. Then, continuous soft prompts The enhanced input embedding sequence is formed by inserting the classification tag [CLS] after it and before the rest of the text tokens: ,in, This indicates the embedding corresponding to the [CLS] tag. This indicates the embedding corresponding to the remaining text tokens. This concatenation method allows the model to prioritize receiving the prompts generated by the graph structure when encoding text.
[0037] The enhanced input embedding sequence is fed into the pre-trained language model, and the final hidden state corresponding to the classification label [CLS] is obtained. The class probabilities are obtained through a linear classification layer and a softmax function; the output formula for the classification probability is: ,in, and Indicates the classification layer parameters, Indicates input text Category The predicted probability is calculated. During the training phase, the cross-entropy loss function is used to optimize the model parameters, and model selection and early stopping are performed based on the performance on the validation set.
[0038] In this invention, the pre-trained language model uses bert-base-uncased as the backbone network and fine-tunes the last Transformer layer by default to balance training overhead and classification performance in scenarios with few samples.
[0039] Furthermore, this invention selects publicly available text classification datasets, which are widely used and representative in the field of short text classification research, as the corpus source for model training and evaluation. This invention uses six standard publicly available short text classification datasets: AG News, MR, Twitter, Snippets, TagMyNews, and Ohsumed. Among them, AG News is used for news topic classification, with clear category boundaries, suitable for verifying the applicability of the model in general topic recognition scenarios; MR mainly comes from film review texts, suitable for sentiment classification tasks, with a lot of subjective expression in the text; Twitter comes from social media short sentences, with colloquial language and significant noise; Snippets and TagMyNews mainly come from search summaries and news headlines, with short text lengths and rich topics; Ohsumed comes from medical literature indexes, with strong domain terminology features. The above data cover various typical application scenarios such as news, social media, sentiment analysis, and medical texts, effectively supporting the structural modeling and classification capability verification of the graph network and soft cue fine-tuning fusion model under different semantic densities, text styles, and domain conditions.
[0040] Furthermore, to ensure that the proposed method possesses stable representation learning capabilities and classification performance in few-shot scenarios, the selected corpus should be sufficiently representative in terms of sample size, category settings, and supervision methods. Each dataset contains explicit category labels and employs a unified few-shot partitioning protocol: 20 samples are randomly selected from each category as the training set, 20 samples as the validation set, and the remaining samples as the test set. To reduce the impact of randomness from a single random partition, five independent random partitions are used for repeated experiments, and the mean and standard deviation are reported. The above settings can simulate real-world low-resource text classification scenarios, enabling the model to learn effective classification features even under limited labeling conditions.
[0041] Furthermore, the selected public datasets are all publicly released standard corpora widely used in text classification research, possessing stable text content and reliable label sources. During the preprocessing stage, uniform lowercase conversion, basic normalization, whitespace segmentation, and low-frequency word filtering operations are performed on all texts to construct a unified vocabulary. Simultaneously, a PMI word co-occurrence graph is constructed based on all original text information, rather than label information, and a document-to-word TF-IDF sparse mapping is generated on the same vocabulary space. This ensures that each text sample not only has the original sequence input but also possesses word-level node relationships for graph structure modeling and a document-level graph representation foundation for prompt generation, supporting consistent indexing and efficient computation throughout the subsequent WORDGCN encoding, prompt generation, and BERT classification processes.
[0042] The workflow of this invention is as follows: 1. Construct and preprocess a few-shot text classification dataset that integrates graph networks and soft cueing: The selected dataset includes six standard short text classification corpora: AG News, MR, Twitter, Snippets, TagMyNews, and Ohsumed. First, all original texts undergo basic cleaning and normalization, including unifying letter case, performing lightweight word segmentation, removing extremely low-frequency terms, and constructing a unified vocabulary V based on the minimum document frequency threshold. 2. A sliding window is used to count the co-occurrence frequency of terms across the entire corpus, the point mutual information (PMI) value between terms is calculated, and edges greater than the threshold τ are retained to generate a sparse weighted adjacency matrix A. 3. By adding self-loops to the adjacency matrix A, we obtain... Furthermore, symmetric normalization is performed to obtain the normalized graph structure matrix. This is for subsequent graph convolutional encoding; 4. For each text d, consider the co-occurrence of words. Figure 1 Calculate TF-IDF sparse vectors on the vocabulary V and save them as a set of word indices. and corresponding weights This is used to subsequently pool the word graph representation into a document-level graph representation; 5. Input the normalized PMI word co-occurrence graph into a two-layer WORDGCN graph encoder, and obtain the word node structure representation H through graph convolution, residual connection, layer normalization and nonlinear activation operations; 6. For each text d, represent the word nodes according to its TF-IDF non-zero word index set Id and corresponding weights td,i. Perform weighted summation to generate document-level graph embeddings. ; 7. Embed document-level diagrams The input consists of a two-layer fully connected network for generating prompts, which, after tanh activation, is mapped to a continuous soft prompt vector of fixed length L. And rearrange them into L hint tokens; 8. Generate continuous soft prompts Inserted into the BERT input sequence after the [CLS] token and before the rest of the tokens, while expanding the attention mask, and using the [CLS] hidden state output by BERT as the classification representation, the text category probability is output through the classification layer; 9. Supervised optimization of the model is performed using cross-entropy loss, and model selection and early stopping control are based on validation set performance. All the graph structures, sparse mappings, and intermediate representations generated by hints can be managed using sparse formats or pre-stored methods to improve computational efficiency and model stability.
[0043] To verify the effectiveness of the method of this invention, experiments were conducted using six publicly available short text classification datasets: MR, Twitter, Snippets, TagMyNews, Ohsumed, and AG News. These datasets cover scenarios such as sentiment analysis, search summarization, news topic recognition, and biomedical literature indexing, and can comprehensively verify the applicability of the method of this invention in various types of short text tasks. Table 1 lists the basic statistical information of the six datasets.
[0044] Table 1. Basic Statistical Information of the Dataset
[0045] Tables 2 and 3 present the comparison results between the method of this invention and several reproducible experimental baselines under a unified few-shot protocol. TF-IDF+SVM is the traditional sparse feature baseline, Graph-only WordGCN is the graph model baseline, BERT-only is the standard pre-trained language model fine-tuning baseline, and Soft Prompt is the standard learnable soft cue baseline. The method of this invention outperforms Graph-only WordGCN and Soft Prompt on all six datasets, and also shows varying degrees of complementary gains compared to BERT-only on datasets such as TagMyNews, Ohsumed, and Twitter.
[0046] Table 2. Classification results on the MR, AG News, and Twitter datasets (Acc. / Macro-F1, %)
[0047] Table 3. Classification results on the Snippets, TagMyNews, and Ohsumed datasets (Acc. / Macro-F1, %)
[0048] Furthermore, in the efficiency evaluation, the method of this invention, under the conditions of an average of two datasets, a batch size of 8, and only fine-tuning the last Transformer layer, achieves approximately 9.95M trainable parameters, a peak GPU memory usage of approximately 514.70MB, and a single batch training time of approximately 0.01651 seconds. Compared with standard learnable soft hints, the method of this invention introduces word graph encoding and instance-level hint generation, thus incurring moderate additional overhead, but the overall overhead remains within an acceptable range, balancing performance improvement and engineering deployability. The trainable parameter count, peak GPU memory usage, and throughput (seconds / batch) for different hint modes are shown in Table 4.
[0049] Table 4 Efficiency statistics of different prompting modes
[0050] Length prompt This directly affects the size of the model's trainable parameters and its expressive power. To examine the effect of the method of this invention... Sensitivity, in A comparison was made, and the results are shown in Table 5. Overall, = 5 performs stably on most datasets; when When the cue length is too large (e.g., MR), it may introduce too many degrees of freedom, leading to increased training variance or overfitting. To visually illustrate the trend across different datasets, a curve showing the relationship between cue length and Macro-F1 score was plotted, as shown below. Figure 5 As shown.
[0051] Table 5 Length Indication Sensitivity analysis (six datasets; mean ± standard deviation)
[0052] This invention does not require constructing a document-level large graph, nor does it rely on multi-stage comparative training objectives. Instead, while retaining the lightweight advantages of soft cue fine-tuning, it injects corpus-level word co-occurrence structure information into the cue vector, thereby improving classification robustness and generalization ability under few-sample conditions. Experimental results on six public datasets—MR, AG News, Twitter, Snippets, TagMyNews, and Ohsumed—show that the proposed method consistently outperforms graph model baselines and standard soft cue baselines under a unified 20 training samples + 20 validation samples / class protocol, and demonstrates strong application potential on semantically sparse or domain-specific datasets.
[0053] Example 2 The present invention also provides a few-sample text classification device, comprising: The present invention also provides a few-sample text classification device, comprising: The first processing module is used to perform standardized preprocessing on the original text and build a unified vocabulary; The second processing module is used to obtain normalized graph structure moments by constructing a word co-occurrence graph based on a unified vocabulary. The third processing module is used to obtain document-level graph embeddings based on normalized graph structure moments through graph network encoding and document-level structure representation; The fourth processing module is used to embed and map the document-level graph into a fixed-length continuous soft cue vector through two layers of multilayer perceptrons; The fifth processing module is used to insert continuous soft cues after the classification labels in the input sequence of the pre-trained language model to form a cue-enhanced input representation; the hidden states corresponding to the classification labels are taken and the class probabilities are output by the linear classification layer, and then trained using the cross-entropy loss function.
[0054] As one embodiment of the present invention, the first processing module performs character standardization, lowercaseization, word segmentation, and low-frequency word filtering on the original text to establish a unified vocabulary.
[0055] As one embodiment of the present invention, the second processing module is used to calculate the point mutual information value, construct a PMI weighted word co-occurrence graph, and perform symmetric normalization after adding self-loops to obtain a normalized graph structure matrix, without using tag information, based on the sliding window statistical word co-occurrence relationship of the original text.
[0056] As one embodiment of the present invention, the third processing module uses a two-layer word graph convolutional coding network to encode the standardized word graph to obtain a word node graph representation; at the same time, it combines the document-to-word TF-IDF sparse mapping to perform weighted pooling on the word node representation to form a document-level graph embedding.
[0057] Example 3 The present invention also provides a few-shot text classification system, comprising: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program performs a few-shot text classification method when executed by the processor.
[0058] Example 4 The present invention also provides a storage medium storing a computer program that executes a few-sample text classification method when running.
[0059] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Various modifications and improvements made to the technical solutions of the present invention by those skilled in the art without departing from the spirit of the present invention should fall within the protection scope defined by the claims of the present invention.
Claims
1. A few-shot text classification method, characterized in that, include: Step S1: Perform standardization preprocessing on the original text to construct a unified vocabulary; Step S2: Based on the unified vocabulary, obtain the normalized graph structure moments by constructing a word co-occurrence graph; Step S3: Based on the normalized graph structure moments, obtain the document-level graph embedding through graph network encoding and document-level structural representation; Step S4: The document-level graph embedding is mapped into a continuous soft cue vector of fixed length using a two-layer multilayer perceptron. Step S5: Insert continuous soft cues after the classification labels in the input sequence of the pre-trained language model to form a cue-enhanced input representation; take the hidden states corresponding to the classification labels, output the class probabilities through a linear classification layer, and train the model using the cross-entropy loss function.
2. The few-shot text classification method of claim 1, wherein, In step S1, the original text is standardized, lowercaseed, segmented, and low-frequency words are filtered to establish a unified vocabulary.
3. The few-shot text classification method of claim 2, wherein, In step S2, without using label information, the co-occurrence relationship of terms is statistically analyzed based on the sliding window of the original text, the point mutual information value is calculated, a PMI weighted word co-occurrence graph is constructed, and after adding self-loops, it is symmetrically normalized to obtain a normalized graph structure matrix.
4. The few-shot text classification method of claim 3, wherein, In step S3, a two-layer word graph convolutional coding network is used to encode the standardized word graph to obtain the word node graph representation; at the same time, the word node representation is weighted and pooled by combining the document-word TF-IDF sparse mapping to form a document-level graph embedding.
5. A few-shot text classification apparatus, characterized by comprising: include: The first processing module is used to perform standardized preprocessing on the original text and build a unified vocabulary; The second processing module is used to obtain normalized graph structure moments by constructing a word co-occurrence graph based on a unified vocabulary. The third processing module is used to obtain document-level graph embeddings based on normalized graph structure moments through graph network encoding and document-level structure representation; The fourth processing module is used to embed and map the document-level graph into a fixed-length continuous soft cue vector using a two-layer multilayer perceptron. The fifth processing module is used to insert continuous soft cues after the classification labels in the input sequence of the pre-trained language model to form a cue-enhanced input representation; the hidden states corresponding to the classification labels are taken and the class probabilities are output by the linear classification layer, and then trained using the cross-entropy loss function.
6. The few-shot text classification apparatus of claim 5, wherein, The first processing module performs character standardization, lowercase conversion, word segmentation, and low-frequency word filtering on the original text to establish a unified vocabulary.
7. The few-shot text classification apparatus of claim 6, wherein, The second processing module is used to calculate the point mutual information value, construct the PMI weighted word co-occurrence graph, and perform symmetric normalization after adding self-loops to obtain the normalized graph structure matrix, without using label information, based on the sliding window of the original text to count the co-occurrence relationship of terms.
8. The few-shot text classification apparatus of claim 7, wherein, The third processing module uses a two-layer word graph convolutional coding network to encode the standardized word graph to obtain the word node graph representation; at the same time, it combines the document-to-word TF-IDF sparse mapping to perform weighted pooling on the word node representation to form a document-level graph embedding.
9. A few-shot text classification system, comprising: include: A memory and a processor, wherein the memory stores a computer program executed by the processor, the computer program performing the few-sample text classification method as described in any one of claims 1-4 when executed by the processor.
10. A storage medium, characterized by The storage medium has stored thereon a computer program which, when executed, performs the few-shot text classification method of any one of claims 1-4.