Skip to content

feat(model): retrain zh-hans and zh-hant models on Unicode corpora - #1467

Merged
tushuhei merged 2 commits into
mainfrom
feat/retrain-zh-unicode
Oct 26, 2026
Merged

tushuhei merged 2 commits into
mainfrom
feat/retrain-zh-unicode

Conversation

@tushuhei

Copy link
Copy Markdown
Member

Summary

Retrains the Simplified Chinese (budoux/models/zh-hans.json) and Traditional Chinese (budoux/models/zh-hant.json) models on the Unicode Test Corpora (gutenberg/*/out/google/breakpoints/zh-Hans and zh-Hant) using the updated LogitBoost pipeline.

Key Changes

  • scripts/prepare_unicode.py:
    • Support <bcp47_lang>_<flavor> model identifiers (e.g., zh-hans, zh-hant, ja_word) and map them to the corresponding Unicode Test Corpora directory (zh-Hans, zh-Hant, ja).
    • Add --line-break punctuation attachment mode so opening/closing CJK punctuation attaches to adjacent phrases while preserving spaces adjacent to ASCII alphanumerics/symbols (e.g. Project Gutenberg™).
    • Strip zero-width spaces (\u200b) and support deterministic --split-dir (train/val/test) generation.
  • scripts/run_training_pipeline.py:
    • Automatically prepare Unicode Test Corpora splits for zh-hans, zh-hant, and *_word models when splits do not yet exist.
    • Cap auto-balanced fine-tuning weight scaling at MAX_AUTO_WEIGHT_SCALE = 30 so small fine-tuning datasets do not overpower general corpus statistics.
  • Chinese AA Reduplication Fine-Tuning (data/finetuning/zh-hans/reduplications.txt, data/finetuning/zh-hant/reduplications.txt):
    • Add 31 neutral everyday sentences covering common Chinese AA/AABB reduplications (人人, 家家, 年年, 月月, 日日, 个个/個個, 层层/層層, 件件, 句句, 字字, 行行, etc.) that were sparse in the base Gutenberg literary corpus.
  • Retrained Models (budoux/models/zh-hans.json, budoux/models/zh-hant.json):
    • zh-hans.json: 95.49% test accuracy (95.45% F1) on the held-out test split.
    • zh-hant.json: 94.88% test accuracy (94.96% F1) on the held-out test split.

Test Plan

  • uv run pytest (192 passed)
  • uv run python scripts/lint_data.py
  • uv run ruff check .
  • uv run pyrefly check

Retrain Simplified Chinese (`budoux/models/zh-hans.json`) and Traditional
Chinese (`budoux/models/zh-hant.json`) models on the Unicode Test Corpora
with `--line-break` punctuation attachment, ASCII-adjacent space
preservation, and targeted fine-tuning samples for common Chinese AA
reduplications (`data/finetuning/zh-hans/reduplications.txt` and
`data/finetuning/zh-hant/reduplications.txt`).

Also update `scripts/run_training_pipeline.py` to:
- Support `<bcp47_lang>_<flavor>` model identifiers and automatic Unicode
  corpus preparation.
- Cap auto-balanced fine-tuning weight scaling at `MAX_AUTO_WEIGHT_SCALE = 30`
  so small fine-tuning datasets do not overpower general corpus statistics.

Change-Id: I91f88a34c49ef02c6293d33b8681f48ca3939821
@tushuhei
tushuhei requested a review from kojiishi October 26, 2026 00:55
kojiishi
kojiishi previously approved these changes Oct 26, 2026

@kojiishi kojiishi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tushuhei
tushuhei merged commit 0c2c1c1 into main Oct 26, 2026
41 checks passed
@tushuhei
tushuhei deleted the feat/retrain-zh-unicode branch October 26, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants