File size: 4,766 Bytes
7247224
 
 
 
 
c60aec7
 
7247224
e6970ed
29999bf
 
 
 
 
 
 
 
 
 
7247224
 
 
 
3ffe872
e6970ed
3ffe872
e6970ed
70b9505
 
 
 
 
 
 
 
 
 
 
 
e6970ed
3ffe872
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e6970ed
 
 
 
 
 
3ffe872
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29999bf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
---
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