SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2402.11138 · 2024

Contrastive Instruction Tuning

arXiv · PDF · Open in the Atlas

Code that ran

11 of 12 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; 10 failures of our instrument; 1 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/2402.11138.json · badge: /api/ran/2402.11138.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
luka-group/CoIN canonical (classifier label)
classifier basis: census
11 ran · 1 no recorded run
FunctionStatusWhere it lives
batch_concat Ran
ran; our contract draft was wrong, not the code
luka-group/CoIN/ContrastiveDataCollator.py
code served (permissive licence) · get_code("8428b74a83050be7")
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 tuple. 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

torch.manual_seed(0)

# Create two batches with different sequence lengths
# batch1: shape (2, 3) - 2 samples, sequence length 3
batch1 = torch.tensor([[1.0, 2.0, 3.0],
                       [4.0, 5.0, 6.0]])

# batch2: shape (2, 5) - 2 samples, sequence length 5
batch2 = torch.tensor([[7.0, 8.0, 9.0, 10.0, 11.0],
                       [12.0, 13.0, 14.0, 15.0, 16.0]])

ARGS = {
    "batch1": batch1,
    "batch2": batch2,
    "pad_to_left": True,
    "pad_value": 0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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
calc_avg_std Ran
ran, honoured the contract we drafted
luka-group/CoIN/promptbench/postprocessing.py
code served (permissive licence) · get_code("161e3ffde5559cc2")
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 tuple, 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 numpy as np

# The function calc_avg_std takes all_acc as a parameter
# It calls np.mean() and np.std() on it, so it needs to be array-like
# Create a small list of accuracy values
all_acc = [0.85, 0.90, 0.88, 0.92, 0.87]

ARGS = {
    "all_acc": all_acc
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple 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
generate_flan_input Ran
ran; our contract draft was wrong, not the code
luka-group/CoIN/utils/common_utils.py
code served (permissive licence) · get_code("5bba9fd93c67d653")
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.

import torch
import torch.nn as nn

# Analyze the function: generate_flan_input takes two string parameters
# inputs: a string
# targets: an optional string (defaults to None)
# The function concatenates strings and returns the result

# Create simple string inputs
inputs_value = "What is the capital of France?"
targets_value = "The capital of France is Paris."

ARGS = {
    'inputs': inputs_value,
    'targets': targets_value
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — 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
get_perturb_key_name Ran
ran; our contract draft was wrong, not the code
luka-group/CoIN/promptbench/postprocessing.py
code served (permissive licence) · get_code("8e607e82d12be46e")
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.

import torch

torch.manual_seed(0)

ARGS = {
    'perturb': 'noise'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — 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
load_contrastive_dataset Ran
ran; our contract draft was wrong, not the code
luka-group/CoIN/utils/common_utils.py
code served (permissive licence) · get_code("09be23529d48b7bd")
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 Dataset. 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 pickle
import pandas as pd
import tempfile
import os
from datasets import Dataset

# Create a temporary CSV file for testing
temp_dir = tempfile.mkdtemp()
csv_path = os.path.join(temp_dir, "test_data.csv")
pickle_path = os.path.join(temp_dir, "test_data.pkl")

# Create sample data as a pandas DataFrame
sample_data = pd.DataFrame({
    'col1': [1, 2, 3],
    'col2': ['a', 'b', 'c'],
    'col3': [1.5, 2.5, 3.5]
})

# Save as CSV
sample_data.to_csv(csv_path, index=False)

# Save as pickle
with open(pickle_path, 'wb') as f:
    pickle.dump(sample_data, f)

ARGS = {
    'datafile_path': csv_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
datasets, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Dataset — a Dataset output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Dataset output the recorded ndim 1 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
load_data_from_pkl Ran
ran; our contract draft was wrong, not the code
luka-group/CoIN/utils/common_utils.py
code served (permissive licence) · get_code("3ac33615ed8caaa5")
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 os
import pickle
import tempfile

# Create a temporary directory and a test pickle file
temp_dir = tempfile.mkdtemp()
test_data = {"key": "value", "number": 42, "list": [1, 2, 3]}
test_filepath = "test_data.pkl"
test_file_path = os.path.join(temp_dir, test_filepath)

with open(test_file_path, 'wb') as f:
    pickle.dump(test_data, f)

ARGS = {
    "output_dir": temp_dir,
    "filepath": test_filepath
}
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 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
merge_batch_prompts Ran
ran; our contract draft was wrong, not the code
luka-group/CoIN/ContrastiveDataCollator.py
code served (permissive licence) · get_code("c6b522eb3c5cd206")
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
from transformers import BatchEncoding

torch.manual_seed(0)

# Create small sample BatchEncoding objects with required keys
# Batch size: 2, sequence length: 4 for batch1, 3 for batch2
original_tokenized_full_prompt = BatchEncoding({
    'input_ids': torch.tensor([[101, 2054, 2003, 102], [101, 2054, 2003, 102]]),  # shape (2, 4)
    'attention_mask': torch.tensor([[1, 1, 1, 1], [1, 1, 1, 1]]),  # shape (2, 4)
    'labels': torch.tensor([[101, 2054, 2003, 102], [101, 2054, 2003, 102]])  # shape (2, 4)
})

paraphrased_tokenized_full_prompt = BatchEncoding({
    'input_ids': torch.tensor([[101, 2054, 102], [101, 2003, 102]]),  # shape (2, 3)
    'attention_mask': torch.tensor([[1, 1, 1], [1, 1, 1]]),  # shape (2, 3)
    'labels': torch.tensor([[101, 2054, 102], [101, 2003, 102]])  # shape (2, 3)
})

ARGS = {
    'original_tokenized_full_prompt': original_tokenized_full_prompt,
    'paraphrased_tokenized_full_prompt': paraphrased_tokenized_full_prompt,
    'pad_to_left': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — 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
save_importance Ran
ran; our contract draft was wrong, not the code
luka-group/CoIN/promptbench/visualize.py
code served (permissive licence) · get_code("bce2eca67602b56d")
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.

import numpy as np
import torch

torch.manual_seed(0)

# Construct arguments for save_importance function
words = ['hello', 'world', 'test', 'python']
importance = np.array([0.2, 0.5, 0.8, 0.3])

ARGS = {
    'words': words,
    'importance': importance
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
matplotlib, numpy, torch — 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
separate_batch_prompts Ran
ran; our contract draft was wrong, not the code
luka-group/CoIN/ContrastiveDataCollator.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from vegetable-yx/CoIPO, is pointer only (licence: NONE) · get_code("56739640fa432aa6")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from vegetable-yx/CoIPO, 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.

vis_by_delete Ran
ran; our contract draft was wrong, not the code
luka-group/CoIN/promptbench/visualize.py
code served (permissive licence) · get_code("bfd54763b0c09524")
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 torch.nn as nn
import numpy as np

torch.manual_seed(0)

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.embedding = nn.Embedding(100, 8)
        self.linear = nn.Linear(8, 1)
    
    def forward(self, input_ids, labels=None):
        embedded = self.embedding(input_ids)
        pooled = embedded.mean(dim=1)
        logits = self.linear(pooled)
        
        loss = None
        if labels is not None:
            loss_fn = nn.MSELoss()
            loss = loss_fn(logits.squeeze(), labels.squeeze().float())
        
        class Output:
            pass
        
        output = Output()
        output.loss = loss
        return output

class SimpleTokenizer:
    def __call__(self, text, return_tensors=None):
        tokens = text.split()
        token_ids = [min(hash(token) % 97 + 1, 99) for token in tokens]
        
        result = {'input_ids': torch.tensor([token_ids], dtype=torch.long)}
        return result

model = SimpleModel()
tokenizer = SimpleTokenizer()
input_sentence = "the quick brown fox"
label = "animal"

ARGS = {
    'model': model,
    'tokenizer': tokenizer,
    'input_sentence': input_sentence,
    'label': label
}
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
vis_by_grad Ran
ran; our contract draft was wrong, not the code
luka-group/CoIN/promptbench/visualize.py
code served (permissive licence) · get_code("da651a51337729cf")
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 tuple, ndim 2, 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 torch
import torch.nn as nn

torch.manual_seed(0)

class MockTokenizer:
    def __init__(self):
        self.vocab_size = 10
    
    def tokenize(self, text):
        # Simulate tokenization with subword markers
        return ['▁hello', 'world']
    
    def __call__(self, text, return_tensors=None):
        # Return mock token ids and attention mask
        if return_tensors == 'pt':
            return {
                'input_ids': torch.tensor([[1, 2, 3]]),
                'attention_mask': torch.tensor([[1, 1, 1]])
            }
        return {'input_ids': [[1, 2, 3]], 'attention_mask': [[1, 1, 1]]}

class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.embedding = nn.Embedding(10, 4)
        self.lm_head = nn.Linear(4, 10)
    
    def get_input_embeddings(self):
        return self.embedding
    
    def forward(self, inputs_embeds, attention_mask, labels):
        # Simple forward pass
        logits = self.lm_head(inputs_embeds)
        
        # Compute simple loss
        loss = logits.mean()
        
        class Output:
            def __init__(self, loss_val):
                self.loss = loss_val
        
        return Output(loss)
    
    def eval(self):
        super().eval()
        return self

model = MockModel()
tokenizer = MockTokenizer()
input_sentence = "hello world"
label = "test"

ARGS = {
    'model': model,
    'tokenizer': tokenizer,
    'input_sentence': input_sentence,
    'label': label
}
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 tuple, ndim 2, dtype family float — a tuple 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
create_dataset Not yet run
unverified (harvested, no recorded run)
luka-group/CoIN/promptbench/dataload.py
code served (permissive licence) · get_code("beb8b40b0c4a53c8")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 1 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 1 later) and 11 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
separate_batch_prompts 1 other paper
1 later
2603.03314 (2026-03)
Towards Self-Robust LLMs: Intrinsic Prompt Noise Resistance via CoIPO

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

Instruction tuning has been used as a promising approach to improve the performance of large language models (LLMs) on unseen tasks. However, current LLMs exhibit limited robustness to unseen instructions, generating inconsistent outputs when the same instruction is phrased with slightly varied forms or language styles. This behavior indicates LLMs' lack of robustness to textual variations and generalizability to unseen instructions, potentially leading to trustworthiness issues. Accordingly, we propose Contrastive Instruction Tuning, which maximizes the similarity between the hidden representations of semantically equivalent instruction-instance pairs while minimizing the similarity between semantically different ones. To facilitate this approach, we augment the existing FLAN collection by paraphrasing task instructions. Experiments on the PromptBench benchmark show that CoIN consistently improves LLMs' robustness to unseen instructions with variations across character, word, sentence, and semantic levels by an average of +2.5% in accuracy. Code is available at https://github.com/luka-group/CoIN.

For agents

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

get_harvested_code_for_paper("2402.11138")
get_code_for_paper("2402.11138")
have("2402.11138")

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

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

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

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

Connect an agent — have() is free.