Spaces:
Running on Zero
Running on Zero
Daryl Lim Claude Opus 4.6 commited on
Commit Β·
2cbad7c
1
Parent(s): e0dc6e1
docs: update CLAUDE.md and README.md for CUDA-only support
Browse filesReflect removal of MPS, float16/float32 device logic, corrected
input format, and CUDA-only requirement for slow tests.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CLAUDE.md
CHANGED
|
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|
| 4 |
|
| 5 |
## Project Overview
|
| 6 |
|
| 7 |
-
A Hugging Face Spaces app that translates English text to 183 evaluated languages (Table 14, Section A.9) from Google's [MADLAD-400](https://arxiv.org/pdf/2309.04662) 3B Seq2Seq model. Built with Gradio and deployed on HF Spaces. Falls back to CPU with a warning when no GPU is available.
|
| 8 |
|
| 9 |
## Commands
|
| 10 |
|
|
@@ -25,21 +25,21 @@ ruff format .
|
|
| 25 |
ty check
|
| 26 |
|
| 27 |
# Test
|
| 28 |
-
pytest # all tests (slow tests require
|
| 29 |
pytest -m "not slow" # fast tests only
|
| 30 |
-
pytest -m slow # model tests only
|
| 31 |
```
|
| 32 |
|
| 33 |
## Architecture
|
| 34 |
|
| 35 |
-
**`app.py`** β Single-file application. Uses `@lru_cache` for lazy loading of the `google/madlad400-3b-mt` tokenizer and model
|
| 36 |
|
| 37 |
**`langmap/`** β Package with `langid_mapping.py`, a hand-maintained dictionary mapping 183 evaluated language tokens to human-readable language names (sourced from Table 14, Section A.9 of the MADLAD-400 paper; evaluation sets: WMT, Flores-200, NTREX, Gatones). Available languages at runtime are the intersection of this mapping and the model's vocabulary.
|
| 38 |
|
| 39 |
-
**`tests/`** β Pytest suite split into fast (`test_langmap.py`) and slow (`test_app.py`). Slow tests require
|
| 40 |
|
| 41 |
## Tooling
|
| 42 |
|
| 43 |
- **Ruff** β linter and formatter (`ruff.toml`). Rules: `E`, `F`, `I`, `W`. Line length: 120.
|
| 44 |
- **ty** β type checker (`ty.toml`). Python 3.12 target.
|
| 45 |
-
- **pytest** β test runner (`pytest.ini`). Custom `slow` marker for
|
|
|
|
| 4 |
|
| 5 |
## Project Overview
|
| 6 |
|
| 7 |
+
A Hugging Face Spaces app that translates English text to 183 evaluated languages (Table 14, Section A.9) from Google's [MADLAD-400](https://arxiv.org/pdf/2309.04662) 3B Seq2Seq model. Built with Gradio and deployed on HF Spaces. Falls back to CPU with a warning when no CUDA GPU is available.
|
| 8 |
|
| 9 |
## Commands
|
| 10 |
|
|
|
|
| 25 |
ty check
|
| 26 |
|
| 27 |
# Test
|
| 28 |
+
pytest # all tests (slow tests require CUDA + model download)
|
| 29 |
pytest -m "not slow" # fast tests only
|
| 30 |
+
pytest -m slow # model tests only (CUDA only)
|
| 31 |
```
|
| 32 |
|
| 33 |
## Architecture
|
| 34 |
|
| 35 |
+
**`app.py`** β Single-file application. 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 183 evaluated language tokens to human-readable language names (sourced from Table 14, Section A.9 of the MADLAD-400 paper; evaluation sets: WMT, Flores-200, NTREX, Gatones). Available languages at runtime are the intersection of this mapping and the model's vocabulary.
|
| 38 |
|
| 39 |
+
**`tests/`** β Pytest suite split into fast (`test_langmap.py`) and slow (`test_app.py`). Slow tests require CUDA and model download; they are auto-skipped without CUDA. Fast tests in `test_app.py` verify the module imports without triggering model download.
|
| 40 |
|
| 41 |
## Tooling
|
| 42 |
|
| 43 |
- **Ruff** β linter and formatter (`ruff.toml`). Rules: `E`, `F`, `I`, `W`. Line length: 120.
|
| 44 |
- **ty** β type checker (`ty.toml`). Python 3.12 target.
|
| 45 |
+
- **pytest** β test runner (`pytest.ini`). Custom `slow` marker for CUDA-dependent tests.
|
README.md
CHANGED
|
@@ -18,7 +18,7 @@ Translate English text to 183 evaluated languages (Table 14, Section A.9) using
|
|
| 18 |
## Requirements
|
| 19 |
|
| 20 |
- Python 3.12
|
| 21 |
-
-
|
| 22 |
|
| 23 |
## Setup
|
| 24 |
|
|
@@ -38,5 +38,5 @@ ruff check . # lint
|
|
| 38 |
ruff format . # format
|
| 39 |
ty check # type check
|
| 40 |
pytest -m "not slow" # fast tests
|
| 41 |
-
pytest # all tests (requires
|
| 42 |
```
|
|
|
|
| 18 |
## Requirements
|
| 19 |
|
| 20 |
- Python 3.12
|
| 21 |
+
- CUDA GPU (recommended) or CPU
|
| 22 |
|
| 23 |
## Setup
|
| 24 |
|
|
|
|
| 38 |
ruff format . # format
|
| 39 |
ty check # type check
|
| 40 |
pytest -m "not slow" # fast tests
|
| 41 |
+
pytest # all tests (requires CUDA + model download)
|
| 42 |
```
|