Big language model-based small sample intention research and judgment and situation awareness method and system
By using a small-sample intent judgment method based on a large language model, combined with supervised contrastive learning and adversarial reinforcement training, and dynamically expanding the intent knowledge base, the problems of dynamic emergence of intent and data scarcity in open worlds are solved, achieving efficient intent recognition and anomaly detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- UNIV OF ELECTRONICS SCI & TECH OF CHINA
- Filing Date
- 2026-03-27
- Publication Date
- 2026-06-30
AI Technical Summary
Existing technologies face challenges in the open world, such as the dynamic emergence of intentions, data scarcity, and high costs of incremental learning. Traditional supervised learning methods struggle to effectively identify new intentions and are prone to catastrophic forgetting.
We employ a small-sample intent assessment method based on a large language model. By dynamically managing context and generating input prompts through structured concatenation, we combine supervised contrastive learning and adversarial reinforcement training to train a deep discriminative encoder for intent recognition and anomaly detection, and dynamically expand the intent knowledge base.
It achieves highly robust and low-cost intent discovery and recognition in data-scarce environments, improves the reuse rate of known intents and the ability to discover unknown emerging intents, and the system has the ability to continuously evolve.
Smart Images

Figure CN122311209A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing, and in particular to a method and system for small-sample intent assessment and situational awareness based on a large language model. Background Technology
[0002] In the context of modern informatization and intelligentization, the fusion, understanding, and situational awareness of massive amounts of multi-source heterogeneous information in specific fields (such as military confrontation, cybersecurity, financial risk control, and public opinion analysis) has become a core requirement. Intent recognition, as a key link in situational understanding, not only needs to understand the current observable behavior of entities, but also to infer their deeper action objectives.
[0003] For a long time, supervised learning methods based on deep learning have made significant progress in intent recognition tasks within the field of natural language processing. However, their core assumption is a "closed world," meaning that the intent category in the testing environment must be completely consistent with the training set. This situation leads to three fundamental technical difficulties: 1. First, the real-world environment is full of uncertainty, which will inevitably lead to a large number of new intentions that have never been seen in historical data (i.e., out-of-distribution or OOD intentions). Traditional supervised models lack recognition mechanisms when faced with these new intentions, which can easily lead to catastrophic misjudgments. 2. Secondly, high-quality domain-specific intent (such as military intent, risk control intent, etc.) labeled data is extremely difficult to obtain and highly confidential, making the model very susceptible to "data hunger" and few-shot learning dilemma; 3. Finally, traditional fine-tuning-based models are static. Once the system needs to identify new intentions, it usually requires collecting all data again and performing full fine-tuning, which is not only computationally expensive but also causes serious "catastrophic forgetting" problems.
[0004] Therefore, how to achieve robust and low-cost intent discovery and recognition in an open world where data is scarce and intents emerge dynamically has become a bottleneck that current technology urgently needs to overcome. Summary of the Invention
[0005] The purpose of this invention is to overcome the technical difficulties of traditional supervised learning methods in terms of dynamic emergence of intentions in open worlds, data scarcity, and high incremental learning costs, and to provide a method and system for small-sample intention judgment and situational awareness based on a large language model.
[0006] The objective of this invention is achieved through the following technical solution: A first aspect of the present invention provides a method for small-sample intent assessment and situational awareness based on a large language model, comprising the following steps: S1. Receive the query text to be analyzed, calculate its semantic similarity with historical samples in the preset intent knowledge base, dynamically retrieve the list of known intents most relevant to the query text to be analyzed, and construct an intent reference; S2. Generate a unified task instruction containing domain constraints through a context prompt generator, and structurally concatenate the unified task instruction, the intent reference, and the query text to be analyzed to generate an input prompt; S3. Call the large language model to perform inference based on the input prompts and output the intent recognition result, which includes known intent labels or new intent tags; and package and save the output of the large language model as an augmented training set containing pseudo-labels; S4. Based on the enhanced training set containing pseudo-labels, a deep discriminative encoder is trained using a strategy based on supervised contrastive learning and adversarial enhancement joint training to refine the text feature space; S5. Extract refined features of the query text to be analyzed using the trained deep discriminant encoder, and calculate its anomaly score relative to all known intent distributions based on the refined features. When the anomaly score exceeds a preset threshold, determine that the intent corresponding to the query text to be analyzed is an anomalous intent.
[0007] In some embodiments, it also includes: S6. Cache the query texts that are determined to have abnormal intent, and when the number of cached texts reaches a preset threshold, re-execute steps S1-S3 for the batch of query texts, and use the new round of intent recognition results to perform incremental fine-tuning of the deep discriminant encoder.
[0008] In some embodiments, step S3 verifies the query text marked as a new intent, and writes the verified new intent and its description into a preset intent knowledge base; the verification includes: Semantic deduplication: Calculate the maximum cosine similarity between the feature vector of the query text and the center vectors of all known intents in the knowledge base. If the maximum cosine similarity exceeds a preset threshold, it is classified into the most similar known intent category. Clustering test: When multiple query texts are labeled as the same new intent, the density of all query texts in the feature space is calculated, and the average silhouette coefficient is used to evaluate the clustering quality. Only sample clusters that pass the test are confirmed as valid new intents.
[0009] In some embodiments, the input prompt is represented by the following formula: in, This indicates the final input prompt. Indicates a unified task instruction. This represents the example sample most relevant to the current query text to be analyzed. Indicates intent for reference. This represents structured text concatenation operations. This is the current query text to be analyzed.
[0010] In some embodiments, the training of the depth discriminative encoder includes: The input samples are mapped to normalized feature vectors through a deep discriminative encoder; The cross-entropy loss is calculated using an auxiliary classification head based on the pseudo-labels of the input samples. Perturbations are added along the gradient ascent direction of the feature vectors in the cross-entropy loss to generate adversarial examples; The original input sample and the adversarial sample are treated as positive sample pairs under the same intent, and optimized using a supervised contrastive learning loss function.
[0011] In some embodiments, the supervised contrastive learning loss function is defined as: in, This represents the total number of samples in the training batch. This represents the anchor sample index in this batch. The feature vector of the anchor point sample; Indicates samples excluding anchor points in the batch. The set of indices for all other samples; Represents a set Center and anchor point Having the same pseudo-label The set of positive sample indexes This is the size of the positive sample set; It is the index of positive samples. This is the feature vector corresponding to the positive sample. It is the index of all samples except the positive samples. These are the feature vectors corresponding to these samples; It is a temperature hyperparameter.
[0012] In some embodiments, the calculation of the anomaly score includes: Calculate the Mahalanobis distance from the refined feature to each known intention distribution, and take the smallest Mahalanobis distance as its anomaly score.
[0013] In some embodiments, the loss function for incremental learning is defined as: in, Represents cross-entropy loss, This represents the loss from knowledge distillation. Indicates the current model, Represents the old model, It is the balance coefficient.
[0014] A second aspect of the present invention provides a small-sample intent assessment and situational awareness system based on a large language model, comprising: A dynamic context manager is used to receive the query text to be analyzed, calculate its semantic similarity with historical samples in a preset intent knowledge base, dynamically retrieve the list of known intents most relevant to the query text to be analyzed, and construct an intent reference. A context prompt generator is used to generate a unified task instruction containing domain constraints, and to structurally concatenate the unified task instruction, the intent reference, and the query text to be analyzed to generate an input prompt; The enhanced training set generation module is used to call the large language model to perform inference based on the input prompts and output the intent recognition result, which includes known intent labels or new intent tags; and to package and save the output of the large language model as an enhanced training set containing pseudo-labels. The feature space refinement module is used to refine the text feature space by training a deep discriminative encoder based on the augmented training set containing pseudo-labels and employing a strategy of joint training based on supervised contrastive learning and adversarial augmentation. An anomaly detection module is used to extract refined features of the query text to be analyzed using a trained deep discriminant encoder, and calculate its anomaly score relative to all known intent distributions based on the refined features. When the anomaly score exceeds a preset threshold, the intent corresponding to the query text to be analyzed is determined to be an anomalous intent.
[0015] In some embodiments, it also includes: The closed-loop feedback module is used to cache query texts that are determined to have abnormal intent by the anomaly detection module. When the number of cached texts reaches a preset threshold, the dynamic context manager, context prompt generator, and enhanced training set generation module are triggered to generate a new round of intent recognition results. The new round of intent recognition results are then used to incrementally fine-tune the deep discriminative encoder.
[0016] It should be further noted that the technical features corresponding to the above-mentioned options and embodiments can be combined or substituted with each other to form new technical solutions without conflict.
[0017] Compared with the prior art, the beneficial effects of the present invention are: 1. Automated prompting engineering: A unified task instruction containing domain constraints is generated through a context prompt generator (ICPG). The unified task instruction, the intent reference, and the query text to be analyzed are then structurally concatenated to generate input prompts. LLM automatically analyzes a small number of intent samples to generate accurate, concise task prompts rich in domain knowledge. This completely avoids the tedious manual prompt writing, greatly reduces the workload of manual prompt writing, and ensures the consistency and repeatability of prompt quality.
[0018] 2. Intelligent Few-Shot Sampling: This invention employs a semantically based few-shot sampling (SFS) strategy to dynamically retrieve the most relevant examples from historical data and inject them into the prompts. Specifically, the dynamic context manager calculates semantic similarity to retrieve the most relevant few-shot examples and known intent descriptions from the intent knowledge base. This is equivalent to dynamically constructing a "mini-training set" for each inference task. Even if the entire system has only a very small amount of initial seed data, this retrieval enhancement method can provide the most valuable contextual information for LLM, greatly compensating for the sparsity of global data and effectively alleviating the data hunger problem under few-shot learning.
[0019] 3. Dynamic Intent Knowledge Base Expansion: Through the Known Intent Feedback (KIF) mechanism, identified and discovered intents are dynamically maintained and injected into subsequent prompts, enabling the frozen LLM to continuously learn during the inference process and expand its intent knowledge base without retraining, perfectly addressing the challenge of dynamically emerging intents.
[0020] 4. The system framework of this invention realizes an efficient and completely training-free intent discovery scheme, which not only maintains the powerful zero-shot generalization and deep semantic understanding advantages of LLM, but also significantly improves the reuse rate of known intents and the ability to discover unknown emerging intents (OODs) through automated and intelligent prompt construction and context management. Attached Figure Description
[0021] Figure 1 This is a flowchart illustrating a small-sample intent assessment and situational awareness method based on a large language model, as shown in an embodiment of the present invention. Figure 2 This is a schematic diagram illustrating the action adaptive adjustment mechanism in an embodiment of the present invention.
[0022] Figure 3 This is a flowchart illustrating a reinforcement learning-driven large model and external tool collaboration framework according to an embodiment of the present invention. Detailed Implementation
[0023] The technical solution 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, not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. 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] It should be noted that the defects in the solutions in the prior art are all the results of the inventors' practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed by the embodiments of this application in the following text should be the inventors' contributions to this application in the process of invention and creation, and should not be understood as technical content known to those skilled in the art.
[0025] In view of the technical problems pointed out in the background art, the present invention provides the following embodiments: In one exemplary embodiment, a method for small-sample intent assessment and situational awareness based on a large language model is provided, such as... Figure 1 As shown, it includes the following steps: S1. Receive the query text to be analyzed, calculate its semantic similarity with historical samples in the preset intent knowledge base, dynamically retrieve the list of known intents most relevant to the query text to be analyzed, and construct an intent reference; S2. Generate a unified task instruction containing domain constraints through a context prompt generator, and structurally concatenate the unified task instruction, the intent reference, and the query text to be analyzed to generate an input prompt; S3. Call the large language model to perform inference based on the input prompts and output the intent recognition result, which includes known intent labels or new intent tags; and package and save the output of the large language model as an augmented training set containing pseudo-labels; S4. Based on the enhanced training set containing pseudo-labels, a deep discriminative encoder is trained using a strategy based on supervised contrastive learning and adversarial enhancement joint training to refine the text feature space; S5. Extract refined features of the query text to be analyzed using the trained deep discriminant encoder, and calculate its anomaly score relative to all known intent distributions based on the refined features. When the anomaly score exceeds a preset threshold, determine that the intent corresponding to the query text to be analyzed is an anomalous intent.
[0026] The core innovation of this invention lies in organically combining the semantic understanding advantages of LLM with the geometric boundary characterization capabilities of discriminative models, forming a complementary advantage. Specifically, as... Figure 2As shown, the first stage addresses the question of "where does the data come from," guiding LLM to discover new intents in unlabeled data through dynamic context construction. The second stage addresses the question of "how to define the boundaries," refining the feature space through contrastive learning and distributed modeling to achieve precise separation of new and old intents. The two stages form a closed loop through an intent knowledge base and an anomaly feedback mechanism, enabling the system to continuously evolve. The specific implementation process of the two stages is as follows: Phase 1: Large-scale model-guided intent discovery and annotation In intent recognition scenarios, directly using Large Language Models (LLMs) for intent identification faces two superficial problems: First, the text generated by LLMs is random and creative, easily leading to "illusions," such as over-inference when the intelligence text is semantically ambiguous, or incorrect knowledge associations when contextual information conflicts, making its ability to discover unknown intents unreliable. Second, the context window length of LLMs is limited; faced with a constantly accumulating vast historical intelligence database and intent knowledge base, it is impossible to directly cram all known information into the prompts. The deeper technical challenge lies in how to accurately filter out the most valuable information for the current query within a limited context capacity, while suppressing the illusionary tendency of LLMs, so that it can accurately identify known intents and reliably discover unknown intents.
[0027] To overcome the aforementioned difficulties, this invention designs a dynamic context manager. Its core idea is to inject reference content with maximum information density into a limited context through semantic similarity retrieval. Specifically, the system first maintains an intent knowledge base. The knowledge base adopts a hierarchical storage architecture, comprising two main parts: a known intent knowledge base and a newly discovered intent knowledge base. The known intent knowledge base stores the intent categories and their feature representations from the initial training set, while the newly discovered intent knowledge base dynamically records new intents identified during the reasoning process. Each intent category corresponds to a semantic center vector and several representative samples.
[0028] For each new intelligence query to be analyzed The system uses a pre-trained sentence encoder (such as Sentence-BERT) to map it into a high-dimensional semantic vector. The choice of Sentence-BERT is based on its excellent performance in semantic similarity calculation tasks, especially its stability when handling long texts and complex semantic relationships. Additionally, historical samples in the knowledge base... It is also pre-encoded as a feature vector A vector index is established, and the Hierarchical Navigation Small World (HNSW) algorithm is used to accelerate the retrieval process, ensuring that similarity calculation is completed in milliseconds.
[0029] To provide the most valuable few-sample examples within a limited context window, the system uses cosine similarity to measure the semantic relevance between the current query and historical samples, defined by the formula: in, This represents the semantic embedding vector of the query to be analyzed. The semantic embedding vector representing the historical sample. The L2 norm of the vectors is represented. The range of values for cosine similarity is... A higher similarity value indicates that the two vectors are more aligned in direction in the semantic space, meaning they are semantically similar. By maximizing this similarity, the system can dynamically retrieve the vectors most relevant to the current query. 1 example, constituting the example set .here It is a dynamically adjustable hyperparameter that is automatically determined based on the remaining capacity of the current context window and the complexity of the query, and its value range is usually from 3 to 10.
[0030] Similarly, the system calculates the query vector and the center vectors of each known intent. Based on similarity, filter out the list of most relevant known intents. The intent center vector is defined as the average of the embeddings of all samples in that class: in Intent Category The system selects the sample set with the highest similarity. An intention (usually) )constitute These intents are most likely to be relevant to the current query, providing an accurate reference to known intents for LLM.
[0031] Based on this, the system generates a unified task instruction containing domain constraints through an automated context prompt generator (ICPG). The core working principle of ICPG is to adopt a multi-stage generation strategy: In the task understanding stage, LLM analyzes the basic objectives of intent recognition, input and output format requirements, and domain-specific constraints; in the knowledge integration stage, LLM combines concepts in the domain knowledge template (such as combat unit types, action patterns, and spatiotemporal relationships in military activities) with specific manifestations in examples to form a deep understanding of various intents; in the prompt construction stage, based on the above understanding, LLM generates detailed prompts containing elements such as clear task descriptions, domain-specific constraints, output format specifications, and error handling mechanisms.
[0032] Specifically, this invention requires that the generated prompts explicitly contain key instructions; that is, the model should not forcibly assign any utterance to a known intent, but rather encourage it to create new intent categories based on semantic understanding. The prompts also specify naming conventions for new intents: they must adopt a tripartite structure of "Action Subject + Action Type + Action Objective," such as "Enemy armored forces outflank and encircle the logistics supply line." This structured naming ensures the interpretability of the new intents and the standardization of subsequent processing.
[0033] Ultimately, the system combines these modules to dynamically construct input prompts that maximize information content for the LLM. : In this formula This indicates the final input prompt. Indicates a unified task instruction. This represents the example sample most relevant to the current query text to be analyzed. Indicates intent for reference. This represents structured text concatenation operations. This is the current query text to be analyzed. Specific delimiters and markers are used during concatenation, such as "### Task Description###" and "### Reference Example###", to distinguish different parts, enabling the LLM to clearly understand the function of each module.
[0034] By entering this customized prompt LLM can accurately determine intent from text or discover new intents. The output format of LLM is strictly standardized as a JSON structure, containing the following fields: intent_label (intent label, "NEW_INTENT" if it's a new intent), intent_name (intent name, generated for new intents), confidence (confidence score, between 0 and 1), and explanation (a brief description of the reasoning process). This structured output facilitates subsequent automated processing.
[0035] Once the LLM identifies potential new intents, the system performs a rigorous verification process. First, semantic deduplication is performed, and the maximum cosine similarity between the feature vector of the new intent candidate sample and the center vectors of all known intents in the knowledge base is calculated. if Exceeding the threshold If the threshold (usually set to 0.85) is too similar to a known intent, it is considered that the sample may not be a truly new intent and is classified into the category of the most similar known intent. Next, a clustering test is performed. When multiple samples are labeled with the same new intent, the system calculates the density of these samples in the feature space and uses the average silhouette coefficient to evaluate the clustering quality. Only clusters of samples that pass the test are confirmed as valid new intents.
[0036] The verified new intents and their descriptions are persistently written into the knowledge base. Meanwhile, the system packages and saves the LLM output as an augmented training set containing a large number of pseudo-labels. This process enables the automatic transformation from unlabeled data to weakly labeled data, providing a training foundation for the second stage.
[0037] Phase Two: Discriminative Intent Refinement and Anomaly Detection The main technical challenge in the second phase, "Discriminative Intent Refinement and Anomaly Detection," lies in the inevitable noise inherent in the pseudo-labeled dataset generated by the LLM in the first phase. The inference process of LLM is a "black box," with insufficiently sharp decision boundaries, making it difficult to provide a stable geometric interpretation of the feature space when faced with carefully constructed adversarial samples or semantically ambiguous military texts. Superficial problems manifest as: a certain proportion of mislabeled samples in the pseudo-labels; blurred boundaries between different intents, especially the easy confusion between semantically similar intents; and low accuracy in detecting truly unknown anomalous intents. The deeper technical challenge lies in how to learn a feature space from noisy, weakly labeled data that possesses both strong discriminative power for known classes and sensitive detection capabilities for unknown classes.
[0038] In response to this difficulty, such as Figure 3 As shown, this invention proposes a discriminative refining scheme based on supervised contrastive learning (SCL) and adversarial enhancement joint training. The system introduces a deep discriminative encoder. Mapping the input text into a normalized feature vector and satisfy This normalization operation places the feature vectors on a unit hypersphere. This normalization operation eliminates the influence of the feature vector's magnitude, allowing the model to focus more on directional information, which aligns with the inherent need for semantic similarity comparison.
[0039] To force the model to learn noise-insensitive essential features, this invention first constructs intent-aware adversarial feature enhancement. The core idea of adversarial training is that the model must not only perform well on the original samples but also remain correct on its most difficult perturbation version. Specifically, for the original feature vector... The corresponding first-stage pseudo-label is We use an auxiliary linear classification head Calculate cross-entropy loss Then, along the loss function, the features are... Perturbations are added to the gradient ascent direction to generate the most difficult-to-classify adversarial examples, the generation process of which is defined by the following formula: In this formula, The cross-entropy loss represents the cross-entropy loss on the feature vector. The gradient indicates the direction in which the loss increases most rapidly; The sign function is used to extract the direction information of the gradient rather than its magnitude, which stems from the design idea of the Fast Gradient Sign Method (FGSM). This represents a hyperparameter used to control the strength of the resistance to perturbations, which is determined to be 0.1 on the validation set in this invention through grid search; The operation ensures the perturbed vector It is reprojected back onto the unit hypersphere, maintaining the normalization properties of the feature.
[0040] After constructing adversarial examples, the system treats them and the original samples as positive sample pairs with the same intent, and utilizes supervised contrastive learning loss functions. Perform geometric-level optimization of the feature space by combining intra-class aggregation and inter-class separation: In the formula, This represents the total number of samples in the training batch. This represents the anchor sample index in this batch. The feature vector of the anchor point sample; Indicates samples excluding anchor points in the batch. The set of indices for all other samples; Represents a set Center and anchor point Having the same pseudo-label The set of positive sample indexes (including adversarial samples) (corresponding index) This is the size of the positive sample set; and These are the indices of the positive samples and all other samples (negative samples), respectively. and The feature vectors corresponding to these samples; It is a temperature hyperparameter used to adjust the model's sensitivity to difficult negative samples; a smaller one... This allows the model to focus more on the negative samples most similar to the anchor samples, thereby learning more refined boundaries.
[0041] The core idea of supervised contrastive loss is: in the normalized feature space, for each anchor sample, we want its similarity (dot product) with all positive samples to be as large as possible, while its similarity with all negative samples to be as small as possible. The logarithmic probability term in the loss function is precisely the mathematical expression of this goal of "bringing positive samples closer and pushing negative samples away." This is achieved by minimizing... The model clusters samples with the same intent (including its adversarial variants) on a hypersphere while pushing away samples with different intents, thereby obtaining a more robust and pure feature representation.
[0042] After completing the discriminative refinement of the feature space, the system needs to address the challenge of accurately separating anomalies or novel intentions during the online inference phase. Simply relying on the output probability of the classification head often leads to overconfident misclassification of out-of-distribution samples because the softmax function has the property of "forcing" a sum of 1, assigning a relatively high probability to the most similar class even if a sample does not belong to any known class.
[0043] Therefore, this invention utilizes a multivariate Gaussian distribution for each known intent. We model the deep feature space. After training, we extract refined features from all known class samples in the training set. The mean vector and covariance matrix of each known intent category are calculated using maximum likelihood estimation: in For the first The number of samples in each class Represents the vector transpose. Covariance matrix. It captures the variance of features across various dimensions and the correlations between different dimensions, thus providing a more accurate description of the distribution shape of the category. In practical applications, due to the varying feature dimensions... Possibly higher and sample size Because estimation of the complete covariance matrix is finite, direct estimation may be unstable. This invention employs shrinkage estimation to regularize the covariance matrix: in It is the coefficient of shrinkage. It is the identity matrix. This treatment ensures the positive definiteness of the covariance matrix and improves numerical stability.
[0044] For any new test sample, we first extract its refined features. Then calculate its **Mahanobis distance** to each known intention distribution: in, Indicates test sample Compared to the first Mahalanobis distance for a known intention For the first The inverse of the class-shrinking covariance matrix. The advantage of Mahalanobis distance over Euclidean distance is that it not only considers the distance from features to class centers, but also performs a whitening transformation on the feature space through the inverse of the covariance matrix, eliminating the influence of inconsistencies in dimensions and correlations across different dimensions, thus ensuring consistency of the distance metric across the distribution shapes of each class.
[0045] Geometrically, Mahalanobis distance measures the negative logarithm of the probability density function of a test point relative to a Gaussian distribution; a larger distance indicates a lower probability that the point belongs to that distribution. The system extracts the minimum Mahalanobis distance of the sample relative to all known intentions as its anomaly score. in This represents the total number of currently known intents. If this score exceeds a dynamic threshold set based on the validation set... If the threshold is not met, the sample is determined to be an out-of-distribution anomalous intent (i.e., a novel intent). The setting adopts an empirical method based on the validation set: calculate the anomaly score of all known class samples on the validation set, and take its 95th percentile as the threshold to ensure that the false alarm rate of known class samples is controlled within 5%.
[0046] When the system determines that a sample is an OOD (Out of Detail) anomaly, it will intercept it and store it in the pending processing pool. The processing pool is maintained using a queue structure. When the number of samples in the pool reaches a preset threshold... When the threshold (usually 100) is reached, the system automatically triggers the first phase of the process, using the large model to perform a new round of intent discovery and naming on this batch of abnormal samples. The advantage of this closed-loop feedback mechanism is that the large model only needs to be called when the data accumulates to a certain scale, avoiding the high cost of frequent calls; at the same time, the abnormal samples filtered by the discriminative model have higher "purity", and the success rate of the large model in discovering new intents is also higher.
[0047] Once a new intent is identified, the system needs to perform incremental learning to expand its capabilities. Traditional full retraining is costly and can lead to catastrophic forgetting. This invention employs a lightweight incremental fine-tuning strategy: freezing the discriminative encoder. Most parameters are fine-tuned only for the last few layers and the classification head; at the same time, a knowledge distillation loss is introduced to ensure that the model does not forget knowledge of old classes during the learning of new classes. The loss function for incremental learning is defined as: The first term is the cross-entropy loss, used to learn new classes; the second term is the knowledge distillation loss, which minimizes the current model. Compared with the old model Differences in outputs on old class samples are used to preserve old knowledge; It is a balance coefficient that controls the trade-off between new and old knowledge.
[0048] Through the above design, the system achieves complete closed-loop evolution capability: the first stage is responsible for discovering new intentions and providing weak labels; the second stage is responsible for refining features and accurately detecting anomalies; anomaly samples are fed back to the first stage to confirm the new intentions; and the incremental learning module integrates new knowledge into the model. The entire process requires no manual intervention, can run autonomously for a long time, and continuously adapt to the dynamically evolving battlefield environment.
[0049] In another exemplary embodiment, based on the same inventive concept as the method embodiment, a small-sample intent assessment and situational awareness system based on a large language model is provided, including: A dynamic context manager is used to receive the query text to be analyzed, calculate its semantic similarity with historical samples in a preset intent knowledge base, dynamically retrieve the list of known intents most relevant to the query text to be analyzed, and construct an intent reference. A context prompt generator is used to generate a unified task instruction containing domain constraints, and to structurally concatenate the unified task instruction, the intent reference, and the query text to be analyzed to generate an input prompt; The enhanced training set generation module is used to call the large language model to perform inference based on the input prompts and output the intent recognition result, which includes known intent labels or new intent tags; and to package and save the output of the large language model as an enhanced training set containing pseudo-labels. The feature space refinement module is used to refine the text feature space by training a deep discriminative encoder based on the augmented training set containing pseudo-labels and employing a strategy of joint training based on supervised contrastive learning and adversarial augmentation. An anomaly detection module is used to extract refined features of the query text to be analyzed using a trained deep discriminant encoder, and calculate its anomaly score relative to all known intent distributions based on the refined features. When the anomaly score exceeds a preset threshold, the intent corresponding to the query text to be analyzed is determined to be an anomalous intent.
[0050] Preferably, the system further includes: The closed-loop feedback module is used to cache query texts that are determined to have abnormal intent by the anomaly detection module. When the number of cached texts reaches a preset threshold, the dynamic context manager, context prompt generator, and enhanced training set generation module are triggered to generate a new round of intent recognition results. The new round of intent recognition results are then used to incrementally fine-tune the deep discriminative encoder.
[0051] This system proposes a two-stage hybrid framework of "generative guidance and discriminative refinement". The overall solution of this framework is as follows: First, the zero-shot and few-shot generalization capabilities of Large Language Models (LLM) are used as a data labeling engine to discover new intentions and generate pseudo-labels in dynamic contexts; then, to address the noise and boundary ambiguity issues in LLM generation, a deep discriminative model is used for feature refinement and anomaly detection, thereby establishing an intention recognition closed-loop system that can autonomously evolve and dynamically expand.
[0052] Based on the above method and system, a specific intent recognition process is provided. It can be performed according to the following steps: First, automated context construction and retrieval are implemented. Pre-trained encoders such as Sentence-BERT are deployed in the system, and a very limited military intent seed dataset is input to extract semantic features from the seed data and construct an initial intent knowledge base. When the system receives a new batch of unknown text queries At that time, for each query The corresponding formula is used to calculate its features compared with those of each sample in the knowledge base. Cosine similarity, dynamically selecting Top- Highly similar historical samples And the most relevant list of known intents Finally, a predefined instruction template is generated using an automated script. Dynamically retrieved , and the current query The task prompts are then structured and assembled according to the corresponding formulas. .
[0053] Secondly, large-scale model reasoning and dynamic knowledge base updates are implemented. This involves presenting the complete task hints built in the previous step. Input is fed into a large language model (such as GPT-4 or LLaMA) via API or local deployment interface. The large model outputs the intent determination result and natural language description based on the prompts. The system intercepts candidate samples marked as new intents by the large model, calculates their maximum similarity with existing intents in the knowledge base using a semantic deduplication module, and performs a clustering test on their sample clusters. New intents that pass the test and their descriptions are persistently written into the knowledge base. Meanwhile, the system packages and saves the output of the large model as an augmented training set containing a large number of pseudo-labels. .
[0054] Then, supervised comparison and adversarial pre-training are implemented. A deep neural network encoder is built on a training server with GPU computing power, and the augmented training set is read. During each forward propagation, the gradient of the loss is calculated, and the hidden features are processed according to the corresponding formula along the direction of the rising gradient of the cross-entropy loss. Applying controlled strength of counter-perturbation Generate an enhanced adversarial view. Then, view the original image of the current sample. and confrontation view For positive sample pairs, samples with different pseudo-labels are mined from the current batch as negative samples, using samples with temperature parameters. Supervised contrastive learning loss function Gradient backpropagation is performed to continuously update the encoder weights until the feature space exhibits strong intra-class convergence and inter-class repulsion properties.
[0055] Next, fine-tuning of the classification head and modeling of outlier distributions are implemented. The encoder's main weights are frozen or retained with a very low learning rate, and a multilayer perceptron (MLP) is attached as the classification head at its top layer. Joint fine-tuning using cross-entropy loss and supervised contrastive loss is performed to fix the classification boundary. After training, features are extracted from all known class samples in the training set, and maximum likelihood estimation is used to calculate the category of each known intent. eigenmean vector Covariance Matrix Thus, multivariate Gaussian distribution models for each category are constructed in the latent space.
[0056] Finally, online inference and closed-loop feedback are implemented. The final model is deployed on a streaming data inference service. When real-time input text is received, the encoder extracts its deep features. The preliminary classification probability is calculated, and the Mahalanobis distance of this feature relative to all known multivariate Gaussian distributions is calculated using the corresponding formula. If the minimum Mahalanobis distance Exceeding the preset security threshold If a sample is identified as an OOD (Out of Detail) anomaly, the system rejects its classification result and marks it as an OOD anomaly, storing it in the processing pool (anomaly pool). When the anomaly pool accumulates to a certain number, the system automatically triggers the first-stage process, using a large model to perform a new round of intent naming and verification on these anomaly samples, and using new data to perform lightweight incremental fine-tuning of the discriminative encoder, completing the continuous closed-loop evolution of the system's capabilities.
[0057] The above detailed embodiments are a description of the present invention. It should not be considered that the specific embodiments of the present invention are limited to these descriptions. For those skilled in the art, several simple deductions and substitutions can be made without departing from the concept of the present invention, and all of these should be considered to fall within the protection scope of the present invention.
Claims
1. A method for small-sample intent assessment and situational awareness based on a large language model, characterized in that, Includes the following steps: S1. Receive the query text to be analyzed, calculate its semantic similarity with historical samples in the preset intent knowledge base, dynamically retrieve the list of known intents most relevant to the query text to be analyzed, and construct an intent reference; S2. Generate a unified task instruction containing domain constraints through a context prompt generator, and structurally concatenate the unified task instruction, the intent reference, and the query text to be analyzed to generate an input prompt; S3. Call the large language model to perform inference based on the input prompts and output the intent recognition result, which includes known intent labels or new intent tags; The output of the large language model is then packaged and saved as an augmented training set containing pseudo-labels. S4. Based on the enhanced training set containing pseudo-labels, a deep discriminative encoder is trained using a strategy based on supervised contrastive learning and adversarial enhancement joint training to refine the text feature space; S5. Extract refined features of the query text to be analyzed using the trained deep discriminant encoder, and calculate its anomaly score relative to all known intent distributions based on the refined features. When the anomaly score exceeds a preset threshold, determine that the intent corresponding to the query text to be analyzed is an anomalous intent.
2. The method for small-sample intent assessment and situational awareness based on a large language model according to claim 1, characterized in that, Also includes: S6. Cache the query texts that are determined to have abnormal intent, and when the number of cached texts reaches a preset threshold, re-execute steps S1-S3 for the batch of query texts, and use the new round of intent recognition results to perform incremental fine-tuning of the deep discriminant encoder.
3. The method for small-sample intent assessment and situational awareness based on a large language model according to claim 1, characterized in that, In step S3, the query text marked as a new intent is validated, and the validated new intent and its description are written into a preset intent knowledge base; the validation includes: Semantic deduplication: Calculate the maximum cosine similarity between the feature vector of the query text and the center vectors of all known intents in the knowledge base. If the maximum cosine similarity exceeds a preset threshold, it is classified into the most similar known intent category. Clustering test: When multiple query texts are labeled as the same new intent, the density of all query texts in the feature space is calculated, and the average silhouette coefficient is used to evaluate the clustering quality. Only sample clusters that pass the test are confirmed as valid new intents.
4. The method for small-sample intent assessment and situational awareness based on a large language model according to claim 1, characterized in that, The input prompt is represented by the following formula: in, This indicates the final input prompt. Indicates a unified task instruction. This represents the example sample most relevant to the current query text to be analyzed. Indicates intent for reference. This represents structured text concatenation operations. This is the current query text to be analyzed.
5. The method for small-sample intent assessment and situational awareness based on a large language model according to claim 1, characterized in that, The training of the depth discriminative encoder includes: The input samples are mapped to normalized feature vectors through a deep discriminative encoder; The cross-entropy loss is calculated using an auxiliary classification head based on the pseudo-labels of the input samples. Perturbations are added along the gradient ascent direction of the feature vectors in the cross-entropy loss to generate adversarial examples; The original input sample and the adversarial sample are treated as positive sample pairs under the same intent, and optimized using a supervised contrastive learning loss function.
6. The method for small-sample intent assessment and situational awareness based on a large language model according to claim 5, characterized in that, The supervised contrastive learning loss function is defined as follows: in, This represents the total number of samples in the training batch. This represents the anchor sample index in this batch. The feature vector of the anchor point sample; Indicates samples excluding anchor points in the batch. The set of indices for all other samples; Represents a set Center and anchor point Having the same pseudo-label The set of positive sample indexes This is the size of the positive sample set; It is the index of positive samples. This is the feature vector corresponding to the positive sample. It is the index of all samples except the positive samples. These are the feature vectors corresponding to these samples; It is a temperature hyperparameter.
7. The method for small-sample intent assessment and situational awareness based on a large language model according to claim 1, characterized in that, The calculation of the abnormal score includes: Calculate the Mahalanobis distance from the refined feature to each known intention distribution, and take the smallest Mahalanobis distance as its anomaly score.
8. The method for small-sample intent assessment and situational awareness based on a large language model according to claim 2, characterized in that, The loss function for incremental learning is defined as: in, Represents cross-entropy loss, This represents the loss from knowledge distillation. Indicates the current model, Represents the old model, It is the balance coefficient.
9. A small-sample intent judgment and situational awareness system based on a large language model, characterized in that, include: A dynamic context manager is used to receive the query text to be analyzed, calculate its semantic similarity with historical samples in a preset intent knowledge base, dynamically retrieve the list of known intents most relevant to the query text to be analyzed, and construct an intent reference. A context prompt generator is used to generate a unified task instruction containing domain constraints, and to structurally concatenate the unified task instruction, the intent reference, and the query text to be analyzed to generate an input prompt; The enhanced training set generation module is used to call the large language model to perform inference based on the input prompts and output the intent recognition result, which includes known intent labels or new intent tags. The output of the large language model is then packaged and saved as an augmented training set containing pseudo-labels. The feature space refinement module is used to refine the text feature space by training a deep discriminative encoder based on the augmented training set containing pseudo-labels and employing a strategy of joint training based on supervised contrastive learning and adversarial augmentation. An anomaly detection module is used to extract refined features of the query text to be analyzed using a trained deep discriminant encoder, and calculate its anomaly score relative to all known intent distributions based on the refined features. When the anomaly score exceeds a preset threshold, the intent corresponding to the query text to be analyzed is determined to be an anomalous intent.
10. The small-sample intent judgment and situational awareness system based on a large language model according to claim 9, characterized in that, Also includes: The closed-loop feedback module is used to cache query texts that are determined to have abnormal intent by the anomaly detection module. When the number of cached texts reaches a preset threshold, the dynamic context manager, context prompt generator, and enhanced training set generation module are triggered to generate a new round of intent recognition results. The new round of intent recognition results are then used to incrementally fine-tune the deep discriminative encoder.