SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2205.01308 · NAACL · 2022

Contrastive Learning for Prompt-Based Few-Shot Language Learners

Chongyang Gao, Soroush Vosoughi, Yiren Jian

arXiv · PDF · Open in the Atlas

Code that ran

6 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 5 failures of our instrument; 5 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2205.01308.json · badge: /api/ran/2205.01308.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
yiren-jian/LM-SupCon canonical (classifier label)
classifier basis not recorded on the link
6 ran · 5 no recorded run
FunctionStatusWhere it lives
default_dev_objective Ran
ran, honoured the contract we drafted
yiren-jian/LM-SupCon/src/trainer.py
pointer only (licence: MIT); the stored copy get_code serves, from uijeongjang/lora-ntk, is pointer only (licence: NONE) · get_code("e448786d5ff1875a")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from uijeongjang/lora-ntk, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

get_only_chars Ran
ran; our contract draft was wrong, not the code
yiren-jian/LM-SupCon/src/eda.py
code served (permissive licence) · get_code("f15117422b72cf43")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

# The function takes a single parameter 'line' which is a string
# It processes the string by removing certain characters, replacing others,
# converting to lowercase, and cleaning up spaces

line = "Hello, World! This is a test-string with 'quotes' and—dashes.\n\tAnd tabs."

ARGS = {
    'line': line
}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
input_example_to_string Ran
ran; our contract draft was wrong, not the code
yiren-jian/LM-SupCon/src/dataset.py
code served (permissive licence) · get_code("e768e25ca95f70cd")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

class Example:
    def __init__(self, text_a, text_b=None):
        self.text_a = text_a
        self.text_b = text_b

example_with_text_b = Example("Hello world", "This is text b")
example_without_text_b = Example("Hello world", None)

ARGS = {
    "example": example_with_text_b,
    "sep_token": "[SEP]"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
input_example_to_tuple Ran
ran; our contract draft was wrong, not the code
yiren-jian/LM-SupCon/src/dataset.py
code served (permissive licence) · get_code("fbef70dc7c700501")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import logging
import pandas as pd

logger = logging.getLogger(__name__)

# Create a simple example class that mimics the structure needed
class Example:
    def __init__(self, text_a, text_b=None):
        self.text_a = text_a
        self.text_b = text_b

# Test case 1: example with both text_a and text_b
example_both = Example(text_a="Hello world", text_b="Goodbye world")

# Test case 2: example with only text_a
example_single = Example(text_a="Hello world", text_b=None)

# Test case 3: example with None text_a and None text_b
example_empty = Example(text_a=None, text_b=None)

# Use the most complete example for the ARGS dict
ARGS = {
    "example": example_both
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
select_neighbors Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
yiren-jian/LM-SupCon/src/label_search.py
pointer only (licence: MIT); the stored copy get_code serves, from korawat-tanwisuth/pouf, is pointer only (licence: NONE) · get_code("b69b1ad29fd21db5")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from korawat-tanwisuth/pouf, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

text_classification_metrics Ran
ran; our contract draft was wrong, not the code
yiren-jian/LM-SupCon/src/processors.py
code served (permissive licence) · get_code("b62076c5483738dc")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Construct arguments for text_classification_metrics
task_name = "sentiment"

# Create predictions and labels as numpy arrays
# The function compares them with == and calls .mean()
preds = np.array([0, 1, 0, 1], dtype=np.int64)
labels = np.array([0, 1, 1, 1], dtype=np.int64)

ARGS = {
    "task_name": task_name,
    "preds": preds,
    "labels": labels,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
eval_pairing_acc Not yet run
unverified (harvested, no recorded run)
yiren-jian/LM-SupCon/src/label_search.py
pointer only (licence: MIT); the stored copy get_code serves, from korawat-tanwisuth/pouf, is pointer only (licence: NONE) · get_code("47923f36537f5f79")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from korawat-tanwisuth/pouf, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

get_synonyms Not yet run
unverified (harvested, no recorded run)
yiren-jian/LM-SupCon/src/eda.py
pointer only (licence: MIT); the stored copy get_code serves, from vano1205/efficientcl, is pointer only (licence: NONE) · get_code("461078e5a822e755")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from vano1205/efficientcl, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

select_likely_words Not yet run
unverified (harvested, no recorded run)
yiren-jian/LM-SupCon/src/label_search.py
pointer only (licence: MIT); the stored copy get_code serves, from korawat-tanwisuth/pouf, is pointer only (licence: NONE) · get_code("be6b57168b0424f3")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from korawat-tanwisuth/pouf, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

synonym_replacement Not yet run
unverified (harvested, no recorded run)
yiren-jian/LM-SupCon/src/eda.py
pointer only (licence: MIT); the stored copy get_code serves, from HenryPengZou/DeCrisisMB, is pointer only (licence: NONE) · get_code("56366bd6ff30a29a")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from HenryPengZou/DeCrisisMB, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

tokenize_multipart_input Not yet run
unverified (harvested, no recorded run)
yiren-jian/LM-SupCon/src/dataset.py
code served (permissive licence) · get_code("090deb73a074d4df")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 10 are also present in other papers whose code we hold (10 with at least one paper dated earlier, 0 the same month, 10 later) and 1 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
input_example_to_string 9 other papers
3 dated earlier, 6 later
2110.01256 (2021-10)
Revisiting Self-Training for Few-Shot Learning of Language Model
2110.06274 (2021-10)
LiST: Lite Prompted Self-training Makes Parameter-Efficient Few-shot Learners
2202.11451 (2022-02)
Zero-shot Cross-lingual Transfer of Prompt-based Tuning with a Unified Multilingual Prompt
and 6 more not named here
input_example_to_tuple 9 other papers
3 dated earlier, 6 later
2110.01256 (2021-10)
Revisiting Self-Training for Few-Shot Learning of Language Model
2110.06274 (2021-10)
LiST: Lite Prompted Self-training Makes Parameter-Efficient Few-shot Learners
2202.11451 (2022-02)
Zero-shot Cross-lingual Transfer of Prompt-based Tuning with a Unified Multilingual Prompt
and 6 more not named here
default_dev_objective 7 other papers
3 dated earlier, 4 later
2110.01256 (2021-10)
Revisiting Self-Training for Few-Shot Learning of Language Model
2110.06274 (2021-10)
LiST: Lite Prompted Self-training Makes Parameter-Efficient Few-shot Learners
2202.11451 (2022-02)
Zero-shot Cross-lingual Transfer of Prompt-based Tuning with a Unified Multilingual Prompt
and 4 more not named here
get_only_chars 6 other papers
3 dated earlier, 3 later
1901.11196 (2019-01)
EDA: Easy Data Augmentation Techniques for Boosting Performance on Text Classification Tasks
2103.07552 (2021-03)
Few-Shot Text Classification with Triplet Networks, Data Augmentation, and Curriculum Learning
2204.01959 (2022-04)
Data Augmentation for Intent Classification with Off-the-shelf Large Language Models
and 3 more not named here
get_synonyms 6 other papers
4 dated earlier, 2 later · 1 only as an assembly brick
2103.07552 (2021-03)
Few-Shot Text Classification with Triplet Networks, Data Augmentation, and Curriculum Learning
2109.05941 (2021-09)
Efficient Contrastive Learning via Novel Data Augmentation and Curriculum Learning
2204.01959 (2022-04)
Data Augmentation for Intent Classification with Off-the-shelf Large Language Models
and 3 more not named here
synonym_replacement 6 other papers
4 dated earlier, 2 later · 1 only as an assembly brick
2103.07552 (2021-03)
Few-Shot Text Classification with Triplet Networks, Data Augmentation, and Curriculum Learning
2109.05941 (2021-09)
Efficient Contrastive Learning via Novel Data Augmentation and Curriculum Learning
2204.01959 (2022-04)
Data Augmentation for Intent Classification with Off-the-shelf Large Language Models
and 3 more not named here
text_classification_metrics 6 other papers
2 dated earlier, 4 later
2110.01256 (2021-10)
Revisiting Self-Training for Few-Shot Learning of Language Model
2110.06274 (2021-10)
LiST: Lite Prompted Self-training Makes Parameter-Efficient Few-shot Learners
2210.05643 (2022-10)
A Kernel-Based View of Language Model Fine-Tuning
and 3 more not named here
eval_pairing_acc 2 other papers
1 dated earlier, 1 later
2110.06274 (2021-10)
LiST: Lite Prompted Self-training Makes Parameter-Efficient Few-shot Learners
2305.00350 (2023-05)
POUF: Prompt-oriented unsupervised fine-tuning for large pre-trained models
select_likely_words 2 other papers
1 dated earlier, 1 later
2110.06274 (2021-10)
LiST: Lite Prompted Self-training Makes Parameter-Efficient Few-shot Learners
2305.00350 (2023-05)
POUF: Prompt-oriented unsupervised fine-tuning for large pre-trained models
select_neighbors 2 other papers
1 dated earlier, 1 later
2110.06274 (2021-10)
LiST: Lite Prompted Self-training Makes Parameter-Efficient Few-shot Learners
2305.00350 (2023-05)
POUF: Prompt-oriented unsupervised fine-tuning for large pre-trained models

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

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.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2205.01308")
get_code_for_paper("2205.01308")
have("2205.01308")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2205.01308.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2205.01308.svg)](https://syntology.ai/paper/2205.01308)

Connect an agent — have() is free.