Skip to content
UBC-NLPPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

LatentMT

Machine Translation with Latent Reasoning

This repository contains the code, data recipes, and experiment pipeline for training machine translation systems with latent reasoning looped language models for the paper: LatentMT: Machine Translation with Latent Reasoning.

Contents


Overview of the pipeline

The pipeline has three stages that are launched from two entry points:

  1. Train and Inference are launched together by the single public launcher src/entrypoint_of_entrypoint.sh. It sweeps over the recurrent-depth values in UT_STEPS_VALUES, and for each one submits a training Slurm job followed by an inference job that depends on it. Each inference run id is appended to a manifest file (eval_run_ids.txt) as it is launched.
  2. Evaluation is launched separately from src/entrypoint_eval.sh. It reads the run-id manifest, computes CPU metrics (BLEU / chrF) locally, and submits a GPU Slurm job for COMET scoring.

1. Environment setup

The setup script src/prepare_env/run.sh creates virtual environments and downloads all required models.

export HF_TOKEN=YOUR_HF_TOKEN
bash src/prepare_env/run.sh

Data preparation

Each dataset is prepared from its original source as follows:

Dataset (registry key) Direction Recipe
drtMetaphorTrans English→Chinese data/DRT/README.md — copy the MetaphorTrans train/val/test JSONL from the DRT repo.
ArzEnMultiGenre English→Egyptian Arabic data/ArzEn-multiGenre/README.md — download from Mendeley Data and run processing.py.
oldi_flores200_eng_Latn-* English→(many) data/OLDI_seed_Flores200/README.md — download FLORES-200 + OLDI-seed and run hf_to_jsonl.py.

2. Running experiments

All training + inference runs go through the single public launcher src/entrypoint_of_entrypoint.sh. Run it from the repository root.

Adapting the pipeline to your own experiments

To run your own experiments, change the environment variables you pass to the launcher. The most common knobs:

  • Dataset — set TRAIN_DATASET_NAME / INFER_DATASET_NAME to any registry key.
  • New datasets — to train on a dataset that is not already registered, write its train/validation/test splits as JSONL where each row has id, text (source), trans (reference translation), and a metadata object. Then register them by adding a DatasetSpec entry to DATASET_REGISTRY in src/dataset_preparer.py.
  • Recurrent-depth sweep — UT_STEPS_VALUES is a comma-separated list of recurrent depths to sweep (e.g. UT_STEPS_VALUES=2,4,6).
  • Training — EPOCHS, PER_DEVICE_TRAIN_BATCH_SIZE, GRADIENT_ACCUMULATION_STEPS, and the LoRA knobs LORA_R, LORA_ALPHA, LORA_DROPOUT.
  • Inference — PIPELINE_INFER_MODE (lora to use the trained adapter, or base for the base model), SHOT_MODE (zero, few, or both), NUM_SHOTS, TEMPERATURE, TOP_P, DO_SAMPLE.

Evaluation

Evaluation can be run after inference completes. src/entrypoint_eval.sh reads the run-id manifest that the pipeline populated (eval_run_ids.txt), computes CPU metrics locally, and submits a Slurm GPU job for COMET:

bash src/entrypoint_eval.sh

3. Reproducing the experimental results

The command below reproduces our DRT (MetaphorTrans, English→Chinese) results. To reproduce our results on the other datasets, swap TRAIN_DATASET_NAME / INFER_DATASET_NAME for another registry key and adjust the hyperparameters:

MODEL_NAME_OR_PATH="$PWD/my_custom_models/my_ouro2p6_thinking" \
ENABLE_SLURM_TMPDIR_STAGING=0 \
QUICK_TEST=0 \
RUN_TRAIN=1 \
RUN_INFERENCE=1 \
RUN_EVAL=0 \
TRAIN_DATASET_NAME=drtMetaphorTrans \
INFER_DATASET_NAME=drtMetaphorTrans \
UT_STEPS_VALUES=1,2,3,4,5,6 \
EPOCHS=3 \
LEARNING_RATES=2e-4 \
LORA_R=32 \
LORA_ALPHA=64 \
PIPELINE_INFER_MODE=lora \
SHOT_MODE=zero \
TRAIN_THINK_MODE=off \
INFER_THINK_MODE=off \
SKIP_GIT_SYNC=1 \
bash src/entrypoint_of_entrypoint.sh

Cite

Please consider citing if our paper/code is helpful to you:

@misc{chen2026latentmtmachinetranslationlatent,
      title={LatentMT: Machine Translation with Latent Reasoning},
      author={Wei-Rui Chen and Samar M. Magdy and Chiyu Zhang and Wenhui Zhu and Zhipeng Wang and Muhammad Abdul-Mageed},
      year={2026},
      eprint={2607.18618},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2607.18618},
}

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages