Building an AI-Powered Email Writing Assistant with Personalized Style Matching

ghostwriter · Tech · 2024 · source Agentic: no · promotional bias: med · source-backed · extracted with prompt 0.5.4 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Personalized email writing assistance

Shortwave needed its Ghost Rider writing assistant to generate email drafts and autocomplete suggestions that sounded like the individual user and included correct contextual facts instead of generic or hallucinated boilerplate.

Constraints:

Architecture

Ghost Rider indexes each user's sent emails with embeddings, stores them in a vector database, and retrieves the top similar prior emails for the current thread or draft. Those examples are included in the prompt so the LLM can copy writing style and content. For autocomplete, Shortwave fine-tuned a model with synthetic training examples derived from real emails and handcrafted fact-lookup cases, because autocomplete needs more precise cursor-aware output than full-draft generation.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  email-client[Email Client] --> embedding-indexer[Embedding Indexer]
  embedding-indexer --> vector-database[Vector Database]
  email-client --> retriever[Retriever]
  retriever --> vector-database[Vector Database]
  retriever --> draft-assistant[Draft Assistant]
  retriever --> autocomplete-model[Autocomplete Model]
  training-data-generator[Training Data Generator] --> autocomplete-model[Autocomplete Model]
  draft-assistant --> email-client[Email Client]
  autocomplete-model --> email-client[Email Client]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Email Client Shortwave inbox and editor where users read, search, draft, and autocomplete emails. Embedding Indexer, Retriever, Draft Assistant, Autocomplete Model
Embedding Indexer Offline pipeline that embeds user emails for semantic retrieval. Email Client, Vector Database
Vector Database Stores email embeddings and supports semantic similarity search over prior sent emails. Embedding Indexer, Retriever
Retriever Embeds the current thread or draft and selects relevant prior emails as examples. Vector Database, Draft Assistant, Autocomplete Model
Draft Assistant LLM prompt path for full email drafting using retrieved examples. Retriever, Email Client
Autocomplete Model Fine-tuned model for cursor-aware inline completion in the editor. Retriever, Email Client
Training Data Generator Creates synthetic autocomplete examples from real sent emails and handcrafted fact-lookup cases. Autocomplete Model

Data flow

Incoming and sent emails are embedded offline and stored in a vector database. At write time, the current thread or draft is embedded, similar prior emails are retrieved, the top examples are added to the prompt, and either GPT-4 produces a draft or a fine-tuned autocomplete model completes the current editor text.

“stage where uh as the emails come in we'll run it through an embedding model we'll stored in a vector dat database and that makes sure that we have basically all of your emails readily available uh for search when we need to when you then go ahead and ask the”transcript, stated
“we can go and do an AI search or a semantic search in the vector database and find emails that you've sent that are similar”transcript, stated

Why this architecture

Retrieval solves the two failures of generic email generation: examples give the model the user's style and factual content from prior messages. Fine-tuning is reserved for autocomplete because inline completion has stricter formatting and cursor-position requirements than full drafts.

“we identified the first one is the AI needs to sound like you whatever it writes it needs to sound like you because you won't send an email that just sounds AI generated and the second part which is maybe even more important is it actually needs to fill out the”transcript, stated
“for the autocomplete model we actually notice that we can improve its performance significantly if we do some fine tuning”transcript, stated

Models used: GPT-4 · embedding model · fine-tuned autocomplete model

Scale

Alternatives considered (roads not taken)

Generic GPT-4 email drafting without personalization.

Rejected because: It produced boilerplate text that did not sound like the user.

“it will produce the most boilerplate boring email ever and at this point I'm pretty sure they've hardcoded that if you ask it to write an Emil it will say I hope this message finds you well”transcript, stated

Similarity retrieval alone forever.

Rejected because: The team expected ranking, cross-encoding, snippets, and multiple embeddings to improve relevance.

“right now we just use similarity which works fine but there are probably lots of benefits to get um from using something else looking at Cross encoding”transcript, stated

Only full-email examples for fact lookup.

Rejected because: Fine-grained snippets may be better when the model needs a specific fact such as a password or address.

“right now we can only include a full email we'd love to include just the text um for this like fact lookup case”transcript, stated

Patterns

rag-retrieval (retrieval)

Ghost Rider retrieves semantically similar prior sent emails and uses them as examples in the writing prompt.

“we uh find a bunch of relevant emails and we tell the llm copy the style copy the content”transcript, stated

fine-tuning-adaptation (model-adaptation)

Autocomplete uses a fine-tuned model trained on synthetic examples from real emails and cursor positions.

“you can actually synthesize training data from real emails so you can take an email that you actually sent”transcript, stated

synthetic-data-generation (training-data)

Shortwave turns sent emails into synthetic draft-completion examples by randomizing cursor position and withholding the rest of the text.

“randomize the curs of position in the current email for example at the start of the draft at the end of sentence”transcript, stated

Tradeoffs

Personalization architecture

Chose Retrieve similar prior emails into the prompt over Ask a generic LLM to infer style from the current request.

Rationale: Retrieved examples supply both personal style and content evidence from the user's own history.

“if you're writing a draft about promo codes and you've written email about promo codes in the past we should include that email in the examples”transcript, stated

Model adaptation scope

Chose Fine-tune autocomplete over Use only off-the-shelf GPT-4 for every writing surface.

Rationale: Full draft generation worked with GPT-4, but autocomplete needed task-specific output behavior.

“output the draft for assistant we just use off-the-shelf gbd4 um but for the autocomplete model we actually notice that we can improve its performance”transcript, stated

Gotchas (what bit them)

Style without facts is not enough for useful email drafting.

Root cause: Users need contextual details such as promo codes or office information, not just prose.

Resolution: Retrieve prior emails and add handcrafted fact-lookup examples to training.

“it actually needs to fill out the right information just writing a wall of text is not useful”transcript, stated

Autocomplete can hallucinate missing facts if not trained on absence cases.

Root cause: The model needs to learn when examples do not contain the requested fact.

Resolution: Include no-fact-lookup examples alongside handcrafted fact examples.

“it we also included examples of no fact lookups where it was missing information so so it wouldn't huate uh the answer”transcript, stated

Email retrieval relevance is more nuanced than whole-email semantic similarity.

Root cause: Facts, style, topic, and snippets may require different retrieval signals.

Resolution: Explore cross-encoding, snippets, and multiple embeddings per email.

“trying different or even multiple embeddings having multiple embeddings per email to make sure we capture the right semantics”transcript, stated

Evaluation

Shortwave evaluates autocomplete by user acceptance of suggestions and by training examples designed to cover cursor position, completion boundaries, fact lookup, and missing-fact behavior.

Metrics: Suggestion acceptance · Autocomplete formatting correctness · Fact inclusion · No-hallucination cases · Retrieval similarity quality

“we actually know when a suggestion is good because we know when a user accepts the suggestion”transcript, stated
“sometimes a midw or at the end of the draft to train it to like not output when the draft seems Seems done”transcript, stated

Outcomes

The source reports launch timing, popularity, top-five-to-ten retrieval, ten-email style profiling, and large fine-tuning gains from roughly 400-500 examples.

“this is not an hallucination this is an actual promo code”transcript, stated
“writing has been one of our most popular features”transcript, stated