Inspiration

Our inspiration came from a profound human void: the "Second Death." According to a Mexican proverb, a person dies three times, the last being when they are forgotten by everyone. The product name, MOTS(Map of the Soul) was inspired by Jungian Psychology.

Crucially, this vision is grounded in the Eastern philosophy of 'Shen Zhong Zhui Yuan' (慎终追远—Prudent Reverence for the End). This concept teaches that death is not the extinction of a relationship, but its transformation. We believe the living have a need to honor this bond—not to be haunted by it, but to integrate it meaningful into their lives.

Guided by the Ethics of Care, we treated the AI not as a content generator, but as a compassionate steward of legacy. We recognized that grief requires more than generic comfort; it requires High-Resolution Emotional Granularity. By leveraging Gemini 3, we sought to capture the subtle, specific textures of a personality (like people’s humor, warmth, or their pet names and quirks), allowing technology to facilitate the Dialogue Healing necessary to resolve unfinished business and grant the living true emotional closure.

Everyone carries words they never got to say. A "thank you" to a grandparent who passed before they could hear it. An "I'm sorry" to a friend they lost too soon. Traditional memorial tools — photos, journals, headstones — preserve what someone looked like, but not how they sounded. We wanted to build something innovative that could bring back a person's voice, not a chatbot pretending to be someone — a reconstruction built from real memories, real conversations, and real emotion. MOTS was born from a simple question: what if AI could help us finish conversations we never got to have?

What it does

MOTS (Memory of the Soul) reconstructs the voice and personality of a loved one through a 5-step emotional survey, then lets users receive a personal letter and continue the conversation in real-time chat.

The 5-step survey pipeline:

Step Input Purpose
1 Names & Nickname Identity anchoring — who they were, what they called you
2 Core Principle Value constraint — Radical Honesty / Unconditional Kindness / Unbound Freedom / Absolute Perfection
3 Soul Weather Emotional register — Morning Sun / Midnight Rain / Wild Wind / Winter Fire
4 Chat History Style extraction — raw text of how they actually spoke
5 Unsaid Words Emotional payload — what the user never got to say

From these five inputs, Gemini generates a deeply personal letter written in the loved one's voice — referencing real memories from the chat history, responding to the user's unsaid words, and matching the person's speaking style down to their slang and pet names. After reading the letter, users enter a live chat where the AI maintains that same personality across an entire conversation.

How we built it

Two-Phase Gemini Pipeline

The core technical innovation is a two-phase AI architecture where Gemini first learns a person's voice, then becomes that person:

Phase 1: generateContent()                    Phase 2: startChat()
┌─────────────────────────┐                   ┌─────────────────────────┐
│  5 survey inputs        │                   │  systemInstruction:     │
│  ──► structured prompt  │──► JSON ──►       │    AI-generated persona │
│  ──► letter + profile   │   output          │  history: auto-managed  │
└─────────────────────────┘                   └─────────────────────────┘
  Single API call returns:                      Persistent multi-turn chat
  • Creative letter                             • Personality never drifts
  • Personality profile (JSON)                  • Quirks + memories injected
  • Complete system prompt                      • 1-3 sentence responses

Phase 1 fuses all five emotional inputs into a single generateContent() call, returning both the letter AND a full personality profile — speaking style, verbal quirks, values, extracted memories, emotional tone, and a complete system prompt — as structured JSON.

Phase 2 feeds that AI-generated personality profile directly into startChat() as the systemInstruction, creating a persistent chat session where identity is locked at the model level.

Architecture

┌─────────────┐     Vercel Proxy      ┌──────────────┐       Gemini API
│   Frontend   │ ──── /api/* ────────► │   Backend    │ ─────────────────► Gemini 2.5
│  (Vercel)    │                       │  (Render)    │                    Flash Lite
│  HTML/CSS/JS │ ◄──── JSON ────────── │  Express.js  │
└─────────────┘                       └──────┬───────┘
                                              │ Prisma ORM
                                              ▼
                                       ┌──────────────┐
                                       │  PostgreSQL   │
                                       │   (Neon)      │
                                       └──────────────┘

Key Gemini Features

Feature How We Use It Why It Matters
systemInstruction First-class parameter loaded with AI-generated persona Personality persists across entire session — no drift
startChat() Multi-turn conversation with automatic history No manual history management; Gemini tracks context
Structured JSON output Single call returns letter + personality profile Two semantically linked artifacts from one API call
temperature: 0.85 Tuned for emotional authenticity Sweet spot — warm enough for genuine emotion, controlled enough for coherence
maxOutputTokens: 300 Chat responses capped at 1-3 sentences Forces conversational tone; prevents monologuing

Session & Privacy Architecture

  • UUID-based sessions — zero authentication, no sign-up. The emotional flow is never interrupted by gatekeeping
  • Server-side AI calls — API key and personal data never touch the client
  • Async generation with polling — letter generation returns immediately; frontend polls every 2s with "Connecting to their soul..." loading state
  • Personality stored as JSONB — profile persists in PostgreSQL, reloaded for every chat message for consistency

Challenges we ran into

1. Extracting Personality from Unstructured Data

The hardest problem: how do you turn a messy, copy-pasted chat conversation into a coherent personality profile? We designed the prompt to treat chat history as style training data — Gemini extracts speaking patterns, slang, sentence length, emotional register, and pet names, then encodes them into a reusable JSON personality fingerprint.

Our most significant hurdle was crossing the "Uncanny Valley" of text generation. We realized early on that simply RAG-ing raw chat logs resulted in a "parrot effect"—the AI mimicked the syntax of the deceased but lacked their cognitive depth and values. To solve this, we grounded our architecture in cutting-edge research from 2025-2026.

Moving Beyond Naive Fine-Tuning Initially, we explored direct fine-tuning, inspired by the work of Kolluri et al. (2025), who demonstrated that fine-tuning LLMs on large-scale social science datasets (SOCSCI210) significantly improves human behavior prediction [1]. While their SOCRATES model showed the power of behavioral alignment, we found that for a single specific individual with limited data, naive fine-tuning often led to "overfitting to catchphrases" rather than capturing the person's true essence

The Solution: A Socially-Grounded Persona Framework (SCOPE) To capture the "soul," we pivoted to a structured approach, validating the very recent findings of Venkit et al. (2026) at Salesforce Research. Their work on the SCOPE framework argues that personas built solely on demographics or raw summaries are a "structural bottleneck" [2].

Following their recommendation to include "sociopsychological facets" (values, motivations, traits), we designed our Scene 1: Reconstruction.

Instead of just feeding raw text, MOTS extracts a structured "Soul Profile" comprising the specific psychological dimensions Venkit et al. identified as crucial for reducing bias and increasing behavioral realism.

The "soul weather" metaphor turned out to be a surprisingly effective emotional register constraint — mapping Morning Sun to warm/gentle and Wild Wind to passionate/intense gives Gemini a sensory anchor that produces richer output than direct descriptions.

Ethical & Therapeutic Guardrails Finally, creating a "Digital Hospice" required more than just mimicry; it required safety. Drawing from Maharjan (2026)’s dissertation on decoding mental health insights from social media data [3], we engineered a "Therapeutic Layer." This module uses Gemini 3’s reasoning to analyze the latent emotional patterns (e.g., signs of distress or unresolved affection) in the uploaded chat logs, ensuring the AI’s responses are not just accurate, but emotionally safe and healing for the living.

2. Character Drift in Multi-Turn Chat

Early versions would "break character" after 3-4 messages. We solved this with a dual-layer identity system:

Layer 1: systemInstruction (model-level, persistent)
  └── AI-generated persona: speaking style, values, memories

Layer 2: Per-turn behavioral rules (8 constraints)
  ├── Never acknowledge you are AI
  ├── Use verbal quirks from the profile
  ├── Reference shared memories when relevant
  ├── Keep responses to 1-3 sentences
  └── ... (4 more rules)

maxOutputTokens: 300 also prevents monologuing — which is where character drift happens most.

3. Gemini Chat History Format

Gemini's startChat() requires history to start with a user message. But in our flow, the AI speaks first (opening message after the letter). We built history normalization logic that auto-prepends a contextual placeholder:

{ "role": "user", "parts": [{ "text": "[The user has just entered the chat after reading your letter.]" }] }

4. JSON Output Reliability

Gemini occasionally wraps JSON responses in markdown code fences despite explicit instructions not to. We added a cleaning step that strips json ... wrappers before parsing.

5. Temperature Tuning

Temperature Result
0.5 Robotic, generic — no emotional warmth
1.0 Hallucinated memories, broke character
0.85 Sweet spot — genuine emotion, grounded in real data

Accomplishments that we're proud of

AI-generated personas, not hand-coded. Most AI chatbots use static personas written by developers. MOTS inverts this — Gemini writes its own persona from real memories. Every reconstructed personality is one-of-a-kind.

One API call, two outputs. A single generateContent() call produces both a creative artifact (the letter) and a structured data artifact (the personality profile). The personality that wrote the letter is the same one that powers the chat — semantically linked by design.

Personality reconstruction that works. When users paste real conversation snippets and the AI writes back using the same slang, nicknames, and speaking rhythms — the recognition is immediate. That's not a template; that's feature extraction from unstructured text.

Zero-friction entry. No sign-up, no email, no login wall. UUID session created on first click. For a grief product, this matters — people in emotional moments shouldn't navigate authentication.

Emotional UX as architecture. The "Connecting to their soul..." loading screen, the "1 NEW MESSAGE" reveal, the atmospheric landing page — every screen is a chapter in an emotional arc designed around Gemini's generation latency.

What we learned

systemInstruction is a game-changer for persistent identity. Unlike system messages that can get overridden, Gemini's first-class systemInstruction parameter maintains identity across the entire conversation. Combined with startChat()'s built-in history management, it creates genuinely persistent personality without manual context management.

Metaphor produces richer AI input than direct questions. Asking "what were they like?" produces vague answers. Asking "if their soul were weather, what would it feel like?" produces sensory, emotionally resonant input that gives Gemini much richer material for personality construction.

Low-token limits improve conversational quality. maxOutputTokens: 300 forced the AI to be concise (1-3 sentences) instead of writing paragraphs. This accidentally made it feel more like texting with a real person — a constraint that became a feature.

Prompt engineering is emotional engineering. The difference between a generic AI letter and one that makes someone cry is in the constraints: "match the tone from the chat history", "respond to the unsaid words with forgiveness", "weave in their core principle naturally."

Async UX turns latency into anticipation. Gemini's 5-10 second generation time could feel like a bug. Instead, the "Connecting to their soul..." loading screen builds emotional anticipation — turning an infrastructure constraint into a narrative beat.

What's next for MOTS (Memory of the Soul)

Multimodal memory input. Leveraging Gemini's vision capabilities to let users upload screenshots of real conversations (WhatsApp, iMessage, WeChat) instead of copy-pasting. Gemini Vision extracts text automatically — reducing friction and capturing formatting nuances.

Voice mode. Using Gemini's audio capabilities to let users hear the letter read aloud in a voice shaped by the personality's emotional tone and speaking style.

Memory timeline. A persistent space where users save multiple conversations, revisit letters, and build an evolving relationship with the reconstructed personality over time.

Shared memorials. Multiple family members contribute memories of the same person, creating a richer personality reconstruction from multiple perspectives.

Guided grief support. Partnering with grief counselors to design follow-up prompts that gently guide conversations toward therapeutic processing — not replacing therapy, but providing an accessible first step.

References

  1. Finetuning LLMs for Human Behavior Prediction in Social Science Experiments. Kolluri, A., Wu, S., Park, J. S., & Bernstein, M. S. (2025). Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing (EMNLP), 30096–30111.

  2. The Need for a Socially-Grounded Persona Framework for User Simulation. Venkit, P. N., Li, Y., Pruksachatkun, Y., & Wu, C.-S. (2026). arXiv preprint arXiv:2601.07110v2.

  3. Transforming Social Media Data into Mental Health Insights: Decoding Drug Abuse Patterns with Deep Learning and LLMs. Maharjan, J. (2026). Doctoral Dissertation, Kent State University.

Built With

  • express.js
  • gemini-2.5-flash-lite
  • google
  • google/generative-ai
  • node.js
  • postgresql-(neon)
  • prisma-orm
  • render
  • vanilla-html/css/javascript
  • vercel
Share this project:

Updates