SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1811.01100 · 2018

Prior Knowledge Integration for Neural Machine Translation using Posterior Regularization

arXiv · PDF · Open in the Atlas

Code that ran

5 of 8 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, 0 violated it and 5 have no contract verdict; 0 failures of our instrument; 3 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/1811.01100.json · badge: /api/ran/1811.01100.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
Glaceon31/PR4NMT canonical (classifier label)
classifier basis: census
5 ran · 3 no recorded run
FunctionStatusWhere it lives
getUnique Ran
ran on a synthesized input
Glaceon31/PR4NMT/thumt/mrt_utils.py
code served (permissive licence) · get_code("c42b5207b9898fb3")
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. 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

torch.manual_seed(0)

# Build a minimal config dict with required keys
config = {
    'index_eos_trg': 2,  # End-of-sentence token index
}

# Build y: a numpy array representing an indexed target sentence
# Should be a 2D array that can be squeezed to 1D
y = np.array([[1, 5, 3, 2, 0, 0]])  # shape (1, 6), contains EOS token at index 2

# Build samples: a 2D numpy array of sampled hypotheses
# Each column is a different sample
samples = np.array([
    [1, 5, 4, 2],
    [5, 3, 6, 2],
    [3, 2, 2, 2],
])  # shape (3, 4) - 3 tokens, 4 samples

# Build a minimal model (not actually used in getUnique, but required as parameter)
class DummyModel(torch.nn.Module):
    def __init__(self):
        super(DummyModel, self).__init__()
        self.linear = torch.nn.Linear(10, 10)
    
    def forward(self, x):
        return self.linear(x)

model = DummyModel()

# Build a minimal data collection class (not actually used in getUnique, but required as parameter)
class DataCollection:
    def __init__(self):
        self.vocab_size = 100
    
    def get_vocab(self):
        return list(range(100))

data = DataCollection()

# Construct the ARGS dictionary with all parameters
ARGS = {
    'samples': samples,
    'y': y,
    'config': config,
    'model': model,
    'data': data,
}
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 tuple — a tuple output has no array shape of its own; none is 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
getYM Ran
ran on a synthesized input
Glaceon31/PR4NMT/thumt/mrt_utils.py
code served (permissive licence) · get_code("7357ce5e5a8a5157")
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 numpy

# Create sample indexed sentences (list of lists of integers)
# Each inner list represents a sentence with word indices
y = [
    [1, 2, 3],           # First sentence with 3 tokens
    [4, 5, 6, 7, 8],     # Second sentence with 5 tokens
]

# Create configuration dict with the required key
config = {
    'index_eos_trg': 0  # End-of-sequence token index for target
}

ARGS = {
    'y': y,
    'config': config
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — 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
getbatch Ran
ran on a synthesized input
Glaceon31/PR4NMT/thumt/data.py
code served (permissive licence) · get_code("767594de05c41d6c")
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 numpy

# Create small sample data
# lx: list of 1-D numpy arrays representing source sentences
lx = [
    numpy.array([1, 2, 3], dtype='int64'),
    numpy.array([4, 5], dtype='int64'),
]

# ly: list of 1-D numpy arrays representing target sentences
ly = [
    numpy.array([10, 11, 12], dtype='int64'),
    numpy.array([20, 21], dtype='int64'),
]

# config: dictionary with required keys
config = {
    'maxlength': 10,
    'index_eos_src': 0,
    'index_eos_trg': 0,
}

ARGS = {
    'lx': lx,
    'ly': ly,
    'config': config,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — 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
load_config Ran
ran on a synthesized input
Glaceon31/PR4NMT/thumt/config.py
code served (permissive licence) · get_code("2ae23dcd48d34547")
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 json

torch.manual_seed(0)

# The load_config function takes a single parameter 'config' which can be:
# 1. A JSON string
# 2. A config string in "key: value" format with optional comments

# Test case 1: JSON format
json_config = {
    "batchsize": 50,
    "save_freq": 10000,
    "model": "RNNsearch",
    "dim_rec_enc": 1000
}
json_config_str = json.dumps(json_config)

# Test case 2: Custom format with comments
custom_config_str = """
batchsize: 100
save_freq: 5000
beam_size: 12
model: 'RNNsearch'  # This is a comment
maxlength: 75  # Another comment
"""

# Use the JSON format as the main test case
ARGS = {
    "config": json_config_str
}
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 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
update_config Ran
ran on a synthesized input
Glaceon31/PR4NMT/thumt/config.py
code served (permissive licence) · get_code("eb12977ef9c8db5b")
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 torch.nn as nn

torch.manual_seed(0)

# Create a minimal config dictionary
base_config = {
    'model': 'RNNsearch',
    'src_text': '',
    'trg_text': '',
    'src': '',
    'trg': '',
    'src_shuf': '',
    'trg_shuf': '',
    'vocab_src': '',
    'vocab_trg': '',
    'ivocab_src': '',
    'ivocab_trg': '',
    'data_corpus': 'json',
    'data_vocab': 'cPickle',
    'index_unk_src': 1,
    'index_unk_trg': 1,
    'index_eos_src': 30000,
    'index_eos_trg': 30000,
    'num_vocab_src': 30001,
    'num_vocab_trg': 30001,
    'dim_rec_enc': 1000,
    'dim_rec_dec': 1000,
    'dim_emb_src': 620,
    'dim_emb_trg': 620,
    'maxout': 2,
    'maxlength': 50,
    'sort_batches': 20,
    'batchsize': 80,
    'max_iter': 1000000,
    'try_iter': 100000,
    'sample_freq': 100,
    'sample_length': 50,
    'n_samples': 1,
    'sample_times': 1,
    'sample_sentence': '',
    'save': True,
    'save_freq': 2000,
    'save_path': 'models',
    'checkpoint_freq': 2000,
    'checkpoint_model': 'checkpoint_model.npz',
    'checkpoint_status': 'checkpoint_status.pkl',
    'optimizer': 'adadelta',
    'lr': 1.0,
    'rho': 0.95,
    'epsilon': 1e-06,
    'clip': 1.0,
    'alpha_adam': 0.0005,
    'alphadecay_adam': 0.998,
    'beta1_adam': 0.9,
    'beta2_adam': 0.999,
    'eps_adam': 1e-08,
    'MRT': False,
    'init_model': 'models/model_best.npz',
    'sampleN': 100,
    'LenRatio': 1.5,
    'MRT_alpha': 0.005,
    'semi_learning': False,
    'reconstruct_lambda': 0.1,
    'auto_lambda_1': 1,
    'auto_lambda_2': 10,
    'semi_sampleN': 10,
    'sample_num': 10,
    'PR': False,
    'sampleN_PR': 80,
    'LenRatio_PR': 1.5,
    'sample_attn': False,
    'lambda_PR': 0.0001,
    'lambda_MLE': 0.0004,
    'alpha_PR': 0.2,
    'features_PR': ['feature_word'],
    'word_table': '',
    'feature_weight_word': 1.0,
    'phrase_table': '',
    'max_phrase_length': 4,
    'feature_weight_phrase': 1.0,
    'length_ratio': 1.236,
    'feature_weight_length_ratio': 1.0,
    'feature_weight_wordcount': 1.0,
    'feature_weight_attention_coverage': 1.0,
    'valid_dir': 'validation',
    'test_dir': 'eval',
    'valid_src': '',
    'valid_ref': '',
    'test_src': [],
    'test_ref': [],
    'beam_size': 10,
}

# Create update dictionary with some modifications
update_dict = {
    'model': 'RNNsearch_v2',
    'batchsize': 32,
    'lr': 0.5,
    'beam_size': 5,
}

ARGS = {
    'config': base_config,
    'dic': update_dict,
}
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 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
getMRTBatch Not yet run
unverified (harvested, no recorded run)
Glaceon31/PR4NMT/thumt/mrt_utils.py
code served (permissive licence) · get_code("878f83660a5bd125")
How it ran

no invocation recorded.

load_model_and_data Not yet run
unverified (harvested, no recorded run)
Glaceon31/PR4NMT/thumt/get_layer.py
code served (permissive licence) · get_code("efef39463944f659")
How it ran

no invocation recorded.

parse_config Not yet run
unverified (harvested, no recorded run)
Glaceon31/PR4NMT/thumt/config.py
code served (permissive licence) · get_code("fcd3927c403bea29")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 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 8 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

Although neural machine translation has made significant progress recently, how to integrate multiple overlapping, arbitrary prior knowledge sources remains a challenge. In this work, we propose to use posterior regularization to provide a general framework for integrating prior knowledge into neural machine translation. We represent prior knowledge sources as features in a log-linear model, which guides the learning process of the neural translation model. Experiments on Chinese-English translation show that our approach leads to significant improvements.

For agents

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

get_harvested_code_for_paper("1811.01100")
get_code_for_paper("1811.01100")
have("1811.01100")

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

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

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

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

Connect an agent — have() is free.