Spaces:
Running
Running
Daryl Lim Claude Opus 4.6 (1M context) commited on
Commit ·
29c2951
1
Parent(s): 5c5f600
docs: update architecture description and test counts
Browse filesReflect gr.HTML info element, translate button in input column, and
updated test counts (45 total, 35 fast, 10 slow).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CLAUDE.md
CHANGED
|
@@ -32,11 +32,11 @@ pytest -m slow # model tests only (CUDA only)
|
|
| 32 |
|
| 33 |
## Architecture
|
| 34 |
|
| 35 |
-
**`app.py`** — Single-file application with a Google Translate-style two-column layout: left column has a static "English" dropdown
|
| 36 |
|
| 37 |
**`langmap/`** — Package with `langid_mapping.py`, a hand-maintained dictionary mapping 22 Tier 1 production-ready language tokens (BLEU 35+ both directions, Section A.10) to human-readable language names. Available languages at runtime are the intersection of this mapping and the model's vocabulary.
|
| 38 |
|
| 39 |
-
**`tests/`** —
|
| 40 |
|
| 41 |
## Tooling
|
| 42 |
|
|
|
|
| 32 |
|
| 33 |
## Architecture
|
| 34 |
|
| 35 |
+
**`app.py`** — Single-file application with a Google Translate-style two-column layout: left column has a static "English" dropdown, input textbox with inline clear button, a `gr.HTML` element showing a keyboard shortcut hint and live character count (`Press Ctrl+Enter to apply · X / 2,000`), and the Translate button (shows "Translating..." during processing); right column has a searchable target language dropdown (with locale codes, e.g., "French (fr)") and output textbox with copy button. Ctrl+Enter submits from the input. Uses `@lru_cache` for lazy loading of the `google/madlad400-3b-mt` tokenizer and model (no download on import). Uses `float16` on CUDA, `float32` on CPU. MPS is not supported (produces garbage output with T5 models). Translation prepends a language token with a space to the input text (e.g., `<2fr> Hello`) before tokenization and generation. The `@spaces.GPU` decorator allocates GPU on HF Spaces infrastructure.
|
| 36 |
|
| 37 |
**`langmap/`** — Package with `langid_mapping.py`, a hand-maintained dictionary mapping 22 Tier 1 production-ready language tokens (BLEU 35+ both directions, Section A.10) to human-readable language names. Available languages at runtime are the intersection of this mapping and the model's vocabulary.
|
| 38 |
|
| 39 |
+
**`tests/`** — 45 tests (35 fast, 10 slow). `test_langmap.py` has 8 fast tests for language mapping validation. `test_app.py` has 27 fast tests (signatures, device fallback, UI layout including English dropdown, textbox height, inline clear, character count in HTML element, shortcut hint in HTML element, translate button in input column, filterable dropdown, locale codes, no title) and 10 slow tests (translation with various parameters, language mapping). Slow tests require CUDA and model download; auto-skipped without CUDA.
|
| 40 |
|
| 41 |
## Tooling
|
| 42 |
|
README.md
CHANGED
|
@@ -38,6 +38,6 @@ The Gradio interface launches at `http://localhost:7860`.
|
|
| 38 |
ruff check . # lint
|
| 39 |
ruff format . # format
|
| 40 |
ty check # type check
|
| 41 |
-
pytest -m "not slow" #
|
| 42 |
-
pytest # all
|
| 43 |
```
|
|
|
|
| 38 |
ruff check . # lint
|
| 39 |
ruff format . # format
|
| 40 |
ty check # type check
|
| 41 |
+
pytest -m "not slow" # 35 fast tests
|
| 42 |
+
pytest # all 45 tests (slow require CUDA + model download)
|
| 43 |
```
|