A weakly supervised language model prompting learning method and system
By employing a weakly supervised learning method and utilizing prompt templates with open-ended questions and answer formats, complementary predictions are generated in groups, and prompt dependencies are modeled. This addresses the problem of weak generalization ability in language model prompt learning and achieves efficient and stable prompt learning results.
Patent Information
- Application Number
- CN202510340195.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-21
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2045-03-21
AI Technical Summary
Existing technologies have weak generalization ability in language model prompt learning, fail to effectively utilize the dependencies between prompts, resulting in high computational cost, low efficiency and poor stability.
We employ a language model-based prompt learning method. By collecting prompt templates for open-ended questions and answer formats, we generate complementary predictions in groups. We then use a graph model to model the dependencies and accuracy parameters between prompts and aggregate multiple imperfect prompts to obtain the final result.
It significantly improves the effectiveness and stability of prompt learning, lowers the application threshold, enhances generalization ability and performance, and simplifies the complexity of prompt engineering.
Smart Images

Figure CN120278265B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of natural language processing, and more particularly, to a weakly supervised language model prompt learning method and system. BACKGROUND
[0002] In recent years, large-scale pre-training language models (LLM) have emerged in the field of natural language processing. These models have strong language understanding and generation capabilities, can quickly adapt to new tasks through a small number of prompt examples, achieve zero-shot learning, and greatly simplify the use process. Prompt learning has become an important paradigm for utilizing the capabilities of LLM. However, there are still many challenges in designing high-quality prompts.
[0003] Currently, prompt engineering requires a large amount of manual parameter tuning, but the stability of the prompt is still poor, and the prediction result is sensitive to changes in the prompt. To achieve the ease of use of prompt learning, it is necessary to study how to quickly obtain high-quality prompts. At the same time, there is a dependency relationship and complementary information between prompts, which is also a potential way to improve performance.
[0004] For the prompt learning problem of language models, the existing technology discloses a method based on transfer coherence. This method mainly constructs a prompt library, conducts a large number of prompt candidate searches and evaluations, and selects the most coherent prompt for downstream tasks. Specifically, first, a prompt template is constructed according to the downstream task, including input-output examples and placeholders. Then a large number of prompt candidates are generated, and perplexity is used to evaluate the quality of the prompt. Finally, the prompt with the lowest perplexity is selected for transfer learning in the downstream task. This method can search for high-quality prompts from a large number of candidates without the need for manual design and adjustment.
[0005] However, this method also has certain defects. First, a large number of candidates need to be traversed to search for the optimal prompt, with very high computational cost. Second, it relies too much on the fixed perplexity indicator, which may not fully evaluate the downstream effect of the prompt. Third, the generalization ability of the method itself is weak, and it needs to search for prompts from scratch for each task. Fourth, the dependency relationship between prompts is not considered, and the complementary information of different prompts cannot be utilized.
[0006] To overcome the instability of a single prompt, the existing technology discloses a self-consistency prompt aggregation method. This method generates multiple sets of prompts for the language model, requiring each set of prompts to consistently predict the same output, and then performs majority voting on all consistent predictions to obtain the final result. This self-consistency constraint can filter out low-quality prompts, making the prediction more stable and reliable. This method does not require manual annotation of data and can automatically obtain training signals, making it suitable for various prompt learning problems.
[0007] However, this method also has some drawbacks. First, it has a strong requirement for self-consistency, which may filter out valid hints. Second, the majority voting method is too simplistic and does not adequately model the dependencies between hints. Third, it requires generating a large number of hints to achieve consistency, resulting in low computational efficiency. Fourth, its generalization ability is limited, and different tasks require manual design of hint templates. Summary of the Invention
[0008] This invention aims to provide a language model prompt learning method and system based on weak supervision, in order to solve the problems of weak generalization ability of language model prompt learning and failure to consider the dependencies between prompts.
[0009] The technical solution adopted by this invention to solve its technical problem is: a language model prompting learning method based on weak supervision, comprising the following steps:
[0010] Collect prompt templates in the format of open questions and answers, forming a set of several prompt templates;
[0011] Given an input to a set, select a prompt template from the set to obtain a general prediction of the input;
[0012] Several prompt templates are grouped so that the prompt templates in each group emphasize different aspects of the input, generating complementary predictions;
[0013] By learning the precision parameters and dependencies of the hint template through weak supervision, several imperfect hints are aggregated to obtain imperfect predictions;
[0014] The final result is obtained by aggregating the predictions of all prompt templates through joint distribution.
[0015] Preferably, the collection uses prompt templates in the format of open-ended questions and answers, forming a set of several prompt templates including:
[0016] The prompt template uses an open-ended question and answer format and provides an example;
[0017] Any prompt template includes several versions. By changing and modifying the examples, a collection of prompt templates can be formed.
[0018] Preferably, the examples include input examples and output examples.
[0019] Preferably, the step of giving input to a set and selecting a prompt template from the set to obtain a regular prediction of the input includes:
[0020] Choose any prompt template and generate a question using the question function;
[0021] The question and input are used to obtain intermediate predictions through an answer function;
[0022] The intermediate predictions are mapped to the output space to obtain the predictions for the input;
[0023] Repeat the above steps with other prompt templates to obtain several predictions;
[0024] Aggregate all predictions to obtain a regular prediction for the input.
[0025] Preferably, the step of grouping several prompt templates, such that the prompt templates in each group emphasize different aspects of the input, and generating complementary predictions includes:
[0026] The prompt templates in the set are divided into several groups, and each group uses a different question format to obtain the predictions for each group, which is to provide complementary predictions for different aspects of the input.
[0027] Preferably, each set of prompt templates also obtains the prediction for each set through random sampling or clustering.
[0028] Preferably, the step of aggregating several imperfect hints to obtain imperfect predictions by learning the accuracy parameters and dependencies of the hint template through weak supervision includes:
[0029] Construct a graph model representing the dependencies between prompts and an inverse covariance matrix that satisfies the graph structure property;
[0030] The inverse covariance matrix is decomposed into the sum of a low-rank matrix and a sparse matrix;
[0031] Dependency graphs are obtained from sparse matrices and used to learn dependency structures;
[0032] The precision parameter is learned based on the dependency structure and cue chain to obtain the joint distribution. Several imperfect cues are aggregated to obtain imperfect predictions.
[0033] Preferably, the accuracy parameters include the accuracy strength of each prompt and the interdependence strength between prompts.
[0034] Preferably, the step of aggregating the predictions of all cue templates through joint distribution to obtain the final result includes:
[0035] Based on the input, use a chain of prompts to collect predictions from all the prompts;
[0036] The posterior probability is calculated based on the joint distribution, and the prediction is made according to the maximum a posteriori probability criterion to obtain the final result.
[0037] A weakly supervised language model prompting learning system, which applies the aforementioned weakly supervised language model prompting learning method, includes:
[0038] The prompt template collection module is used to collect prompt templates in the format of open questions and answers, forming a collection of several prompt templates;
[0039] The regular prediction generation module is used to obtain a regular prediction of the input by selecting a prompt template from the set, given an input to the set.
[0040] The complementary prediction generation module is used to group several prompt templates, so that the prompt templates in each group emphasize different aspects of the input, and generate complementary predictions.
[0041] The imperfect prediction generation module is used to learn the accuracy parameters and dependencies of the hint template through weak supervision, aggregate several imperfect hints, and obtain imperfect predictions.
[0042] The prediction aggregation module is used to aggregate the predictions of all prompt templates through joint distribution to obtain the final result.
[0043] The beneficial effects of this invention are:
[0044] Compared with existing technologies, this application provides a language model prompt learning method and system based on weak supervision. By modeling prompt dependencies, it effectively utilizes the complementarity of different prompts, can easily and quickly aggregate multiple imperfect prompts, and adopts an open question-and-answer format for prompts. It significantly improves the performance on multiple language comprehension tasks, while also enhancing the stability and generalization ability of the performance, and greatly reducing the application threshold of prompt learning. Attached Figure Description
[0045] Figure 1 This is a schematic diagram of the process of a language model prompting learning method based on weak supervision according to the present invention;
[0046] Figure 2 This is a schematic diagram of a language model prompting learning system module based on weak supervision according to the present invention.
[0047] The accompanying drawings are for illustrative purposes only and should not be construed as limiting the invention. To better illustrate the embodiments, some parts in the drawings may be omitted, enlarged, or reduced, and do not represent the actual product dimensions. It is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings. Detailed Implementation
[0048] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0049] like Figure 1 As shown, a language model prompting learning method based on weak supervision according to the present invention includes the following steps:
[0050] S1: Collect prompt templates in the format of open questions and answers, forming a set of several prompt templates;
[0051] S2: Given an input to a set, select a prompt template from the set to obtain a general prediction of the input;
[0052] S3: Group several prompt templates so that the prompt templates in each group emphasize different aspects of the input, and generate complementary predictions;
[0053] S4: By learning the precision parameters and dependencies of the hint template through weak supervision, several imperfect hints are aggregated to obtain imperfect predictions;
[0054] S5: The final result is obtained by aggregating the predictions of all prompt templates through joint distribution.
[0055] In one embodiment of the above scheme, a novel prompting framework is proposed. It utilizes an open-ended question-and-answer format for prompting, recursively applying a language model to implement a prompt chain, thereby transforming the input to a more optimized format. Simultaneously, it employs weakly supervised learning to model prompt dependencies and accuracy without requiring manually labeled data, achieving effective aggregation of multiple imperfect prompts. This embodiment significantly improves the prompting learning effect and stability, enables small-model matching of large-model approaches, reduces application difficulty, solves the challenges of personalization and dependency modeling in prompting engineering, and realizes a new paradigm for efficient, generalizable, and easy-to-use prompting learning.
[0056] Preferably, in step S1, the collection of prompt templates in the format of open-ended questions and answers, forming a set of several prompt templates, includes:
[0057] The prompt template uses an open-ended question and answer format and provides an example;
[0058] Any prompt template includes several versions. By changing and modifying the examples, a collection of prompt templates can be formed.
[0059] Preferably, the examples include input examples and output examples.
[0060] In the above scheme, for various natural language understanding tasks, the input is specific example data x and labeled y; for reading comprehension tasks, x is the text content and questions, and y is the answer; for text classification, x is the sample text, and y is the category label.
[0061] Collect multiple prompt templates p containing input placeholders to form a set P. Initially, the templates are designed using an open-ended question and answer format, providing input and output examples. To ensure diversity, templates with different variations and question styles are collected. These templates are general and can be reused on different inputs. For each template, multiple versions are generated, increasing diversity by changing the examples and making minor modifications. The final result is a set P = {p1, p2, ..., p...} containing multiple templates. m}, where m represents the number of templates. For a given input x, use different templates p from the set P. m (x) is used to prompt the language model and collect multiple prediction results; by introducing operations such as variation examples and question styles, the diversity between prompts can be increased, different aspects of the input x can be emphasized, and complementary information can be obtained in the end.
[0062] Preferably, in step S2, the process of providing a given input to a set and selecting a prompt template from the set to obtain a general prediction of the input includes:
[0063] Choose any prompt template and generate a question using the question function;
[0064] The question and input are used to obtain intermediate predictions through an answer function;
[0065] The intermediate predictions are mapped to the output space to obtain the predictions for the input;
[0066] Repeat the above steps with other prompt templates to obtain several predictions;
[0067] Aggregate all predictions to obtain a regular prediction for the input.
[0068] In the above scheme, a language model is recursively applied to generate multiple predictions for each input x using a cue chain approach. The specific implementation steps are as follows:
[0069] For input x, select a prompt template p∈P and use the question() function to generate the corresponding question q, i.e., q = question(x); provide question q and the original input x together to the answer() function to generate the corresponding intermediate prediction a, i.e., a = answer(q,x); map the intermediate prediction a to the output space Y to obtain the prediction for input x. Repeat the above steps, selecting different prompt templates p∈P, to generate new questions q and intermediate predictions a; finally, a set of predictions is obtained. All predictions are aggregated to obtain the final prediction y for input x; by recursively applying the language model, different questions and predictions are generated multiple times to better transform the format of input x and collect multiple prediction results.
[0070] Preferably, in step S3, grouping the several prompt templates so that the prompt templates in each group emphasize different aspects of the input and generating complementary predictions includes:
[0071] The prompt templates in the set are divided into several groups, and each group uses a different question format to obtain the predictions for each group, which is to provide complementary predictions for different aspects of the input.
[0072] Preferably, each set of prompt templates also obtains the prediction for each set through random sampling or clustering.
[0073] In the above scheme, the prompt templates p are grouped so that each group of prompt templates emphasizes different aspects of the input x, using various question formats to obtain complementary information; the prompt template set P is divided into several groups {P1, P2, ..., P...} K Each group contains L templates; each group uses different question formats, such as Yes / No, W-word categories (what, where, when, etc.), multiple choice, etc., to achieve diversity; the diversity of examples in each group is obtained through random sampling or clustering; for input x, each group P i Each will generate a set of predictions Where i∈[1,K], x is viewed from different perspectives to obtain complementary information; all predictions are aggregated to obtain the final prediction result:
[0074]
[0075] By grouping and varying examples and question formats, different cue chains P(x) can emphasize different aspects of the input x, generating complementary predictions and providing information for subsequent aggregation.
[0076] Preferably, in step S4, the process of aggregating several imperfect hints to obtain imperfect predictions by learning the accuracy parameters and dependencies of the hint template through weak supervision includes:
[0077] Construct a graph model representing the dependencies between prompts and an inverse covariance matrix that satisfies the graph structure property;
[0078] The inverse covariance matrix is decomposed into the sum of a low-rank matrix and a sparse matrix;
[0079] Dependency graphs are obtained from sparse matrices and used to learn dependency structures;
[0080] The precision parameter is learned based on the dependency structure and cue chain to obtain the joint distribution. Several imperfect cues are aggregated to obtain imperfect predictions.
[0081] Preferably, the accuracy parameters include the accuracy strength of each prompt and the interdependence strength between prompts.
[0082] In the above scheme, a graph model G = (V, E) is constructed, where V contains nodes of variables {y, P(x)}, E represents the dependencies between the variables, and the inverse covariance matrix satisfies the graph structure property.
[0083] Right now When p i and p j Conditional independence;
[0084] in, Represents the inverse covariance matrix Sigma -1 The element p in the i-th row and j-th column i and p j Let i and j represent variables i and j, respectively.
[0085] Applying Robust PCA to decompose the original data, it can be represented as the sum of a low-rank matrix and a sparse matrix. The original data matrix can be represented in the following form:
[0086] M = L + S;
[0087] Where M is the original data matrix, L is the low-rank matrix, and S is the sparse matrix.
[0088] The sparse part reflects the dependency structure, and the dependency graph is obtained from the sparse structure. Then, in the case of unlabeled data, a structure learning method is used to learn the dependency structure. The learning process primarily involves observing the graph structure properties of the inverse covariance matrix of the output matrix; and then applying the learned dependency graph... And for cue chain prediction, the EM method is used to learn the accuracy parameter θ of the cue, where θ includes the accuracy strength θ of each cue. i The correlation strength θ between the clue and the clue ij The joint distribution estimate is obtained. Aggregate all hints using the model:
[0089]
[0090] By modeling cue dependencies and precision parameters, multiple imperfect cuees can be reliably aggregated without the need for manually labeled data.
[0091] Preferably, in step S5, the step of aggregating the predictions of all cue templates through joint distribution to obtain the final result includes:
[0092] Based on the input, use a chain of prompts to collect predictions from all the prompts;
[0093] The posterior probability is calculated based on the joint distribution, and the prediction is made according to the maximum a posteriori probability criterion to obtain the final result.
[0094] In the above scheme, the final result is obtained by aggregating all the predictions given by the prompts through Pr(y|P(x)).
[0095] For each input x, use the cue chain P(x) to collect all predictions, resulting in:
[0096] P(x) = {p1(x), p2(x), ..., p m (x)};
[0097] Based on the joint distribution Pr(y|P(x)) learned in step S4, calculate the posterior probability:
[0098] Pr(y|P(x))∝Pr(y,P(x));
[0099] Prediction is made using the maximum a posteriori probability criterion.
[0100]
[0101] That is, select the most likely output y under the given cue chain P(x) as the prediction;
[0102] Repeat this process for all inputs x∈D to obtain all predictions.
[0103] By modeling the accuracy and dependencies of hints, multiple imperfect hints can be aggregated to obtain more stable and accurate predictions than a single hint.
[0104] The above approach employs an open-ended question-answering format for prompts, which significantly improves performance on multiple language understanding tasks compared to a limited output format. This demonstrates that open prompts better align with the pre-training objectives of language models and are key to improved performance. By modeling prompt dependencies, the prompt aggregation effect is significantly improved compared to simple majority voting. Furthermore, it reduces variance and enhances stability.
[0105] like Figure 2 As shown, a language model prompting learning system based on weak supervision applies the aforementioned language model prompting learning method based on weak supervision, including:
[0106] The prompt template collection module is used to collect prompt templates in the format of open questions and answers, forming a collection of several prompt templates;
[0107] The regular prediction generation module is used to obtain a regular prediction of the input by selecting a prompt template from the set, given an input to the set.
[0108] The complementary prediction generation module is used to group several prompt templates, so that the prompt templates in each group emphasize different aspects of the input, and generate complementary predictions.
[0109] The imperfect prediction generation module is used to learn the accuracy parameters and dependencies of the hint template through weak supervision, aggregate several imperfect hints, and obtain imperfect predictions.
[0110] The prediction aggregation module is used to aggregate the predictions of all prompt templates through joint distribution to obtain the final result.
[0111] The above solutions address the high computational cost of finding the optimal suggestion by automatically converting the suggestion format to reduce search difficulty; they improve generalization by using a recursive suggestion framework to solve the problem of poor generalization caused by searching for suggestions from scratch for each task; they address the issue of excessive consistency requirements potentially filtering out valid information by aggregating multiple suggestions, utilizing complementary information, retaining all suggestions, and accommodating more information; and they address the problem of overly simplistic majority voting without modeling dependencies by directly modeling suggestion accuracy, eliminating the need for repeated generation and improving efficiency.
[0112] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the implementation of the present invention. Those skilled in the art can make other variations or modifications based on the above description. It is neither necessary nor possible to exhaustively describe all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the claims of the present invention.
Claims
1. A weakly supervised based language model prompting learning method, characterized in that, The method comprises the following steps: collecting prompt templates in the form of open questions and answers to form a set of prompt templates; given an input to the set, selecting prompt templates in the set to obtain a regular prediction of the input; grouping the prompt templates to emphasize different aspects of the input, and generating complementary predictions; aggregating several imperfect prompts by weakly supervised learning of the precision parameters and dependency relationships of the prompt templates to obtain an imperfect prediction; aggregating all predictions of the prompt templates by joint distribution to obtain a final result; the collecting prompt templates in the form of open questions and answers to form a set of prompt templates comprises: the prompt templates are in the form of open questions and answers, and examples are provided; any prompt template comprises several versions, and the set of prompt templates is formed by replacing examples and modifying examples; the given input to the set, selecting prompt templates in the set to obtain a regular prediction of the input comprises: selecting any prompt template, and generating a question by a question function; the question and the input are used to obtain an intermediate prediction by an answer function; mapping the intermediate prediction to an output space to obtain a prediction for the input; selecting other prompt templates to repeat the operation to obtain several predictions; aggregating all predictions to obtain a regular prediction for the input; the grouping the prompt templates to emphasize different aspects of the input, and generating complementary predictions comprises: dividing the prompt templates in the set into several groups, and using different question forms to obtain a prediction for each group, which is a complementary prediction for different aspects of the input; the aggregating several imperfect prompts by weakly supervised learning of the precision parameters and dependency relationships of the prompt templates to obtain an imperfect prediction comprises: constructing a graph model representing the dependency relationship between prompts and an inverse covariance matrix satisfying the graph structure; decomposing the inverse covariance matrix into the sum of a low-rank matrix and a sparse matrix; obtaining a dependency graph from the sparse matrix for learning the dependency structure; learning the precision parameters according to the dependency structure and the prompt chain to obtain a joint distribution, and aggregating several imperfect prompts to obtain an imperfect prediction.
2. The weakly supervised language model prompting method of claim 1, wherein, the examples comprise input examples and output examples.
3. The weakly supervised language model prompting method of claim 1, wherein, each group of prompt templates further obtains a prediction for each group by random sampling or clustering.
4. The weakly supervised language model prompting method of claim 3, wherein, the precision parameters comprise the precision strength of each prompt and the dependency strength between prompts.
5. The weakly supervised language model prompting method of claim 3, wherein, the aggregating all predictions of the prompt templates by joint distribution to obtain a final result comprises: collecting all predictions of the prompts according to the input using the prompt chain; calculating the posterior probability according to the joint distribution, and obtaining a final result according to the maximum a posteriori probability criterion.
6. A weakly supervised language model prompting learning system applying the weakly supervised language model prompting learning method of claim 1, characterized in that, comprise: a prompt template collection module for collecting prompt templates in the form of open questions and answers to form a set of prompt templates; a regular prediction generation module for giving an input to the set and selecting prompt templates in the set to obtain a regular prediction of the input; a complementary prediction generation module for grouping the prompt templates to emphasize different aspects of the input and generating complementary predictions; The imperfect prediction generation module is configured to learn precision parameters and dependency relationships of the prompt templates through weakly supervised learning, aggregate a plurality of imperfect prompts, and obtain imperfect predictions. The prediction aggregation module is configured to aggregate predictions of all prompt templates through joint distribution to obtain a final result. The collection of prompt templates in the format of open questions and answers includes: The prompt templates are in the format of open questions and answers and provide examples. Any prompt template includes a plurality of versions, and the collection of prompt templates is formed by replacing examples and modifying examples. The given input is input into the collection, and a prompt template in the collection is selected to obtain a regular prediction of the input, which includes: Any prompt template is selected, and a question is generated through a question function. The question and the input obtain an intermediate prediction through an answer function. The intermediate prediction is mapped to an output space to obtain a prediction for the input. Other prompt templates are selected to repeat the above operations to obtain a plurality of predictions. All predictions are aggregated to obtain a regular prediction for the input. The plurality of prompt templates are grouped, and the prompt templates in each group emphasize different aspects of the input to generate complementary predictions, which includes: The prompt templates in the collection are divided into a plurality of groups, and each group adopts a different question form to obtain a prediction of each group, which is a complementary prediction of different aspects of the input. The imperfect prediction generation module is configured to learn precision parameters and dependency relationships of the prompt templates through weakly supervised learning, aggregate a plurality of imperfect prompts, and obtain imperfect predictions, which includes: A graph model representing the dependency relationship between prompts and an inverse covariance matrix satisfying the graph structure are constructed. The inverse covariance matrix is decomposed into a sum of a low-rank matrix and a sparse matrix. The dependency graph is obtained according to the sparse matrix, and is used to learn the dependency structure. The precision parameters are learned according to the dependency structure and the prompt chain to obtain a joint distribution, and a plurality of imperfect predictions are aggregated to obtain imperfect predictions.
Citation Information
Patent Citations
Lightweight fine-grained image recognition method for cross-layer feature interaction in weak supervision scene
CN111652236A
Legal question and answer method based on weak supervised learning and joint learning mechanism, and equipment
CN113297360A