SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2402.03216 · 2024

M3-Embedding: Multi-Linguality, Multi-Functionality, Multi-Granularity Text Embeddings Through Self-Knowledge Distillation

arXiv · PDF · Open in the Atlas

Code that ran

11 of 14 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; 3 honoured the contract we drafted, 1 violated it and 2 have no contract verdict; 5 failures of our instrument; 3 no recorded run), measured 2026-11-21; 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.03216.json · badge: /api/ran/2402.03216.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
allen-li1231/treehop-rag community (classifier label)
classifier basis not recorded on the link
8 ran · 3 no recorded run
terrierteam/pyterrier_dr community (classifier label)
classifier basis not recorded on the link
3 ran · 0 no recorded run
FunctionStatusWhere it lives
accuracy Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
allen-li1231/treehop-rag/metrics.py
pointer only (licence: MIT); the stored copy get_code serves, from Haoang97/CausalProbe-2024, is pointer only (licence: NONE) · get_code("e76cf27d36723be3")
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 Haoang97/CausalProbe-2024, 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.

bounded_process_pool_map Ran
ran on a synthesized input
allen-li1231/treehop-rag/src/concurrency.py
code served (permissive licence) · get_code("46c70937101d407b")
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 torch
import numpy as np
from multiprocessing import get_context

# Define a simple picklable function for testing
def simple_computation(x):
    """A simple CPU-bound function that's picklable at module level."""
    return x * x + sum(range(x))

# Create items as (index, args_tuple) pairs
items = [
    (0, (5,)),
    (1, (10,)),
    (2, (15,)),
    (3, (20,)),
    (4, (25,)),
]

# Construct the ARGS dictionary with all required and optional parameters
ARGS = {
    'fn': simple_computation,
    'items': items,
    'num_workers': 2,
    'max_pending': 3,
    'total': 5,
    'progress_bar': True,
    'progress_desc': 'Processing tasks',
    'progress_position': 0,
    'progress_leave': True,
    'mp_context': None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch, tqdm — 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
gather Ran
ran, honoured the contract we drafted
allen-li1231/treehop-rag/src/dist_utils.py
pointer only (licence: MIT); the stored copy get_code serves, from facebookresearch/contriever, is pointer only (licence: NOASSERTION) · get_code("9fb6e57668661c38")
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 facebookresearch/contriever, and GitHub could not classify the licence of that repository (NOASSERTION). 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.

gather_nograd Ran
ran, honoured the contract we drafted
allen-li1231/treehop-rag/src/dist_utils.py
pointer only (licence: MIT); the stored copy get_code serves, from agwaBom/TPOUR, is pointer only (licence: NONE) · get_code("01971cc37e6fe583")
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 agwaBom/TPOUR, 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.

has_answer Ran
ran on a synthesized input
allen-li1231/treehop-rag/src/evaluation.py
code served (permissive licence) · get_code("88720c6e874a2b03")
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 bool, ndim 0, dtype family float, shape () 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 unicodedata

class SimpleTokenizer:
    """Minimal tokenizer that implements the tokenize method."""
    def tokenize(self, text, uncased=False):
        if uncased:
            text = text.lower()
        # Simple whitespace tokenization
        return text.split()

# Create instances for the function parameters
answers = ["hello world", "test case"]
text = "This is a hello world example with some test case content"
tokenizer = SimpleTokenizer()

ARGS = {
    "answers": answers,
    "text": text,
    "tokenizer": tokenizer
}
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 bool, ndim 0, dtype family float, shape () — shape () 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
hf_bucket_url Ran
ran; our contract draft was wrong, not the code
terrierteam/pyterrier_dr/pyterrier_dr/_star_tokenizer.py
code served (permissive licence) · get_code("b2be6c932ce41084")
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

ARGS = {
    'identifier': 'bert-base-uncased',
    'postfix': 'pytorch_model.bin',
    'cdn': False
}
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
is_remote_url Ran
ran, violated the contract we drafted
terrierteam/pyterrier_dr/pyterrier_dr/_star_tokenizer.py
code served (permissive licence) · get_code("4381d1f588a7f42a")
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 bool, ndim 0, dtype family float, shape () 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
from urllib.parse import urlparse

ARGS = {
    'url_or_filename': 'https://example.com/model.pth'
}
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 bool, ndim 0, dtype family float, shape () — shape () 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
metric_max_over_ground_truths Ran
ran; our contract draft was wrong, not the code
allen-li1231/treehop-rag/metrics.py
code served (permissive licence) · get_code("6829ceb72569fa12")
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) and returned float, ndim 0, dtype family float, shape () 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 numpy as np

torch.manual_seed(0)

def simple_metric_fn(prediction, ground_truth):
    """A simple metric function that computes similarity between two tensors."""
    if isinstance(prediction, torch.Tensor) and isinstance(ground_truth, torch.Tensor):
        return float(torch.nn.functional.cosine_similarity(
            prediction.unsqueeze(0), 
            ground_truth.unsqueeze(0)
        ).item())
    return 0.0

prediction = torch.randn(4)
ground_truths = [torch.randn(4), torch.randn(4), torch.randn(4)]

ARGS = {
    "metric_fn": simple_metric_fn,
    "prediction": prediction,
    "ground_truths": ground_truths,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () 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
randomcrop Ran
ran; our contract draft was wrong, not the code
allen-li1231/treehop-rag/src/data.py
pointer only (licence: MIT); the stored copy get_code serves, from facebookresearch/contriever, is pointer only (licence: NOASSERTION) · get_code("e037474365501512")
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 facebookresearch/contriever, and GitHub could not classify the licence of that repository (NOASSERTION). 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.

url_to_filename Ran
ran; our contract draft was wrong, not the code
terrierteam/pyterrier_dr/pyterrier_dr/_star_tokenizer.py
code served (permissive licence) · get_code("e827d94caab33f59")
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.

from hashlib import sha256

ARGS = {
    "url": "https://example.com/model.weights",
    "etag": "abc123def456"
}
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
varsize_gather_nograd Ran
ran, honoured the contract we drafted
allen-li1231/treehop-rag/src/dist_utils.py
pointer only (licence: MIT); the stored copy get_code serves, from facebookresearch/contriever, is pointer only (licence: NOASSERTION) · get_code("b1ad8cd3a7168b7f")
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 facebookresearch/contriever, and GitHub could not classify the licence of that repository (NOASSERTION). 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.

bounded_thread_pool_map Not yet run
unverified (harvested, no recorded run)
allen-li1231/treehop-rag/src/concurrency.py
code served (permissive licence) · get_code("be452e3c3f240a7c")
How it ran

no invocation recorded.

calculate_matches Not yet run
unverified (harvested, no recorded run)
allen-li1231/treehop-rag/src/evaluation.py
code served (permissive licence) · get_code("ab39d4a37bfc2be6")
How it ran

no invocation recorded.

check_answer Not yet run
unverified (harvested, no recorded run)
allen-li1231/treehop-rag/src/evaluation.py
code served (permissive licence) · get_code("9691cc44ab024ac1")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 11 are also present in other papers whose code we hold (8 with at least one paper dated earlier, 7 the same month, 10 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
calculate_matches 13 other papers
3 dated earlier, 3 the same month, 7 later
2112.08688 (2021-12)
Evidentiality-guided Generation for Knowledge-Intensive NLP Tasks
2401.03568 (2024-01)
Agent AI: Surveying the Horizons of Multimodal Interaction
2401.16979 (2024-01)
Re3val: Reinforced and Reranked Generative Retrieval
and 10 more not named here
check_answer 13 other papers
3 dated earlier, 3 the same month, 7 later
2112.08688 (2021-12)
Evidentiality-guided Generation for Knowledge-Intensive NLP Tasks
2401.03568 (2024-01)
Agent AI: Surveying the Horizons of Multimodal Interaction
2401.16979 (2024-01)
Re3val: Reinforced and Reranked Generative Retrieval
and 10 more not named here
url_to_filename 12 other papers
11 dated earlier, 1 later
1909.11942 (2019-09)
ALBERT: A Lite BERT for Self-supervised Learning of Language Representations
2004.09297 (2020-04)
MPNet: Masked and Permuted Pre-training for Language Understanding
2005.00796 (2020-05)
A Simple Language Model for Task-Oriented Dialogue
and 9 more not named here
varsize_gather_nograd 10 other papers
1 the same month, 9 later
2402.07867 (2024-02)
PoisonedRAG: Knowledge Corruption Attacks to Retrieval-Augmented Generation of Large Language Models
2403.06840 (2024-03)
RA-ISF: Learning to Answer and Understand from Retrieval Augmentation via Iterative Self-Feedback
2404.19705 (2024-04)
When to Retrieve: Teaching LLMs to Utilize Information Retrieval Effectively
and 7 more not named here
gather_nograd 9 other papers
1 the same month, 8 later
2402.07867 (2024-02)
PoisonedRAG: Knowledge Corruption Attacks to Retrieval-Augmented Generation of Large Language Models
2403.06840 (2024-03)
RA-ISF: Learning to Answer and Understand from Retrieval Augmentation via Iterative Self-Feedback
2404.19705 (2024-04)
When to Retrieve: Teaching LLMs to Utilize Information Retrieval Effectively
and 6 more not named here
gather 8 other papers
1 the same month, 7 later
2402.07867 (2024-02)
PoisonedRAG: Knowledge Corruption Attacks to Retrieval-Augmented Generation of Large Language Models
2403.06840 (2024-03)
RA-ISF: Learning to Answer and Understand from Retrieval Augmentation via Iterative Self-Feedback
2404.19705 (2024-04)
When to Retrieve: Teaching LLMs to Utilize Information Retrieval Effectively
and 5 more not named here
hf_bucket_url 8 other papers
7 dated earlier, 1 later
1909.11942 (2019-09)
ALBERT: A Lite BERT for Self-supervised Learning of Language Representations
2004.09297 (2020-04)
MPNet: Masked and Permuted Pre-training for Language Understanding
2005.00796 (2020-05)
A Simple Language Model for Task-Oriented Dialogue
and 5 more not named here
is_remote_url 7 other papers
7 dated earlier
1909.11942 (2019-09)
ALBERT: A Lite BERT for Self-supervised Learning of Language Representations
2004.09297 (2020-04)
MPNet: Masked and Permuted Pre-training for Language Understanding
2005.00796 (2020-05)
A Simple Language Model for Task-Oriented Dialogue
and 4 more not named here
randomcrop 7 other papers
1 dated earlier, 1 the same month, 5 later
2310.11511 (2023-10)
Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflection
2402.07867 (2024-02)
PoisonedRAG: Knowledge Corruption Attacks to Retrieval-Augmented Generation of Large Language Models
2403.06840 (2024-03)
RA-ISF: Learning to Answer and Understand from Retrieval Augmentation via Iterative Self-Feedback
and 4 more not named here
metric_max_over_ground_truths 6 other papers
3 dated earlier, 1 the same month, 2 later
2104.08773 (2021-04)
Cross-Task Generalization via Natural Language Crowdsourcing Instructions
2210.10861 (2022-10)
QA Domain Adaptation using Hidden Space Augmentation and Self-Supervised Contrastive Adaptation
2310.11511 (2023-10)
Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflection
and 3 more not named here
accuracy 3 other papers
1 dated earlier, 2 later
2310.11511 (2023-10)
Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflection
2406.11357 (2024-06)
Refiner: Restructure Retrieval Content Efficiently to Advance Question-Answering Capabilities
2506.21215 (2025-06)
Unveiling Causal Reasoning in Large Language Models: Reality or Mirage?

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-21.

Repositories linked to this paper

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

Abstract

In this paper, we introduce a new embedding model called M3-Embedding, which is distinguished for its versatility in \textit{Multi-Linguality}, \textit{Multi-Functionality}, and \textit{Multi-Granularity}. It provides a uniform support for the semantic retrieval of more than 100 working languages. It can simultaneously accomplish the three common retrieval functionalities: dense retrieval, multi-vector retrieval, and sparse retrieval. Besides, it is also capable of processing inputs of different granularities, spanning from short sentences to long documents of up to 8,192 tokens. The effective training of M3-Embedding presents a series of technical contributions. Notably, we propose a novel self-knowledge distillation approach, where the relevance scores from different retrieval functionalities can be integrated as the teacher signal to enhance the training quality. We also optimize the batching strategy, which enables a large batch size and high training throughput to improve the discriminativeness of embeddings. M3-Embedding exhibits a superior performance in our experiment, leading to new state-of-the-art results on multilingual, cross-lingual, and long-document retrieval benchmarks.

For agents

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

get_harvested_code_for_paper("2402.03216")
get_code_for_paper("2402.03216")
have("2402.03216")

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

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

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

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

Connect an agent — have() is free.