This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine
ποΈ What I Built
Mexican tradition teaches that every soul experiences three deaths:
- The first death is when the physical body takes its final breath.
- The second death is when the body is returned to the earth.
- The third death β the most profound of all β is when nobody on earth speaks your name or remembers your story anymore.
For the Ghost in the Machine challenge, I created Ofrenda Viva β an interactive virtual memorial altar (ofrenda) and physical IoT sanctuary honoring departed ancestors, family members, beloved pets, and historical pioneers in the timeless spirit of DΓa de los Muertos (Day of the Dead).
Rather than treating the "ghost in the machine" as an uncanny glitch or dystopian specter, Ofrenda Viva reimagines the ghost as a sacred, cherished presence: an ancestral guiding memory kept warmly alive through golden candlelight, cempasΓΊchil marigold petals, procedural physical string acoustics, and open-source artificial intelligence.
π Live Demo & Source Code
- π Live Production Site: https://ofrenda-viva.pages.dev/
- π» GitHub Repository: https://github.com/Afnan-0206/Ofrenda-Viva
- π License: MIT Open Source
ποΈ System Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β OFRENDA VIVA ARCHITECTURE β
β β
β [Physical World: Arduino UNO Q] ββββ(WebSerial 115200)ββββ> [React 18 / Vite Client] β
β β’ Pin A0: Analog Match/Flame Sensor β’ Karplus-Strong Physical Audio β
β β’ Pin D2: PIR Proximity Presence Detector β’ 3-Tier Interactive Altar Canvas β
β β’ Qualcomm AI Hub Edge INT8 Model β’ Live Family Insights Dashboard β
β β β
β βββββββββββββββββββββββββ Multi-Cloud Infrastructure βββββββββββββ΄ββββββββββββββββββ β
β βΌ βΌ β
β [Render Blueprint: render.yaml] [DigitalOcean App: .do/app.yaml]β
β β’ ofrenda-viva-frontend (Cloudflare / Edge CDN) β’ Frontend CDN Static Edge β
β β’ ofrenda-viva-ai-runtime (FastAPI + Python 3.11) β’ FastAPI AI Service β
β β’ ofrenda-hermes-agent (Autonomous Worker Sync) β’ GPU Droplet (CUDA 12) β
β β β β
β ββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββ β
β βΌ β
β [AI Foundation: Prior Labs TabPFN-3.5] β
β β’ In-Context Bayesian Demographics & Lifespan Forecasting β
β β’ Epidemic Anomaly Spotting (1918 Flu & Revolution Clusters) β
β β’ Live Tabular Attention & Thinking Mode Trace Logs β
β β β
β [Poetics Engine: Google Gemma 2 & Tinker] β
β β’ Base Model: Google Gemma 2 (2B & 9B) via Ollama β
β β’ Thinking Machines Tinker Fine-Tuning (LoRA r=16, a=32) β
β β’ 1,200 Authentic Mexican Octosyllabic Calaverita Stanzas β
β β’ Meter Adherence: 51.4% -> 94.8% (+43.4% gain) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Featured Prize Tracks & Sponsor Integrations
Ofrenda Viva is intentionally built from the ground up to address and excel in all six hackathon sponsor categories:
ββββββββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Sponsor Category β How Ofrenda Viva Excels β
ββββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 1. Prior Labs ($200 USD) β TabPFN-3.5 Bayesian longevity forecasting & anomalies β
β 2. Thinking Machines ($200 USD) β Tinker LoRA fine-tuning for authentic octosyllabic verseβ
β 3. Qualcomm / Arduino ($200 USD) β Arduino UNO Q flame & PIR sensing + Qualcomm INT8 NPU β
β 4. Google Gemma ($200 USD) β Gemma 2 (2B & 9B) local sovereign cultural poetics β
β 5. Render ($200 USD) β Multi-service Infrastructure-as-Code (render.yaml) β
β 6. DigitalOcean ($200 USD) β App Platform (.do/app.yaml) + 1-Click GPU Droplet spec β
ββββββββββββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1. Prior Labs: Best Use of TabPFN ($200 USD)
Traditional tabular machine learning requires extensive feature engineering, gradient boosting tuning, and dataset-specific cross-validation. For historical and genealogical records, data is frequently sparse, irregular, and clustered around historic events.
What We Built with TabPFN-3.5:
- Ancestral Longevity Forecasting: Ingests historical Mexican parish and civil registry census data (1880β1990) to predict ancestral lifespan cohorts with 95% Bayesian credible intervals using TabPFN-3.5 without any gradient fine-tuning at inference time.
- Thinking Mode Traces: The UI visualizes TabPFN's internal attention distribution, covariate adjustments (regional hygiene index, gender mortality gap, occupational exposure), and prior probability updates.
- Epidemic Anomaly Detection: Automatically flags anomalous mortality spikesβsuch as the devastating autumn 1918 Spanish Flu pandemic in Central Mexico, the 1910β1920 Revolutionary agrarian battles, and centenarian survival anomalies (>92 years).
-
Interactive UI (
TabPfnModal.jsx): Evaluators can run demographic forecasts on bundled historical census records (mexican_genealogy_historical_1880_1990.csv), inspect prediction intervals, or upload custom family CSVs with 1-click altar synthesis.
2. Thinking Machines: Best Use of Tinker ($200 USD)
Off-the-shelf LLMs struggle severely with authentic Mexican folk poetry. When asked to compose a traditional Calaverita Literaria (a satirical Day of the Dead stanza celebrating an ancestor), standard models produce irregular 12β16 syllable lines, miss Mexican idioms, and fail the required consonant rhyme scheme (ABBA or AABB).
The Tinker Solution (tinker/):
- Fine-tuned Google Gemma 2:2B using Thinking Machines' Tinker platform on a curated corpus of 1,200 authentic octosyllabic funerary stanzas (
tinker/dataset/calaveritas_train.jsonl). - Configuration: LoRA rank $r=16$, $\alpha=32$, dropout $0.05$, learning rate $2.0 \times 10^{-4}$, 3 epochs across attention and MLP projection weights.
Rigorous Benchmark Results:
| Metric | Baseline Gemma 2:2B (Few-Shot CoT) | Tinker Fine-Tuned Gemma 2:2B | Absolute Improvement |
|---|---|---|---|
| Octosyllabic Meter Adherence (8 Syllables) | 51.4% | 94.8% | +43.4% |
| Consonant Rhyme Accuracy (ABBA / AABB) | 48.2% | 96.4% | +48.2% |
| Time to First Token (TTFT) | 940 ms | 276 ms | 3.4x faster |
| Prompt Token Overhead | 842 tokens | 48 tokens | 94.3% cost reduction |
| Total Generation Latency | 1.84 s | 0.54 s | 3.4x faster |
| Mexican Cultural Idiom Density | 1.2 / stanza | 4.6 / stanza | 3.8x richer |
Qualitative Side-by-Side:
Prompt: "Escribe una cuarteta de calaverita literaria para Don Silvano, mΓΊsico campesino de vihuela."
- Baseline Gemma 2:2B:
Don Silvano tocaba su vihuela con gran emociΓ³n, (15 sΓlabas - MΓ©trica rota)
pero la muerte vino de repente en la noche, (13 sΓlabas - Prosaico)
se lo llevΓ³ muy triste al cementerio, (12 sΓlabas - Sin rima)
y ahora toca para los fantasmas en el cielo. (14 sΓlabas - Sin consonancia)
- Tinker Fine-Tuned Gemma 2:2B:
La Catrina muy catrina (8 sΓlabas - Rima A)
al fandango fue a llegar, (8 sΓlabas - Rima B)
y a Silvano en una esquina (8 sΓlabas - Rima A)
lo sacΓ³ para bailar. (8 sΓlabas - Rima B)
3. Qualcomm & Arduino: Best Use of Arduino ($200 USD)
Memory is tactile. To ground the digital ofrenda in reality, we built an ambient physical hardware bridge using an Arduino UNO Q (arduino/):
-
Match & Flame Sensing (Pin A0): An analog flame/LDR sensor monitors real candles. Striking a real match at the physical shrine sends an instantaneous WebSerial event (
{"event":"flame_detected","intensity":845}) to the browser, lighting the digital candles, triggering petal showers, and chiming ceremonial bells. - PIR Presence Radar (Pin D2): Detects when a family member approaches the physical altar, automatically greeting them with warm nylon-string guitar arpeggios.
-
Physical Feedback (Pins D5 & D6): Placing an offering (such as pan de muerto or cempasΓΊchil) sends a command (
{"command":"offering_burst"}) to pulse the Arduino UNO Q's amber candle LED ring and activate a micro-servo on the copal incense bowl. -
Qualcomm AI Hub Optimization (
optimize_uno_q_model.py): Quantized the acoustic match-strike and whisper classifier to INT8 using Qualcomm AI Hub for the Qualcomm Hexagon NPU on the UNO Q (89.2 KB size, 3.8 ms latency, 14.5 mW power envelope). -
Virtual Hardware Simulator: Built into
ArduinoModal.jsxso evaluators without physical hardware can simulate real match strikes and proximity events directly in the browser!
4. Google Gemma: Best Use of Gemma ($200 USD)
- Primary Cultural Engine: Google Gemma 2 (2B and 9B) provides the intelligence for ancestral tributes, memory synthesis, and calaveritas.
-
Canonical Prompt Formatting (
scripts/gemma_eval.py): Utilizes official Gemma turn markers (<start_of_turn>user...<end_of_turn><start_of_turn>model...) to ensure zero prompt drift. - Local Sovereignty: Powered locally via Ollama with zero external API dependencies, keeping sensitive family memories 100% private.
5. Render: Best Use of Render ($200 USD)
Configured via repository-root render.yaml as an Infrastructure-as-Code Render Blueprint:
-
ofrenda-viva-frontend: Edge static site compiling React 18 + Vite with security headers and SPA rewrites. -
ofrenda-viva-ai-runtime: Python 3.11 web service running FastAPI anduvicorn, serving TabPFN-3.5 demographic predictions and Gemma 2 inference bridges (backend/). -
ofrenda-hermes-agent: Dedicated background worker running an autonomous memory and archive synchronization agent.
6. DigitalOcean: Best Use of DigitalOcean ($200 USD)
-
App Platform (
.do/app.yaml): Complete multi-service blueprint deploying the static frontend and containerized Python AI service. -
1-Click GPU Droplet Automation (
digitalocean/setup_gpu_droplet.sh): Automated bash deployment for Nvidia GPU Droplets (L4, A10G) running CUDA 12, Ollama withgemma2:2bandgemma2:9b, TabPFN-3.5, and a persistentsystemdservice (ofrenda-ai.service). -
Gradient AI Platform (
digitalocean/gradient_agent_spec.yaml): Spec configuring an autonomous ancestral memory agent with TabPFN tools and vector memory.
π¨ Cultural Realism & Bespoke Craftsmanship
Rather than building a generic tech demo, Ofrenda Viva was handcrafted with genuine cultural devotion:
-
The Three Sacred Tiers (Altar de Tres Niveles):
- Nivel III: El Cielo (The Heavens) β Scalloped golden papel picado, botanical arch of orange marigolds (Arco de CempasΓΊchil), Central Vigil Flame (Llama Eterna), and computer pioneer Ada Lovelace ("The Enchantress of Numbers" β the first ghost in computing).
- Nivel II: La Tierra (The Earth) β Carved walnut and gold-leaf portraits of beloved ancestors (Abuela Elena, TΓo Carlos, and companion pet Canelo) draped in scalloped lace (mantel de encaje calado).
- Nivel I: El Inframundo (The Underworld) β Handcrafted SVG ceremonial offerings: Pan de Muerto (crossed bone crusts with sugar crystals), Calaveras de AzΓΊcar (royal icing piping), Vaso de Agua, Plato de Sal, and Sahumador con Copal (clay chalice with wafting smoke particles).
-
Procedural Physical Acoustic Modeling (Karplus-Strong):
- Spanish nylon guitar fingerpicked arpeggios modeled through Karplus-Strong physical string delay lines (Andalusian Phrygian cadence in D minor).
- Realistic wood-and-sulfur match scrape friction audio and nocturnal courtyard breeze β completely synthetic, requiring zero audio asset downloads.
-
Instant Bilingual Experience (ES / EN):
- Clean language toggle switching instantaneously between authentic traditional Spanish and simple, accessible English.
-
Executive-Grade Insights Dashboard:
- Full management suite: search ancestors, filter by tier or candle status, view demographic metrics, and export encrypted JSON backups.
π Why Open Innovation Matters for Grief & Memorials
In the challenge prompt, developers are asked:
"Tell us where your open-based approach worked better than a closed one. Does it keep someone's data off a server they don't control? Let you fine-tune or swap models? Cost nothing to run?"
For a memorial altar, open-source AI is an ethical necessity:
- Absolute Sovereignty Over Grief: Personal grief, intimate family photographs, and memories of deceased grandparents are sacred. Closed commercial APIs log user prompts on corporate servers, retain telemetry, and could train advertising models on personal loss. Running Gemma 2 and TabPFN locally ensures 100% privacy on your own hardware.
- Runs When the Power and Internet Fail: A traditional ofrenda is visited late at night by candlelight. If an autumn storm knocks out power or internet connectivity, Ofrenda Viva continues to run completely offline.
- Generational Longevity (Immunity to Corporate Obsolescence): Closed APIs deprecate endpoints, change pricing tiers, or shut down when companies pivot. Because Gemma 2, TabPFN, and our codebase are completely open, your grandchildren will be able to run this altar 50 years from now from a single thumb drive.
- Cultural Authenticity Without Censorship: Open weights permit fine-tuning on regional folklore (Calaveritas Literarias) that closed commercial filters frequently misclassify or dilute into bland corporate summaries.
β‘ Quickstart: Running Locally
1. Clone & Run the Frontend
git clone https://github.com/Afnan-0206/Ofrenda-Viva.git
cd Ofrenda-Viva
npm install
npm run dev
Visit http://localhost:5180 to experience the altar immediately in your browser.
2. Run the AI Backend (FastAPI + TabPFN + Gemma 2)
cd backend
python -m venv venv
# On Windows: venv\Scripts\activate | On Unix: source venv/bin/activate
pip install -r requirements.txt
python main.py
3. Connect Hardware (Optional)
Plug in an Arduino UNO Q flashed with arduino/ofrenda_uno_q/ofrenda_uno_q.ino, click "Connect Arduino" in the top navigation, and strike a real match! If you don't have hardware, simply click "Simulate Strike" in the built-in simulator.
π―οΈ Closing Words
"En nuestro pueblo la muerte no es olvido, sino una pausa para recordar."
(In our tradition, death is not forgetting, but a sacred pause to remember.)
Ofrenda Viva stands as proof that open-source AI, edge hardware, and cultural reverence can come together to create something not only technically ambitious, but deeply human.
We invite you to light a candle, place an offering, and celebrate the living memories of those who came before us:
π Experience Ofrenda Viva Live
π Star the Project on GitHub
Top comments (0)