Papers › Contrastive Learning for Prompt-Based Few-Shot Language Learners

Contrastive Learning for Prompt-Based Few-Shot Language Learners

3 May 2022NAACL 2022 7arXiv:2205.01308archive 2025-07-28

Yiren Jian, Chongyang Gao, Soroush Vosoughi

The impressive performance of GPT-3 using natural language prompts and in-context learning has inspired work on better fine-tuning of moderately-sized models under this paradigm. Following this line of work, we present a contrastive learning framework that clusters inputs from the same class for better generality of models trained with only limited examples. Specifically, we propose a supervised contrastive framework that clusters inputs from the same class under different augmented "views" and repel the ones from different classes. We create different "views" of an example by appending it with different language prompts and contextual demonstrations. Combining a contrastive loss with the standard masked language modeling (MLM) loss in prompt-based few-shot learners, the experimental results show that our method can improve over the state-of-the-art methods in a diverse set of 15 language tasks. Our framework makes minimal assumptions on the task or the base model, and can be applied to many recent methods with little modification. The code will be made available at: https://github.com/yiren-jian/LM-SupCon.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2205.01308")

Code

Syntology Ran 6 of 11 code samples harvested from 1 repository linked to this paper; 5 have no recorded run. Of those that ran: 1 ran · honoured contract; 1 ran · our draft was wrong; 1 ran · fixture could not drive it; 3 ran with no contract checked.

By repository: official repository: 11 samples from 1 repository, 6 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

yiren-jian/lm-supcon officialmentioned in papermentioned on GitHubpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

11 samples harvested; 6 ran; 1 honoured the contract we drafted; 5 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · honoured contract
1ran · our draft was wrong
1ran · fixture could not drive it
3ran
5unverified

Licence: 0 of the 11 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from yiren-jian/LM-SupCon. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

default_dev_objective yiren-jian/LM-SupCon/src/trainer.py official repository ran · honoured contract MIT (permissive) · e448786d5ff1875a · report
get_only_chars yiren-jian/LM-SupCon/src/eda.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · f15117422b72cf43 · report
input_example_to_string yiren-jian/LM-SupCon/src/dataset.py official repository ran MIT (permissive) · e768e25ca95f70cd · report
input_example_to_tuple yiren-jian/LM-SupCon/src/dataset.py official repository ran MIT (permissive) · fbef70dc7c700501 · report
select_neighbors yiren-jian/LM-SupCon/src/label_search.py official repository ran · fixture could not drive it MIT (permissive) · b69b1ad29fd21db5 · report
text_classification_metrics yiren-jian/LM-SupCon/src/processors.py official repository ran MIT (permissive) · b62076c5483738dc · report
eval_pairing_acc yiren-jian/LM-SupCon/src/label_search.py official repository unverified MIT (permissive) · 47923f36537f5f79 · report
get_synonyms yiren-jian/LM-SupCon/src/eda.py official repository unverified MIT (permissive) · 461078e5a822e755 · report
select_likely_words yiren-jian/LM-SupCon/src/label_search.py official repository unverified MIT (permissive) · be6b57168b0424f3 · report
synonym_replacement yiren-jian/LM-SupCon/src/eda.py official repository unverified MIT (permissive) · 56366bd6ff30a29a · report
tokenize_multipart_input yiren-jian/LM-SupCon/src/dataset.py official repository unverified MIT (permissive) · 090deb73a074d4df · report

Tasks

Contrastive LearningIn-Context LearningLanguage ModelingLanguage ModellingMasked Language Modeling

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

AdamAttentionAttention DropoutBASEBPEContrastive LearningCosine AnnealingDense ConnectionsDropoutGPT-3Layer NormalizationLinear LayerLinear Warmup With Cosine AnnealingMulti-Head AttentionResidual ConnectionSoftmaxWeight Decay

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections