Repository navigation
feat(studio): add Hmong language support and detection in Translate (#18674) - #18737
Conversation
…ained on it Languages outside Hy-MT2's model card are marked chatOnly: the picker, the recent tabs and Detect language hide them while Hy-MT2 translates, a chat-only pick falls back to the last Hy-MT2 target when switching to it, and the browser-locale default target never picks one. Adds more common Hmong function words for detection. [skip ci]
…n languages branch
|
@codex review |
1 similar comment
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 82fe77b230
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| setPrefs: (patch) => { | ||
| const prefs = { ...get().prefs, ...patch }; | ||
| const prefs = fitLanguages({ ...get().prefs, ...patch }); |
There was a problem hiding this comment.
Preserve the language metadata of restored translations
After translating English→Hmong with a chat model, selecting Hy-MT2 and reopening that history entry makes restore() call setTarget("hmn"), which now silently falls back to another language, such as en. restore() then builds result and attempt from those coerced preferences while keeping the original Hmong output, so translationIsStale() returns false; read-aloud and outputToSource() consequently treat Hmong text as English. Preserve the history entry's actual language metadata and mark it stale or select a compatible model, rather than recording the fallback target as the language of the saved translation.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 3109555: restore keeps the entry's own from/target on the shown result, so a Hmong entry reopened under Hy-MT2 reads as stale and read aloud / use as source still treat it as Hmong (store test covers it).
Restoring a Hmong translation while Hy-MT2 is selected falls the target back to a Hy-MT2 language; the shown result now keeps the entry's languages, so it reads as stale and read aloud / use as source still treat it as Hmong.
# Conflicts: # studio/frontend/src/features/translate/languages.ts # studio/frontend/tests/translate-detect-language.test.ts # studio/frontend/tests/translate-page.test.ts # studio/frontend/tests/translate-store.test.ts
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3109555498
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ...resultOf(entry.source, get().prefs), | ||
| from, | ||
| ...(target ? { target } : {}), |
There was a problem hiding this comment.
Suppress auto-translation when restoring incompatible history
If autoTranslate is enabled and Hy-MT2 has already served a translation, restoring an English→Hmong entry while its fallback target is French makes shown.target (and therefore attempt.target) "hmn" while prefs.target is "fr". The auto-translation effect in translate-page.tsx (lines 1279–1299) sees that mismatch and schedules a new translation after 800 ms, so merely opening history clears the saved Hmong output from the pane and replaces it with French. Preserve the saved metadata on result, but suppress the automatic run for restores or keep the current-preferences scheduling snapshot separate from the displayed result.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b7a9eff: only result keeps the entry's languages; attempt matches the settings, so the as-you-type effect sees nothing to rerun and the saved output stays (store test asserts attempt.target == prefs.target after restore).
Only the shown result keeps the entry's languages; the attempt snapshot matches the settings, so translating as you type leaves the saved output.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
… since #18924 (#18942) ## Summary `Backend tests` (the `(Python 3.13, rest)` shard) is red on `main` since #18924: ``` tests/test_xformers_stub_diffusion_parity.py:407: in test_xformers_is_never_selected_on_a_rocm_target E AssertionError: assert None == 'aiter' ``` Both ROCm wheel parametrizations fail. It shows on unrelated PRs, for example the staging run for #18737, which only touches translate files. #18924 made an explicit `aiter` pick on ROCm run the auto pick when diffusers has no usable local aiter backend (`_diffusers_aiter_usable()`), so the pick no longer fails mid-render. That change is correct. #18924 patched `_diffusers_aiter_usable` in its own tests, but this older parity test still asserted that `aiter` is always honoured on a ROCm target. On a runner whose diffusers has no local aiter backend, which is every CI runner, that is no longer true. ## Fix The test now pins both outcomes explicitly instead of depending on the runner's diffusers: - With `_diffusers_aiter_usable` returning True, an `aiter` pick on ROCm is still `aiter`. - With it returning False, an `aiter` pick resolves to the same backend as `auto`. The xformers assertions the test exists for are unchanged. Only the test changes. ## Testing - `tests/test_xformers_stub_diffusion_parity.py`: 2 failed on `main`, all pass with this change. - The file plus `tests/test_diffusion_attention.py` and `tests/test_diffusion_attention_aiter_alias.py`: 193 passed. - Sabotage: with #18924's fallback (`if alias == "aiter" and _is_cuda_rocm(target) and not _diffusers_aiter_usable(): alias = ATTN_AUTO`) removed, the new no-aiter assertion fails for both ROCm wheels, alongside #18924's own `test_dead_aiter_on_rocm_is_the_auto_pick` cases.
# Conflicts: # studio/frontend/src/features/translate/detect-language.ts # studio/frontend/src/features/translate/languages.ts # studio/frontend/tests/translate-detect-language.test.ts # studio/frontend/tests/translate-page.test.ts
…nslothai#18723) (unslothai#18738) Related to unslothai#18723 ### Summary Adds official support and automatic script/language detection in Unsloth Translate for **Amharic (`am`)** along with popular African continent languages (**Swahili `sw`**, **Hausa `ha`**, **Yoruba `yo`**, **Igbo `ig`**, **Zulu `zu`**, **Afrikaans `af`**, and **Somali `so`**). ### Changes - **`studio/frontend/src/features/translate/languages.ts`** - Add `am` (Amharic), `sw` (Swahili), `ha` (Hausa), `yo` (Yoruba), `ig` (Igbo), `zu` (Zulu), `af` (Afrikaans), and `so` (Somali) to `TRANSLATE_LANGUAGES`. - **`studio/frontend/src/features/translate/detect-language.ts`** - Add `[/\p{Script=Ethiopic}/gu, "am"]` to `SINGLE_SCRIPT` so Ethiopic/Ge'ez script text is recognized as Amharic. - Add `sw`, `ha` (`"ɓɗƙ"`), `yo` (`"ẹọṣ"`), `ig` (`"ịụṅ"`), `zu`, `af`, and `so` entries to `LATIN`. - Exclude the four plain dot-below vowels (`ẹ`, `ị`, `ọ`, `ụ`) used by Yoruba and Igbo from the Vietnamese `/[ơưđăạ-ỹ]/gu` shortcut (`/(?![ẹịọụ])[ơưđăạ-ỹ]/gu`) so Yoruba and Igbo are not misclassified as Vietnamese. - **`studio/frontend/tests/translate-detect-language.test.ts`** - Add sentences and short phrases for `am`, `sw`, `ha`, `yo`, `ig`, `zu`, `af`, and `so` to `SENTENCES`, verifying all supported Translate languages are recognized without collisions. ### Before and After #### Before  #### After  ### Verification - `node --experimental-strip-types --test tests/translate-*.test.ts` (`studio/frontend`): 54/54 passed - `npm run typecheck` (`studio/frontend`): passed (0 errors) ### Maintainer follow-ups This branch builds on unslothai#18737 (merged in), which marks languages outside Hy-MT2's model card as `chatOnly`: they are offered and detected only when a chat model translates, and with Hy-MT2 (the default) the page behaves exactly as before. Merge unslothai#18737 first. Detection: the original word lists were built from the test sentences, so everyday text in most of these languages was not detected. Measured on held-out sentences from the Universal Declaration of Human Rights translations (sentence level): | Language | main | this PR as submitted | now | |---|---|---|---| | Amharic | 0/62 | 62/62 | 62/62 | | Swahili | 0/83 | 25/83 | 78/83 | | Hausa | 0/82 | 13/82 | 80/82 | | Yoruba | 0/86 (85 read as Vietnamese) | 84/86 | 84/86 | | Igbo | 0/72 (71 read as Vietnamese) | 50/72 | 72/72 | | Zulu | 0/69 | 4/69 | 61/69 | | Afrikaans | 0/73 (66 read as Dutch) | 0/73 (66 read as Dutch) | 62/73 | | Somali | 0/78 | 17/78 | 74/78 | - The lists now hold each language's common function words; Zulu, Swahili and Somali also score typical word shapes (noun class and verb prefixes, long vowels with x / q / dh). - A new language only scores when the text has evidence no Hy-MT2 language's list holds (one of its own words, letters or word shapes), so it can never take a verdict away from English, Dutch, French, Portuguese, Tagalog and the rest. Afrikaans shares only the words already on the Dutch list and wins on its own words. - Short Vietnamese phrases ("Mẹ ơi", "Dịch vụ", "Chị bị ho hôm qua") are Vietnamese again, while Yoruba and Igbo text is no longer read as Vietnamese. - No verdict moved for any of the 38 existing languages across 42,597 UDHR sentences in 537 translations, nor across 2,945 English sentences from the repo docs. Before / after, translating with a chat model (picker gains the new languages; Afrikaans was read as Dutch):  Before / after with Hy-MT2 1.8B, the default (same 38 languages; Afrikaans is no longer misread as Dutch):  Tests: `node --experimental-strip-types --test tests/translate-*.test.ts` 59/59, `npm run typecheck` clean. --------- Co-authored-by: Daniel Han <[email protected]>
Related to #18674
Summary
Adds Hmong (
hmn) to the Unsloth Translate language catalog and Latin-script language detector (detectTranslateLanguage), so Hmong source text is accurately recognized byDetect language(instead of falling back tonullor misclassifying as Polish/Spanish) and can be selected as a source or target language.Changes
studio/frontend/src/features/translate/languages.ts{ code: "hmn", name: "Hmong" }toTRANSLATE_LANGUAGES.studio/frontend/src/features/translate/detect-language.tskuv,koj,nws,peb,nej,lawv,yog,muaj,tsis,tau,yuav,xav,nyob,mus,ua,hais,pom,paub,kawm,thiab,rau,hauv,txog,lub,tus,cov,tias,vim,zoo,tsaug,ntau,lus,hmoob, etc.) toLATIN.hmn.studio/frontend/tests/translate-detect-language.test.tsSENTENCES.hmn.Before and After
Before
After
Verification
node --experimental-strip-types --test tests/translate-*.test.ts(studio/frontend): 54/54 passednpm run typecheck(studio/frontend): passed (0 errors)Maintainer follow-ups
Hy-MT2, the default Translate model, is trained on the 38 languages on its model card, and Hmong is not one of them. So languages outside that list are now marked
chatOnly:Tests:
node --experimental-strip-types --test tests/translate-*.test.ts56/56,npm run typecheckclean.