SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2607.19181 · 2026

Reasoning Before Translation: Enhancing Legal Machine Translation with Structured Reasoning

Andreas Fischer, Aixiu An, Michael Jungo, Eloi Eynard, Mark Drenhaus, Jean Hennebert, Sébastien Rumley

arXiv · PDF · Open in the Atlas

Code that ran

4 of 6 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, 1 violated it and 0 have no contract verdict; 2 failures of our instrument; 2 no recorded run), measured 2026-11-23; 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/2607.19181.json · badge: /api/ran/2607.19181.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
aixiuxiuxiu/Legal-MT-SFT-RL canonical (classifier label)
classifier basis: census
4 ran · 2 no recorded run
FunctionStatusWhere it lives
create_prompt Ran
ran; our contract draft was wrong, not the code
aixiuxiuxiu/Legal-MT-SFT-RL/convert_jsonl_to_prompts.py
code served (permissive licence) · get_code("07986447a705f50c")
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

LANGUAGE_CODES = {'fr': 'French', 'de': 'German', 'it': 'Italian', 'en': 'English', 'rm': 'Romansh'}

PROMPT_SIMPLE = '### Instruction\nTranslate the following sentence from {lang_source} to {lang_target} while respecting Swiss legal parlance.\n\n### Input\n{source}'

def create_prompt(data, prompt_template=PROMPT_SIMPLE):
    prompt = prompt_template.format(lang_source=LANGUAGE_CODES[data['src_lang']], lang_target=LANGUAGE_CODES[data['tgt_lang']], source=data['src_sent'])
    return dict(question=prompt)

data = {
    'src_lang': 'en',
    'tgt_lang': 'fr',
    'src_sent': 'The contract is hereby terminated.'
}

ARGS = {
    'data': data,
    'prompt_template': PROMPT_SIMPLE
}
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
sync_tensor Ran
ran, honoured the contract we drafted
aixiuxiuxiu/Legal-MT-SFT-RL/dist.py
code served (permissive licence) · get_code("cf24bed17decd364")
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 2, dtype family float, shape (2, 4) 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 context,
# the function will hit the early return and just return the tensor as-is.
# We'll construct arguments that work in this single-process scenario.

# Create a small tensor for testing
tensor = torch.randn(2, 4)

# Test with different reduction modes
ARGS = {
    'tensor': tensor,
    'reduction': 'mean'
}
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 2, dtype family float, shape (2, 4) — shape (2, 4) 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
sync_values Ran
ran, violated the contract we drafted
aixiuxiuxiu/Legal-MT-SFT-RL/dist.py
code served (permissive licence) · get_code("0cad9a69338db41a")
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

torch.manual_seed(0)

ARGS = {
    'values': [1.5, 2.3, 3.7],
    'device': torch.device('cpu'),
    'reduction': 'mean'
}
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 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
unwrap_tokeniser Ran
ran; our contract draft was wrong, not the code
aixiuxiuxiu/Legal-MT-SFT-RL/model/utils.py
code served (permissive licence) · get_code("34ba62ccba3d3211")
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 MockTokenizer. 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 transformers import PreTrainedTokenizerBase

class MockTokenizer(PreTrainedTokenizerBase):
    """Minimal tokenizer implementation for testing."""
    def __init__(self):
        # PreTrainedTokenizerBase requires these minimal attributes
        self.model_max_length = 512
        self.vocab_size = 1000
        
    def get_vocab(self):
        return {str(i): i for i in range(self.vocab_size)}
    
    @property
    def vocab_size(self):
        return self._vocab_size
    
    @vocab_size.setter
    def vocab_size(self, value):
        self._vocab_size = value

class MockProcessor:
    """Processor with a tokenizer attribute."""
    def __init__(self):
        self.tokenizer = MockTokenizer()

# Test case 1: processor with tokenizer attribute
processor_with_tokenizer = MockProcessor()

# Test case 2: tokenizer passed directly (no processor wrapper)
tokenizer_direct = MockTokenizer()

ARGS = {
    "processor": processor_with_tokenizer
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MockTokenizer — a MockTokenizer output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MockTokenizer 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
init Not yet run
unverified (harvested, no recorded run)
aixiuxiuxiu/Legal-MT-SFT-RL/dist.py
code served (permissive licence) · get_code("968bb0ff4e9f3f20")
How it ran

no invocation recorded.

unwrap_model Not yet run
unverified (harvested, no recorded run)
aixiuxiuxiu/Legal-MT-SFT-RL/model/utils.py
code served (permissive licence) · get_code("0c3ff94987c68b53")
How it ran

no invocation recorded.

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

Repositories linked to this paper

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

Abstract

Neural machine translation (NMT) in the legal domain is a linguistically and conceptually demanding task, primarily due to the complexity of legal language and the high level of precision it requires. The recent emergence of reasoningcapable language models opens new possibilities for tackling such challenges. They add to a set of other previously proposed techniques to enhance the translation quality, which includes supervised fine-tuning and reinforcement learning. In this work, we perform a comparison between these various approaches. More particularly, we evaluate small language models such as Qwen3.5 4B, Qwen3.5 9B, and Gemma 3 12B enhanced with various re-training paradigms and compare their performances against frontier reasoning models. We focus on the Swiss legal system, which-with its unique multilingual statutes-offers a particularly challenging testbed for reasoning-augmented models. Our results show that the quality of small "base" models can be greatly enhanced, and that reinforcement learning with verifiable rewards can be applied to NMT in the legal domain and surpasses the translation quality of supervised fine-tuning. The performance of enhanced small models is close to the one of state-of-the-art reasoning models yet remains inferior. We also note that re-training paradigms yield diminishing returns as model size increase. The code and models are publicly available at https://github.com/aixiuxiuxiu/Legal-MT-SFT-RL.

For agents

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

get_harvested_code_for_paper("2607.19181")
get_code_for_paper("2607.19181")
have("2607.19181")

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

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

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

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

Connect an agent — have() is free.