Ghostwriter - AI Writing That Learns From You

Jonny Dimond22 May 2024

Problem

A large language model (LLM) asked to write an email produces generic, long-winded text ("I hope this message finds you well"). Users do not send it: it does not sound like them and lacks the facts they would have written. Shortwave, an AI-first email client, needed drafts in each user's voice with the right facts, plus inline autocomplete.

Example from the article: a customer asks "do you have a promo code?". Autocomplete proposes the user's usual opening and then the code "AI project 2024" with "10% off". The model took the code from an earlier email the user had sent to their team.

Solution in brief

Retrieve the user's own past sent emails that are similar to the current thread or draft, put them in the prompt, and tell the LLM to copy their style and content. Autocomplete uses a model fine-tuned on a few hundred synthetic examples built from the user's real emails.

Questions this case answers
  • How to make an LLM generate text in an individual user's voice and with the user's own facts when per-user fine-tuning is too costly
  • How to build training data for a cursor-position completion model from a corpus of the user's finished texts
  • How to make an LLM draft emails that sound like a specific user?
  • How to make generated drafts contain the right facts, such as a promo code or an office address?

Tools and methods

  • Embeddings and vector database — index every email on arrival, search for similar ones at draft time
  • Retrieval-augmented prompt — the user's sent emails as examples
  • GPT-4 — drafts for the assistant, without fine-tuning; the team swaps models as better ones appear
  • Fine-tuned model — autocomplete with exact whitespace and "output nothing" behavior
  • Email cleaning pipeline — extracts the text the user actually wrote from nested threads
Continue reading — it's free

Google or a one-time email code. No password.