Method and system for dynamic updating of file classification decision boundary based on online contrastive learning
By employing an online comparative learning-based method for dynamically updating the decision boundary of file classification, and utilizing the dynamic updating of semantic feature vectors and concept prototype vectors, this method solves the problem of file classification that cannot respond in real time in existing technologies, achieving efficient real-time adaptive classification and stability.
Patent Information
- Application Number
- CN202611106751.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-24
- Publication Date
- 2026-11-03
AI Technical Summary
Existing document classification technologies cannot achieve real-time adaptive classification that triggers updates instantly upon a single user feedback, does not require full retraining, and has an end-to-end response time of less than a few seconds. In particular, they are unable to meet real-time response capabilities when business semantics change dynamically.
The document classification decision boundary dynamic update method based on online contrastive learning obtains the semantic feature vector of the document to be classified, maintains the concept prototype vector, uses supervised contrastive loss and momentum protection loss for single-step parameter updates, and combines dynamic gradient mask and exponential moving average strategies to dynamically adjust the classification boundary.
It enables boundary updates to be triggered instantly with a single user feedback, reducing computational costs, ensuring the system's real-time adaptive classification performance and long-term operational stability, and meeting the engineering feasibility requirement of end-to-end response time within a few seconds.
Smart Images

Figure CN123030689A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence and natural language processing, and in particular to a method and system for dynamically updating decision boundaries for document classification based on online comparative learning. Background Technology
[0002] With the continued deepening of digital transformation, the number of electronic documents generated in the daily operations of enterprises is growing exponentially, including various types such as contract texts, financial vouchers, technical reports, legal documents, and administrative archives. How to accurately and efficiently classify these massive amounts of documents automatically has become a core functional requirement of intelligent document management systems.
[0003] Existing document classification technologies mainly fall into two categories. One is rule-based classification, which uses manually predefined keyword dictionaries or regular expressions for classification. However, the cost of maintaining rules increases dramatically with the number of categories, making it difficult to cover semantic diversity. The other is static classification models based on pre-trained language models such as BERT and RoBERTa. These methods achieve high classification accuracy on standard benchmark datasets, but have significant drawbacks: the decision boundary is fixed in the parameter space after model training, unable to adapt dynamically to changes in business semantics; when updating category definitions or incorporating user feedback, a large amount of labeled data must be collected again and the entire training process restarted, typically taking hours or even days; single user error corrections cannot be directly converted into model updates, requiring a sufficient number to trigger batch updates, resulting in severely insufficient real-time response capabilities. While continuous learning research has proposed a series of techniques to reduce catastrophic forgetting, these generally require maintaining replay buffers or complex parameter tuning, still necessitating batch data to trigger updates. Prototype networks achieve classification by maintaining prototype vectors for each category, but their static prototype vectors lack an effective online update mechanism. Supervised contrastive learning has demonstrated excellent discriminative power in feature space learning, but its standard form requires batch offline training. In summary, existing technologies cannot simultaneously meet the engineering constraints of instant updates triggered by single user feedback, no need for full retraining, and end-to-end response time within seconds. Summary of the Invention
[0004] To address the aforementioned technical problems in related technologies, this invention proposes a method and system for dynamically updating the decision boundary of document classification based on online comparative learning, which can overcome the above-mentioned shortcomings of the prior art.
[0005] To achieve the above-mentioned technical objectives, the technical solution of the present invention is implemented as follows: A method for dynamically updating decision boundaries for document classification based on online comparative learning; This method for dynamically updating the decision boundary for document classification based on online contrastive learning includes the following steps: Obtain the semantic feature vector of the file to be classified; Maintain a concept prototype vector for each category, which represents the central position of the corresponding category in the semantic space; Based on the similarity between the semantic feature vector and each concept prototype vector, the predicted category of the file to be classified is determined; In response to the received user feedback signal regarding the predicted category, the feedback signal containing at least the correct category labeled by the user, a supervised contrastive loss is constructed based on the semantic feature vector, the predicted category, and the correct category, and a single-step parameter update is performed using the weighted sum of the supervised contrastive loss and the momentum conservation loss as the total loss; wherein, the momentum conservation loss is used to constrain the offset of the concept prototype vector corresponding to the correct category in this update; When performing parameter updates, based on the dynamically determined gradient mask, only the concept prototype vector corresponding to the correct category and some parameters of the top layer of the pre-trained language model encoder are updated, and the updated top layer parameters do not exceed two Transformer layers. Based on the updated parameters, the concept prototype vector corresponding to the correct category is updated using an exponential moving average strategy.
[0006] Furthermore, the dynamically determined gradient mask is jointly determined by the type of the feedback signal and the confidence bias, wherein the confidence bias is the difference between the predicted probability of the predicted category and the predicted probability of the correct category; When the feedback signal is a confirmation feedback, the set of updatable parameters is limited to the concept prototype vector corresponding to the correct category; When the feedback signal is error correction feedback and the confidence deviation is less than a preset threshold, the set of updatable parameters is limited to the concept prototype vector corresponding to the correct category and the concept prototype vector corresponding to the predicted category. When the feedback signal is error correction feedback and the confidence deviation is not less than the preset threshold, the set of updatable parameters is expanded to include the concept prototype vector corresponding to the correct category, the concept prototype vector corresponding to the predicted category, and at least one layer of parameters at the top layer of the pre-trained language model encoder; the number of updated top-level parameter layers increases with the increase of the confidence deviation, and the upper limit is two layers.
[0007] Furthermore, the supervised comparison loss is calculated according to the following formula: , in, The semantic feature vector This is the concept prototype vector corresponding to the correct category. For the concept prototype vectors of categories other than the correct category, sim(·,·) is the cosine similarity function. This refers to temperature hyperparameters. The momentum protection loss is calculated according to the following formula: , in, This refers to the proposal value of the concept prototype vector corresponding to the correct category mentioned in this update. This is a snapshot value of the concept prototype vector corresponding to the correct category as described before this update. Momentum protection weights; The exponential moving average strategy updates the concept prototype vector corresponding to the correct category according to the following formula: , in, This is the concept prototype vector corresponding to the correct category mentioned earlier. For the updated concept prototype vector, This is the attenuation coefficient.
[0008] Furthermore, when the feedback signal is error correction feedback, a repulsive shift is also performed on the concept prototype vector corresponding to the predicted category, causing it to move away from the semantic feature vector; the repulsive shift is calculated according to the following formula: , in, The concept prototype vector corresponding to the predicted category mentioned before the update. The conceptual prototype vector after rejection displacement. To exclude displacement step size.
[0009] Furthermore, when obtaining the semantic feature vector, if the text length of the file to be classified exceeds the maximum input length of the pre-trained language model, the text is divided into multiple overlapping blocks according to the step size, and the semantic feature vectors of each block are extracted and then weighted average pooling is performed to obtain the semantic feature vector.
[0010] Furthermore, after updating the concept prototype vector, a consistency verification step is also performed: Based on the historical verification anchor set, calculate the classification accuracy of each category after the update; If the classification accuracy of any of the categories decreases by more than a preset threshold compared to the state before the update, the system will automatically roll back to the state of the concept prototype vector library before the update. If the automatic rollback is triggered, an audit task is generated and the feedback signal and the accuracy comparison information before and after the rollback are recorded. After receiving the audit decision result, if the audit decision result is adoption or reversal, the parameter update step is re-executed with the reduced momentum protection weight, and the sample corresponding to the feedback is permanently added to the historical verification anchor set.
[0011] Furthermore, when the user-declared category does not belong to the existing category set, a dynamic expansion of the new category is performed: Using the semantic feature vector as the initial concept prototype vector of the new category, the new category is added to the category set and marked as uncertain; when the new category is in an uncertain state, its classification confidence upper limit is lower than the confidence threshold of the stable category; when the number of confirmed samples received by the new category reaches a preset threshold, the new category is upgraded to a stable state. Before adding the new category to the category set, the minimum cosine distance between the initial concept prototype vector and all existing category prototype vectors is calculated. If the minimum cosine distance is less than the isolation threshold, the user is prompted with the most similar existing category, and a decision is made based on the user's confirmation whether to perform new category expansion or switch to error correction feedback.
[0012] Furthermore, when the confidence level of the predicted category is lower than a preset threshold, a labeling request is proactively initiated to the user.
[0013] According to another aspect of the present invention, a system for dynamically updating decision boundaries for document classification based on online contrastive learning is provided, comprising: The document semantic feature extraction module is used to obtain the semantic feature vector of the file to be classified. The concept vector library management module is used to maintain a concept prototype vector for each category. The concept prototype vector is used to represent the central position of the corresponding category in the semantic space. A feedback trigger control module is used to receive feedback signals from the user regarding the predicted category, wherein the feedback signals contain at least the correct category labeled by the user; The online contrastive learning local fine-tuning module is used to construct a supervised contrastive loss based on the semantic feature vector, the predicted category, and the correct category. The weighted sum of the supervised contrastive loss and the momentum conservation loss is used as the total loss to perform single-step parameter updates. The momentum conservation loss is used to constrain the offset of the concept prototype vector corresponding to the correct category in this update. The local fine-tuning module updates only the concept prototype vector corresponding to the correct category and some parameters of the top layer of the pre-trained language model encoder based on a dynamically determined gradient mask, and the updated top-level parameters do not exceed two Transformer layers. The decision boundary dynamic update module is used to update the concept prototype vector corresponding to the correct category based on the updated parameters using an exponential moving average strategy.
[0014] This system, based on online comparative learning for dynamically updating the decision boundary of document classification, includes... Furthermore, it also includes a consistency verification and rollback module, which is used to calculate the classification accuracy of each category after updating the concept prototype vector based on the historical verification anchor set. If the classification accuracy of any category decreases by more than a preset threshold compared to before the update, it will automatically roll back to the concept prototype vector library state before the update.
[0015] The beneficial effects of this invention are as follows: By using the concept prototype vector as the geometric anchor point of the decision boundary and transforming boundary adjustment into incremental displacement of the prototype vector, boundary updates can be triggered instantly with a single user feedback without full retraining, thus achieving real-time adaptive classification with an end-to-end response time of less than a few seconds; by using a dynamic gradient masking mechanism to limit the parameter update range to a small number of parameters at the top level of the prototype vector and the pre-trained language model encoder, the computational cost of a single update is reduced by several orders of magnitude compared to full retraining, thus achieving engineering feasibility for frequent incremental updates in a production environment; by using momentum-protected loss to constrain the single offset amplitude of the concept vector and combining historical anchor set consistency verification and automatic rollback mechanism, the destruction of historical boundaries caused by frequent incremental updates is effectively prevented, thus achieving classification stability and security in long-term system operation. Attached Figure Description
[0016] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0017] Fig. 1 This is a flowchart of the method for dynamically updating the decision boundary of document classification based on online comparative learning, as described in this invention. Fig. 2 This is a flowchart of the feedback type-driven adaptive gradient mask and displacement amplitude linkage mechanism of the present invention; Fig. 3 This is a geometrical diagram of the semantic space of the conceptual vector incremental displacement of this invention. Detailed Implementation
[0018] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. 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.
[0019] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," "clockwise," and "counterclockwise," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limiting this invention.
[0020] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the stated features. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified. Furthermore, the terms "installed," "connected," and "linked" should be interpreted broadly; for example, they may refer to a fixed connection, a detachable connection, or an integral connection; they may refer to a mechanical connection or an electrical connection; they may refer to a direct connection or an indirect connection through an intermediate medium; and they may refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.
[0021] like Figs. 1 to 3 As shown in the embodiment of the present invention, the method for dynamically updating the decision boundary of document classification based on online contrastive learning includes the following steps: To facilitate understanding of the above technical solutions of the present invention, the following detailed description of the above technical solutions of the present invention is provided through specific embodiments and working principles.
[0022] Step 1: Extraction of semantic features of the document This step performs semantic encoding on the input file based on a pre-trained language model (PLM). The choice of PLM is unrestricted; any of the following models can be used: BERT-Base / Large, RoBERTa-Base / Large, or domain-adaptive document encoders such as LongFormer and Beltagy. PLM weights are derived from publicly available pre-trained model repositories such as HuggingFaceModel Hub or enterprise-developed pre-trained models. By default, these weights remain frozen during the inference phase of this system, and are only selectively updated through gradient masks during the online fine-tuning phase in step five.
[0023] The input file text is represented as a token sequence D={t1,t2,…,t} n}, where n is the total number of tokens after tokenization, and t i The i-th token is generated by the PLM-compatible tokenizer, such as WordPiece or the BPE algorithm.
[0024] Standard procedure ( Add a special marker [CLS] to the beginning of the token sequence D and [SEP] to the end to form [CLS,t1,…,t]. n [,SEP]; The input PLM is processed through multi-layer Transformer encoding. The output vector at the [CLS] position in the last hidden layer is extracted and used as the semantic feature representation of the entire file.
[0025] Processing workflow for extremely long documents ( (This refers to the maximum input length of the PLM, such as 512 tokens in BERT). Organize the document by step Divided into several overlapping blocks ,default value: token, where D i Independently execute standard PLM coding to obtain the corresponding [CLS] vector h i ∈R d ; Weighted average pooling is performed on the [CLS] vectors of all blocks: weight w i The content density is jointly determined by the relative position of the block in the document and the content density estimated by the proportion of non-stop word tokens in each block, and after normalization, it satisfies Σ. i w i = 1.
[0026] Standard document semantic feature vector:
[0027] Long document chunking and weighted pooling: , i = 1, 2, …, m w i = ρ i / Σ j ρ j ,in
[0028] (The beginning and end have low weight, while the middle has high weight) dens(D i = Number of non-stop word tokens / |D i | (Block content density) x = Σ i w i · h i , satisfying Σ i w i = 1, w i >0, in: d represents the hidden layer dimension of the PLM. (BERT-Base: d=768; BERT-Large / RoBERTa-Large: d=1024), m is the number of document segments. PLM maximum number of input tokens (default 512). Set the block segmentation step size (default 256). Generate semantic feature vector x ∈ R of the input file d All subsequent processing steps use this vector as the unified semantic input.
[0029] This provides a high-quality and stable semantic foundation for subsequent classification decisions, contrastive learning loss calculations, and concept vector update steps. The PLM backbone parameters are frozen during the inference phase to ensure consistency in feature extraction; the weighted pooling strategy ensures that the semantic information of ultra-long documents is not lost due to truncation, thus improving the accuracy of long document classification.
[0030] Step 2: Concept Vector Library Construction and Initialization This step builds upon the semantic feature vector extraction capability output from Step 1, and the set of labeled training files S = {(D} provided during the system initialization phase. i , y i ) | i = 1, 2, …, N}, where D iLet y be the original text of the i-th training file. i ∈ C = {c1, c2, …, c k} represents the corresponding category label, N is the total number of files in the training set, and k is the initial total number of categories.
[0031] For each file D in the training set i Call the PLM encoder from step one to obtain its semantic feature vector x i ∈ d .
[0032] For each category c ∈ C, calculate the concept prototype vector μ_c, which is defined as the arithmetic mean of the feature vectors of all training samples for that category:
[0033] in: —The set of feature vectors of training samples for category c The number of training samples for class c (required) ) The concept prototype vectors of all categories constitute the concept vector library:
[0034] The concept vector library M is stored in a vector database that supports millisecond-level approximate nearest neighbor (ANN) retrieval. It is recommended to use the IVFFlat or HNSW index structure of FAISS (Johnson et al., 2019[8]) to ensure query efficiency when the number of categories k is large. At the same time, the system maintains versioned persistent snapshots for M for use in the rollback operation in step seven. The snapshot data is stored in the local file system or object storage service, and the path format is .
[0035] A dynamically updatable concept vector library M is constructed, in which each category is uniquely represented by a d-dimensional prototype vector, which can be further expanded into a multi-prototype structure to support multimodal category distribution.
[0036] The concept vector library serves as a set of geometric anchor points for classification decision boundaries. By abstracting the classification boundary in the high-dimensional parameter space into the geometric structure of low-dimensional prototype vectors, all subsequent boundary adjustment operations are equivalent to incremental displacements of the prototype vectors. This transforms the complex model update problem into simple and efficient vector operations, which is the core design principle for achieving low-cost real-time updates.
[0037] Step 3: Initial classification decision based on the cosine similarity prototype network (corresponding to the joint operation of modules M1 and M2) This step is based on the semantic feature vector x ∈ of the file to be classified obtained in step one. d and the current concept vector library maintained in step two. .
[0038] For the feature vector x of the file to be classified, calculate its cosine similarity with the prototype vector μ_c of each category in the concept vector library:
[0039] Where · represents the inner product operation, and ||·||2 represents the L2 norm.
[0040] A larger value indicates that the semantics are closer.
[0041] The similarity scores are normalized to a probability distribution using a Softmax function with a temperature coefficient τ:
[0042] Where τ ∈ (0.05, 0.20] (default value τ = 0.10) is the temperature hyperparameter. The smaller τ is, the sharper the distribution (the more certain the decision), and the larger τ is, the smoother the distribution (the higher the uncertainty).
[0043] Obtain the predicted category and confidence score: ← Prediction Category ← Confidence score, conf(x) ∈ (0, 1) Confidence assessment and active learning triggering: like (Default θ_conf = 0.70): The system marks the file as "low confidence, awaiting annotation" and sends an active annotation request to the user. The interface also displays the top-3 candidate categories and their probabilities to help users make quick decisions.
[0044] like : Directly display the predicted category Users can choose to confirm or correct errors.
[0045] Output prediction category The confidence score conf(x) and the complete probability distribution vector P(· | x) ∈ k Meanwhile, samples with low confidence levels awaiting feedback are labeled.
[0046] While providing file classification services, a low-confidence detection mechanism guides user feedback to the most uncertain samples in the system, maximizing the information gain of each user interaction and providing high-value supervisory signals for boundary updates in subsequent steps.
[0047] Step 4: User feedback signal capture and structured parsing (corresponding module M3) This step is based on the classification results output in step three. , conf(x), P(·|x)) and the categorized feedback behavior submitted by users through front-end interactive interfaces such as web pages, mobile applications or API interfaces.
[0048] The system supports capturing the following three types of feedback signals and parsing them into standardized feedback records: Type 1: Correction Feedback Triggering condition: The user believes the system predicts a certain category. Incorrect, manually select the correct category c. (c) ≠ ); Analysis result: Generates feedback triple F = (x, , c ); Trigger effect: Invoke step five for local fine-tuning, bringing x closer to x. The distance, pushing away and The distance.
[0049] Type 2: Confirmation Feedback Triggering condition: User explicitly confirms the system's predicted category. Correct (c) = ); Analysis result: Generate feedback pair F = (x, , ); Triggering effect: Step five is invoked to perform only the EMA enhancement update of the positive class prototype, strengthening the existing classification boundaries.
[0050] Type 3: New Class Declaration Triggering condition: The user determines that the current file belongs to a new category that does not exist in the system C library, and enters the name of the new category in the interface. ; Analysis result: A new class application record was generated. ; Trigger effect: Skip step five and proceed directly to step eight, the new category dynamic expansion process.
[0051] All feedback records are appended with the following metadata fields and synchronously written to the system audit log (log format: JSONLines, storage path: : Feedback record structure: { "feedback_id": UUID v4 (unique identifier, generated by the system). "timestamp": ISO 8601 format timestamp (UTC time zone). "file_id": A unique identifier for the file (provided by the upstream file management system). "feature_vec": x (d-dimensional semantic feature vector, float32 format) "pred_class": (System-predicted category label string) "true_class": c (User-labeled correct category tag string) "confidence": conf(x) (classification confidence, float32). "feedback_type": "correction" | "confirmation" | "new_class" } Each time a single feedback record is written to the log, the asynchronous processing flow of subsequent steps (step five or step eight) is immediately triggered, without waiting for batch accumulation, ensuring an end-to-end response time within 5 seconds.
[0052] Standardized feedback triple F = (x, , c (Correction / Confirmation Type) or New Application Record (New class type), used as direct input for subsequent steps.
[0053] The user's implicit domain knowledge is explicitly transformed into structured data with minimal interaction cost through a single click or text input, forming the sole external knowledge injection point for the entire closed-loop adaptive system. An audit log mechanism ensures that all feedback operations are traceable, auditable, and reversible.
[0054] Step 5: Online comparative learning for local fine-tuning (corresponding module M4) This step is based on the feedback triplet F = (x, obtained from step four.) , c Step two involves maintaining the current concept vector library M and its versioned snapshot, as well as the top-level parameters of the PLM encoder from step one. This step is the core innovative module of the entire system, and its processing flow is shown in the appendix. Fig. 2 As shown.
[0055] This step is divided into four sub-steps, which are executed sequentially: Sub-step 5.1: Construction of positive and negative sample pairs Based on the feedback triple F = (x, , c Construct the set of positive and negative samples required for contrastive learning: Positive Pair: (x, ) -- The current file feature vector x and the correct category prototype labeled by the user. Forming positive sample pairs; -- x is the encoded output from step one; Real-time query from the vector library in step two.
[0056] Negative Set:
[0057] -- The set of prototype vectors for all categories except the correct category in the concept vector library; ── k represents the total number of elements in the current category.
[0058] Sub-step 5.2: Supervision and Comparison Loss Calculation Based on the set of positive and negative samples, calculate the supervised contrastive loss (SCL):
[0059] in: sim(·,·) — Cosine similarity function (same as the definition in step three) τ — Temperature hyperparameter, sharing the same value as in step three (default τ = 0.10) Σ_{c'≠c } — Summing over all negative sample classes (i.e., all elements in N_neg) The value of L_scl ranges from [0, +∞). The smaller the value, the closer the current sample x is to the correct class prototype and the farther it is from all the incorrect class prototypes in the feature space, that is, the larger the classification boundary margin.
[0060] Sub-section 5.3: Calculation of Momentum Protection Loss To prevent excessive shift of the concept vector due to a single feedback (i.e., boundary oscillation problem), a momentum protection loss (MPL) is introduced:
[0061] in: — In this gradient descent step, the following steps were performed: Parameter update proposal value — Loaded from versioned snapshots prior to this update Old value (Data source: Persistent snapshot from step two, path:) ) λ ∈ (0.1, 0.3] — Momentum protection weight (default value λ = 0.2) The larger λ is, the stronger the constraint on the concept vector offset, and the more conservative the boundary update. Sub-section 5.4: Construction of total loss, gradient mask and parameter update. Calculate the total fine-tuning loss and perform parameter updates: Total loss:
[0062] Existing gradient masking techniques (such as LoRA-type parameter fine-tuning methods) typically employ a pre-fixed update range (e.g., a fixed selection of the top N layers). Their mask granularity is independent of the specific input data or feedback semantics, making them a static, task-independent parameter compression method. The key improvement of this invention lies in the fact that the granularity of the gradient mask is not fixed, but rather determined by the feedback type parsed in step four. Difference from confidence level The dynamic variables are jointly determined, so that the "single feedback" input signal directly determines the scope and strength of the update in the parameter space. The two form a strong coupling relationship, rather than a simple combination of "feedback trigger switch + regular mask".
[0063] Specifically, define the mask granularity function. Its input is the feedback triplet. Including auxiliary confidence information, the output is the set of updatable parameters for this update. and the corresponding displacement amplitude coefficient: The probability gap between the system's original prediction and the user's correctly labeled category is measured. The larger the gap, the more serious the deviation between the original decision boundary and the true semantics, and a larger and stronger update should be applied. The smaller the gap (i.e. the model "almost guessed correctly" and only the confidence ranking was wrong), the more minor adjustments are needed.
[0064] Three-level mapping rules between feedback type and mask granularity:
[0065] in: (Default 0.2) is the threshold for judging mild and severe error correction. Data source: hyperparameter search / historical feedback distribution statistics; When the PLM top-level update branch is triggered, the number of Transformer layers participating in the update is... Similarly Continuous adjustment, rather than being fixed at a constant 2:
[0066] Right now The larger the value, the more top-level PLM layers are included in the update scope (the upper limit is 2 layers, consistent with the low-cost constraint of this invention). When smaller It only updates the prototype vector and does not affect PLM parameters.
[0067] Synchronous adjustment of displacement amplitude coefficient: The result of this mask granularity judgment is simultaneously fed back to step six to adjust the EMA coefficient and the repulsion step size to match the "severity" of this update.
[0068] in This is the coupling coefficient (default 0.05). , Replace the constant in the original formula in step six , This design ensures that feedback with a larger confidence bias corresponds to a larger EMA update step size. Decrease means new sample weights By increasing the intensity of the feedback and the stronger the repulsion, the end-to-end linkage of the three elements—"feedback severity, parameter update range, and vector displacement amplitude"—is achieved, rather than setting fixed hyperparameters for each of the three elements independently.
[0069] Gradient Masking Strategy: Based on the above dynamically determined set of updatable parameters ,right About all model parameters Find the gradient: ;right Force the gradient of all parameters in the array to be set to zero: Only for The parameters in the code are updated using gradient descent. Because... The mechanism is dynamically determined by the feedback type and confidence deviation. It achieves on-demand updates with "one feedback, one granularity". Compared with the conventional parameter fine-tuning method with fixed granularity, it adopts differentiated update strategies for minor and major errors while maintaining the same update efficiency. This reduces the risk of over-updating for minor error correction scenarios and ensures sufficient update intensity for serious misjudgment scenarios.
[0070] Parameter update rules (Adam optimizer): right For each parameter θ, perform one Adam update: (First-order moment estimation) (Second-order moment estimation)
[0071] Hyperparameter values: η ∈ [1×10 -5 5×10 -4 (Learning rate, default η = 1×10) -4 ) β1= 0.9, β2= 0.999, ε = 1×10 -8 (Adam standard default value) Update steps: 1 step (single feedback triggers single-step update) After completing one step of gradient descent update, we obtain: (1) the updated positive class prototype vector proposal value. (2) Optional error class prototype vector proposal value (3) The parameter increment ΔW of the PLM top layer ≤ 2 layers, the above results are all passed to step six for persistent update of the vector library. The number of parameters that can be updated in a single fine-tuning is about 0.1%~1% of the full model. On a standard GPU (NVIDIA T4, 16GB video memory per card), the entire process takes no more than 4 seconds, leaving sufficient processing time for steps six and seven.
[0072] By using contrastive learning loss to narrow the semantic distance between the current sample and the correct class prototype in the feature space, while widening the distance with all incorrect class prototypes, precise local calibration of the classification decision boundary is achieved; momentum protection loss controls the offset magnitude of a single update to prevent boundary oscillation; gradient masking mechanism protects the underlying parameters of PLM from interference and prevents catastrophic forgetting.
[0073] Step Six: Incremental displacement of concept vectors and dynamic update of decision boundaries (corresponding module M5) This step is based on the gradient direction information calculated in step five. , (and the current concept vector library maintained in step two) (Where the superscript t denotes the t-th update time step, with an initial value of t = 0). See the appendix for a geometric diagram of this step. Fig. 3 .
[0074] This step is executed in two sub-operations: Sub-operation 6.1: Positive Prototype EMA Incremental Displacement The concept prototype vector for the correct class is updated using an Exponential Moving Average (EMA) strategy:
[0075] in: — Original prototype vector of the positive class before update (from vector library) ) — The semantic feature vector of the file that triggered the feedback (from step one) α ∈ (0.90, 0.99] —— EMA attenuation coefficient (default value α = 0.95) The physical meaning of α: the weight of historical prototype information in the new prototype; α = 0.95 indicates that new samples contribute 5% to the directional adjustment, while historical accumulation contributes 95% to the stability.
[0076] — Updated positive class prototype vector The EMA formula is equivalent to an exponentially weighted average of all confirmation / correction samples of the same category from time step 0 to t. More recent samples have higher weights, while earlier samples have exponentially decreasing weights, thus achieving continuous accumulation of historical knowledge and dynamic incorporation of new knowledge.
[0077] Sub-operation 6.2: Error class prototype exclusion shift (optional operation, activated only during error correction feedback) When the feedback type is error correction feedback (c ≠ When the error occurs, a repulsion update is performed on the prototype vector of the incorrectly predicted class, moving it away from the current sample in the semantic space and widening the decision boundary margin between the correct and incorrect classes.
[0078] in: — Error prediction class prototype vector before update (from vector library) ) — The feature vector of the file that triggered the feedback (same as above) β ∈ (0.01, 0.05] —— Exclusionary displacement step size (default value β = 0.02) — From x to μ_{ The unit vector in the direction. β is the displacement magnitude along this direction (measured in L2 norm).
[0079] — Error class prototype vector after rejection After completing the two sub-operations, the update result is written to the vector database: And order: (Update the positive class prototype) (Update the error class prototype only when providing error feedback) The decision boundary is determined by the concept vector library. The geometric structure is implicitly defined by Voronoi segmentation: any file D is classified into the category corresponding to the prototype with the highest cosine similarity to its feature vector. After the prototype vector is updated, the Voronoi segmentation automatically adjusts accordingly, without the need for explicit recalculation of the boundary hyperplane. The time complexity of the update operation is O(k·d) (where k is the number of categories and d is the vector dimension), taking approximately 10–50 milliseconds in a typical configuration (k=100, d=768).
[0080] Updated concept vector library The classification decision boundary has been locally and accurately reconstructed. The new boundary expands in the direction of the correct class and shrinks in the direction of the incorrect class. The current feedback file x will be correctly classified into c in the updated vector space. category.
[0081] The local update of the decision boundary is completed with a computational complexity of O(k·d), which is several orders of magnitude lower than the O(N·d·L) complexity of full retraining (where N is the size of the training set and L is the number of Transformer layers). This is a key technical support for the system to meet the 5-second real-time response constraint. The EMA mechanism ensures the smoothness and stability of the boundary adjustment, while the rejection shift mechanism actively expands the inter-class margin. The two mechanisms work together to improve classification accuracy.
[0082] Step 7: Update consistency verification and automatic rollback (corresponding module M6) This step is based on the updated concept vector library obtained in step six. and the system's built-in set of historical verification anchor points Among them, each type of anchor point set , Includes at least this category The confirmed correct samples (feature vector-label pairs) are sourced from: (a) high-confidence representative samples selected from the training set during system initialization; and (b) high-quality prediction results explicitly confirmed by users during historical operation. The anchor set is stored in a separate read-only database and does not participate in any update operations, ensuring its objectivity and stability as a validation benchmark. Furthermore, this step also considers the results of manual review and adjudication generated from disputed samples. This serves as the input basis for reflow triggering.
[0083] Perform a fast classification accuracy evaluation on the validation anchor set, and calculate the accuracy for each class after the update:
[0084] in: [·] — Indicator function; returns 1 if the condition within the parentheses is true, otherwise returns 0. — The classification probability is calculated using the updated vector library (formula same as in step three). — The true category label of anchor sample x_v — The classification accuracy of category c on its anchor set after the update. Precision rollback judgment conditions: Triggering rollback conditions: c ∈ C, such that
[0085] Where δ = 0.05 (configurable, with a default tolerance of 5 percentage points for accuracy fluctuation). — Precision of category c before the update (read from the cache of the previous validation results) If the rollback condition is triggered, perform the following sequence of operations: ① Rollback vector library: (Restore from snapshot file, path:) ) ② Record disputed samples: The feedback F = (x, , c Write to the disputed sample queue (path: ) ③ Return a message to the user: "The current feedback conflicts with historical data and has been temporarily suspended pending manual review." ④ Update precision cache: Keep Remain unchanged (keeping the value before the update) If the rollback condition is not triggered, perform the following sequence of operations: ① Confirm Retention Update the persistent files of the vector library. ② Update precision cache: (Updated for all C versions) ③ Return a success message to the user and record the update result in the audit log. For disputed samples, a review and return process is adopted: This invention adds an audit reflow submodule after automatic rollback, enabling manual audit results to be re-injected into the system in a structured manner, forming a complete closed loop. The system generates audit tasks. It is then distributed to a manual review queue; the reviewers make a decision. ;according to The system will execute "re-weighting and relabeling" (accept / relabel, momentum protection weights will be adjusted according to the values) for each value. After a temporary downgrade, re-execute steps five through seven) or the "discard and label noise" (reject) operation; for accepted / relabeled samples, additionally, permanently write them into the historical validation anchor set. .
[0086] ①Review task generation and distribution: For each disputed sample that triggers a rollback, the system automatically generates a review task record and writes it to the review queue (path: queues / review_{date}.jsonl). The record structure is as follows:
[0087] in For the original feedback triple, , These are the accuracy assessment results for each category before and after the rollback (data source: accuracy assessment values calculated in step seven), which are helpful for reviewers to compare and determine whether the feedback is indeed noise; review_status is initialized to "pending" (pending review).
[0088] ② Manual review and judgment: Auditors based on Based on the comparison information and the content of the original documents, the following three categories of judgments will be made regarding this dispute feedback, and this will be recorded as the review decision. : J \in \{\,\text{accept}(Accept, correct category confirmed as}\c^ ),\ \text{reject}(Rejected, original judgment upheld}\ \hat{c}),\ \text{relabel}(Reclassified as third category}\ c^{\dagger})\,\} The judgment result is written back to the review record: review_status ← "completed", and the judgment timestamp and reviewer identifier are recorded (for traceability).
[0089] ③ Review result feedback and differentiated re-triggering: According to the review ruling For different values, the system performs corresponding reflow operations, transforming the audit results back into an update driver for the vector library:
[0090] It should be noted that for the two types of decisions, accept and relabel, the credit limit increase mechanism takes effect when steps five to seven are re-executed after the return of the sample: the sample has been manually confirmed in sub-step 7.1.2, and its momentum protection weight... Temporarily lower the price as follows:
[0091] (default This allows high-quality samples, verified by humans, to influence concept vectors with greater displacement amplitude, no longer overly constrained by conventional noise protection strength; simultaneously, the sample is permanently added to the historical verification anchor set in step seven. (or ),Right now:
[0092] This transforms manually reviewed and confirmed samples into a permanent, high-confidence verification benchmark for the system, continuously improving the discrimination capability of subsequent consistency verification processes.
[0093] ④ Review and feedback monitoring indicators: The system records and periodically outputs the following rollback statistics to assess the overall health of the automatic rollback mechanism:
[0094] This metric reflects the proportion of samples that trigger a rollback but are ultimately proven to be genuine and valid feedback. If this proportion remains consistently high, it indicates a potential rollback threshold in step seven. The settings may be too strict; they can be used as... The basis for adaptive adjustment.
[0095] The computational complexity of the entire verification process is O(k · n_anchor · d), and it takes about 50~200 milliseconds under a typical configuration (k=100, n_anchor=5, d=768), ensuring that the entire process is completed within a 5-second constraint.
[0096] Validated and secure updated concept vector library (Upon successful verification), or a stable vector library after automatic rollback. (When rollback is triggered). At this point, the complete boundary update process triggered by a single feedback event is completed, forming a logical closed loop. Simultaneously, after manual review and reflow processing, the following are obtained: (a) the final effective update for genuine and valid feedback (accept / relabel case), (b) feedback records identified as noise and permanently discarded (reject case), and (c) the expanded set of historical verification anchor points. .
[0097] Building an end-to-end security network to prevent noise feedback, user errors, or adversarial input from undermining established correct classification boundaries is the last line of defense for the long-term stable operation of the system. A precision caching mechanism ensures that each verification uses the latest accuracy benchmark, avoiding error accumulation. The disputed sample review and re-entry submodule transforms "automatic rollback" from a process termination point into a closed-loop relay node: automatically intercepted disputed samples no longer remain in the queue but are re-entered into the system evolution with differentiated strategies after manual adjudication. By permanently expanding the verification anchor set, each manual review effort translates into an incremental improvement in the system's future automatic verification capabilities, truly achieving a complete self-evolutionary closed loop of "automatic interception—manual adjudication—high-quality signal re-injection," rather than a one-way protective rejection.
[0098] Step 8: Dynamic expansion of new categories (corresponding to modules M3+M2 combined, open world supported) This step is based on the new class declaration record obtained from step four. (in (A new category name declared by the user), and the current concept vector library M and category set C.
[0099] This step is executed in the following sub-process sequence: Subprocess 8.1: Semantic Proximity Constraint Check Before accepting a new category, the semantic distinguishability between the new category and existing categories is first verified to prevent the duplicate registration of essentially the same category. Calculate the cosine distance for all existing category prototypes:
[0100] in (Initialize directly with the feature vector of the first sample of the new class) Calculate the minimum cosine distance:
[0101] Prior conditions: Isolation threshold, default ) like : Show users and Most similar existing category and their similarity, The user is prompted to confirm: "Does this file belong to an existing category?" ? If the user confirms that it belongs to : Convert to error feedback Proceed to step five for further processing.
[0102] If the user confirms it as a new category: The threshold for this request has been lowered to 0.05, and execution continues.
[0103] like Proceed directly to subprocess 8.2.
[0104] Sub-process 8.2: Initialization of the new class prototype (Using the feature vector of the first new class sample as the initial prototype) Add the new class prototype to the vector library and mark it as "uncertain":
[0105]
[0106] (Uncertain state marker) (Confirm sample counter, initial value is 1) Subprocess 8.3: Uncertainty Region Protection Mechanism New categories in an "uncertain state" are given a low-confidence label during classification prediction: If the predicted category : Add the following prompt when displaying prediction results: "This is a newly created category; classification results are pending confirmation." The upper limit of conf(x) is forcibly set to 0.60 (lower than the normal category). ) Category status upgrade conditions: when )hour: (Upgraded to stable state) Remove the confidence level cap and process as normal. Each time a user provides confirmation feedback for this category, it triggers:
[0107] Simultaneously perform the EMA update in step six:
[0108] The expanded concept vector library M^{new} = M ∪ {μ_{c_new}} and category set The new category is safely connected to the system in an uncertain protection state, and will be automatically upgraded to a stable category after accumulating enough confirmed samples.
[0109] It supports open-world classification scenarios, eliminating the need for the system to pre-enumerate all categories. The category system can evolve naturally with business development, completely solving the limitations of closed category sets. Semantic proximity constraints prevent category fragmentation, and the uncertainty region protection mechanism avoids the risk of overconfidence when there is insufficient data for new categories.
[0110] Summary and explanation of key parameters The following table summarizes all configurable parameters involved in this invention, their meanings, data sources, and typical value ranges:
[0111] In summary, by employing the technical solutions described above, this invention uses concept prototype vectors as geometric anchors for decision boundaries and transforms boundary adjustments into incremental displacements of prototype vectors. This allows for immediate boundary updates triggered by a single user feedback without requiring full retraining, achieving real-time adaptive classification with end-to-end response times within seconds. Furthermore, the dynamic gradient masking mechanism limits parameter updates to a small number of parameters at the top level of the prototype vector and the pre-trained language model encoder, reducing the computational cost of a single update by several orders of magnitude compared to full retraining. This ensures the feasibility of handling frequent incremental updates in a production environment. Finally, by constraining the single-shift amplitude of concept vectors with momentum-protected loss and combining historical anchor set consistency verification with an automatic rollback mechanism, the invention effectively prevents historical boundary corruption caused by frequent incremental updates, thereby achieving classification stability and security during long-term system operation.
[0112] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for dynamically updating the decision boundary of document classification based on online comparative learning, characterized in that: Includes the following steps: Obtain the semantic feature vector of the file to be classified; Maintain a concept prototype vector for each category, which represents the central position of the corresponding category in the semantic space; Based on the similarity between the semantic feature vector and each concept prototype vector, the predicted category of the file to be classified is determined; In response to the received user feedback signal regarding the predicted category, the feedback signal containing at least the correct category labeled by the user, a supervised contrastive loss is constructed based on the semantic feature vector, the predicted category, and the correct category, and a single-step parameter update is performed using the weighted sum of the supervised contrastive loss and the momentum conservation loss as the total loss; wherein, the momentum conservation loss is used to constrain the offset of the concept prototype vector corresponding to the correct category in this update; When performing parameter updates, based on the dynamically determined gradient mask, only the concept prototype vector corresponding to the correct category and some parameters of the top layer of the pre-trained language model encoder are updated, and the updated top layer parameters do not exceed two Transformer layers. Based on the updated parameters, the concept prototype vector corresponding to the correct category is updated using an exponential moving average strategy.
2. The method for dynamically updating the decision boundary of document classification based on online contrastive learning according to claim 1, characterized in that, The dynamically determined gradient mask is jointly determined by the type of the feedback signal and the confidence bias, wherein the confidence bias is the difference between the predicted probability of the predicted class and the predicted probability of the correct class. When the feedback signal is a confirmation feedback, the set of updatable parameters is limited to the concept prototype vector corresponding to the correct category; When the feedback signal is error correction feedback and the confidence deviation is less than a preset threshold, the set of updatable parameters is limited to the concept prototype vector corresponding to the correct category and the concept prototype vector corresponding to the predicted category. When the feedback signal is error correction feedback and the confidence deviation is not less than the preset threshold, the set of updatable parameters is expanded to include the concept prototype vector corresponding to the correct category, the concept prototype vector corresponding to the predicted category, and at least one layer of parameters at the top layer of the pre-trained language model encoder; the number of updated top-level parameter layers increases with the increase of the confidence deviation, and the upper limit is two layers.
3. The method for dynamically updating the decision boundary of document classification based on online contrastive learning according to claim 1, characterized in that, The supervised comparison loss is calculated according to the following formula: , in, The semantic feature vector This is the concept prototype vector corresponding to the correct category. For the concept prototype vectors of categories other than the correct category, sim(·,·) is the cosine similarity function. This refers to temperature hyperparameters. The momentum protection loss is calculated according to the following formula: , in, This refers to the proposal value of the concept prototype vector corresponding to the correct category mentioned in this update. This is a snapshot value of the concept prototype vector corresponding to the correct category as described before this update. Momentum protection weights; The exponential moving average strategy updates the concept prototype vector corresponding to the correct category according to the following formula: , in, This is the concept prototype vector corresponding to the correct category mentioned earlier. For the updated concept prototype vector, This is the attenuation coefficient.
4. The method for dynamically updating the decision boundary of document classification based on online contrastive learning according to claim 1, characterized in that, When the feedback signal is error correction feedback, a repulsive shift is also performed on the concept prototype vector corresponding to the predicted category, causing it to move away from the semantic feature vector; the repulsive shift is calculated according to the following formula: , in, The concept prototype vector corresponding to the predicted category before the update. The conceptual prototype vector after rejection displacement. To exclude displacement step size.
5. The method for dynamically updating the decision boundary of document classification based on online contrastive learning according to claim 1, characterized in that, When obtaining the semantic feature vector, if the text length of the file to be classified exceeds the maximum input length of the pre-trained language model, the text is divided into multiple overlapping blocks according to the step size, and the semantic feature vectors of each block are extracted and then weighted average pooling is performed to obtain the semantic feature vector.
6. The method for dynamically updating the decision boundary of document classification based on online contrastive learning according to claim 1, characterized in that, After updating the concept prototype vector, a consistency verification step is also performed: Based on the historical verification anchor set, calculate the classification accuracy of each category after the update; If the classification accuracy of any of the categories decreases by more than a preset threshold compared to the state before the update, the system will automatically roll back to the state of the concept prototype vector library before the update. If the automatic rollback is triggered, an audit task is generated and the feedback signal and the accuracy comparison information before and after the rollback are recorded. After receiving the audit decision result, if the audit decision result is adoption or reversal, the parameter update step is re-executed with the reduced momentum protection weight, and the sample corresponding to the feedback is permanently added to the historical verification anchor set.
7. The method for dynamically updating the decision boundary of document classification based on online contrastive learning according to claim 1, characterized in that, When the user-declared category does not belong to the existing category set, perform dynamic expansion of the new category: Using the semantic feature vector as the initial concept prototype vector of the new category, the new category is added to the category set and marked as uncertain; when the new category is in an uncertain state, its classification confidence upper limit is lower than the confidence threshold of the stable category; When the cumulative number of confirmed samples received by the new category reaches a preset threshold, the new category will be upgraded to a stable state. Before adding the new category to the category set, the minimum cosine distance between the initial concept prototype vector and all existing category prototype vectors is calculated. If the minimum cosine distance is less than the isolation threshold, the user is prompted with the most similar existing category, and a decision is made based on the user's confirmation whether to perform new category expansion or switch to error correction feedback.
8. The method for dynamically updating the decision boundary of document classification based on online contrastive learning according to claim 1, characterized in that, When the confidence level of the predicted category is lower than a preset threshold, a labeling request is proactively sent to the user.
9. A system for dynamically updating decision boundaries for online comparative learning document classification, characterized in that: include: The document semantic feature extraction module is used to obtain the semantic feature vector of the file to be classified. The concept vector library management module is used to maintain a concept prototype vector for each category. The concept prototype vector is used to represent the central position of the corresponding category in the semantic space. A feedback trigger control module is used to receive feedback signals from the user regarding the predicted category, wherein the feedback signals contain at least the correct category labeled by the user; The online contrastive learning local fine-tuning module is used to construct a supervised contrastive loss based on the semantic feature vector, the predicted category, and the correct category. The weighted sum of the supervised contrastive loss and the momentum conservation loss is used as the total loss to perform single-step parameter updates. The momentum conservation loss is used to constrain the offset of the concept prototype vector corresponding to the correct category in this update. The local fine-tuning module updates only the concept prototype vector corresponding to the correct category and some parameters of the top layer of the pre-trained language model encoder based on a dynamically determined gradient mask, and the updated top-level parameters do not exceed two Transformer layers. The decision boundary dynamic update module is used to update the concept prototype vector corresponding to the correct category based on the updated parameters using an exponential moving average strategy.
10. The online comparative learning-based document classification decision boundary dynamic update system according to claim 9, characterized in that, It also includes a consistency verification and rollback module, which is used to calculate the classification accuracy of each category after updating the concept prototype vector based on the historical verification anchor set. If the classification accuracy of any category decreases by more than a preset threshold compared to before the update, it will automatically roll back to the concept prototype vector library state before the update.
