A newer version of the Gradio SDK is available: 6.28.0
metadata
title: CTFAlign Demo
emoji: 🔗
colorFrom: indigo
colorTo: green
sdk: gradio
sdk_version: 5.9.1
app_file: app.py
pinned: false
license: mit
short_description: Demo of document-level word alignment algorithms.
preload:
- Qwen/Qwen3-Embedding-4B
- jhu-clsp/mmBERT-base
- sentence-transformers/LaBSE
CTFAlign · Document-level Word Alignment — demo
Interactive demo for CTFAlign: choose one of the models from the paper's experiments, paste a document pair, and see the predicted word alignments. Hover a word to highlight its aligned counterpart(s) in the other text.
- Model — experiment models with a document-level tuned layer: Qwen3-Embedding-4B (default), LaBSE, mmBERT-base.
- Method —
ctfalign(default) ormdpalign. - Mode — base SimAlign variant:
argmax(default) oritermax. - Language pair — used to pick the tuned encoder layer; leave on
(auto)to use the modal-best layer for the model. Layer and k/w are auto-filled with the values actually used (from the model / language pair / method) and stay editable. - Context window — small-context models (LaBSE, 512 tokens) warn when a document exceeds their limit; prefer a larger-context model for long documents.
Exporting Alignment Labels
Export alignment (accordion under the viewer) exposes the same result the
/align endpoint returns: the Pharaoh string (i-j …,), a copyable table of aligned pairs with their surface strings, the full
JSON, and alignment.json / alignment.talp downloads.
Programmatically:
from gradio_client import Client
r = Client("miwytt/ctfalign-demo").predict(
"mmBERT-base", "ctfalign", "argmax", "(auto)", None, None,
source_text, target_text, "auto", api_name="/align",
)
r["pharaoh"] # "0-0 1-1 2-4 ..."
r["alignment"] # [{"s": 0, "t": 0, "source": "...", "target": "..."}, ...]
r["source"]["units"] # the units the indices refer to
r["source"]["level"] # "word" or "subword" (indices are meaningless without it)
r["config"] # model / method / mode / layer / k / segmentation actually used
r["baseline_simalign"] # the unconstrained SimAlign baseline, same shapes
r["warnings"] # e.g. the text was chunked -> degraded quality
Run locally with pip install -r requirements.txt gradio && python app.py.