SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2402.09906 · 2024

Generative Representational Instruction Tuning

arXiv · PDF · Open in the Atlas

Code that ran

10 of 10 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; 0 honoured the contract we drafted, 2 violated it and 0 have no contract verdict; 8 failures of our instrument; 0 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.09906.json · badge: /api/ran/2402.09906.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
contextualai/gritlm canonical (classifier label)
classifier basis: census
10 ran · 0 no recorded run
FunctionStatusWhere it lives
cached Ran
ran; our contract draft was wrong, not the code
contextualai/gritlm/gritlm/training/GradCache/src/grad_cache/functional.py
pointer only (licence: MIT); the stored copy get_code serves, from cxcscmu/longembeddinganalysis, is pointer only (licence: NONE) · get_code("7f1946b9c385a5cf")
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 cxcscmu/longembeddinganalysis, 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.

cat_input_tensor Ran
ran; our contract draft was wrong, not the code
contextualai/gritlm/gritlm/training/GradCache/src/grad_cache/functional.py
code served (permissive licence) · get_code("fab5db4632e2fa87")
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 function. 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 torch import Tensor

torch.manual_seed(0)

# The function cat_input_tensor is a decorator that takes a Callable and returns a decorated function
# It doesn't actually call the function within the decorator definition itself, just wraps it
# So we need to provide a simple function that accepts tensors/lists of tensors and returns a Tensor

def dummy_loss_fn(*args, **kwargs) -> Tensor:
    """A simple function that returns a tensor, used to test the decorator"""
    # Sum all tensor arguments
    result = torch.tensor(0.0)
    for arg in args:
        if isinstance(arg, Tensor):
            result = result + arg.sum()
    for val in kwargs.values():
        if isinstance(val, Tensor):
            result = result + val.sum()
    return result

ARGS = {
    "func": dummy_loss_fn
}
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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
filter_results_by_id Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
contextualai/gritlm/rag/base.py
code served (permissive licence) · get_code("a0d15d3d57a7efe0")
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 3, 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 logging

logger = logging.getLogger(__name__)

torch.manual_seed(0)

# Create batch_metadata - list of dicts with 'id' field
batch_metadata = [
    {'id': 'doc_1', 'other_field': 'value1'},
    {'id': 'doc_2', 'other_field': 'value2'}
]

# Create passages - list of lists of dicts with 'id' field
passages = [
    [
        {'id': 'doc_1', 'text': 'passage text 1'},
        {'id': 'doc_3', 'text': 'passage text 3'},
        {'id': 'doc_4', 'text': 'passage text 4'},
        {'id': 'doc_5', 'text': 'passage text 5'},
    ],
    [
        {'id': 'doc_2', 'text': 'passage text 2'},
        {'id': 'doc_6', 'text': 'passage text 6'},
        {'id': 'doc_7', 'text': 'passage text 7'},
        {'id': 'doc_8', 'text': 'passage text 8'},
    ]
]

# Create scores - list of lists of floats
scores = [
    [0.9, 0.8, 0.7, 0.6],
    [0.95, 0.85, 0.75, 0.65]
]

# topk parameter
topk = 3

# training parameter
training = False

ARGS = {
    'batch_metadata': batch_metadata,
    'passages': passages,
    'scores': scores,
    'topk': topk,
    'training': training
}
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, ndim 3, 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
gather_input_tensor Ran
ran; our contract draft was wrong, not the code
contextualai/gritlm/gritlm/training/GradCache/src/grad_cache/functional.py
code served (permissive licence) · get_code("7917a2079ec6b095")
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 function. 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
from torch import Tensor
from torch import distributed as dist
from unittest.mock import MagicMock, patch

torch.manual_seed(0)

# Mock distributed functions since we're not in a real distributed setup
def mock_get_world_size():
    return 2

def mock_get_rank():
    return 0

def mock_all_gather(gathered_list, tensor):
    # Simulate all_gather by filling the list with the tensor
    for i in range(len(gathered_list)):
        gathered_list[i].copy_(tensor)

# Create a simple loss function to be decorated
def simple_loss(pred: Tensor, target: Tensor) -> Tensor:
    """A simple loss function that takes two tensors and returns a scalar."""
    return torch.nn.functional.mse_loss(pred, target)

# Create another variant that uses kwargs
def loss_with_kwargs(pred: Tensor, target: Tensor, weight: Tensor = None) -> Tensor:
    """Loss function that accepts keyword arguments."""
    loss = torch.nn.functional.mse_loss(pred, target)
    if weight is not None:
        loss = loss * weight.mean()
    return loss

# Patch the distributed module
with patch('torch.distributed.get_world_size', mock_get_world_size):
    with patch('torch.distributed.get_rank', mock_get_rank):
        with patch('torch.distributed.all_gather', mock_all_gather):
            # Create test tensors
            pred_tensor = torch.randn(2, 4)
            target_tensor = torch.randn(2, 4)
            weight_tensor = torch.randn(2, 3)

ARGS = {
    'func': simple_loss,
    'axis': 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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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_gpus_max_memory Ran
ran; our contract draft was wrong, not the code
contextualai/gritlm/evaluation/eval_mteb.py
pointer only (licence: MIT); the stored copy get_code serves, from tianyi-lab/moe-embedding, is pointer only (licence: NONE) · get_code("aecadcaa2ac48b1b")
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 tianyi-lab/moe-embedding, 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_varsize Ran
ran; our contract draft was wrong, not the code
contextualai/gritlm/rag/dist_utils.py
code served (permissive licence) · get_code("89b5c380d2c5ffda")
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 Tensor, ndim 1, dtype family int, shape (1,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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.distributed as dist

torch.manual_seed(0)

# Create a small tensor with distinct dimensions
x = torch.randn(2, 4)

# Set dim parameter
dim = 0

# Build ARGS dictionary
ARGS = {
    "x": x,
    "dim": dim,
}
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 Tensor, ndim 1, dtype family int, shape (1,) — shape (1,) as a later run recorded it
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
gritlm_instruction_format Ran
ran; our contract draft was wrong, not the code
contextualai/gritlm/evaluation/eval_mteb.py
pointer only (licence: MIT); the stored copy get_code serves, from tianyi-lab/moe-embedding, is pointer only (licence: NONE) · get_code("62866964865efbd3")
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 tianyi-lab/moe-embedding, 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.

varsize_all_gather Ran
ran, violated the contract we drafted
contextualai/gritlm/rag/dist_utils.py
pointer only (licence: MIT); the stored copy get_code serves, from m3hrdadfi/rag-memory-interplay, is pointer only (licence: NONE) · get_code("fc996bc980b83cab")
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 m3hrdadfi/rag-memory-interplay, 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.

varsize_gather Ran
ran, violated the contract we drafted
contextualai/gritlm/rag/dist_utils.py
code served (permissive licence) · get_code("e7db08249643c567")
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 Tensor, ndim 4, dtype family float, shape (2, 4, 3, 5) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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.distributed as dist

torch.manual_seed(0)

# Since dist.is_initialized() will return False in non-distributed setup,
# the function will simply return x early. We still need to provide valid arguments.

# Create a simple tensor with distinct dimensions for probing
x = torch.randn(2, 4, 3, 5)

# dst parameter: rank to gather to
dst = 0

# dim parameter: dimension to gather along
dim = 1

ARGS = {
    "x": x,
    "dst": dst,
    "dim": dim,
}
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 Tensor, ndim 4, dtype family float, shape (2, 4, 3, 5) — shape (2, 4, 3, 5) as a later run recorded it
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
zephyr_instruction_format Ran
ran; our contract draft was wrong, not the code
contextualai/gritlm/evaluation/eval_mteb.py
pointer only (licence: MIT); the stored copy get_code serves, from tianyi-lab/moe-embedding, is pointer only (licence: NONE) · get_code("a591f38d473d9770")
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 tianyi-lab/moe-embedding, 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.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 7 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 7 later) and 3 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
get_gpus_max_memory 4 other papers
4 later
2408.09121 (2024-08)
Selective Prompt Anchoring for Code Generation
2410.10814 (2024-10)
Your Mixture-of-Experts LLM Is Secretly an Embedding Model For Free
2025.findings-acl.1384 (2025 (year only))
Accelerating Adaptive Retrieval Augmented Generation via Instruction-Driven Representation Reduction of Retrieval Overlaps
and 1 more not named here
cached 3 other papers
3 later
2404.04163 (2024-04)
Dwell in the Beginning: How Language Models Embed Long Documents for Dense Retrieval
2506.11350 (2025-06)
GLAP: General contrastive audio-text pretraining across domains and languages
2510.00523 (2025-10)
VIRTUE: Visual-Interactive Text-Image Universal Embedder
cat_input_tensor 3 other papers
3 later
2404.04163 (2024-04)
Dwell in the Beginning: How Language Models Embed Long Documents for Dense Retrieval
2506.11350 (2025-06)
GLAP: General contrastive audio-text pretraining across domains and languages
2510.00523 (2025-10)
VIRTUE: Visual-Interactive Text-Image Universal Embedder
gather_input_tensor 3 other papers
3 later
2404.04163 (2024-04)
Dwell in the Beginning: How Language Models Embed Long Documents for Dense Retrieval
2506.11350 (2025-06)
GLAP: General contrastive audio-text pretraining across domains and languages
2510.00523 (2025-10)
VIRTUE: Visual-Interactive Text-Image Universal Embedder
varsize_all_gather 3 other papers
1 dated earlier, 2 later
2308.07922 (2023-08)
RAVEN: In-Context Learning with Retrieval-Augmented Encoder-Decoder Language Models
2406.18847 (2024-06)
Learning Retrieval Augmentation for Personalized Dialogue Generation
2410.05162 (2024-10)
Deciphering the Interplay of Parametric and Non-parametric Memory in Retrieval-augmented Language Models
gritlm_instruction_format 2 other papers
2 later
2410.10814 (2024-10)
Your Mixture-of-Experts LLM Is Secretly an Embedding Model For Free
2605.30992 (2026-05)
Eigenvectors of Experts are Training-free Non-collapsing Routers
zephyr_instruction_format 2 other papers
2 later
2410.10814 (2024-10)
Your Mixture-of-Experts LLM Is Secretly an Embedding Model For Free
2605.30992 (2026-05)
Eigenvectors of Experts are Training-free Non-collapsing Routers

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

All text-based language problems can be reduced to either generation or embedding. Current models only perform well at one or the other. We introduce generative representational instruction tuning (GRIT) whereby a large language model is trained to handle both generative and embedding tasks by distinguishing between them through instructions. Compared to other open models, our resulting GritLM 7B sets a new state of the art on the Massive Text Embedding Benchmark (MTEB) and outperforms all models up to its size on a range of generative tasks. By scaling up further, GritLM 8x7B outperforms all open generative language models that we tried while still being among the best embedding models. Notably, we find that GRIT matches training on only generative or embedding data, thus we can unify both at no performance loss. Among other benefits, the unification via GRIT speeds up Retrieval-Augmented Generation (RAG) by > 60% for long documents, by no longer requiring separate retrieval and generation models. Models, code, etc. are freely available at https://github.com/ContextualAI/gritlm.

For agents

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

get_harvested_code_for_paper("2402.09906")
get_code_for_paper("2402.09906")
have("2402.09906")

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

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

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

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

Connect an agent — have() is free.