Spaces:
Sleeping
Sleeping
chore: update .gitattributes and README.md for improved text handling and usage instructions
Browse files- .gitattributes +3 -0
- README.md +100 -1
.gitattributes
CHANGED
|
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
|
| 37 |
+
# Ensure text files normalized with LF endings in repo
|
| 38 |
+
* text=auto eol=lf
|
README.md
CHANGED
|
@@ -22,4 +22,103 @@ This Space showcases the **[tasal9/ZamAI-mT5-Pashto](https://huggingface.co/tasa
|
|
| 22 |
|
| 23 |
### About the Model
|
| 24 |
|
| 25 |
-
This model was fine-tuned on the `tasal9/ZamAI-Pashto-High-Qualituly-Dataset`. It is designed to understand and execute a wide variety of instructions in Pashto.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
### About the Model
|
| 24 |
|
| 25 |
+
This model was fine-tuned on the `tasal9/ZamAI-Pashto-High-Qualituly-Dataset`. It is designed to understand and execute a wide variety of instructions in Pashto.
|
| 26 |
+
|
| 27 |
+
### Modes (Runtime Behavior)
|
| 28 |
+
|
| 29 |
+
The UI exposes a `Mode` dropdown:
|
| 30 |
+
|
| 31 |
+
- `off` – Real model generation (loads weights, may take time first run)
|
| 32 |
+
- `echo` – Returns the prompt exactly (fast, for UI testing)
|
| 33 |
+
- `useless` – Returns a fixed placeholder response (for latency / wiring checks)
|
| 34 |
+
|
| 35 |
+
You can also preset a default via environment: `ECHO_MODE=echo` or `ECHO_MODE=useless` before launching. The UI selection overrides the env per request.
|
| 36 |
+
|
| 37 |
+
### Running Locally
|
| 38 |
+
|
| 39 |
+
```bash
|
| 40 |
+
python app.py
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
Environment variables (optional):
|
| 44 |
+
|
| 45 |
+
| Variable | Purpose | Example |
|
| 46 |
+
|----------|---------|---------|
|
| 47 |
+
| `MODEL_ID` | Override model repo | `tasal9/ZamAI-mT5-Pashto` |
|
| 48 |
+
| `GRADIO_PORT` | Change port | `9000` |
|
| 49 |
+
| `GRADIO_HOST` | Bind address | `0.0.0.0` |
|
| 50 |
+
| `ECHO_MODE` | Default mode (`off\|echo\|useless`) | `echo` |
|
| 51 |
+
| `HF_HOME` | Hugging Face cache root | `/data/hf-cache` |
|
| 52 |
+
| `OFFLINE` | If set to `1/true`, sets `HF_HUB_OFFLINE=1` | `1` |
|
| 53 |
+
| `DEFAULT_MAX_NEW_TOKENS` | Slider default tokens | `128` |
|
| 54 |
+
|
| 55 |
+
Example:
|
| 56 |
+
|
| 57 |
+
```bash
|
| 58 |
+
HF_HOME=/data/hf-cache OFFLINE=1 ECHO_MODE=echo python app.py
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
### Caching & Offline Usage
|
| 62 |
+
|
| 63 |
+
1. Pick a persistent cache directory (fast disk/SSD recommended).
|
| 64 |
+
2. Set `HF_HOME` to that path on every run.
|
| 65 |
+
3. Launch once in real mode (`off`) so weights download.
|
| 66 |
+
4. Set `OFFLINE=1` (or directly `HF_HUB_OFFLINE=1`) for subsequent offline usage.
|
| 67 |
+
|
| 68 |
+
Linux example:
|
| 69 |
+
|
| 70 |
+
```bash
|
| 71 |
+
export HF_HOME=/data/hf-cache
|
| 72 |
+
python app.py # first run downloads
|
| 73 |
+
export OFFLINE=1
|
| 74 |
+
python app.py # offline reuse
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
Windows PowerShell example:
|
| 78 |
+
|
| 79 |
+
```powershell
|
| 80 |
+
$env:HF_HOME = 'D:\hf-cache'
|
| 81 |
+
python app.py # first run
|
| 82 |
+
$env:OFFLINE = '1'
|
| 83 |
+
python app.py # offline
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
### Health Endpoint
|
| 87 |
+
|
| 88 |
+
A lightweight HTTP health check server listens on `HEALTH_PORT` (default `8080`).
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
```bash
|
| 92 |
+
curl http://localhost:8080/health # returns 'ok'
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
### Development Tips
|
| 96 |
+
|
| 97 |
+
- Use `echo` mode to iterate on UI changes without loading the full model.
|
| 98 |
+
- `useless` mode provides a constant response for benchmarking layout latency.
|
| 99 |
+
- Logs show cache configuration: `HF_HOME`, `TRANSFORMERS_CACHE`, and offline status.
|
| 100 |
+
- GPU is auto-detected (CUDA) and displayed in the header if available.
|
| 101 |
+
|
| 102 |
+
### Common Issues
|
| 103 |
+
|
| 104 |
+
| Symptom | Likely Cause | Fix |
|
| 105 |
+
|---------|--------------|-----|
|
| 106 |
+
| Slow first generation | Model weights not cached | Ensure persistent `HF_HOME` |
|
| 107 |
+
| Network calls while offline | Missing `OFFLINE=1` | Export `OFFLINE=1` (sets `HF_HUB_OFFLINE`) |
|
| 108 |
+
| IndentationError on Space | Space not rebuilt | Trigger rebuild / push a new commit |
|
| 109 |
+
| Echo mode still loads model | Open runs before switching | Set `ECHO_MODE=echo` before launch |
|
| 110 |
+
|
| 111 |
+
### Trigger Rebuild (Hugging Face Space)
|
| 112 |
+
|
| 113 |
+
If a rebuild doesn’t trigger automatically, make a no-op commit:
|
| 114 |
+
|
| 115 |
+
```bash
|
| 116 |
+
date > .rebuild
|
| 117 |
+
git add .rebuild
|
| 118 |
+
git commit -m "chore: trigger rebuild"
|
| 119 |
+
git push origin main
|
| 120 |
+
```
|
| 121 |
+
|
| 122 |
+
### License / Usage
|
| 123 |
+
|
| 124 |
+
Refer to the model card of `tasal9/ZamAI-mT5-Pashto` for any licensing or usage constraints. This demo adds only interface logic and does not modify model licensing terms.
|