A method, apparatus, equipment, and medium for context retrieval based on a large language model using feedback distillation.

By constructing an expanded hypothesis set and performing semantic subset decomposition, noise introduction, and feature vectorization, elite, mediocre, and toxic positive samples are separated. A dense retrieval engine is trained using a toxicity-weighted loss function, which solves the problem of identifying toxic positive samples in context retrieval of large language models and improves inference accuracy and information density.

CN121919298BActive Publication Date: 2026-05-26CENT SOUTH UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610374418.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-03-25
Publication Date
2026-05-26
Estimated Expiration
2046-03-25

AI Technical Summary

Technical Problem

In existing large language model context retrieval, it is difficult to identify and avoid toxic positive samples that are correctly labeled but interfere with the model's inference, resulting in a decrease in inference accuracy. The drawback of traditional retrieval machines that select samples based on surface semantic similarity has not been solved.

Method used

An augmented hypothesis set is constructed using Cartesian product operations, semantic subset decomposition is performed, noise is introduced and probe sampling and feature vectorization are carried out, and a set of inferred truth values ​​is generated using truth locking. The set of inferred truth values ​​is then processed hierarchically into elite, mediocre and toxic positive sample sets. A dense retrieval device is trained using a preset toxicity-weighted loss function to identify and avoid toxic positive samples.

Benefits of technology

It achieves high-confidence valuation under unsupervised conditions, accurately separates high-value samples, improves the information density of the context window, reduces data annotation costs, identifies and avoids toxic positive samples, and improves the inference accuracy of large language models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121919298B_ABST
    Figure CN121919298B_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, device, and medium for context retrieval of large language models based on feedback distillation, relating to the fields of artificial intelligence and data distillation technology. The method includes: firstly, constructing a full amplification hypothesis set of unlabeled data through Cartesian product; inferring the truth value through semantic decomposition, noise perturbation, and truth-locking deduction; and then finely stratifying the data into elite, mediocre, and toxic positive sample sets; subsequently, training an initial dense retrieval tool using a loss function with toxicity weights, and distilling out a target dense retrieval tool with value perception capabilities; finally, in the retrieval stage, accurately recalling high-value target context examples from the sample database based on the query text, achieving efficient context retrieval of large language models. This application can identify and avoid toxic positive samples with correct labels but interfering with model inference in context retrieval of large language models, solving the drawback of traditional retrieval tools that only select samples based on surface semantic similarity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of artificial intelligence and data distillation technology, and in particular to a method, apparatus, device and medium for context retrieval of large language models based on feedback distillation. Background Technology

[0002] As the parameter scale of large language models grows exponentially, context learning has become the mainstream paradigm for enhancing their reasoning capabilities. This paradigm eliminates the need to update model parameters; it only requires embedding a small number of examples in prompt words to guide the model through various complex downstream reasoning tasks. The quality of these examples directly determines the reasoning accuracy of the large language model. Against this backdrop, efficiently retrieving optimal contextual examples from massive amounts of text data has become a core technical requirement for ensuring the effectiveness of context learning in large language models and promoting their practical application.

[0003] To address the contextual example retrieval needs of large language models, current practices mainly employ retrieval methods based on semantic vectors or keyword matching, relying on surface semantic distance for sample recall. This allows for the selection of samples similar to the query content from massive amounts of data as contextual examples. Meanwhile, some technologies attempt to evaluate and filter the data by calculating sample scores to categorize sample quality levels. They use a one-way "filtering" logic to retain high-scoring samples and discard low-scoring or negative-scoring samples, attempting to improve retrieval performance by selecting a subset of high-quality samples.

[0004] The main flaw in existing approaches lies in the severe mismatch between semantic similarity and functional effectiveness. Current retrieval systems generally rely on surface semantic distance for recall, implicitly assuming that similar-looking samples will help the model. However, this assumption often fails under the black-box mechanism of large language model inference. In practical applications, a large number of mediocre samples exist; although they are literally similar and correctly labeled, they fail to provide additional decision boundary information, causing valuable context windows to be filled with invalid information. More seriously, there exists a class of toxic positive samples. These samples, although correctly labeled and highly similar to the query, contain distributional biases or spurious relevance features. Once added with prompt words, they interfere with the model's attention mechanism, leading to a decrease in inference accuracy. Current technologies lack the ability to identify such hidden poisons and struggle to purify prompt words at the source. Therefore, identifying and avoiding toxic positive samples with correct labels that interfere with model inference in large language model context retrieval, and addressing the shortcomings of traditional retrieval systems that only select samples based on surface semantic similarity, is an urgent problem to be solved. Summary of the Invention

[0005] The purpose of this application is to provide a method, apparatus, device and medium for context retrieval of large language models based on feedback distillation, which aims to solve the technical problem of how to identify and avoid toxic positive samples that are correctly labeled but interfere with model inference in context retrieval of large language models, and to solve the shortcomings of traditional retrieval machines that only select samples based on surface semantic similarity.

[0006] To achieve the above objectives, this application proposes a context retrieval method based on a large language model using feedback distillation, the method comprising:

[0007] Based on the unlabeled text dataset and discrete candidate label space used for downstream task retrieval of the large language model, a Cartesian product operation is performed on each unlabeled sample in the unlabeled text dataset and each candidate label in the discrete candidate label space to obtain an augmented hypothesis set containing the full semantic mapping.

[0008] Semantic subset decomposition is performed on the hypothesis subset corresponding to each unlabeled sample in the amplified hypothesis set to obtain the true semantic mapping subset and the adversarial error mapping subset corresponding to the unlabeled sample;

[0009] Based on the true semantic mapping subset and the adversarial error mapping subset, noise is introduced, probes are sampled, features are vectorized, and truth values ​​are locked into the amplified hypothesis set to obtain the inferred truth set.

[0010] The inferred truth set is hierarchically processed to obtain an elite sample set, a mediocre sample set, and a toxic positive sample set;

[0011] The initial dense search engine is trained based on the preset toxicity-weighted loss function, the elite sample set, the mediocre sample set, and the toxic positive sample set to obtain the target dense search engine.

[0012] Based on the query text of the large language model, the target context example is retrieved from the sample library by the target dense retrieval tool, thus completing the context retrieval.

[0013] Furthermore, to achieve the above objectives, this application also proposes a context retrieval device for a large language model based on feedback distillation, the device comprising:

[0014] The hypothesis set construction module is used to perform a Cartesian product operation on each unlabeled sample in the unlabeled text dataset and each candidate label in the discrete candidate label space based on the unlabeled text dataset and discrete candidate label space used for downstream task retrieval of the large language model, so as to obtain an expanded hypothesis set containing the full semantic mapping.

[0015] The semantic subset decomposition module is used to perform semantic subset decomposition on the hypothesis subset corresponding to each unlabeled sample in the amplified hypothesis set to obtain the true semantic mapping subset and the adversarial error mapping subset corresponding to the unlabeled sample.

[0016] The truth-locking module is used to introduce noise, sample probes, vectorize features, and lock truth values ​​on the augmented hypothesis set based on the true semantic mapping subset and the adversarial error mapping subset, so as to obtain the inferred truth set.

[0017] The sample stratification module is used to perform stratification processing on the inferred truth set to obtain an elite sample set, a mediocre sample set, and a toxic positive sample set.

[0018] The training distillation module is used to train the initial dense search engine based on the preset toxicity-weighted loss function, the elite sample set, the mediocre sample set, and the toxic positive sample set, to obtain the target dense search engine.

[0019] The context retrieval module is used to retrieve target context examples from the sample library based on the query text of the large language model through the target dense retrieval tool, thereby completing the context retrieval.

[0020] Furthermore, to achieve the above objectives, this application also proposes a large language model context retrieval device based on feedback distillation, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the large language model context retrieval method based on feedback distillation as described above.

[0021] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the large language model context retrieval method based on feedback distillation as described above.

[0022] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the large language model context retrieval method based on feedback distillation as described above.

[0023] One or more technical solutions proposed in this application have at least the following technical effects:

[0024] First, an expanded hypothesis set is constructed by exhaustively combining unlabeled samples with candidate labels using Cartesian product operations. Then, without real annotations, a set of inferred truth values ​​is derived using semantic subset decomposition, noise introduction, and truth locking mechanisms, thus achieving automated high-confidence estimation of massive unsupervised data at low cost. Next, the set of inferred truth values ​​is hierarchically processed to accurately separate high-value elite samples, inefficient mediocre samples, and highly concealed toxic positive samples, providing fine-grained value judgment criteria for subsequent training. Subsequently, an initial dense retrieval engine is trained using triplet data containing toxic positive samples as strong negative examples and a preset toxicity-weighted loss function, successfully distilling the sample value judgment ability into the model, giving it value perception capabilities beyond surface semantics. Finally, in the retrieval stage, the target dense retrieval engine can prioritize the recall of elite samples from the sample library based on the query text and automatically filter out interference items, outputting the optimal target context example. This application not only significantly reduces data annotation costs and increases the information density of the context window, but also identifies and avoids toxic positive samples that are correctly labeled but interfere with model inference in context retrieval of large language models, solving the drawback of traditional retrieval machines that only select samples based on surface semantic similarity. Attached Figure Description

[0025] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0026] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0027] Figure 1 This is a flowchart illustrating an embodiment of the large language model context retrieval method based on feedback distillation provided in this application.

[0028] Figure 2 This is a flowchart illustrating Embodiment 2 of the large language model context retrieval method based on feedback distillation provided in this application;

[0029] Figure 3 This is a schematic diagram of the module structure of the large language model context retrieval device based on feedback distillation according to an embodiment of this application;

[0030] Figure 4 This is a schematic diagram of the device structure of the hardware operating environment involved in the large language model context retrieval method based on feedback distillation in the embodiments of this application.

[0031] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0032] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0033] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0034] It should be noted that the executing entity of this application embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or computer system capable of realizing the above functions. The following uses a computer system as an example to describe this embodiment and the subsequent embodiments.

[0035] Based on this, embodiments of this application provide a context retrieval method for a large language model based on feedback distillation, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the large language model context retrieval method based on feedback distillation in this application.

[0036] In this embodiment, the large language model context retrieval method based on feedback distillation includes steps S10 to S60:

[0037] Step S10: Based on the unlabeled text dataset and discrete candidate label space used for downstream task retrieval of the large language model, perform Cartesian product operation on each unlabeled sample in the unlabeled text dataset and each candidate label in the discrete candidate label space to obtain an augmented hypothesis set containing full semantic mapping.

[0038] It's important to clarify that downstream tasks refer to the specific application scenarios or target tasks that the large language model needs to perform (e.g., sentiment analysis, text classification, or logical reasoning). These tasks determine the form of the model's final output and the evaluation criteria. Unlabeled text datasets refer to collections containing a large amount of raw text content that has not yet been manually or automatically labeled with corresponding categories. This data typically originates from real-world business scenarios, retaining only the input information and lacking the standard answers. The discrete candidate label space refers to the finite set of all possible output results for the downstream task. These results are usually mutually exclusive and explicit category names or options (e.g., "positive," "negative"), constituting the target range for model prediction. An unlabeled sample refers to a single, independent text unit extracted from the unlabeled text dataset. It possesses complete semantic content for model analysis but lacks a correct category label to which it is currently bound at the processing stage. Candidate labels refer to each specific category option in the discrete candidate label space. They represent any theoretically possible outcome state to which the unlabeled sample could be assigned, used to construct hypothetical mapping relationships. Full semantic mapping refers to the exhaustive pairing of every unlabeled sample in the dataset with every candidate label in the label space, forming a complete semantic association network covering all possible combinations, ensuring that no potential "sample-label" correspondence is missed. The expanded hypothesis set refers to a new dataset generated through Cartesian product operations, containing every possible combination of the original unlabeled samples and all candidate labels. Each combination is considered a "hypothetical labeled sample" to be verified, providing a foundational data pool for subsequent value assessment.

[0039] Understandably, in order to extract the semantic value of massive unlabeled data in the absence of manual annotation, the hypothesis space construction process based on full label enumeration is first executed. The large-scale unlabeled training dataset to be processed is defined as follows: ,in Representing the An unstructured text sample, Let be the total number of samples; define the discrete candidate label space of the target downstream task as . ,in This represents the total number of categories. (For a set) Each unlabeled sample , and Each candidate label in Perform a Cartesian product operation to generate an expanded hypothesis set containing the full semantic mapping. The mathematical construct of the expanded hypothesis set is defined as follows:

[0040]

[0041] Step S20: Perform semantic subset decomposition on the hypothesis subset corresponding to each unlabeled sample in the amplified hypothesis set to obtain the true semantic mapping subset and the adversarial error mapping subset corresponding to the unlabeled sample.

[0042] It's important to clarify that a hypothesis subset refers to a specific set of combinations formed by pairing a particular unlabeled sample from the augmented hypothesis set with all candidate labels in the discrete candidate label space. This set exhausts all theoretically possible labeling scenarios for that sample. A true semantic mapping subset refers to the mapping relationships selected from the hypothesis subset that conform to the inherent objective laws of the data or the high-confidence judgment of a large language model. These represent the set of correct labels that the sample is statistically most likely to belong to (usually containing a unique truth label). An adversarial error mapping subset refers to those mapping relationships in the hypothesis subset that, although incorrectly labeled, are highly similar to the sample in semantic features or possess strong deceptive power. These "hard negative examples" are often located near the decision boundary and are key interference terms for training the retrieval model to identify subtle differences and improve robustness.

[0043] Understandably, the process of constructing the expanded hypothesis set linearly expands the original data space to a size of [missing information]. The joint hypothesis space. To clarify the internal structural properties of this space, for any sample... Hypothesis subset Theoretically, it can be decomposed into two mutually exclusive subspaces: a subset of real semantic mappings. subset of adversarial error mapping Assuming the sample The potential, undiscovered true labels in the current unsupervised stage are Then the mathematical expression of this decomposition relation is:

[0044]

[0045] Adversarial error mapping subset The sample pairs in the input text It is completely identical to the real sample, but is forced to be assigned an incorrect semantic label. It introduces a high intensity of semantic conflict into the feature space, that is, it forces the model to distinguish the subtle probabilistic differences between the correct label and the incorrect label when the input features are exactly the same.

[0046] Step S30: Based on the true semantic mapping subset and the adversarial error mapping subset, noise is introduced, probes are sampled, features are vectorized, and truth values ​​are locked into the amplified hypothesis set to obtain the inferred truth set.

[0047] It should be noted that the inferred truth set refers to the set of high-confidence label results selected from the set of amplified hypotheses containing interference by introducing noise to simulate the complexity of the real data distribution, extracting key discriminative features through probe sampling, converting semantic information into computable values ​​using feature vectorization, and finally filtering them out from the set of amplified hypotheses containing interference through a truth-locking mechanism. This set represents the "pseudo-labeled" truth value that the system infers for each unlabeled sample that is closest to the objective fact after multi-dimensional calculation and game analysis without original labels.

[0048] Understandably, firstly, the computer system, based on the distribution characteristics of the real semantic mapping subset and the adversarial error mapping subset, injects random perturbations (e.g., Gaussian noise or label flipping noise) that conform to specific statistical laws into the sample features or label probability distribution of the augmented hypothesis set. This is done to simulate the unavoidable labeling errors and environmental interference in real data, preventing the subsequent model from overfitting to ideal, pure data. Then, the system performs probe sampling in the noisy data space, probing the response sensitivity of each sample under different label hypotheses by designing specific query vectors or activation patterns. This accurately extracts key discriminative features that can significantly distinguish between correct mappings and adversarial error mappings (e.g., abrupt changes in attention weights or contradictory nodes in the logical reasoning chain). This step aims to lock in the core signals that determine the sample category from a complex noisy background. Next, the computer system maps the extracted key discriminative features into high-dimensional dense numerical vectors for feature vectorization (e.g., converting text semantics into a 768-dimensional floating-point array) to utilize mathematical tools to calculate the deep semantic distance and association strength between samples and labels. Finally, the system performs a truth-locking operation. By comparing the score differences or confidence boundaries of vectorized features between the true semantic mapping subset and the adversarial error mapping subset, it uses a margin maximization or voting mechanism to eliminate false high-scoring items that are misled by noise. This uniquely determines an inferred label that best conforms to the logical objective facts for each unlabeled sample (e.g., locking a comment as "negative" rather than the superficially similar "neutral"), thereby generating the final set of inferred truth values.

[0049] Step S40: The inferred truth set is processed in layers to obtain an elite sample set, a mediocre sample set, and a toxic positive sample set.

[0050] It's important to clarify that the elite sample set refers to those high-quality samples selected from the truth set that not only have extremely high confidence in label inference but also whose semantic features provide clear decision boundaries for large language models and significantly improve inference accuracy. These are the most valuable "positive teaching materials" in context learning. The mediocre sample set refers to those samples in the truth set whose labels are correct and without obvious errors, but whose semantic information is redundant, lacks uniqueness, or has low distinguishability from query samples, contributing negligible or even zero to the improvement of the model's inference ability. These are considered "invalid data"—useless and not worth discarding. The toxic positive sample set refers to a special type of highly deceptive sample in the truth set. Their labels are judged correct in the inference results, but their semantic features (such as spurious relevance or distribution bias) can mislead the attention mechanism of large language models, causing logical biases or decreased accuracy during inference. These are "correctly labeled but functionally harmful" interference items.

[0051] As an example, the step of hierarchically processing the inferred truth set to obtain an elite sample set, a mediocre sample set, and a toxic positive sample set includes: extracting all samples with positive attribution weights from the inferred truth set to construct a positive candidate set; solving for the optimal dynamic threshold for partitioning the positive candidate set based on the principle of minimizing the sum of squared errors within the group; partitioning the positive candidate set according to the optimal dynamic threshold to obtain an elite sample set and an initial mediocre sample set; integrating the initial mediocre sample set with the zero-weight samples in the inferred truth set to obtain a complete mediocre sample set; and extracting the toxic positive sample set from the inferred truth set according to a preset machine precision value.

[0052] It's important to note that the positive candidate set refers to a subset of samples selected from the true inference set whose attribution weights are strictly greater than zero. These samples are initially identified as having some positive contribution or information gain to the reasoning process of the large language model and serve as the foundational data pool for subsequent refined stratification. The principle of minimizing the sum of squared errors within a subset is a statistical optimization criterion aimed at finding a split point that minimizes the sum of the squared differences between the sample values ​​within each subset and the mean of that subset. This ensures that the features within both the elite and mediocre sample sets are the purest and least differentiated. The optimal dynamic threshold is the specific numerical boundary calculated based on the principle of minimizing the sum of squared errors within a subset. It is not a fixed constant but is automatically adjusted according to the data distribution characteristics of the current positive candidate set, used to accurately distinguish between high-value elite samples and low-value mediocre samples.

[0053] The initial mediocre sample set refers to the set of samples whose attribution weights, although positive, are below the optimal dynamic threshold after segmenting the positive candidate set. These samples are considered to have limited contribution to the model's inference and are therefore classified into a lower level. They need to be merged with zero-weight samples to form a complete mediocre category. Zero-weight samples are those judged to have no impact on the inference results of the large language model during the attribution weight calculation process, and whose contribution value is exactly zero. These samples typically contain redundant information or neutral features, offering neither positive help nor negative interference. The preset machine precision value is a very small positive value (e.g., 1e-8) defined in the computer system to define the boundary between "non-zero" and "zero" in floating-point operations. In this step, it is specifically used to capture toxic positive samples with slightly negative attribution weights that, although correctly labeled, have a hidden negative impact on the model.

[0054] Understandably, in constructing the set of inferred truth values... Then, based on attribution weights The numerical distribution adaptively defines the boundary between "high value" and "low value". Given the significant non-stationarity of the weight distribution output by the linear surrogate model under different tasks or data domains, using a fixed threshold for segmentation is difficult to adapt to dynamically changing numerical ranges. Therefore, based on the principle of minimizing the sum of squared errors within a small group, an adaptive stratification of high and low value is implemented. By optimizing the one-dimensional clustering objective of samples in the weight space, the optimal splitting plane between elite and mediocre examples is automatically searched, and samples with significant negative contributions are isolated into a toxic set.

[0055] To accurately distinguish between elite and mediocre samples within the positive weight interval, the system extracts a set. All samples with positive weights constitute the positive candidate set. Define a segmentation threshold variable to be optimized on this set. This variable will Divide into two temporary subsets: one with a weight higher than the other. High energy region and weight lower than low energy region To find the optimal natural breakpoint, let... Represents the global attribution weight vector The middle corresponds to the sample Given the component values, we construct an optimization function with the objective of minimizing the weighted sum of within-class variances, i.e., the expression for the optimal dynamic threshold, as follows:

[0056]

[0057] in, This refers to a certain dynamic threshold. It refers to a certain sample. refers to samples The corresponding optimal attribution weight, and Representing subsets and The mean of the internal weights, It refers to The high-weighted reorganizations that are divided down include all Greater than The sample refers to the sample in The lower-weighted reorganizations that are divided include all Less than or equal to The sample.

[0058] The physical meaning of the above optimization process lies in finding a split point that minimizes the weight difference within the "elite group" and the "mediocre group," thereby ensuring a high degree of consistency in intra-group properties and maximizing inter-group differences. Based on the solved optimal dynamic threshold... Elite sample set For samples located in the high-energy region in the positive candidate set, their mathematical construction is as follows:

[0059]

[0060] These samples are located at the top of the long tail of the weight distribution. They are not only correctly labeled, but their content distribution also closely matches the validation set. Statistically, they demonstrate a strong driving force for the confidence of model inference and serve as core positive example anchors in subsequent retrieval machine training.

[0061] A mediocre sample set is constructed using the remaining interval of the aforementioned optimal boundary. This set encompasses samples with weights between zero and a dynamic threshold. Samples between, i.e. The mediocre sample set is represented as follows:

[0062]

[0063] Although the labels of such samples are correctly inferred, their information gain is negligible, representing effective noise occupying the context window. In contrastive learning, these samples will serve as weak negative examples to train the retrieval system to identify and filter invalid information, thereby improving the information density within the limited context window.

[0064] Finally, regarding the toxic positive sample set in the negative weight region. Unlike variance optimization for the positive region, the partitioning of the negative region is based on the sign attribute of the weights. The system extracts all samples with weights strictly less than zero and introduces significance test constraints to remove computational noise. The toxic positive sample set is represented as follows:

[0065]

[0066] in, This is a preset machine precision value. A characteristic of toxic positive samples is that even if they represent the relatively optimal semantic mapping within the augmentation hypothesis set, their absolute contribution value is still negative, indicating that the unstructured text sample... These inherently constitute persistent interference with model inference and must be strongly suppressed. Toxic positive samples contain distributional biases, spurious relevance, or misleading keywords. As a structurally correct but functionally harmful hidden trap, this set will be given a high-weighted exclusion loss in subsequent steps, forcing the retrieval engine to establish a clear safety buffer zone in the vector space.

[0067] Step S50: Train the initial dense retrieval system according to the preset toxicity-weighted loss function, the elite sample set, the mediocre sample set, and the toxic positive sample set to obtain the target dense retrieval system.

[0068] It should be noted that the pre-defined toxicity-weighted loss function is a specially designed mathematical optimization objective formula. When calculating the model training error, it not only considers the prediction accuracy of the samples but also introduces specific weight coefficients to differentiate between different categories of samples. In particular, it applies higher penalty weights to the toxic positive sample set or assigns greater positive gain weights to the elite sample set. This forces the model to learn to strictly avoid those correctly labeled but interfering "toxic" features during training, while strengthening its ability to identify high-value samples. The target-dense retrieval engine refers to the final retrieval model obtained after training with the pre-defined toxicity-weighted loss function. It no longer relies solely on surface semantic similarity for matching but successfully internalizes the sample value judgment ability distilled from the linear surrogate model. It can accurately identify and prioritize the retrieval of elite samples, automatically filter mediocre samples, and effectively suppress the recall of toxic positive samples, becoming a core component of intelligent retrieval with "value perception" capabilities.

[0069] As an example, the step of training an initial dense retrieval machine based on a preset toxicity-weighted loss function, the elite sample set, the mediocre sample set, and the toxic positive sample set to obtain a target dense retrieval machine includes: constructing a dense semantic encoder and a semantic similarity metric space, and building an initial dense retrieval machine based on the dense semantic encoder; sampling positive examples from the elite sample set, ordinary negative examples from the mediocre sample set, and strong negative examples from the toxic positive sample set to form triplet training samples; mapping the triplet training samples to corresponding real number vectors through the dense semantic encoder, and calculating the semantic similarity between samples based on the semantic similarity metric space; substituting the semantic similarity into the preset toxicity-weighted loss function to obtain the training loss value of the initial dense retrieval machine; iteratively updating the network parameters of the initial dense retrieval machine based on the gradient descent method until the training loss value converges to less than or equal to a preset loss threshold; and determining the initial dense retrieval machine after parameter convergence as the target dense retrieval machine.

[0070] It's important to note that a dense semantic encoder is a model component based on deep neural networks (e.g., the Transformer architecture). Its core function is to compress and map input text samples into continuous numerical vectors of fixed dimensions, capturing deep semantic features of the text in the vector space rather than simply matching keywords. The semantic similarity metric space refers to the high-dimensional vector geometric space constructed by the dense semantic encoder. Within this space, the distance between any two sample vectors (e.g., cosine distance or Euclidean distance) is defined as an indicator of their semantic relevance; the closer the distance, the more similar the semantics. The initial dense retrieval unit refers to the original retrieval model that has not yet completed value perception training. It consists of a pre-built dense semantic encoder, possessing basic semantic encoding and similarity calculation functions, but lacking the ability to distinguish the specific value of samples for the reasoning task (e.g., identifying toxic samples). It serves as the starting point model for optimization. Positive examples refer to samples sampled from an elite sample set during training. These are considered high-value, correctly labeled, and valuable data for large language model reasoning, serving as "anchors" that need to be closely matched with query samples in the training objective. Ordinary negative examples are samples sampled from the mediocre sample set. Although their labels may be correct, they contain little information or do not significantly help inference. During training, they are considered regular noise items that need to be kept at a certain distance from the query sample. Strong negative examples are samples sampled from the toxic positive sample set. These are "dangerous" data that are correctly labeled but will seriously mislead the model's inference. During training, they are given the highest negative weights, forcing the retrieval model to push them as far away from the query sample as possible in order to learn to avoid such implicit noise.

[0071] A triplet training sample refers to the smallest training unit consisting of one positive example, one ordinary negative example, and one strong negative example. This structure forces the model to simultaneously learn to close the distance with high-value samples, push away the distance with low-value samples, and strongly reject the distance with toxic samples in a single update. A real-valued vector is a one-dimensional array of continuous floating-point numbers generated after processing by a dense semantic encoder. Mathematically, it represents the coordinate position of a text sample in the semantic space. Semantic similarity is a quantified value calculated using the distance formula in the semantic similarity metric space. It characterizes the degree of association between positive examples and queries, and between negative examples and queries in the triplet training samples; a higher value indicates a greater semantic similarity. The training loss value is a scalar value obtained by substituting the calculated semantic similarity into a preset toxicity-weighted loss function. It comprehensively reflects the total error of the current model in distinguishing elite samples, mediocre samples, and toxic positive samples; a higher value indicates a worse model performance. The preset loss threshold is a very small positive standard (e.g., 0.01) set by the user to determine whether the training process has ended. When the training loss value calculated iteratively decreases and stabilizes below this value, it is considered that the model has converged and achieved the expected optimization effect.

[0072] Understandably, after completing the ternary stratification of sample value and the mining of "toxic positive samples," a differentiable dense vector retrieval model is constructed and trained, and the linear surrogate model is based on attribution weights. The discrete value judgment ability is distilled into the continuous vector space of the retrieval model, enabling it to automatically narrow down the values. High-value samples were selected and differentially excluded. and The system aims to enhance the logical perception capabilities of low- to medium-value or harmful samples. To this end, a complete training scheme was designed, including encoder construction, triplet sampling, toxicity-weighted loss calculation, and gradient dynamics optimization.

[0073] First, a dense semantic encoder and a similarity metric space are constructed. The encoder network is defined as follows:

[0074]

[0075] in, For the network parameters to be optimized (e.g., the attention matrix and feedforward layer weights in the Transformer model); It refers to the input sample space, which is the set of all possible text sequences that can be used as input. It means A real vector space.

[0076] For any text sequence in the sample space Map it to Normalization ( Normalization, a method of dividing a vector by itself (Methods for handling norms to make their length 1) 3D real vector Within this feature space, define query examples. With candidate examples The semantic similarity function between them is the dot product of their vectors:

[0077]

[0078] in, Refers to query examples The corresponding normalized feature vector, Candidate examples The corresponding normalized feature vector.

[0079] For each query example From elite sample set Middle sampling positive examples From mediocre sample sets Medium sampling ordinary negative examples From the toxic positive sample set Strong negative examples in medium sampling This sampling strategy ensures that the model can not only learn semantic relevance, but also identify invalid information and harmful interference.

[0080] To establish an asymmetric safety buffer zone for toxic samples in vector space, a toxicity-weighted loss function is constructed. The retrieval and matching problem is modeled as a classification problem, and the model is defined in the temperature coefficient... The following is a query example. Correctly matched elite samples negative log-likelihood loss (i.e., a pre-defined toxicity-weighted loss function):

[0081]

[0082] in, Defined as a toxicity sensitivity coefficient, used to explicitly amplify from The weights of the samples in the set in the denominator partition function. This parameter controls the dynamics of gradient backpropagation. Strong rejection of samples in the middle.

[0083] To clarify the effectiveness mechanism of this loss function, the loss function is... Similarity score for toxic negative examples Taking the partial derivatives, we obtain the gradient response formula:

[0084]

[0085] in, For the normalization term of the denominator, This is the predicted probability that the current retrieval model classifies the toxic sample as a positive example.

[0086] For the same prediction probability misjudgment, from The gradient feedback is controlled by the coefficient Significantly weighted amplification occurs during gradient descent optimization, affecting the encoder. Will be more affected than from ordinary negative examples The repulsive force is multiple times greater, thus forcing the parameter update direction to prioritize the correction of the query example. The error of being too close to a toxic sample eventually forms a vector space with... Centered on, elites gather Closely surrounded, mediocre collection Peripheral distribution, toxic clusters The topological structure is extremely far removed. Through this mechanism, the retrieval engine successfully learned the value judgment logic of the linear proxy model, achieving a leap from surface semantic matching to deep value alignment.

[0087] Step S60: Based on the query text of the large language model, retrieve the target context example from the sample library using the target dense retrieval tool to complete the context retrieval.

[0088] It's important to note that the query text refers to the specific question, instruction, or raw statement input by the user or downstream application into the large language model. It is the trigger and core basis of the entire retrieval process, determining what auxiliary information the system needs to find to assist the model in reasoning. The sample library refers to the final data storage pool built after preliminary data cleaning, value stratification, and training and optimization of the target-dense retrieval engine. It contains vectorized indexes of various types of data, including elite samples and mediocre samples, and represents the actual data range from which the retrieval engine performs its search operations. Target context examples refer to a small set of high-quality samples precisely selected from the sample library by the target-dense retrieval engine and ultimately embedded into the large language model's prompts. These examples are not only semantically relevant to the query text but also functionally validated to effectively guide the model in generating correct inference results, representing the final deliverable for completing the context retrieval task.

[0089] Understandably, the process begins with the computer system receiving the query text from the large language model and passing it as input to the trained target dense retrieval engine. Next, the target dense retrieval engine uses its internal dense semantic encoder to transform the query text into a high-dimensional real-valued vector. It then performs vector similarity matching in a sample database containing various hierarchical samples. During this process, the target dense retrieval engine calculates the association score between the query text and each candidate sample in the sample database based on the value judgment capability assigned by a pre-defined toxicity-weighted loss function. It prioritizes elite samples with high attribution weights while actively suppressing the recall probability of mediocre samples and completely eliminating interference from toxic positive samples. Then, the system sorts the candidate results in descending order based on the calculated semantic similarity scores, selecting the top-ranked high-quality samples as target context examples. Finally, the obtained target context examples are combined with the query text from the large language model to construct complete prompt words, which are then input into the large language model, thus completing the entire context retrieval process and ensuring that the model can perform efficient reasoning based on the optimal auxiliary information filtered by value.

[0090] This embodiment provides a large language model context retrieval method based on feedback distillation. First, an expanded hypothesis set is constructed by exhaustively combining unlabeled samples with candidate labels through Cartesian product operations. Then, without real annotations, a set of inferred truth values ​​is derived using semantic subset decomposition, noise introduction, and truth locking mechanisms, thereby achieving automated high-confidence estimation of massive unsupervised data at low cost. Next, the set of inferred truth values ​​is processed hierarchically to accurately separate high-value elite samples, inefficient mediocre samples, and highly concealed toxic positive samples, providing fine-grained value judgment criteria for subsequent training. Subsequently, an initial dense retrieval engine is trained using triplet data containing toxic positive samples as strong negative examples and a preset toxicity-weighted loss function, successfully distilling the sample value judgment ability into the model, giving it value perception capabilities beyond surface semantics. Finally, in the retrieval stage, the target dense retrieval engine can prioritize the recall of elite samples from the sample library based on the query text and automatically filter out interference items, outputting the optimal target context example. This embodiment not only significantly reduces data annotation costs and increases the information density of the context window, but also identifies and avoids toxic positive samples that are correctly labeled but interfere with model inference in context retrieval of large language models, solving the drawback of traditional retrieval machines that only select samples based on surface semantic similarity.

[0091] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in Embodiment 1 above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 2 , Figure 2This is a flowchart illustrating the second embodiment of the large language model context retrieval method based on feedback distillation of this application. Step S30 of the large language model context retrieval method based on feedback distillation includes steps S31 to S36:

[0092] Step S31: Based on the adversarial error mapping subset, adversarial noise is introduced into the amplification hypothesis set to obtain the target amplification hypothesis set;

[0093] Step S32: Probe sampling is performed on the target amplification hypothesis set to obtain the prompt word sequence;

[0094] Step S33: Perform feature vectorization on all the prompt word sequences to obtain sparse binary vectors, and construct a probe sampling matrix based on all the sparse binary vectors;

[0095] Step S34: Send the prompt word sequence to the large language model to obtain the reasoning response output by the large language model on the standard validation set;

[0096] Step S35: Construct a linear surrogate model based on the probe sampling matrix and the inference response, and solve the linear surrogate model using a regularized regression algorithm to obtain the optimal attribution weight vector that characterizes the actual inference marginal contribution rate of the sample.

[0097] Step S36: Based on the optimal attribution weight vector and the true semantic mapping subset, the target augmentation hypothesis set is truth-locked to obtain the inferred truth set.

[0098] It should be noted that adversarial noise refers to specific perturbation data or label-flipped samples artificially injected into the augmented hypothesis set based on the feature distribution of a subset of adversarial error mappings. This aims to simulate highly deceptive error patterns in real-world scenarios, enhancing the robustness of subsequent models to boundary cases. The target augmented hypothesis set refers to a new dataset successfully incorporating adversarial noise into the original augmented hypothesis set. It constitutes a complex testing environment containing both pure hypotheses and perturbations, used for subsequent more realistic value assessment. Cue word sequences are text instruction strings extracted from the target augmented hypothesis set using probe sampling techniques, consisting of specific samples and labels. These sequences are designed as the smallest information units capable of evoking differentiated responses from large language models, serving as "probes" to probe the model's internal decision-making logic.

[0099] Sparse binary vectors are high-dimensional numerical representations of each cue word sequence, where most dimensions are zero, with only dimensions corresponding to specific features (e.g., whether a sample appears or a label is selected) marked as one. This efficiently records the structural composition of the cue words. A probe sampling matrix is ​​a mathematical matrix formed by stacking the sparse binary vectors corresponding to all cue word sequences row-wise. It comprehensively records the participation of samples and labels in each probe experiment and serves as a bridge connecting the input data and the model's output response. The standard validation set is a pre-prepared set of high-quality test data with generally accepted correct labels. It is used to objectively evaluate the reasoning performance of the large language model on the current cue word sequence without noise interference, serving as the benchmark for calculating attribution weights. The inference response refers to the specific prediction result (e.g., classification label, generated text, or probability distribution) generated by the large language model for the standard validation set after receiving and processing each cue word sequence, reflecting the actual impact of the cue word sequence on the model's decision.

[0100] A linear surrogate model is a simplified mathematical statistical model (e.g., linear regression) designed to establish a linear mapping between the constituent features of the cue word sequence (probe sampling matrix) and the changes in the inference performance of a large language model (inference response), thus approximating the local behavior of complex black-box models. Regularized regression algorithms are optimization methods that introduce penalty terms (e.g., L1 or L2 norms) when solving linear equations to prevent overfitting caused by high feature dimensionality or data collinearity, ensuring that the calculated weight coefficients have generalization ability and stability. The actual inference marginal contribution rate of a sample refers to the net increase or decrease in the inference accuracy of a specific unlabeled sample on the standard validation set after the addition of cue words, relative to the baseline state, reflecting the true auxiliary or interfering value of the sample. The optimal attribution weight vector is a set of coefficients obtained after solving the linear surrogate model using a regularized regression algorithm, where each coefficient precisely corresponds to the actual inference marginal contribution rate of a sample, and the sign and magnitude directly indicate whether the sample is an elite, mediocre, or toxic positive sample.

[0101] As an example, the step of constructing a linear surrogate model based on the probe sampling matrix and the inference response, and solving the linear surrogate model using a regularized regression algorithm to obtain the optimal attribution weight vector representing the actual inference marginal contribution rate of the sample includes: calculating the overall performance response value of each sampling based on the inference response, and concatenating all the overall performance response values ​​to obtain a response vector; constructing a linear surrogate model based on the probe sampling matrix and the response vector, and setting the attribution weight vector as the parameter to be solved in the linear surrogate model; constructing a convex optimization objective function containing a data fidelity term, a first regularization term, and a second regularization term according to the elastic network regularization mechanism; and solving the convex optimization objective function using the proximal gradient descent method to obtain the optimal attribution weight vector representing the actual inference marginal contribution rate of the sample.

[0102] It should be noted that the overall performance response value refers to the quantitative performance metric (e.g., accuracy, F1 score, or negative log-likelihood loss) calculated by comparing the inference results of the large language model on the standard validation set with the true labels for each probe sampling sequence of prompt words. This value intuitively reflects the comprehensive impact of the current sample combination on the model's inference ability. The response vector is a one-dimensional column vector formed by concatenating the overall performance response values ​​corresponding to all probe samplings in the sampling order. As the dependent variable (target value) in the linear surrogate model, it carries all the performance fluctuation information of the large language model under different sample combinations. The elastic network regularization mechanism is a composite regularization strategy that combines L1 norm (lasso) and L2 norm (ridge regression) penalty terms. It can both compress the weights of unimportant samples to zero through the L1 term to achieve feature selection and handle the high collinearity problem between samples through the L2 term, ensuring the stability and sparsity of attribution weight solution under complex data distributions. The data fidelity term refers to the part of the convex optimization objective function used to measure the error between the predicted value of the linear surrogate model and the actual observed response vector (e.g., residual sum of squares). Its function is to force the model's fitting results to be as close as possible to the actual reasoning performance of the large language model, preventing excessive deviation from objective facts.

[0103] The first regularization term refers to the penalty part of the objective function based on the L1 norm. Its coefficient controls the sparsity of the model, aiming to automatically filter out key samples that significantly contribute to inference and directly reduce the weights of a large number of redundant or invalid mediocre samples to zero, thereby simplifying the model structure. The second regularization term refers to the penalty part of the objective function based on the L2 norm. Its coefficient controls the smoothness of the weights, aiming to prevent weight oscillations or overfitting caused by highly correlated features in the probe sampling matrix (such as the simultaneous occurrence of similar samples), ensuring the numerical continuity and robustness of the attribution weights. Proximal gradient descent is an iterative algorithm specifically designed to solve convex optimization problems containing non-differentiable regularization terms (such as the L1 norm). It adds a "proximal operator" step after each gradient update to handle regularization constraints, enabling efficient and accurate convergence to the optimal attribution weight vector containing sparse solutions.

[0104] As an example, the step of locking the truth value of the target augmentation hypothesis set based on the optimal attribution weight vector and the true semantic mapping subset to obtain the inferred truth value set includes: using a maximum weight posterior inference strategy to determine the inferred truth value of each unlabeled sample based on the optimal attribution weight vector; marking sample pairs whose labels match the inferred truth values ​​of the corresponding unlabeled samples in the target augmentation hypothesis set as valid sample pairs according to a preset indicator function; removing adversarial noise terms with non-maximum weights in the target augmentation hypothesis set using the true semantic mapping subset as a reference; and integrating the remaining valid sample pairs in the target augmentation hypothesis set to obtain the inferred truth value set.

[0105] It's important to note that the maximum weighted posterior inference strategy is a decision rule based on Bayesian principles. It compares the attribution weights of an unlabeled sample under all candidate label hypotheses and directly selects the candidate label with the highest weight as the true category for that sample, thus maximizing the probability of correct inference. The true inference value, calculated using the maximum weighted posterior inference strategy without original manual labeling, is the objectively correct category label that the system confidently identifies as the unlabeled sample. It serves as a "pseudo-gold standard" for subsequent data stratification and model training. The predefined indicator function is a mathematical tool for logical judgment. It outputs a positive value (e.g., 1) when the input condition meets a specific rule (i.e., the hypothesized label perfectly matches the true inference value), and a negative value (e.g., 0) otherwise, quickly filtering out correctly labeled sample combinations. Valid sample pairs refer to "sample-label" combinations in the target augmentation hypothesis set that perfectly match the candidate labels with the inferred true values. These are considered high-quality data units that are semantically and logically valid, forming the foundation for constructing the final dataset. Adversarial noise terms with non-maximum weights refer to noise data that, although artificially introduced as interference and may have gained some attribution weight under a certain incorrect labeling assumption, do not have a weight value that reaches the maximum value among all the assumptions of the sample. This indicates that they have failed to successfully deceive the inference mechanism and belong to redundant or incorrect mappings that should be cleaned up.

[0106] Understandably, this involves constructing an augmented hypothesis set that includes full semantic mapping and adversarial noise. Subsequently, a high-dimensional linear surrogate model was established as an attribution simulator. By fitting the black-box reasoning behavior of a large language model through a high-frequency random probe sampling process, a regularized regression algorithm was used to analyze the independent marginal contribution of each sample in the augmented hypothesis set to the model's reasoning performance. To transform the discrete prompt word selection problem into a continuous linear algebra problem, structured probe sampling and feature vectorization operations were first performed. The cardinality of the augmented hypothesis set was defined as... Set the number of sampling times as In each sampling iteration In the middle, samples are drawn from the amplification hypothesis set based on a uniform distribution without replacement. Construct prompt word sequences from a sample pair The sequence is then mapped to a sparse binary vector in the feature space. The first vector Dimensional elements The definition is as follows:

[0107]

[0108] By The feature vectors sampled multiple times are stacked to construct a dimension of... probe sampling matrix Each row of the matrix represents an independent context configuration, while each column encodes the occurrence pattern of a specific sample across multiple samplings, laying the mathematical foundation for subsequent batch parallel computation.

[0109] For each constructed prompt word sequence Record large language models on the standard validation set The inference response is described above. To capture performance fluctuations more nuanced than discrete accuracy, the confidence marginal gain is used as the regression target. Let the validation set contain... For the nth sample, for the nth one One verification sample When inputting a sequence of prompt words At that time, the model outputs the true label. The difference between the predicted probability and the predicted probability of the maximum mislabel is defined as the single-sample margin. :

[0110]

[0111] in, This refers to a given sequence of prompt words. and input samples Under the condition of large language model (parameters are) Output correct labels The conditional probability; In the same context and input Below, the large language model outputs error labels. The conditional probability in.

[0112] To further eliminate the fundamental capability bias of large language models under zero-sample conditions, a zero-sample baseline is introduced. Perform calibration. Enter only query Without including any context examples, the difference between the model's true label probability and the maximum mislabel probability is:

[0113]

[0114] in, This refers to the large language model's processing of samples without context. Output correct labels The conditional probability; This refers to the large language model's processing of samples without context. Output error labels The conditional probability.

[0115] By calculating the difference between the two and taking the mean over the entire validation set, we obtain the first... Overall performance response value of the next sampling iteration :

[0116]

[0117] Quantification prompts This section focuses on the additional net confidence gain provided to the model inference relative to a zero-sample baseline, eliminating the interference of inherent knowledge acquired by large language models during large-scale pre-training, and purely focusing on the marginal contribution of contextual examples. All of these are considered. The response values ​​obtained from the second sampling test are concatenated into column vectors to construct a dimension of... response vector .

[0118] Based on sampling matrix With response vector A linear proxy model is constructed to fit the behavior of the large language model. The linear proxy model is represented as follows:

[0119]

[0120] in, This refers to the linear surrogate model's input for a certain probe sampling. The predicted overall performance response value, This refers to the sparse binary vector. Represents the transpose of a vector. This refers to the attribution weight vector. This refers to the global bias term in the linear proxy model.

[0121] Given that the amplification hypothesis set artificially introduces a large amount of adversarial noise, and that real high-value samples exhibit significant sparsity in the feature space, traditional least squares estimation is highly prone to overfitting. Therefore, an elastic network regularization mechanism is introduced, and the following convex optimization objective function is constructed to solve for the optimal weights:

[0122]

[0123] in, This refers to the total number of probe samplings, which is the number of rows in the probe sampling matrix; This refers to the probe sampling matrix; It is a vector of all ones, used to convert scalars Broadcast to the vector dimension; This refers to the response vector; and It is a non-negative regularization hyperparameter; This refers to the data fidelity item; This refers to the first regularization term; This refers to the second regularization term.

[0124] In this objective function, the first term is the mean squared error data fidelity term, which ensures that the surrogate model can accurately fit the performance change trend of the large language model; the second term is the L1 regularization term (i.e., the first regularization term), whose geometric mechanism is to generate corner solutions in the optimization space, thereby inducing the weight vector. The sparsity of the first term automatically compresses the weights of irrelevant or noisy samples to zero; the third term is the L2 regularization term (i.e., the second regularization term), used to handle the collinearity problem between features and ensure the stability of numerical computation. The convex optimization problem is solved using the proximal gradient descent method to obtain the globally optimal attribution weight vector. . It not only quantitatively characterizes the contribution of the sample, but also reveals the intrinsic properties of the sample: The representative samples have a significant positive causal effect on model inference, i.e., elite samples. The representative sample is invalid information, i.e., a mediocre sample, while This indicates that although the sample may match the label, it significantly reduces the model's inference confidence, making it a toxic sample. This provides a direct mathematical basis for subsequent value stratification.

[0125] Using attribution weight vector The system performs truth locking and value stratification on samples in the amplified hypothesis set to identify hidden risk data that are easily misjudged in traditional retrieval but generate negative gains in actual reasoning.

[0126] Expanding the hypothesis set In the middle, for each original unlabeled input The system generates the Cartesian product. Each input-label hypothesis is paired mutually exclusively. Due to the weights of the linear surrogate model... The contribution of samples to the confidence margin of the large model is quantitatively characterized; a true and correct semantic mapping should have a higher contribution value than an incorrect adversarial mapping. Therefore, a maximum weighted posterior inference strategy is used to determine the pseudo-label for each sample. For the ... Given an input sample, its inferred true value Defined as the label with the highest attribution weight among all candidate combinations, its mathematical expression is:

[0127]

[0128] Based on this inference result, all adversarial noise terms with non-maximum weights are removed from the amplified hypothesis set, and only the correctly inferred sample pairs are retained to construct the true inference set. To ensure the rigor of set definitions, indicator functions are introduced. , Its construction form is as follows:

[0129]

[0130] By using the feedback signals of a large language model as "soft supervision," high-confidence recovery of data semantics was achieved without manual annotation, ensuring that subsequent value analysis focuses on the premise of "correct label logic" and avoiding simple negative impact analysis caused by label errors.

[0131] This embodiment first introduces adversarial noise into the augmented hypothesis set based on an adversarial error mapping subset to construct a target augmented hypothesis set. By simulating a highly deceptive interference scenario, the robustness of data evaluation is enhanced. Then, probe sampling is performed on the target augmented hypothesis set to generate a cue word sequence, which is then converted into a sparse binary vector to construct a probe sampling matrix. This quantifies and records the feature composition of each sample, laying the foundation for establishing a mathematical relationship between input and output. Next, the cue word sequence is input into a large language model, and the inference response is obtained on a standard validation set. This captures the performance fluctuations of the model under different sample combinations, thereby obtaining observational data reflecting the true inference effect. Furthermore, a linear surrogate model is constructed using the probe sampling matrix and the inference response. A regularized regression algorithm is used to solve for the optimal attribution weight vector representing the marginal contribution rate of the actual inference of the sample, achieving accurate quantification of the value of each sample (including positive gain and negative interference) under unsupervised conditions. Finally, combining the optimal attribution weight vector with the true semantic mapping subset, a maximum weight posterior inference strategy is used to eliminate adversarial noise terms with non-maximum weights and lock in valid sample pairs, resulting in a high-confidence set of inference truth values. This embodiment not only derives near-objective truth values ​​from massive amounts of unlabeled data without manual annotation, but also accurately identifies "toxic" samples that are correctly labeled but interfere with reasoning, providing a reliable quantitative basis for the subsequent construction of a retrieval device with value perception capabilities.

[0132] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the context retrieval method of the large language model based on feedback distillation in this application. Any simple transformations based on this technical concept are within the protection scope of this application.

[0133] This application also provides a context retrieval device for a large language model based on feedback distillation. Please refer to [link / reference]. Figure 3 The large language model context retrieval device based on feedback distillation includes:

[0134] Hypothesis set construction module 10 is used to perform Cartesian product operation on each unlabeled sample in the unlabeled text dataset and each candidate label in the discrete candidate label space based on the unlabeled text dataset and discrete candidate label space used for downstream task retrieval of the large language model, so as to obtain an expanded hypothesis set containing the full semantic mapping.

[0135] The semantic subset decomposition module 20 is used to perform semantic subset decomposition on the hypothesis subset corresponding to each unlabeled sample in the amplified hypothesis set to obtain the true semantic mapping subset and the adversarial error mapping subset corresponding to the unlabeled sample.

[0136] The truth value locking module 30 is used to introduce noise, sample probes, vectorize features, and lock truth values ​​on the amplified hypothesis set based on the true semantic mapping subset and the adversarial error mapping subset, so as to obtain the inferred truth value set.

[0137] The sample stratification module 40 is used to perform stratification processing on the inferred truth set to obtain an elite sample set, a mediocre sample set, and a toxic positive sample set.

[0138] The training distillation module 50 is used to train the initial dense search engine based on the preset toxicity-weighted loss function, the elite sample set, the mediocre sample set, and the toxic positive sample set to obtain the target dense search engine.

[0139] The context retrieval module 60 is used to retrieve target context examples from the sample library based on the query text of the large language model through the target dense retrieval tool, thereby completing the context retrieval.

[0140] The large language model context retrieval device based on feedback distillation provided in this application employs the large language model context retrieval method based on feedback distillation in the above embodiments. It can solve the technical problem of how to identify and avoid toxic positive samples with correct labels that interfere with model inference in large language model context retrieval, and overcomes the drawback of traditional retrieval machines that only select samples based on surface semantic similarity. Compared with the prior art, the beneficial effects of the large language model context retrieval device based on feedback distillation provided in this application are the same as those of the large language model context retrieval method based on feedback distillation provided in the above embodiments, and other technical features in the large language model context retrieval device based on feedback distillation are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0141] This application provides a large language model context retrieval device based on feedback distillation. The large language model context retrieval device based on feedback distillation includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the large language model context retrieval method based on feedback distillation in the above embodiment 1.

[0142] The following is for reference. Figure 4 This document illustrates a structural schematic diagram of a large language model context retrieval device based on feedback distillation suitable for implementing embodiments of this application. The large language model context retrieval device based on feedback distillation in embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 4 The illustrated large language model context retrieval device based on feedback distillation is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0143] like Figure 4As shown, the feedback distillation-based large language model context retrieval device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.) that can perform various appropriate actions and processes according to a program stored in ROM (Read Only Memory) 1002 or a program loaded from storage device 1003 into RAM (Random Access Memory) 1004. RAM 1004 also stores various programs and data required for the operation of the feedback distillation-based large language model context retrieval device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via bus 1005. Input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, LCDs (Liquid Crystal Displays), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the feedback distillation-based large language model context retrieval device to wirelessly or wiredly communicate with other devices to exchange data. Although feedback distillation-based large language model context retrieval devices with various systems are shown in the figures, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems can be implemented alternatively.

[0144] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0145] The large language model context retrieval device based on feedback distillation provided in this application employs the large language model context retrieval method based on feedback distillation in the above embodiments. It can solve the technical problem of how to identify and avoid toxic positive samples with correct labels that interfere with model inference in large language model context retrieval, thus overcoming the drawback of traditional retrieval machines that only select samples based on surface semantic similarity. Compared with the prior art, the beneficial effects of the large language model context retrieval device based on feedback distillation provided in this application are the same as those of the large language model context retrieval method based on feedback distillation provided in the above embodiments. Furthermore, other technical features of this large language model context retrieval device based on feedback distillation are the same as those disclosed in the previous embodiment method, and will not be repeated here.

[0146] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0147] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0148] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the large language model context retrieval method based on feedback distillation in the above embodiments.

[0149] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, RAM (Random Access Memory), ROM (Read Only Memory), EPROM (Erasable Programmable Read Only Memory or Flash Memory), optical fibers, CD-ROM (CD-Read Only Memory), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0150] The aforementioned computer-readable storage medium may be included in a large language model context retrieval device based on feedback distillation; or it may exist independently and not be assembled into a large language model context retrieval device based on feedback distillation.

[0151] The aforementioned computer-readable storage medium carries one or more programs. When these programs are executed by a feedback distillation-based large language model context retrieval device, the feedback distillation-based large language model context retrieval device: performs a Cartesian product operation on each unlabeled sample in the unlabeled text dataset and each candidate label in the discrete candidate label space, based on the unlabeled text dataset and discrete candidate label space used for downstream task retrieval of the large language model, to obtain an augmented hypothesis set containing the full semantic mapping; and performs semantic subset decomposition on the hypothesis subset corresponding to each unlabeled sample in the augmented hypothesis set to obtain the true semantic mapping subset corresponding to the unlabeled sample. The system first obtains a set of adversarial error mapping subsets; then, based on the true semantic mapping subset and the adversarial error mapping subset, it introduces noise, samples probes, vectorizes features, and locks truth values ​​into the amplified hypothesis set to obtain an inferred truth set; the inferred truth set is then processed hierarchically to obtain an elite sample set, a mediocre sample set, and a toxic positive sample set; an initial dense retrieval device is trained using a preset toxicity-weighted loss function, the elite sample set, the mediocre sample set, and the toxic positive sample set to obtain a target dense retrieval device; finally, based on the query text of the large language model, the target dense retrieval device retrieves target context examples from the sample database to complete context retrieval.

[0152] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including LAN (Local Area Network) or WAN (Wide Area Network)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0153] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0154] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., computer programs) for executing the above-described feedback distillation-based large language model context retrieval method. This solves the technical problem of how to identify and avoid toxic positive samples with correct labels that interfere with model inference in large language model context retrieval, and addresses the shortcomings of traditional retrieval systems that filter samples solely based on surface semantic similarity. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the feedback distillation-based large language model context retrieval method provided in the above embodiments, and will not be elaborated upon here.

[0155] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the large language model context retrieval method based on feedback distillation as described above.

[0156] The computer program product provided in this application can solve the technical problem of how to identify and avoid toxic positive samples that are correctly labeled but interfere with model inference in large language model context retrieval, and solve the drawback of traditional retrieval machines that only select samples based on surface semantic similarity. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the large language model context retrieval method based on feedback distillation provided in the above embodiments, and will not be repeated here.

[0157] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

Claims

1. A large language model context retrieval method based on feedback distillation, characterized by, The method includes: Based on the unlabeled text dataset and discrete candidate label space used for downstream task retrieval of the large language model, a Cartesian product operation is performed on each unlabeled sample in the unlabeled text dataset and each candidate label in the discrete candidate label space to obtain an augmented hypothesis set containing the full semantic mapping. Semantic subset decomposition is performed on the hypothesis subset corresponding to each unlabeled sample in the amplified hypothesis set to obtain the true semantic mapping subset and the adversarial error mapping subset corresponding to the unlabeled sample; Based on the true semantic mapping subset and the adversarial error mapping subset, noise is introduced, probes are sampled, features are vectorized, and truth values ​​are locked into the amplified hypothesis set to obtain the inferred truth set. The inferred truth set is hierarchically processed to obtain an elite sample set, a mediocre sample set, and a toxic positive sample set; The initial dense search engine is trained based on the preset toxicity-weighted loss function, the elite sample set, the mediocre sample set, and the toxic positive sample set to obtain the target dense search engine. Based on the query text of the large language model, the target context example is retrieved from the sample library by the target dense retrieval device, thus completing the context retrieval; The step of introducing noise, sampling probes, vectorizing features, and locking truth values ​​into the augmented hypothesis set based on the true semantic mapping subset and the adversarial error mapping subset to obtain the inferred truth set includes: Based on the adversarial error mapping subset, adversarial noise is introduced into the amplification hypothesis set to obtain the target amplification hypothesis set; Probe sampling is performed on the target amplified hypothesis set to obtain the prompt word sequence; The feature vectors of all the prompt word sequences are transformed to obtain sparse binary vectors, and the probe sampling matrix is ​​constructed based on all the sparse binary vectors. The prompt word sequence is sent to the large language model to obtain the reasoning response output by the large language model on the standard validation set; A linear surrogate model is constructed based on the probe sampling matrix and the inference response, and the linear surrogate model is solved by a regularized regression algorithm to obtain the optimal attribution weight vector that characterizes the actual inference marginal contribution rate of the sample. Based on the optimal attribution weight vector and the true semantic mapping subset, the truth value is locked for the target augmentation hypothesis set to obtain the inferred truth value set.

2. The method of claim 1, wherein, The step of constructing a linear surrogate model based on the probe sampling matrix and the inference response, and solving the linear surrogate model using a regularized regression algorithm to obtain the optimal attribution weight vector characterizing the actual inference marginal contribution rate of the sample includes: Calculate the overall performance response value for each sample based on the inference response, and concatenate all the overall performance response values ​​to obtain the response vector; A linear surrogate model is constructed based on the probe sampling matrix and the response vector, and the attribution weight vector is set as the parameter to be solved in the linear surrogate model. Based on the elastic network regularization mechanism, a convex optimization objective function is constructed, which includes a data fidelity term, a first regularization term, and a second regularization term. The convex optimization objective function is solved using the proximal gradient descent method to obtain the optimal attribution weight vector that characterizes the actual inference marginal contribution rate of the sample.

3. The method of claim 2, wherein, The linear proxy model is represented as follows: wherein, denotes the overall performance response value predicted by the linear proxy model for a certain probe sampling input denotes the overall performance response value predicted by the linear proxy model for a certain probe sampling input denotes the sparse binary vector, denotes the transpose of a vector, denotes the attribution weight vector, denotes the global bias term in the linear proxy model; The convex optimization objective function is expressed as follows: in, This refers to the total number of probe samplings, which is the number of rows in the probe sampling matrix. This refers to the probe sampling matrix. It is a vector of all 1s. This refers to the response vector. and Is it a non-negative regularization hyperparameter? This refers to the data fidelity item. This refers to the first regularization term. This refers to the second regularization term.

4. The method as described in claim 1, characterized in that, The step of locking the truth value of the target augmentation hypothesis set based on the optimal attribution weight vector and the true semantic mapping subset to obtain the inferred truth value set includes: The maximum weighted posterior inference strategy is adopted to determine the inferred true value of each unlabeled sample based on the optimal attribution weight vector; According to the preset indicator function, sample pairs whose labels in the target amplification hypothesis set match the inferred true values ​​of the corresponding unlabeled samples are marked as valid sample pairs; Using the true semantic mapping subset as a reference, adversarial noise terms with non-maximum weights in the target augmentation hypothesis set are removed; By integrating the remaining valid sample pairs in the target amplification hypothesis set, an inferred truth set is obtained.

5. The method as described in claim 1, characterized in that, The step of performing hierarchical processing on the inferred truth set to obtain the elite sample set, the mediocre sample set, and the toxic positive sample set includes: Extract all samples with positive attribution weights from the inferred truth set to construct a positive candidate set; Based on the principle of minimizing the sum of squared errors within the group, the optimal dynamic threshold for dividing the positive candidate set is obtained. The optimal dynamic threshold is expressed as follows: in, This refers to a certain dynamic threshold. It refers to a certain sample. refers to samples The corresponding optimal attribution weight, and Representing subsets and The mean of the internal weights, It refers to The high-weighted reorganizations that are divided down include all Greater than The sample refers to the sample in The lower-weighted reorganizations that are divided include all Less than or equal to The sample; The positive candidate set is divided according to the optimal dynamic threshold to obtain an elite sample set and an initial mediocre sample set; The elite sample set is represented as follows: in, This refers to the set of inferred truth values; By integrating the initial mediocre sample set with the zero-weighted samples in the inferred truth set, a complete mediocre sample set is obtained; The mediocre sample set is represented as follows: Based on the preset machine accuracy value, a set of toxic positive samples is extracted from the inferred truth set. The set of toxic positive samples is represented as follows: in, This refers to the preset machine precision value.

6. The method according to any one of claims 1 to 5, characterized in that, The step of training the initial dense search engine based on a preset toxicity-weighted loss function, the elite sample set, the mediocre sample set, and the toxic positive sample set to obtain the target dense search engine includes: Construct a dense semantic encoder and a semantic similarity metric space, and build an initial dense retrieval system based on the dense semantic encoder; Positive examples are sampled from the elite sample set, ordinary negative examples are sampled from the mediocre sample set, and strong negative examples are sampled from the toxic positive sample set to form triplet training samples; The dense semantic encoder maps the triplet training samples to corresponding real number vectors, and calculates the semantic similarity between samples based on the semantic similarity metric space. Substituting the semantic similarity into the preset toxicity-weighted loss function, we obtain the training loss value of the initial dense retrieval system; The network parameters of the initial dense retrieval are iteratively updated based on the gradient descent method until the training loss value converges to less than or equal to a preset loss threshold. The initial dense search engine after parameter convergence is determined as the target dense search engine.

7. A context retrieval device for a large language model based on feedback distillation, characterized in that, The device includes: The hypothesis set construction module is used to perform a Cartesian product operation on each unlabeled sample in the unlabeled text dataset and each candidate label in the discrete candidate label space based on the unlabeled text dataset and discrete candidate label space used for downstream task retrieval of the large language model, so as to obtain an expanded hypothesis set containing the full semantic mapping. The semantic subset decomposition module is used to perform semantic subset decomposition on the hypothesis subset corresponding to each unlabeled sample in the amplified hypothesis set to obtain the true semantic mapping subset and the adversarial error mapping subset corresponding to the unlabeled sample. The truth-locking module is used to introduce noise, sample probes, vectorize features, and lock truth values ​​in the amplified hypothesis set based on the true semantic mapping subset and the adversarial error mapping subset to obtain an inferred truth set. The step of introducing noise, sampling probes, vectorizing features, and locking truth values ​​in the amplified hypothesis set based on the true semantic mapping subset and the adversarial error mapping subset to obtain the inferred truth set includes: introducing adversarial noise into the amplified hypothesis set according to the adversarial error mapping subset to obtain a target amplified hypothesis set; sampling probes into the target amplified hypothesis set to obtain a prompt word sequence; and sampling the target amplified hypothesis set to obtain a prompt word sequence. The cue word sequence is vectorized to obtain sparse binary vectors, and a probe sampling matrix is ​​constructed based on all the sparse binary vectors. The cue word sequence is sent to the large language model to obtain the inference response output by the large language model on the standard validation set. A linear surrogate model is constructed based on the probe sampling matrix and the inference response, and the linear surrogate model is solved by a regularized regression algorithm to obtain the optimal attribution weight vector representing the marginal contribution rate of the actual inference of the sample. Based on the optimal attribution weight vector and the true semantic mapping subset, the truth value is locked for the target augmentation hypothesis set to obtain the inference truth set. The sample stratification module is used to perform stratification processing on the inferred truth set to obtain an elite sample set, a mediocre sample set, and a toxic positive sample set. The training distillation module is used to train the initial dense search engine based on the preset toxicity-weighted loss function, the elite sample set, the mediocre sample set, and the toxic positive sample set, to obtain the target dense search engine. The context retrieval module is used to retrieve target context examples from the sample library based on the query text of the large language model through the target dense retrieval tool, thereby completing the context retrieval.

8. A context retrieval device for a large language model based on feedback distillation, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the feedback distillation-based large language model context retrieval method as described in any one of claims 1 to 6.

9. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the large language model context retrieval method based on feedback distillation as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Knowledge distillation and gradient pruning based compression of artificial intelligence based base detector

    CN115136245A

  • Highway intelligent operation and maintenance question-answering system based on large language model

    CN121351981A