SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2601.19871 · 2026

Reflective Translation for Low-Resource Machine Translation via Structured Self-Reflection

Nicholas Cheng

arXiv · PDF · Open in the Atlas

Code that ran

6 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 4 failures of our instrument; 0 no recorded run), measured 2026-11-22; 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/2601.19871.json · badge: /api/ran/2601.19871.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
Nickcheng123/reflective-translation-mt community
Papers with Code archive
6 ran · 0 no recorded run
FunctionStatusWhere it lives
CometWrapper Ran
ran on a synthesized input · constructed an object; no result was computed
Nickcheng123/reflective-translation-mt/src/reflective_translation/pipeline.py
code served (permissive licence) · get_code("2326f8a4aa70e2b4")
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 an instance of its own class, CometWrapper: the run constructed the object and did not call it, so no result was computed. 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

class MockCometModel:
    """Mock COMET model that simulates the predict interface."""
    def predict(self, data):
        """
        Expects data as list of dicts with 'src', 'mt', 'ref' keys.
        Returns list of dicts with 'score' key.
        """
        results = []
        for item in data:
            results.append({'score': 0.75})
        return results

def mock_load_from_checkpoint(model_name):
    """Mock function to replace comet.load_from_checkpoint"""
    return MockCometModel()

# Patch the comet import in CometWrapper
import sys
from unittest.mock import MagicMock

mock_comet = MagicMock()
mock_comet.load_from_checkpoint = mock_load_from_checkpoint
mock_comet.download_model = MagicMock()
sys.modules['comet'] = mock_comet

from typing import Optional, Dict, Any

class CometWrapper:

    def __init__(self, model_name: str='Unloaded'):
        self.model = None
        self.model_name = model_name
        try:
            from comet import download_model, load_from_checkpoint
            self.model = load_from_checkpoint(model_name)
        except Exception:
            self.model = None

    def score(self, sources, references, hypotheses) -> Optional[float]:
        """Return average COMET score across examples or None if COMET not available."""
        if self.model is None:
            return None
        try:
            data = [{'src': s, 'mt': h, 'ref': r} for s, h, r in zip(sources, hypotheses, references)]
            results = self.model.predict(data)
            scores = [float(r.get('score', 0.0)) for r in results]
            return float(np.mean(scores)) if scores else None
        except Exception:
            return None

ARGS = {
    'model_name': 'wmt21-da-estimator'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
comet, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type CometWrapper — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a CometWrapper 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
baseline_prompt Ran
ran; our contract draft was wrong, not the code
Nickcheng123/reflective-translation-mt/src/reflective_translation/pipeline.py
code served (permissive licence) · get_code("70ed64456503729b")
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 = {
    'source': 'Hello, how are you today?',
    'src_lang': 'en',
    'tgt_lang': 'zu'
}
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
compute_bleu Ran
ran, honoured the contract we drafted
Nickcheng123/reflective-translation-mt/src/reflective_translation/pipeline.py
code served (permissive licence) · get_code("5ce1568daa37b696")
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 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.

from nltk.translate.bleu_score import corpus_bleu, SmoothingFunction

# The function expects:
# - references: Sequence[Sequence[str]] - a list of reference translations, where each reference is a list of token strings
# - hypotheses: Sequence[str] - a list of hypothesis translations (each is a string of tokens)

# Create simple token sequences
reference_1 = ["the", "cat", "sat", "on", "the", "mat"]
reference_2 = ["a", "cat", "is", "sitting", "on", "the", "mat"]
reference_3 = ["the", "cat", "was", "on", "the", "mat"]

# References should be a list where each element corresponds to one hypothesis
# and contains multiple reference translations for that hypothesis
references = [
    [reference_1, reference_2],
    [reference_3, reference_1]
]

# Hypotheses should be a list of hypothesis strings (one per reference set)
hypotheses = [
    "the cat sat on the mat",
    "the cat is on the mat"
]

ARGS = {
    "references": references,
    "hypotheses": hypotheses
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
nltk — 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
model_infer Ran
ran; our contract draft was wrong, not the code
Nickcheng123/reflective-translation-mt/src/reflective_translation/pipeline.py
code served (permissive licence) · get_code("99ab7c3011719ac0")
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 os
import torch

# Set seed for reproducibility
torch.manual_seed(0)

# The function takes three parameters: model_name (str), prompt (str), and dry_run (bool)
# Looking at the function body:
# - model_name: used in function signature, not used in body
# - prompt: used with .strip()[:120] in the dry_run path
# - dry_run: boolean flag that controls execution path

# Since the function checks environment variables and uses dry_run mode,
# we'll construct minimal valid arguments

model_name = "gpt-3.5-turbo"
prompt = "Translate this text to Spanish: Hello, how are you?"
dry_run = True

ARGS = {
    "model_name": model_name,
    "prompt": prompt,
    "dry_run": dry_run
}
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
process_translation_pair Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
Nickcheng123/reflective-translation-mt/src/reflective_translation/pipeline.py
code served (permissive licence) · get_code("b0f1323917dedcaf")
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 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 numpy as np
from typing import Dict, Any, Optional, Sequence

# Set up a default threshold for BLEU
DEFAULTS = {
    'bleu_threshold': 0.3
}

# Define ARGS dict with all parameters for process_translation_pair
ARGS = {
    'source': 'The quick brown fox jumps over the lazy dog',
    'reference': 'Indlulamithi emnyama ekhawuleza isigweba esilambile',
    'model_first': 'gpt-3.5-turbo',
    'model_second': 'claude-3.5-haiku',
    'bleu_threshold': 0.25,
    'comet_threshold': None,
    'dry_run': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
comet, nltk, numpy — 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
reflection_prompt Ran
ran; our contract draft was wrong, not the code
Nickcheng123/reflective-translation-mt/src/reflective_translation/pipeline.py
code served (permissive licence) · get_code("39ce8c6e46dc263f")
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 = {
    'source': 'The quick brown fox jumps over the lazy dog.',
    'first_translation': 'Inkosi yesikhumba esibrown isiphakamisela inja eluleka.',
    'src_lang': 'en',
    'tgt_lang': 'zu'
}
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

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 6 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.

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

Low-resource languages such as isiZulu and isiXhosa face persistent challenges in machine translation (MT) due to limited parallel corpora and scarce linguistic resources. Recent work on large language models (LLMs) suggests that self-reflection-the ability of a model to critique and revise its own outputs-can improve reasoning quality and factual consistency. Building on this idea, this paper presents Reflective Translation, a prompting framework in which an LLM internally evaluates and corrects its own translations through structured, multi-round prompting to improve semantic fidelity. The method is evaluated using GPT-3.5 and Claude Haiku 3.5 on English-isiZulu and English-isiXhosa sentence pairs drawn from OPUS-100 and NTREX-African. Translation quality is assessed using BLEU and COMET. Across settings, second-pass translations improve consistently relative to first-pass outputs. This paper further introduces a reflection-augmented dataset consisting of (source, draft, critique, revision) tuples, enabling reproducible analysis of reflective behavior. Overall, the results suggest that reflection-based prompting is a lightweight, modelagnostic approach for improving MT quality in under-resourced languages without fine-tuning or additional labeled data.

For agents

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

get_harvested_code_for_paper("2601.19871")
get_code_for_paper("2601.19871")
have("2601.19871")

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

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

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

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

Connect an agent — have() is free.