Spaces:
Runtime error
Runtime error
Upload BLOG_DRAFT.md
Browse files- BLOG_DRAFT.md +14 -7
BLOG_DRAFT.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# Field Notes: Putting a 20-Year-Old Chinese Trading Theory on a Fine-Tuned 1.7B
|
| 2 |
|
| 3 |
-
*Built for the Build Small hackathon — a Gradio
|
| 4 |
|
| 5 |
## The problem (a real one)
|
| 6 |
|
|
@@ -14,7 +14,9 @@ are dense Chinese jargon, and someone had to run it by hand every evening.
|
|
| 14 |
**Chan Compass** fixes both: a Gradio Space that auto-updates after the US close
|
| 15 |
(18:10 ET), answers exactly one question per ticker — *do I buy or sell tomorrow,
|
| 16 |
at what buy point, in which zone, and where am I wrong?* — and uses a pool of small
|
| 17 |
-
local models as the translators and analysts the rule engine can't be.
|
|
|
|
|
|
|
| 18 |
|
| 19 |
## Why small models are the honest fit
|
| 20 |
|
|
@@ -33,7 +35,7 @@ Early versions shared a single model behind one lock, so the moment two features
|
|
| 33 |
ran at once you'd get "model busy." The fix was a **sub-agent pool** — four small
|
| 34 |
models, each with its own lock, running through llama.cpp:
|
| 35 |
|
| 36 |
-
* **
|
| 37 |
* **Narrator** (sector rotation) — Qwen3-1.7B
|
| 38 |
* **Reporter** (watchlist news + research support) — Qwen3-1.7B
|
| 39 |
* **Analyst** (Auto Research) — Qwen3-4B
|
|
@@ -43,7 +45,7 @@ summary writes, with no collision.
|
|
| 43 |
|
| 44 |
## The fine-tune (the part I'm proudest of)
|
| 45 |
|
| 46 |
-
The
|
| 47 |
(raw read → English summary) pair it produces into a dataset on the `/data`
|
| 48 |
bucket; a couple hundred focused pairs later, I exported the JSONL straight from
|
| 49 |
the app's Model tab, LoRA-tuned **Qwen3-1.7B** on a free Colab T4 with Unsloth,
|
|
@@ -71,9 +73,9 @@ doing everything adequately.
|
|
| 71 |
dataset** so anyone can see how the agent actually reasoned.
|
| 72 |
* **Email any result** — each tab can email its output; on HF (where SMTP is
|
| 73 |
blocked) delivery goes over the Resend HTTPS API, markdown rendered to clean HTML.
|
| 74 |
-
* **
|
| 75 |
|
| 76 |
-
##
|
| 77 |
|
| 78 |
1. **HF build containers are tiny.** `llama-cpp-python` got OOM-killed compiling at
|
| 79 |
*build* time on a Space with 32 GB of *runtime* RAM. Fix: install the runtime at
|
|
@@ -89,11 +91,16 @@ doing everything adequately.
|
|
| 89 |
4. **Platforms block SMTP; ship HTTPS email.** Outbound mail ports are closed on
|
| 90 |
Spaces, so email failed with "network unreachable." The Resend REST API over
|
| 91 |
443 works — and it needs a `User-Agent` header or Cloudflare 403s you.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
## What's next
|
| 94 |
|
| 95 |
The agent traces are already public as a Hub dataset; next I want to grow the
|
| 96 |
-
fine-tune set so the
|
| 97 |
task needs, and feed real family usage back into that loop.
|
| 98 |
|
| 99 |
*Not investment advice. Engine logic unchanged from the original; the app around
|
|
|
|
| 1 |
# Field Notes: Putting a 20-Year-Old Chinese Trading Theory on a Fine-Tuned 1.7B
|
| 2 |
|
| 3 |
+
*Built for the Build Small hackathon — a custom-frontend Gradio app (`gradio.Server`), a local llama.cpp sub-agent pool, a model I fine-tuned myself, and zero cloud APIs.*
|
| 4 |
|
| 5 |
## The problem (a real one)
|
| 6 |
|
|
|
|
| 14 |
**Chan Compass** fixes both: a Gradio Space that auto-updates after the US close
|
| 15 |
(18:10 ET), answers exactly one question per ticker — *do I buy or sell tomorrow,
|
| 16 |
at what buy point, in which zone, and where am I wrong?* — and uses a pool of small
|
| 17 |
+
local models as the translators and analysts the rule engine can't be. The results
|
| 18 |
+
are persisted to disk, so when the family opens the app the next morning, the
|
| 19 |
+
overnight run is already there waiting — no spinner, no recompute.
|
| 20 |
|
| 21 |
## Why small models are the honest fit
|
| 22 |
|
|
|
|
| 35 |
ran at once you'd get "model busy." The fix was a **sub-agent pool** — four small
|
| 36 |
models, each with its own lock, running through llama.cpp:
|
| 37 |
|
| 38 |
+
* **Interpreter** (Signals → AI Interpret) — my **fine-tuned Chan-Tuned Qwen3-1.7B**
|
| 39 |
* **Narrator** (sector rotation) — Qwen3-1.7B
|
| 40 |
* **Reporter** (watchlist news + research support) — Qwen3-1.7B
|
| 41 |
* **Analyst** (Auto Research) — Qwen3-4B
|
|
|
|
| 45 |
|
| 46 |
## The fine-tune (the part I'm proudest of)
|
| 47 |
|
| 48 |
+
The Interpreter sub-agent runs a model I trained myself. The app captures every
|
| 49 |
(raw read → English summary) pair it produces into a dataset on the `/data`
|
| 50 |
bucket; a couple hundred focused pairs later, I exported the JSONL straight from
|
| 51 |
the app's Model tab, LoRA-tuned **Qwen3-1.7B** on a free Colab T4 with Unsloth,
|
|
|
|
| 73 |
dataset** so anyone can see how the agent actually reasoned.
|
| 74 |
* **Email any result** — each tab can email its output; on HF (where SMTP is
|
| 75 |
blocked) delivery goes over the Resend HTTPS API, markdown rendered to clean HTML.
|
| 76 |
+
* **A real custom frontend** — instead of the default Gradio component render, `server.py` builds a `gradio.Server` that serves a hand-built React + Adobe Spectrum 2 UI at `/` and exposes the Python backend as `/api/*` JSON + streaming endpoints. It's still a Gradio app — just wearing its own clothes.
|
| 77 |
|
| 78 |
+
## Five things I learned the hard way
|
| 79 |
|
| 80 |
1. **HF build containers are tiny.** `llama-cpp-python` got OOM-killed compiling at
|
| 81 |
*build* time on a Space with 32 GB of *runtime* RAM. Fix: install the runtime at
|
|
|
|
| 91 |
4. **Platforms block SMTP; ship HTTPS email.** Outbound mail ports are closed on
|
| 92 |
Spaces, so email failed with "network unreachable." The Resend REST API over
|
| 93 |
443 works — and it needs a `User-Agent` header or Cloudflare 403s you.
|
| 94 |
+
5. **A custom frontend on a Gradio Space wants `gradio.Server`, not `.launch()`.**
|
| 95 |
+
Mounting a React UI and calling `app.launch()` made Gradio's SSR startup check
|
| 96 |
+
hit `gradio_api/startup-events` and 404. The fix: treat `gradio.Server` as the
|
| 97 |
+
ASGI app it is and serve it with uvicorn (Docker SDK) — custom look, still a
|
| 98 |
+
Gradio app.
|
| 99 |
|
| 100 |
## What's next
|
| 101 |
|
| 102 |
The agent traces are already public as a Hub dataset; next I want to grow the
|
| 103 |
+
fine-tune set so the Interpreter model keeps sharpening on exactly the phrasing this
|
| 104 |
task needs, and feed real family usage back into that loop.
|
| 105 |
|
| 106 |
*Not investment advice. Engine logic unchanged from the original; the app around
|