Repository navigation
feat(studio): add Amharic and popular African languages to Translate (#18723) - #18738
danielhanchen merged 15 commits into
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.
…n languages branch
…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]
…ryday text The word lists were built from the test sentences, so real text in most of these languages came back undetected (UDHR sentences: Afrikaans 0/73, Zulu 4/69, Hausa 13/82). They now hold each language's common function words, Zulu, Swahili and Somali also score their word shapes, and Dutch and Afrikaans share their common words so only the ones the other lacks decide. Short Vietnamese phrases such as "Mẹ ơi" are Vietnamese again: only text with no Vietnamese-only letter leaves the dot-below vowels to Yoruba and Igbo. [skip ci]
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 77258470c8
ℹ️ 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 saved language metadata when restoring history
After translating into a chat-only language, switching to Hy-MT2 and reopening that history entry silently changes its output language metadata. restore() calls setTarget(entry.target), which this new fitting step coerces to a supported fallback, then constructs result from those modified preferences while retaining the original output. For example, a saved Swahili translation can reopen with result.target === "en" and translationIsStale() === false, causing read-aloud and “Use as source” to treat Swahili as English. Preserve the entry's actual language metadata, or select a compatible model, when restoring it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 3109555 (merged here): restore keeps the entry's own languages on the shown result, so it reads as stale instead of relabelling the output.
| const vietnamese = count(text, /(?![ẹịọụ])[ơưđăạ-ỹ]/gu); | ||
| if (vietnamese > 0 && vietnamese + countOf(text, "ẹịọụ") >= 2) return "vi"; |
There was a problem hiding this comment.
Add Vietnamese disambiguation for shared dot-below vowels
When a Vietnamese phrase's only distinctive characters are the excluded vowels, this condition skips Vietnamese detection entirely, and there is no Vietnamese word scorer in LATIN to recover it. Meanwhile, ị and ụ contribute Igbo scores: Dịch vụ, Dịch vụ công, and Dịch vụ du lịch all return ig in this commit versus vi in its parent. Chat models therefore show the wrong detected language, while the default Hy-MT2 page filters that result to null and disables automatic-source swapping. Add Vietnamese word/context evidence for shared-vowel cases rather than letting those vowels alone select Igbo.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in bbc9cef: a dot-below vowel closed by c, ch, ng, nh, p or t (dịch, lịch) is counted as Vietnamese, so "Dịch vụ" and "Dịch vụ du lịch" are vi again; no verdict moved on any of the 42,597 UDHR sentences otherwise.
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. |
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
…mese "Dịch vụ" has only the dot-below vowels Yoruba and Igbo share, so it read as Igbo; a dot-below vowel closed by c, ch, ng, nh, p or t is Vietnamese only. [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5106926f7f
ℹ️ 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".
| ], | ||
| af: [ | ||
| words( | ||
| `${DUTCH_AFRIKAANS} nie ek jy hy sy hulle julle vir baie sal mekaar hul sê hoekom mense dankie asseblief hom n sodat teen elkeen kry dis my`, |
There was a problem hiding this comment.
Disambiguate English input before selecting Afrikaans
For English input such as My net income is $1000., this entry scores my, net, and is for Afrikaans, while English scores only my and is, so detectTranslateLanguage() now returns af instead of the parent's correct en. With a chat model, the page consequently labels the source as Afrikaans and swapping selects Afrikaans as the reverse target; with Hy-MT2, the new supported-language filter suppresses the result and disables automatic-source swapping. Add distinguishing word or context evidence and regression coverage so these shared tokens do not select Afrikaans on ordinary English input.
Useful? React with 👍 / 👎.
A chat-only language now scores only with evidence no Hy-MT2 language's list
holds (one of its own words, letters or word shapes), the Dutch list is back
to main's, Afrikaans drops my / teen / n / ê, and the Swahili and Somali word
shapes no longer match Tagalog ku- words or English queen / sixteen. Short
Vietnamese with only shared dot-below vowels ("Chị bị ho hôm qua") is scored
by common Vietnamese words. Ethiopic counts letters only. No verdict moves for
any existing language across 42,597 UDHR sentences.
|
@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: 5a3658d196
ℹ️ 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".
| tokens.some( | ||
| (token) => known.has(token) && !HY_MT2_WORDS.has(token), |
There was a problem hiding this comment.
Require language-specific evidence before enabling chat-only scores
HY_MT2_WORDS contains only the existing cue lists, so absence from it does not establish that a token is specific to a chat-only language. For example, ordinary Dutch nou passes this gate for Afrikaans: detectTranslateLanguage("Hoe is het nou?") now returns af, versus nl in the parent. Likewise, English game enables Hausa, changing "A game with a ball." from en to null. With automatic source detection and a different target selected, these inputs lose their detected-language label and Swap action under Hy-MT2; a chat model incorrectly labels the Dutch text as Afrikaans and selects Afrikaans when swapping. Require additional discriminating evidence for these shared words and add these cases to the regression tests.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 0822119: words on the chat-only lists that the Hy-MT2 languages also write (nou, game, lub, ces, site, ...) no longer open a chat-only language's score, and Afrikaans drops nou. Both cases are in the regression test; no verdict moves for any existing language across the 42,597 UDHR sentences or 2,945 English sentences from the repo docs.
…guage score Dutch "nou" let Afrikaans score and English "game" let Hausa score; such words (from the chat-only lists, found in the other languages' text) no longer count as a chat-only language's own evidence, and Afrikaans drops nou. [skip ci]
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. 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". |
# 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
…Run settings close (#18984) ## Summary `Chat UI Tests (extra)` fails intermittently on unrelated PRs at the same step of `tests/studio/playwright_model_config.py`: ``` [ui-modelcfg] STEP Hub Run opens run settings on a page loaded at /hub [ui-modelcfg] OK Hub Run kept run settings open on a page loaded at /hub [ui-modelcfg] FAIL: composer could not be focused after the Hub Run settings closed ``` Seen on #18871 (09:37) and #18738 (20:00) today. Neither touches the chat composer or the model picker, and the same suite passes on other runs. The step presses Escape, waits for the run settings to hide, then calls `focus()` on the composer in one `evaluate` and reads `document.activeElement` in a second. The run settings live in the model picker, a Radix `Popover`, which returns focus to its trigger as it closes. A focus move like that, landing between the two calls, makes this single attempt fail even though the composer is focusable. The product behaviour this guards is unchanged: `ChatComposerFocusableContext` lifts the `focus()` gate in the same commit that closes the picker, and a real click focuses the composer regardless. ## Fix The check now retries `focus()` plus the `activeElement` read for up to 5 s (every 250 ms) through the suite's existing `wait_until`, and fails with the same message if the composer never takes focus. A composer that stays gated after the settings close still fails the gate. Only the test changes. ## Testing - `python -m py_compile` and `ruff check --select F` on the driver: clean. - The suites that read this driver (CI wiring and Playwright selftests): 213 passed. - I could not reproduce the intermittent failure locally, so the timing explanation above is inferred from the two CI logs and the picker's focus handling, not observed directly.
Related to #18723
Summary
Adds official support and automatic script/language detection in Unsloth Translate for Amharic (
am) along with popular African continent languages (Swahilisw, Hausaha, Yorubayo, Igboig, Zuluzu, Afrikaansaf, and Somaliso).Changes
studio/frontend/src/features/translate/languages.tsam(Amharic),sw(Swahili),ha(Hausa),yo(Yoruba),ig(Igbo),zu(Zulu),af(Afrikaans), andso(Somali) toTRANSLATE_LANGUAGES.studio/frontend/src/features/translate/detect-language.ts[/\p{Script=Ethiopic}/gu, "am"]toSINGLE_SCRIPTso Ethiopic/Ge'ez script text is recognized as Amharic.sw,ha("ɓɗƙ"),yo("ẹọṣ"),ig("ịụṅ"),zu,af, andsoentries toLATIN.ẹ,ị,ọ,ụ) used by Yoruba and Igbo from the Vietnamese/[ơưđăạ-ỹ]/gushortcut (/(?![ẹịọụ])[ơưđăạ-ỹ]/gu) so Yoruba and Igbo are not misclassified as Vietnamese.studio/frontend/tests/translate-detect-language.test.tsam,sw,ha,yo,ig,zu,af, andsotoSENTENCES, 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 passednpm run typecheck(studio/frontend): passed (0 errors)Maintainer follow-ups
This branch builds on #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 #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):
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.ts59/59,npm run typecheckclean.