retro / README.md
sankalphs's picture
Update README.md
29999bf verified
|
Raw
History Blame Contribute Delete
4.77 kB
---
title: Retro Alpha
emoji: ๐Ÿ“บ
colorFrom: green
colorTo: blue
sdk: docker
app_port: 7860
pinned: false
tags:
- track:wood
- sponsor:nvidia
- sponsor:modal
- achievement:offgrid
- achievement:welltuned
- achievement:offbrand
- achievement:llama
- achievement:sharing
- achievement:fieldnotes
license: mit
---
# Retro Alpha
**A 90s CRT-style Indian stock market survival game (1994โ€“2004), powered by a fine-tuned NVIDIA Nemotron-3-Nano 4B model.**
Built for the [๐Ÿค— Build Small Hackathon](https://huggingface.co/build-small-hackathon).
---
## ๐Ÿ”— Links
| | |
|---|---|
| ๐ŸŽฎ **Play (main)** | [build-small-hackathon/retro](https://huggingface.co/spaces/build-small-hackathon/retro) |
| ๐ŸŽฎ **Play (alpha)** | [sankalphs/retro-alpha](https://huggingface.co/spaces/sankalphs/retro-alpha) |
| ๐Ÿ“ **Build Blog** | [sankalphs.blogspot.com/2026/06/retro-alpha.html](https://sankalphs.blogspot.com/2026/06/retro-alpha.html) |
| ๐Ÿ™ **GitHub** | [github.com/sankalphs/retro](https://github.com/sankalphs/retro) |
| โ–ถ๏ธ **Video Demo** | [youtu.be/OLJDXhos0Iw](https://youtu.be/OLJDXhos0Iw) |
| ๐Ÿฆ **Social Post** | [x.com/sankalphs/status/2066602928350359694](https://x.com/sankalphs/status/2066602928350359694) |
---
## ๐ŸŽฎ How to Play
| Step | Action |
|------|--------|
| **Goal** | Turn โ‚น10,00,000 into โ‚น20,00,000 over 10 years (120 months) |
| **Review** | Check the Market Watch for asset prices & trends |
| **Trade** | Buy/Sell any asset as a % of your portfolio using the Order Pad |
| **Advance** | Press Advance Month to trigger real historical events & market moves |
| **Analyze** | Ask the AI Advisor about your portfolio or strategy |
| **Review** | Get a Year-End Mentor Review for a sarcastic roast & investment lesson |
### Historical Events
Asian Financial Crisis, Pokhran-II nuclear tests, Dot-com bubble, 9/11, 2004 Indian elections, and more โ€” all influencing asset prices based on real historical data.
---
## ๐Ÿ† Badges Earned
| Badge | How |
|-------|-----|
| **Off-Brand** | Custom CRT terminal UI built from scratch (no Gradio default) |
| **Well-Tuned** | Fine-tuned Nemotron-3-Nano 4B on 1,500+ synthetic market scenarios |
| **Nemotron** | Uses fine-tuned NVIDIA Nemotron-3-Nano-4B (Q4_K_M GGUF) |
| **Off the Grid** | Fully self-contained Docker Space with on-device inference |
| **Sharing is Caring** | Infrastructure-as-code scripts open-sourced on GitHub |
| **Field Notes** | Detailed build log & methodology documented |
---
## ๐Ÿงฑ Tech Stack
```
Frontend โ†’ Custom CRT terminal UI (vanilla HTML/CSS/JS) served via ASGI
Backend โ†’ Python simulation engine + Gradio API
Model โ†’ Fine-tuned NVIDIA Nemotron-3-Nano 4B (Q4_K_M GGUF)
Inference โ†’ Modal GPU cloud endpoint (A10G) with deterministic fallbacks
Data โ†’ 1,500+ synthetic Indian market scenarios via zenmux API
CI/CD โ†’ GitHub Actions โ†’ HF Spaces auto-deploy
```
---
## ๐Ÿš€ Running Locally
```bash
pip install -r requirements.txt
MOCK_LLM=1 python app.py
```
For LLM-powered features, set one of:
- `MODAL_INFERENCE_URL` โ€” Modal cloud endpoint
- `HF_API_URL` + `HF_TOKEN` โ€” Hugging Face Inference API
---
## ๐Ÿ“ Project Structure
```
โ”œโ”€โ”€ app.py # Gradio app entrypoint (ASGI)
โ”œโ”€โ”€ agents.py # LLM inference wrapper
โ”œโ”€โ”€ engine.py # Market simulation engine
โ”œโ”€โ”€ events.py # Historical event triggers
โ”œโ”€โ”€ mentor.py # AI mentor review generator
โ”œโ”€โ”€ modal_app.py # Modal GPU inference endpoint
โ”œโ”€โ”€ download_model.py # GGUF model downloader
โ”œโ”€โ”€ Dockerfile # HF Space container
โ”œโ”€โ”€ requirements.txt # Runtime dependencies
โ”œโ”€โ”€ requirements-train.txt # Training dependencies
โ”œโ”€โ”€ config/
โ”‚ โ””โ”€โ”€ assets.json # Asset definitions
โ”œโ”€โ”€ static/ # Frontend (CSS, JS, HTML)
โ”œโ”€โ”€ schemas/ # JSON schemas for dataset validation
โ”œโ”€โ”€ data/ # Training datasets
โ”œโ”€โ”€ scripts/ # Dataset generation & validation
โ”œโ”€โ”€ training/ # Modal LoRA fine-tuning scripts
โ””โ”€โ”€ tests/ # Test suite
```
---
## ๐Ÿง  Model
The game uses a LoRA fine-tune of **NVIDIA Nemotron-3-Nano-4B** on a custom dataset of 1,500+ Indian market scenarios covering:
- **Agent decisions** (730 examples) โ€” institutional, retail, and tech-permabull personas
- **News impacts** (281 examples) โ€” historical event market reactions
- **Mentor reviews** (255 examples) โ€” year-end portfolio roasts with Sharpe ratios
- **Guardrails** (180 examples) โ€” safety and formatting guidelines
Fine-tuned on Modal A100 40GB โ†’ exported as GGUF Q4_K_M for efficient inference.
---
## ๐Ÿ“„ License
MIT