Spaces:
Runtime error
Runtime error
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,10 +1,102 @@
|
|
| 1 |
---
|
| 2 |
-
title: Duel
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
colorTo: purple
|
| 6 |
sdk: docker
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Duel of Nemotron
|
| 3 |
+
emoji: ⚔️
|
| 4 |
+
colorFrom: indigo
|
| 5 |
colorTo: purple
|
| 6 |
sdk: docker
|
| 7 |
+
python_version: "3.11"
|
| 8 |
+
app_port: 7860
|
| 9 |
+
tags:
|
| 10 |
+
- thousand-token-wood
|
| 11 |
+
- nemotron
|
| 12 |
+
- fine-tuned
|
| 13 |
+
- custom-ui
|
| 14 |
+
- tiny-titan
|
| 15 |
+
- self-play
|
| 16 |
+
- rl
|
| 17 |
+
- fighting-game
|
| 18 |
+
- modal
|
| 19 |
pinned: false
|
| 20 |
---
|
| 21 |
|
| 22 |
+
# Duel of Nemotron ⚔️ — Hybrid Self-Play AI Fighter
|
| 23 |
+
|
| 24 |
+
A cyberpunk fighting game where the AI opponent is powered by a
|
| 25 |
+
**two-tier hybrid**:
|
| 26 |
+
- **Nemotron 3 Nano 4B** (fine-tuned, on Modal A10) — the **strategist**
|
| 27 |
+
- **Tiny Fighter** (~142k params, CPU, in this Space) — the **real-time executor**
|
| 28 |
+
|
| 29 |
+
Nemotron watches the fight and outputs a *mode* (aggressive / defensive /
|
| 30 |
+
grappling / etc.) every several moves. The Tiny Fighter, conditioned on that
|
| 31 |
+
mode plus the last few moves, picks the actual next move in < 1ms on CPU.
|
| 32 |
+
|
| 33 |
+
This is a tiny-model-implements-the-fast-loop + fine-tuned-LLM-sets-the-direction
|
| 34 |
+
pattern: a small CPU policy network for real-time play, a larger fine-tuned
|
| 35 |
+
model for strategic depth.
|
| 36 |
+
|
| 37 |
+
## How It Works
|
| 38 |
+
|
| 39 |
+
```
|
| 40 |
+
Browser (React + Three.js) ──fight state──▶ Space backend (HF Space CPU)
|
| 41 |
+
▲ │
|
| 42 |
+
│ ├──▶ Tiny Fighter (142k, <1ms)
|
| 43 |
+
│ │ returns move + probs
|
| 44 |
+
│ │
|
| 45 |
+
│ └──▶ Modal Nemotron (A10, cold start)
|
| 46 |
+
│ every ~10 moves:
|
| 47 |
+
│ returns strategic weights
|
| 48 |
+
│ ▲
|
| 49 |
+
└──────────────────weights + reasoning────────┘
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
### Training Pipeline (on Modal A100-40GB)
|
| 53 |
+
1. **SFT Bootstrap** — 12k procedural examples teach Nemotron to output
|
| 54 |
+
strategic weight JSON given fight state.
|
| 55 |
+
2. **Self-Play Rollouts** — 100 fights with the SFT model playing both sides.
|
| 56 |
+
Win/loss outcomes provide reward signals.
|
| 57 |
+
3. **Reward-weighted fine-tuning** — positive-reward completions are reinforced,
|
| 58 |
+
negative-reward completions suppressed. 3 epochs, A100-40GB.
|
| 59 |
+
|
| 60 |
+
### The Tiny Fighter
|
| 61 |
+
- **~142k parameter MLP** with BatchNorm, trained on 20k procedurally
|
| 62 |
+
generated (state, strategy) → move examples.
|
| 63 |
+
- Runs on CPU in < 1ms per inference. Real-time safe.
|
| 64 |
+
- Conditioned on Nemotron's strategic weights, so it *adapts its style*
|
| 65 |
+
(aggressive vs. defensive vs. grappling) on the fly.
|
| 66 |
+
- 15-move output vocabulary: jab, cross, hook, kick, uppercut, block, parry,
|
| 67 |
+
dodge, advance, retreat, grapple, throw, sweep, feint, wait.
|
| 68 |
+
|
| 69 |
+
## Badges Targeted
|
| 70 |
+
- ✅ **Tiny Titan** — the 142k param model is genuinely tiny and does real work
|
| 71 |
+
- ✅ **Well-Tuned** — the Nemotron LoRA adapter is published at
|
| 72 |
+
[sankalphs/duel-nemotron-strategist](https://huggingface.co/sankalphs/duel-nemotron-strategist)
|
| 73 |
+
- ✅ **Off-Brand** — custom React + Three.js 3D fighting game (not default Gradio)
|
| 74 |
+
- ✅ **Field Notes** — see blog post
|
| 75 |
+
- ✅ **Modal Award** — training and inference both run on Modal
|
| 76 |
+
- ✅ **Nemotron Quest** — fine-tuned Nemotron 3 Nano 4B for the fight
|
| 77 |
+
|
| 78 |
+
## Local Dev
|
| 79 |
+
|
| 80 |
+
```bash
|
| 81 |
+
# Frontend
|
| 82 |
+
cd 3d-game && npm install && npm run build
|
| 83 |
+
|
| 84 |
+
# Space backend (CPU)
|
| 85 |
+
pip install -r requirements.txt
|
| 86 |
+
python app.py
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
Set `MODEL_SERVER` env var to your Modal inference endpoint to enable
|
| 90 |
+
Nemotron strategy. Without it, the Space falls back to balanced defaults.
|
| 91 |
+
|
| 92 |
+
## Links
|
| 93 |
+
|
| 94 |
+
- **Fine-tuned adapter**: https://huggingface.co/sankalphs/duel-nemotron-strategist
|
| 95 |
+
- **Modal orchestration**: see `modal/app.py` in the repo
|
| 96 |
+
- **Demo video**: _see social post_
|
| 97 |
+
- **Social post**: _see social post_
|
| 98 |
+
|
| 99 |
+
---
|
| 100 |
+
|
| 101 |
+
Built for the [Build Small Hackathon](https://huggingface.co/build-small-hackathon)
|
| 102 |
+
by [@sankalphs](https://huggingface.co/sankalphs). 🍄
|