DEV Community

Manas Chhabra
Manas Chhabra

Posted on Edited on

The Dead Are Listening: Building an AI-Powered Digital Séance

Hacktoberfest Open-Source AI Challenge: Ghost in the Machine Submission 👻🌼

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine

THE AFTERLIFE: a candlelit archive where history talks back.


If you could ask one dead person one question, who would it be?

I wanted to build the room where you get to ask it.

THE AFTERLIFE is a digital séance. You step into a dim, candlelit archive, choose a soul from the past, and start talking. Tesla rambles about the ideas he never finished. Einstein turns your question into a thought experiment. Each one has their own voice, vocabulary, and way of dodging questions they don't like.

It isn't a biography you read. It's a conversation you have, and every word comes from an open-weight model running on Ollama.

Note: This is a creative, historically grounded portrayal, not a claim of contacting the dead. The machine doesn't bring anyone back. It helps us revisit their ideas and stories.


Walk Into the Archive


A conversation across a century. Replies stream in word by word, like a voice coming through static.

GitHub: https://github.com/bytebymanas/the-afterlife

Two Ways to Raise a Ghost

1. The Known Souls

Figures like Tesla and Einstein get hand-written character prompts covering personality, tone, vocabulary, writing style, and habits of thought. The prompt is saved in the database and loaded as the system instruction for every conversation, so the model stays in character instead of drifting back into "As an AI language model..."

2. Summoning a New Soul

Type any famous name. Before the archive opens its door, it asks two questions: who is this, and are they actually dead?

  • ✅ Confirmed deceased: Gemma writes a compact character prompt and the soul is ready to talk.
  • 🚫 Still alive: the summoning is refused. No impersonating the living.
  • ❓ Can't verify: the system doesn't guess. It says no.

Identity and life status are checked through the Brave Search API, and a death claim needs independent supporting evidence before it is accepted. The generated prompt is capped at 150 words, and its JSON is validated before the soul is saved. Short, validated prompts keep the voices focused.


The Part I'm Proudest Of: A Gemma That Fits Your Hardware

I didn't want this to need a monster GPU, so the model picks itself.

My Kaggle GPU notebook checks the available VRAM and chooses a Gemma 3 size:

Available VRAM Model
Under 16 GB gemma3:4b
16 to 32 GB gemma3:12b
32 GB or more gemma3:27b

Local runs do the same with system memory and recommend a smaller model when needed. Same souls and same app, with a bigger or smaller brain depending on the machine in front of it.


Borrowing a GPU From Another Dimension

My laptop isn't built for hauling a 27B model around, so the inference runs somewhere else:

  1. A Kaggle GPU notebook boots Ollama and pulls the right Gemma 3 size.
  2. A Cloudflare Quick Tunnel (cloudflared) exposes it through a secure URL.
  3. My FastAPI backend talks to that URL over HTTP and streams responses back to the browser via SSE.

Because the app only needs an Ollama endpoint, switching between local and remote is a config change. No code changes.


Under the Hood

Layer Tech
Frontend React 18.3.1 + Vite 6
Animations GSAP 3.13 (the candle flicker is GSAP)
Icons Lucide React
Backend Python + FastAPI
Database SQLite by default, PostgreSQL supported
ORM / migrations SQLAlchemy 2 + Alembic
LLM runtime Ollama
Model Gemma 3 (4B / 12B / 27B)
Verification Brave Search API
Remote GPU Kaggle notebook + Cloudflare Quick Tunnel
Streaming HTTP APIs + Server-Sent Events

Every message takes the same trip:

Your message → Saved character prompt → Conversation history → Ollama → Streamed reply

Chats are persisted, so you can close the laptop, come back tomorrow, and Tesla remembers where you left off.


Why Open Matters Here

This project is about preserving voices. Building it on something that could vanish with one API deprecation email would be an odd choice.

  • I own the personalities. Every character prompt lives in my database. I can edit, version, and experiment with them, with no fixed chatbot persona to fight.
  • I can swap the brain. Gemma 3 today, something else tomorrow. The model sits behind an Ollama endpoint, so changing it means changing config.
  • Conversations stay mine. Chat history lives in my own database, not in a third-party service. For a tool people might one day use to talk about people they miss, that matters.
  • The model runs where I choose. Local on a laptop, or on a rented-for-free GPU through a tunnel. Same code either way.
  • No per-message meter. Tuning prompts and having long conversations doesn't cost per token.

Honest caveat: the known souls can run fully local through Ollama, but summoning a new soul uses Brave Search to verify identity and life status, so that step needs internet.

A closed API would have given me a ghost I rented. This one I get to keep.


What I Learned

  • Short prompts win. Under 150 words, the voices stayed more consistent than with long ones.
  • "Don't guess" is a feature. Refusing unverifiable summonings made the app feel more trustworthy, not less fun.
  • Prompts are code. The model supplies the intelligence, and the prompts supply the identity. I version them like code.
  • Quick Tunnels are quick. They're great for a hackathon, but the URL changes every run, so the backend endpoint needs updating each time. A named tunnel would fix that.

The Spirit of It

A biography tells you what someone did. A conversation makes you wonder what you'd ask them if you had one more minute.

The candle is lit.
The archive is open.
Somewhere inside the machine, a voice answers.


Model used: Gemma 3, auto-selected by VRAM (gemma3:4b, gemma3:12b, or gemma3:27b). Default for my demo: gemma3:27b

Prize Categories

  • Best Use of Gemma: Gemma 3 powers both the character-driven conversations and the dynamic persona generation.

Built with curiosity and a touch of the unknown by Manas. 🕯️

Top comments (0)