SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2607.26654 · 2026

Constitutional Midtraining: Content Presence Drives Alignment Gains

Jun Zhao, Hunar Batra, Cameron Tice, Puria Radmard, Nigel Shadbolt, Desiree Cho, Bernie Hogan

arXiv · PDF · Open in the Atlas

Code that ran

10 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; 1 honoured the contract we drafted, 3 violated it and 0 have no contract verdict; 6 failures of our instrument; 4 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/2607.26654.json · badge: /api/ran/2607.26654.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
desBugger/constitutional-mt canonical (classifier label)
classifier basis: census
10 ran · 4 no recorded run
FunctionStatusWhere it lives
build_user_prompt Ran
ran; our contract draft was wrong, not the code
desBugger/constitutional-mt/data_generation/build_prompts.py
code served (permissive licence) · get_code("50b09888949bbb57")
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 numpy as np

# Define the arguments for build_user_prompt
cluster_data = {
    'cluster_name': 'Safety and Security',
    'cluster_label': 'SS-01',
    'values': [
        {
            'name': 'Transparency',
            'definition': 'The ability to understand and explain AI system decisions'
        },
        {
            'name': 'Accountability',
            'definition': 'Responsibility for AI system actions and outcomes'
        },
        {
            'name': 'Fairness',
            'definition': 'Equitable treatment across all user groups'
        }
    ]
}

combo = {
    'doc_type': 'Policy Document',
    'ai_system_type': 'Large Language Model',
    'domain': 'Healthcare',
    'framing': 'Regulatory Compliance'
}

doc_index = 5

primary_value = 'Transparency'

ARGS = {
    'cluster_data': cluster_data,
    'combo': combo,
    'doc_index': doc_index,
    'primary_value': primary_value
}
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 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
extract_fields_via_boundary Ran
ran; our contract draft was wrong, not the code
desBugger/constitutional-mt/data_generation/parse_results.py
code served (permissive licence) · get_code("6c288926817a527b")
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 json
import re

def extract_fields_via_boundary(raw_text: str):
    """Last-resort parser: extract content using the metadata boundary."""
    pv_match = re.search('"primary_value"\\s*:\\s*"([^"]*)"', raw_text)
    if not pv_match:
        return None
    content_marker = '"content": "'
    content_start_pos = raw_text.find(content_marker)
    if content_start_pos == -1:
        return None
    content_start_pos += len(content_marker)
    meta_boundary = re.search('",\\s*\\n\\s*"metadata"\\s*:', raw_text)
    if not meta_boundary:
        return None
    content_end_pos = meta_boundary.start()
    content = raw_text[content_start_pos:content_end_pos]
    content = content.replace('\\n', '\n').replace('\\t', '\t')
    content = content.replace('\\"', '"').replace('\\\\', '\\')
    meta_match = re.search('"metadata"\\s*:\\s*(\\{[^{}]*\\})', raw_text, re.DOTALL)
    if not meta_match:
        return None
    try:
        metadata = json.loads(meta_match.group(1))
    except json.JSONDecodeError:
        return None
    return {'primary_value': pv_match.group(1), 'content': content, 'metadata': metadata}


# Create a valid raw_text string that matches the expected format
raw_text = '''{
    "primary_value": "test_value",
    "content": "This is the main content with some text",
    "metadata": {"key": "value", "count": 42}
}'''

ARGS = {
    'raw_text': raw_text
}
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
fix_content_field Ran
ran; our contract draft was wrong, not the code
desBugger/constitutional-mt/data_generation/parse_results.py
code served (permissive licence) · get_code("9bc9d22d6fb5a32c")
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

# The function takes a raw_text string parameter
# It processes JSON-like content by finding the "content" field and escaping newlines

ARGS = {
    "raw_text": '{"message": "content": "Hello\nWorld\r\nTest\tTab"}'
}
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_docs Ran
ran; our contract draft was wrong, not the code
desBugger/constitutional-mt/data_generation/browse_docs.py
code served (permissive licence) · get_code("60f46b15846d0823")
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 json
from pathlib import Path
import tempfile
import os

# Create a temporary directory structure with test data
temp_dir = tempfile.mkdtemp()
data_output_dir = os.path.join(temp_dir, 'data', 'output')
os.makedirs(data_output_dir, exist_ok=True)

# Create test JSONL files for different suffixes
test_docs = [
    {"id": 1, "text": "document one"},
    {"id": 2, "text": "document two"}
]

for suffix in ['pilot', 'fullgen', 'DR', 'noDR']:
    file_path = os.path.join(data_output_dir, f'test_cluster_{suffix}.jsonl')
    with open(file_path, 'w') as f:
        for doc in test_docs:
            f.write(json.dumps(doc) + '\n')

# Change to temp directory so relative paths work
original_dir = os.getcwd()
os.chdir(temp_dir)

ARGS = {
    'cluster': 'test_cluster',
    'fullgen': False,
    'DR': False,
    'noDR': False
}
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 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
n_docs Ran
ran, honoured the contract we drafted
desBugger/constitutional-mt/data_generation/build_training_mix.py
code served (permissive licence) · get_code("0b517b95a13d1ffd")
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 int, ndim 0, dtype family int, 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

torch.manual_seed(0)

# The function n_docs takes target_tokens and mean_tokens
# and returns round(target_tokens / mean_tokens)
# Both parameters are used in simple numeric division, so they should be numbers

target_tokens = 1000
mean_tokens = 50

ARGS = {
    "target_tokens": target_tokens,
    "mean_tokens": mean_tokens,
}
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 int, ndim 0, dtype family int, 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
run_checkpoint Ran
ran, violated the contract we drafted
desBugger/constitutional-mt/cycle.py
code served (permissive licence) · get_code("e787e98b64a9124e")
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; 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 subprocess
import sys
from pathlib import Path

# Create minimal valid arguments for run_checkpoint
cp = {
    'id': 'test_checkpoint_001'
}

config_path = Path('/tmp/test_config.yaml')

force = False

env = {
    'PATH': '/usr/local/bin:/usr/bin:/bin',
    'PYTHONPATH': str(Path.cwd())
}

ARGS = {
    'cp': cp,
    'config_path': config_path,
    'force': force,
    'env': env
}
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 — no output shape is stated: observe_signature.py could not observe it (import:NameError)
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
run_checkpoint Ran
ran, violated the contract we drafted
desBugger/constitutional-mt/cycle_topup.py
code served (permissive licence) · get_code("09d411ac3c882d70")
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; 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 subprocess
import sys
from pathlib import Path
import tempfile
import os

# Create a minimal config file for testing
with tempfile.NamedTemporaryFile(mode='w', suffix='.yaml', delete=False) as f:
    f.write("# minimal config\n")
    config_path = Path(f.name)

# Define checkpoint dict with required 'id' key
cp = {
    'id': 'test_checkpoint_001'
}

# Define force flag
force = False

# Define environment dict - can be current env or minimal env
env = os.environ.copy()

ARGS = {
    'cp': cp,
    'config_path': config_path,
    'force': force,
    'env': env
}
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 — no output shape is stated: observe_signature.py could not observe it (import:NameError)
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
sample_docs Ran
ran; our contract draft was wrong, not the code
desBugger/constitutional-mt/data_generation/build_training_mix.py
code served (permissive licence) · get_code("7910d22452b0ff5b")
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 random

# Construct docs as a list of strings (simple document representations)
docs = ["doc_one", "doc_two", "doc_three", "doc_four", "doc_five"]

# Create an rng object - use random.Random() for the shuffle and sample methods
rng = random.Random(42)

# Set n to a value that will test the cycling behavior
n = 12

ARGS = {
    "docs": docs,
    "n": n,
    "rng": rng,
}
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 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
strip_reasoning Ran
ran; our contract draft was wrong, not the code
desBugger/constitutional-mt/data_generation/strip_reasoning.py
code served (permissive licence) · get_code("4c3bdecc5a88ccf7")
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 re

def strip_reasoning(content: str) -> str:
    stripped = re.sub('<reasoning>.*?</reasoning>', '', content, flags=re.DOTALL)
    stripped = re.sub('\\n{3,}', '\n\n', stripped)
    return stripped.strip()

ARGS = {
    'content': '<reasoning>This is reasoning</reasoning>\nSome text\n\n\n\nMore text'
}
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
wait_for_vllm Ran
ran, violated the contract we drafted
desBugger/constitutional-mt/cycle.py
code served (permissive licence) · get_code("ca9cc778c2776e58")
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; 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 subprocess
import time
from unittest.mock import Mock, patch

# Create a mock subprocess.Popen object that simulates a running process
mock_proc = Mock(spec=subprocess.Popen)
mock_proc.poll.return_value = None  # Process is still running
mock_proc.returncode = None

ARGS = {
    'proc': mock_proc,
    'timeout': 30
}
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 — no output shape is stated: observe_signature.py could not observe it (no_result)
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
load_docs Not yet run
unverified (harvested, no recorded run)
desBugger/constitutional-mt/data_generation/build_training_mix.py
code served (permissive licence) · get_code("d5de4d72e27e8042")
How it ran

no invocation recorded.

start_vllm Not yet run
unverified (harvested, no recorded run)
desBugger/constitutional-mt/cycle.py
code served (permissive licence) · get_code("d7a146169763af48")
How it ran

no invocation recorded.

start_vllm Not yet run
unverified (harvested, no recorded run)
desBugger/constitutional-mt/cycle_s3.py
code served (permissive licence) · get_code("2040e2000c11f305")
How it ran

no invocation recorded.

start_vllm Not yet run
unverified (harvested, no recorded run)
desBugger/constitutional-mt/cycle_topup.py
code served (permissive licence) · get_code("0491df7f0ed5c161")
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, 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 14 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

Post-training alignment is often shallow, eroding under finetuning. It remains untested as to whether constitutional midtraining interventions can produce durable alignment when cleanly isolated from post-training. We build a 394M-token constitutional corpus from Anthropic's Constitution and apply constitutional midtraining at 120B scale, where principled, values-based content is inserted into midtraining. A 2×2 design (curriculum ordering x deliberative reasoning) was used to produce four constitutionally midtrained conditions, plus a control, which were evaluated on self-generated and established benchmarks including alignment under pressure, value conflict resolution, blackmail, and emergent misalignment. All models were evaluated across three stages: post-midtraining, post-SFT, and post-benign fine-tuning. Constitutionally midtrained models outperformed the control on alignment generalization and durability, notably on blackmail: SFT instilled a blackmail propensity in all models, but constitutional midtraining blunted it, with the advantage surviving benign fine-tuning (-17.5pp). This durability did not extend to settings that required active resistance to incontext pressure or conflict, where the advantage attenuated after SFT. The presence of constitutional content at midtraining also mattered more than its structure, and constitutional midtraining incurred no capability cost, on average, at any stage (MMLU, ARC-Easy, piqa, GSM8K). A modest amount of constitutional content at midtraining could therefore yield broad, persistent alignment gains, offering a cheap, complementary addition to SFT-centered pipelines. Code, data, and models are available (see below).

For agents

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

get_harvested_code_for_paper("2607.26654")
get_code_for_paper("2607.26654")
have("2607.26654")

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

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

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

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

Connect an agent — have() is free.