--- title: LegacyScribe emoji: π colorFrom: yellow colorTo: red sdk: gradio sdk_version: 6.18.0 app_file: app.py pinned: true license: mit short_description: Turn grandparents' memories into a beautiful memory book tags: - backyard-ai - off-brand - best-agent - best-demo - modal - track:backyard - sponsor:modal - achievement:offgrid - achievement:welltuned - achievement:offbrand - achievement:llama models: - build-small-hackathon/legacystribe-Qwen3.5-9B.Q4_K_M datasets: [] ---
![]() |
![]() |
![]() |
![]() |
---
## The Model
| Property | Detail |
|---|---|
| Base model | Qwen3.5-9B-Instruct |
| Quantization | Q4_K_M GGUF (5.78 GB) |
| Fine-tuning method | LoRA rank 16, alpha 32 |
| Training examples | 850 culturally-grounded examples |
| Training compute | Modal A100-40GB, ~2.5 hours |
| Inference | llama.cpp via llama-cpp-python |
| Languages | Nepali Β· English Β· mixed |
### Training Dataset β 850 Examples Across 5 Agents
| Agent | Examples | Categories |
|---|---|---|
| Questioner | 300 | Festivals & jatras, family, work, food, village |
| Arc Detector | 200 | Setup, tension, turn, meaning |
| Extractor | 150 | Person & relationship, time & season, place, emotion |
| Reconciler | 100 | Date conflict, person identity, factual contradiction, no conflict |
| Publisher | 100 | Festival chapter, family story, place & livelihood, mixed memory |
All examples are grounded in **Nepali and South Asian cultural context** β Dashain, Tihar, Indra Jatra, Guthi, kinship terms (hajuramma, bhauju, sasura), Newar traditions, monsoon seasons, village life.
---
## Modal β Training + Inference
Modal powers **both** the fine-tuning pipeline and the live inference backend.
### Fine-tuning on Modal
```python
@app.function(
image=image,
gpu="A100-40GB",
timeout=60 * 60 * 4,
volumes={"/mnt/legacyscribe-data": volume},
)
def train():
from unsloth import FastModel
from trl import SFTTrainer, SFTConfig
# LoRA rank 16 Β· 3 epochs Β· 850 examples
# ~2.5 hours Β· ~$18 from $200 Modal credit
```
### Inference Backend on Modal
The inference backend runs as a dedicated Modal GPU Space, called by the frontend via `gradio_client`:
```
Frontend (HF org Space, CPU)
β gradio_client.predict()
βΌ
Backend (Modal, T4 GPU)
β llama.cpp Β· Qwen3.5-9B Q4_K_M
βΌ
Response β UI update
```
**Modal was used for:**
- β
Fine-tuning (A100-40GB, Unsloth + LoRA)
- β
Dataset volume storage (`legacyscribe-data`)
- β
Inference backend runtime (T4 GPU)
- β
GGUF export and model storage
---
## Architecture
```
build-small-hackathon/legacyscribe (org Space β UI only, CPU free tier)
β
β gradio_client
βΌ
modal/legacyscribe-backend (personal Space β T4 GPU, $250 Modal Credits)
β
β llama.cpp
βΌ
Qwen3.5-9B Q4_K_M (5.78 GB GGUF)
fine-tuned on 850 culturally-grounded examples
```
---
## Tech Stack
| Layer | Technology |
|---|---|
| Model | Qwen3.5-9B-Instruct β Q4_K_M GGUF |
| Fine-tuning | Unsloth + LoRA + TRL SFTTrainer |
| Inference | llama.cpp via llama-cpp-python |
| Training compute | Modal A100-40GB |
| Inference compute | T4 GPU (Modal apps) |
| Frontend | Gradio 6 β fully custom HTML/CSS/JS |
| Backend API | Gradio Interface + gradio_client |
| Fonts | Playfair Display Β· Source Serif 4 Β· JetBrains Mono |
| Animations | CSS 3D transforms Β· pageFlip keyframes Β· spring easing |
---
## Custom UI
LegacyScribe goes well beyond default Gradio components. Every element is custom-built:
- **Leather-bound book page** with CSS 3D spine, stitching detail, and page-curl
- **Page-flip animation** on every new chapter (`rotateY` + `skewY` keyframes)
- **Ruled lines** with text sitting precisely on each line (`line-height: 28px` grid)
- **Opening animation** β a 3D book cover flips open on load, revealing the app
- **Arc pills** β colour-coded narrative stage indicators per memory turn
- **Memory fragment display** β monospace key-value extraction readout
- **Walnut + parchment + gold** colour palette throughout
No `gr.Chatbot`, no `gr.Markdown`, no stock components in the main UI β everything is `gr.HTML` with handwritten CSS.
---
## Demo Video
> πΉ **[Watch the demo](https://youtu.be/fGauUikl-co)**
The demo shows:
1. An elderly person sharing a memory of Indra Jatra in Kathmandu
2. The arc detector identifying "setting the scene"
3. The extractor pulling out who, when, where, emotion
4. The questioner asking one warm follow-up
5. The publisher writing the first chapter onto the book page live
---
## Social Post
> π¦ **[View post - Safal Narshing Shrestha](https://x.com/safalnarshing/status/2066610542626910480)**
> π **[View post - Swoham Kayastha](https://x.com/swohamkayastha/status/2066613735733834133)**
---
## Badges Claimed
| Badge | Reason |
|---|---|
| π² **Backyard AI** | Emotionally resonant, AI-native, whimsical β a memory book that writes itself |
| π¨ **Off Brand** | Fully custom UI β no default Gradio chrome anywhere in the main interface |
| π€ **Best Agent** | 5-agent pipeline with multi-step planning, extraction, reconciliation, and synthesis per turn |
| π¬ **Best Demo** | Demo video + social post + live Space |
| β‘ **Modal** | Fine-tuning + volume storage + inference backend all run on Modal |
---
## Running Locally
```bash
git clone https://huggingface.co/spaces/build-small-hackathon/legacyscribe
cd legacyscribe
pip install gradio gradio_client huggingface_hub
# Set your backend URL
export BACKEND_URL= "https://swohamkayastha--legacystribe-backend-legacyscribeserver-predict.modal.run/"
python app.py
# Open http://localhost:7860
```
To run the full stack locally with the model:
```bash
# Download the GGUF
huggingface-cli download build-small-hackathon/legacystribe-Qwen3.5-9B.Q4_K_M \
Qwen3.5-9B.Q4_K_M.gguf --local-dir ./model
# Run backend
pip install llama-cpp-python
python backend_app.py
```
---
## Team
Built for the **Build Small Hackathon 2026** by [@safalnarsingh](https://huggingface.co/safalnarsingh) and [@SwohamKayastha](https://huggingface.co/SwohamKayastha).
*For every grandmother whose stories deserve to outlast her.*
---