AndrewRqy commited on
Commit ยท
f669e5b
1
Parent(s): 555c51c
README: demo video link, loading-time note, lean/full guidance, point to apprentice field notes
Browse files31 unmodified lines323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310431 unmodified lines# The Apprentice โ Build Small Hackathon> A pixel-art branching fairy-tale game. You inscribe five short oracles before the journey begins; an apprentice has to make every one of them save his life across five trials in a branching graph that converges on one of five distinct endings.**Track**: Thousand Token Wood**Stack**: Gradio + Modal-hosted vLLM + Qwen2.5-14B + custom humor LoRA**Languages**: English + Simplified Chinese**Demo video**: _(to be added by submitter)_**Social post**: _(to be added by submitter)_---## What's in the box| Component | Detail ||---|---|| **Frontend** | Single-file Gradio app (~5000 lines) with a hand-authored pixel-art aesthetic โ Press Start 2P + VT323 fonts, NES-style sharp corners, layered animated scene composition, custom theme that suppresses every visible piece of Gradio chrome. || **Backend** | Qwen2.5-14B-Instruct + custom humor LoRA (`AndrewRqy/oracles-wizard-14b-lora`) served via vLLM on Modal. OpenAI-compatible API; the frontend talks to it through the OpenAI SDK. || **Tiny Titan path** | Qwen2.5-1.5B-Instruct + LoRA, also trained on the same 23k humor corpus (`AndrewRqy/oracles-wizard-1.5b-lora`). Eligible for the โค4B prize. || **Branching narrative** | Hand-authored 15-node story graph with 5 distinct endings. Each fork at trials 2โ4 is picked by an LLM call seeded with the player's inscribed oracle, so the path the apprentice walks is shaped by what wisdom was inscribed. || **6 themes ร 2 languages** | Fantasy, Space-Cowboy, Galactic-Light, Black-Land, Mistgate, Quiet-Years โ each with its own sprite set, finale boss, themed obstacle scenes (finale / arena / passage / trap), localized banner + oracle artifact + apprentice role title. All authored for both English and Chinese. || **Klein-4B sprites** | All in-game art (~105 pixel-art sprites + 4 environment backdrops per theme) was generated locally via Klein-4B on a Modal H100, then chroma-keyed offline. No FLUX, no commercial generators. |## How to play1. **Inscribe** โ pick a language, then a theme, then write five short oracles (any words, gibberish, emoji โ whatever you want).2. **Send-off** โ the mentor seals the parchments and the apprentice leaves.3. **Five trials** โ at each obstacle, the apprentice draws ONE oracle. The model takes the obstacle + the oracle and writes a 200-word resolution in one of three humor modes (wild imagination / accidental trip / last-minute revelation).4. **Boss** โ trial 5 is the world's finale (the dragon for fantasy; the warlord-king for space-cowboy; etc.). Different paths through the tree lead to different bosses.5. **Ending** โ one of 5 distinct endings plays, each with its own preset framing (Why the boss behaved as it did + What the apprentice carried home) and an LLM-expanded 3-paragraph epilogue.6. **Summary** โ clicking through reveals the story tree with the path you took lit gold and the four endings you didn't reach blurred behind "???" for replay motivation.## Badge claims| Badge | Why we claim it ||---|---|| **๐ฏ Well-Tuned** | Qwen2.5-14B + a hand-distilled 23k-example humor LoRA (rank 16, ~6.5 h on H100). The fine-tune visibly steers all three humor modes; the field-notes write-up below details the distillation pipeline. || **๐จ Off-Brand** | ~2000 lines of bespoke CSS, Press Start 2P + VT323 fonts, hand-painted pixel-art sprites, sharp-corner theme that overrides every visible Gradio token, custom story-tree visualization, custom ending banner with five-pip "endings discovered" strip. No stock Gradio chrome reaches the rendered page. || **๐ Field Notes** | See `docs/FIELD_NOTES_distillation.md` โ a ~950-word blog post on the schema-locked Claude-Sonnet-4.5 โ Qwen distillation pipeline, the three humor modes, the JSON enforcement layers, and what 98.4% reject-sampling acceptance got us. || **โก Tiny Titan (prize)** | Same 23k corpus also trained into a Qwen2.5-1.5B LoRA on H100 (~$5.50, ~1.5 h). Eligible for the โค4B prize. |## Running it (locally or on Space)Three environment variables need to be set as **secrets** (HF Space Settings โ Variables and secrets):```MODAL_URL = https://<modal-workspace>--<app-name>-serve.modal.runMODAL_KEY = wk-โฆ (Modal proxy auth key)MODAL_SECRET = ws-โฆ (Modal proxy auth secret)```Once those are set, the Space spins up the Gradio app and the player can immediately walk a trial. No GPU is needed on the Space side โ the LLM call streams in from Modal over HTTPS.If `MODAL_URL` is unset OR `ORACLES_FORCE_MOCK=1`, the app runs in **mock mode** โ every LLM call returns a hand-written placeholder, the visuals still play, but the humor is dead. Useful for offline demos.## Repository layout```oracles_app/โโโ app.py main Gradio file (~5000 lines)โโโ README.md this file (HF Space metadata + write-up)โโโ requirements.txt gradio + openai + Pillowโโโ .gitignore excludes dev artifacts from the Space uploadโโโ oracles/ pure-Python package (state, LLM client, story graph, themes, i18n)โโโ prompts/ LLM prompt templates (resolution / epilogue / interludes / obstacles)โโโ assets/sprites/ ~105 chroma-keyed pixel-art PNGs```The dev-only directories (`modal_backend/`, `scripts/`, `training/`, `tests/`, `lora-out/`, `*_raw.png`) live in this folder on local disk but are excluded from the HF Space upload by `.gitignore`.## Credits31 unmodified lines323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610731 unmodified lines# The Apprentice โ Build Small Hackathon> A pixel-art branching fairy-tale. You inscribe five short oracles before the journey begins; an apprentice has to make every one of them save his life across five trials in a tree that converges on one of five distinct endings.- **Track**: Thousand Token Wood- **Stack**: Docker + Gradio + Modal-hosted vLLM + Qwen2.5-14B + custom humor LoRA- **Languages**: English + ็ฎไฝไธญๆ- **Demo video**: https://youtu.be/Ica9BgX5ZDk- **Social post**: _(to be added by submitter)_- **Field notes**: [`docs/FIELD_NOTES_apprentice.md`](../docs/FIELD_NOTES_apprentice.md)> **โฑ Note on loading time**: this Space ships ~100 pixel-art sprites + theme backdrops. HF Space's free CPU tier has slow egress bandwidth, so first paint of a fresh container can take a minute or two; subsequent page transitions are faster as the browser caches assets. The front-page dropdown lets you flip between **Lean** (small payload, fast loading, default on the Space) and **Full** (parallax banner, scene landscapes, all decorative PNGs โ recommended only on a fast connection or once the Space is warm).## What's inside- **Frontend** โ Single-file Gradio app with a hand-authored pixel-art aesthetic. Press Start 2P + VT323 fonts, NES-style sharp corners, custom theme suppressing all default Gradio chrome.- **Backend** โ Qwen2.5-14B + custom humor LoRA (`AndrewRqy/oracles-wizard-14b-lora`) served via vLLM on Modal. Frontend talks to it through the OpenAI SDK.- **Tiny Titan path** โ Same 23k humor corpus trained into a Qwen2.5-1.5B LoRA (`AndrewRqy/oracles-wizard-1.5b-lora`). Eligible for the โค4B prize.- **Branching narrative** โ Hand-authored 15-node story tree with 5 endings. Each fork at trials 2โ4 is decided by an LLM call seeded with one of the player's oracles, so the path the apprentice walks is shaped by what was inscribed.- **6 themes ร 2 languages** โ Fantasy, Space-Cowboy, Galactic-Light, Black-Land, Mistgate, Quiet-Years. Theme-neutral story nodes + per-theme vocabulary expansion at runtime.- **All art generated locally** โ ~105 pixel-art sprites via Klein-4B on a Modal H100, chroma-keyed offline. No FLUX, no commercial generators.## How to play1. **Inscribe** โ pick a language, theme, visual mode, and narration length. Then write five short oracles. Any words; gibberish counts, emoji counts.2. **Send-off** โ the mentor seals the parchments. The apprentice leaves.3. **Five trials** โ at each obstacle, the apprentice draws ONE oracle. The model takes the obstacle + oracle and writes a ~200-word resolution in one of three humor modes (wild imagination / accidental trip / last-minute revelation).4. **Boss** โ trial 5 is the world's finale (dragon, warlord-king, etc.). Different paths through the tree lead to different bosses.5. **Ending** โ one of 5 distinct endings plays, each with a hand-authored framing (why the boss behaved as it did + what the apprentice carried home), expanded by the LLM into a 3-paragraph epilogue.6. **Summary** โ the story tree shows the path you walked lit gold; the four endings you didn't reach blur behind "???" for replay.## Badge claims| Badge | Why we claim it ||---|---|| ๐ฏ **Well-Tuned** | Qwen2.5-14B + a hand-distilled 23k-example humor LoRA (rank 16, ~6.5h on H100). Visibly steers all three humor modes; details in field notes. || ๐จ **Off-Brand** | ~2000 lines of bespoke CSS, Press Start 2P + VT323 fonts, hand-painted pixel-art sprites, custom story-tree visualization, custom ending banner. No stock Gradio chrome reaches the page. || ๐ **Field Notes** | [`docs/FIELD_NOTES_apprentice.md`](../docs/FIELD_NOTES_apprentice.md) โ a build diary covering what we designed and what broke. || โก **Tiny Titan** | Same 23k corpus trained into a Qwen2.5-1.5B LoRA (~$5.50, ~1.5h on H100). Eligible for the โค4B prize. |## Running itThree environment variables go in HF Space โ **Settings โ Variables and secrets** (or `.env.local` for local runs):```MODAL_URL = https://<workspace>--<app>-serve.modal.runMODAL_KEY = wk-โฆ (Modal proxy auth key)MODAL_SECRET = ws-โฆ (Modal proxy auth secret)```Locally:```bash./run.sh # lean mode, default./run.sh --full # all visual assets enabled (recommended on fast connections)```If `MODAL_URL` is unset OR `ORACLES_FORCE_MOCK=1`, the app runs in **mock mode** โ the UI still works, but narrations are hand-written placeholders.## Repo layout```oracles_app/โโโ app.py # main Gradio fileโโโ Dockerfile # HF Space Docker SDK entryโโโ requirements.txtโโโ oracles/ # state, LLM client, story graph, themes, i18nโโโ prompts/ # LLM prompt templatesโโโ assets/sprites/ # ~105 chroma-keyed pixel-art PNGs```Dev-only dirs (`modal_backend/`, `scripts/`, `training/`, `tests/`, `lora-out/`) live on local disk but are `.gitignore`d from the Space upload.## Credits
README.md+43-40