Design NotebookLM
Understanding the Problem
📓 What is NotebookLM? NotebookLM is a research assistant built around a user's own material. You create a notebook, add sources (PDFs, Google Docs, web pages, YouTube videos, pasted text), and then chat with them. Answers come only from those sources, and every sentence carries a citation you can click to see the exact passage. It can also turn a notebook into a summary, a study guide or a podcast-style audio overview.
It looks like a RAG System, and it is one, but with a very different shape. Enterprise RAG searches one huge corpus shared by thousands of users. NotebookLM has hundreds of millions of tiny corpora, each owned by one user, each holding a few dozen sources at most, and never searched together. That difference drives most of the design.
Functional Requirements
Core Requirements
- Users should be able to create a notebook and add sources: uploaded PDFs, web links, YouTube videos and pasted text.
- Users should be able to ask questions and get answers grounded only in the notebook's sources, choosing which sources are included.
- Every claim in an answer should cite the passage it came from, and clicking a citation should show that passage in the source.
- Users should be able to generate notebook-level outputs such as a summary, a study guide or an audio overview.
Below the line (out of scope)
- Sharing and real-time collaboration on notebooks.
- The notes editor.
- Answering from the open web. If the sources don't cover a question, we say so (see AI Search for that product).
- Training or fine-tuning models on user data.
Non-Functional Requirements
Ask about scale and limits. We'll design for 10M monthly users, 2M daily, a limit of 50 sources per notebook and up to 500,000 words per source.
Core Requirements
- A typical source (a 50-page PDF, an article, a 30-minute video) should be ready to chat with in under 30 seconds; very large ones within a few minutes, with progress shown.
- Answers should start streaming within 3 seconds.
- Answers must be grounded: no claims from the model's general knowledge presented as coming from the sources, and citations must point to text that supports them.
- A user's sources are private to them: never visible to other users and never used for training.
- The system should handle about 10M questions a day (around 400 per second at peak) and 2M new sources a day.
Below the line (out of scope)
- Offline access and mobile-specific sync.
- Abuse of the audio feature (copyrighted books turned into podcasts) beyond basic policy checks.
The back-of-the-envelope shows why this is not enterprise RAG:
- A typical notebook has around 10 sources of maybe 20k tokens each: 200k tokens. The maximum (50 sources x 500,000 words) is roughly 33M tokens, but that's rare.
- At ~500 tokens per chunk, a typical notebook is ~400 chunks. With 768-dimension float32 embeddings (3 KB each), its whole vector index is about 1.2 MB.
- Brute-force cosine similarity over 400 vectors takes well under a millisecond on one CPU core. Even the 33M-token maximum is about 66,000 chunks, a few milliseconds of brute force.
- But there are a lot of notebooks. 100M notebooks x 1.2 MB is about 120 TB of vectors, almost all of which are cold on any given day.
The key insight: we never search across notebooks, so we don't need a big approximate nearest-neighbor index at all. We need cheap storage for a hundred million tiny indexes and a fast way to load the one the user is looking at. That's an object storage and caching problem, not a vector database problem.
There's a second insight. 200k tokens fits inside the context window of current long-context models. For many notebooks we could skip retrieval and give the model everything. Whether that's a good idea depends on cost, which we'll work out in the deep dives.
The Set Up
Planning the Approach
We'll build source ingestion first, then question answering with citations, then generated outputs. The deep dives cover long context versus retrieval, messy source formats, precise citations, audio overviews and storing millions of small indexes.
Defining the Core Entities
- Notebook: a container owned by one user, with a title, a list of sources and a chat history.
- Source: one added item (PDF, URL, video, text). It has a type, a processing status (
processing,ready,failed), the original file or URL, and the extracted, normalized text. - Passage: a chunk of a source's text with its location (page and bounding box for PDFs, character offsets for web pages, a timestamp range for videos) and an embedding. Passages are what we retrieve and cite.
- Message: a question or answer in the notebook's chat. Answers store their citations, each pointing to a passage and a span inside it.
- Artifact: a generated output (summary, study guide, FAQ, audio overview), with the set of sources it was generated from and a status.
API or System Interface
POST /notebooks -> { notebookId }
POST /notebooks/{id}/sources
{ type: "pdf" | "url" | "youtube" | "text", uploadUrl? | url? | text? }
-> { sourceId, status: "processing" }
GET /notebooks/{id}/sources -> [{ sourceId, title, status, error? }]
POST /notebooks/{id}/messages (streams via SSE)
{ question, sourceIds }
-> event: delta data: { text: "The study found ... " }
-> event: citation data: { n: 1, sourceId, passageId, span: [120, 245] }
-> event: done
POST /notebooks/{id}/artifacts { kind: "audio_overview", sourceIds } -> { artifactId }
GET /artifacts/{artifactId} -> { status, url? }
GET /sources/{sourceId}/passages/{passageId} -> { text, location }
PDFs upload directly to object storage through a pre-signed URL, so large files never pass through our API servers. sourceIds in the chat request is the user's source checklist; the server checks each one belongs to the notebook.
High-Level Design
1) Users should be able to add PDFs, links, YouTube videos and text
Adding a source is asynchronous. The API creates the Source row with status processing, puts a job on a queue, and returns immediately; the UI shows a spinner on that source and polls (or listens on a push channel) for it to turn ready.
An Ingestion Worker handles the job in four steps:
- Fetch. PDFs are already in object storage (GCS or S3). For a URL, the worker fetches the page, follows redirects, and extracts the main content (dropping navigation, ads and footers). For YouTube, it fetches the video's caption track if there is one, or downloads the audio and runs speech-to-text. Pasted text needs nothing.
- Extract. Turn the input into normalized text with locations: for PDFs, text with page numbers and bounding boxes (OCR for scanned pages); for web pages, text with character offsets into a saved snapshot; for videos, transcript segments with timestamps.
- Chunk and embed. Split by structure (headings, paragraphs, transcript segments) into ~300-600 token passages, each with its location, and embed them in batches on an Embedding Service.
- Store. Write the normalized text and passages to the source's folder in object storage, the passage metadata to the database, and update the notebook's vector index. Mark the source
ready.
The saved text is a snapshot. If a web page changes later, the notebook keeps answering from the version the user added, which is the right behavior for research (your citations shouldn't move). Users can explicitly refresh a source.
While the source is processing, the worker also asks a small LLM for a short summary and a few suggested questions, which the UI shows when the user clicks the source. They're cheap and make a new source useful before the user types anything.
2) Users should be able to ask questions answered only from their sources
The Chat Service receives the question and the selected source IDs, then:
- Loads the notebook's passage index (we'll see where it lives in the deep dives) and filters it to the selected sources.
- Embeds the question and finds the top passages by cosine similarity, plus a keyword match for exact terms. With a few hundred passages, this is a brute-force scan in memory.
- Builds a prompt: instructions to answer only from the provided passages and cite each claim, the numbered passages with their source titles, the recent chat history, and the question.
- Streams the LLM's answer back over SSE.
The instructions are explicit about grounding: if the passages don't contain the answer, say so. When users ask something general ("what's the capital of France?") in a notebook about quarterly earnings, the right answer is "your sources don't mention this," which is a product decision as much as a technical one. It's what makes users trust the citations.
3) Every claim should cite the passage it came from
The model sees passages labeled [1] to [20] and puts markers after each claim. As the answer streams, the Chat Service maps each marker to a passage ID and sends a citation event. The client turns markers into numbered chips; hovering one shows the passage, and clicking opens the source viewer scrolled to it, with the passage highlighted using its stored location: a page and bounding box for a PDF, offsets in the snapshot for a web page, a timestamp for a video (the player jumps there).
Citations are stored with the answer message, so reopening the notebook later shows the same links, even if the user has since removed or added sources. If a cited source was deleted, the chip shows "source removed" instead of a broken link.
4) Users should be able to generate summaries, study guides and audio overviews
These are jobs, not chat turns. They read many or all sources, take from a few seconds (a summary) to a few minutes (an audio overview), and produce an Artifact the user can come back to.
The API creates an Artifact with status queued and the hash of the source set it was asked for, and puts a job on a queue. An Artifact Worker runs it (described in the deep dives), writes the result (text to the database, audio to object storage), and marks it ready. If an Artifact for the same kind and the same source-set hash already exists, we return it instead of generating again; users often click "generate" twice.
Potential Deep Dives
1) Should we use long context or retrieval?
A typical notebook is 200k tokens. Many models can read that in one prompt, which would mean no chunking, no embeddings and no missed passages. It's worth doing the math before deciding.
Bad Solution: Always Put Every Source in the Prompt
Approach
For every question, concatenate the full text of all selected sources into the prompt.
Challenges
Cost and latency scale with notebook size on every question. At 400 questions per second and 200k tokens each, that's 80M input tokens per second of prefill, about 20 times what a retrieval design sending ~10k tokens needs, and the gap grows with every source a user adds. Time to first token for a 200k-token prompt is several seconds even on fast hardware, which misses our 3-second target. Large notebooks (millions of tokens) don't fit at all. Models also tend to use the middle of a very long context less reliably than the start and end, so "it's all in there" doesn't guarantee it gets used.
Good Solution: Always Retrieve the Top Passages
Approach
Use retrieval for every question: top 10-20 passages, about 5-10k tokens of context.
Challenges
Cheap and fast, but some questions aren't retrieval questions. "Summarize the main argument of this paper," "compare how these three sources define burnout" or "what's missing from this report?" need the whole document or a map of all of them. Top-k retrieval returns a few vaguely related passages and the answer comes out thin.
Great Solution: Choose Per Question, and Cache What Repeats
Approach
Route by the question and the notebook size:
- If the selected sources are small (say under 30k tokens total), put them all in the prompt. It's affordable and gives the best answers.
- Otherwise, classify the question with a small, fast model: specific questions ("what dose was used in the trial?") go to retrieval; global questions ("summarize," "compare," "what are the themes?") use per-source summaries that were generated at ingestion time, plus retrieval for supporting detail, or a map-reduce pass over the sources for the biggest asks.
- Use the model provider's context caching (or prefix caching on self-hosted models) when a user asks several questions in a row over the same large context. The cached prefix is billed and computed at a fraction of the cost on later turns.
Challenges
Routing adds a small model call (around 100-200 ms) and a new way to get things wrong. A misrouted global question gets a thin answer, so log routing decisions and review the low-rated answers. Context caches expire after minutes, so they help a focused session, not a user who comes back tomorrow.
In an interview, saying "we could just use long context" is a good start, not an answer. Do the multiplication: tokens per question times questions per second. It's usually the number that decides the design.
2) How do we handle messy sources?
Ingestion quality decides answer quality. Most user complaints ("it can't find the table on page 12") are parsing problems.
- PDFs range from clean digital exports to phone photos of book pages. Extract digital text where it exists, and OCR only pages that have none (OCR everything and you double the cost and add errors to clean pages). Keep layout: reading order across columns, headings, tables as tables (row and column structure, not a word soup), and figure captions. A vision-language model can describe charts and figures as text so they become searchable. Store every passage with its page and bounding box.
- Web pages need main-content extraction (a readability-style algorithm or a small model) and a stored snapshot. Some pages need JavaScript to render, so run a headless browser for those, with tight timeouts. Respect robots rules and don't bypass paywalls or logins; if we can't fetch a page, the source shows a clear error and the user can paste the text instead.
- YouTube videos usually have captions, either uploaded by the creator or auto-generated. Use them when available, since they're free and fast. Otherwise download the audio and run a speech-to-text model (a 30-minute video transcribes in well under a minute on a GPU). Transcript segments carry timestamps, so a citation can say "12:40" and jump the player there. Captions without punctuation chunk badly, so restore punctuation and sentence boundaries first.
- Very large sources (a 500,000-word book) are split into parts and processed in parallel by several workers, then merged. The source becomes usable for retrieval as soon as all passages are embedded; the summary can finish a little later.
Every stage writes its output to object storage before the next starts, so a failure retries one stage, not the whole source. Each source has its own status, and a failed source shows why (scanned PDF with unreadable pages, page blocked, video has no audio) instead of a generic error.
3) How do we make citations precise and trustworthy?
Citations are the product. A citation that points to a passage that doesn't support the claim is worse than no citation, because it borrows trust it hasn't earned.
Bad Solution: Cite Whole Sources
Approach
After the answer, list which sources were used.
Challenges
"Source: Annual Report 2024 (180 pages)" tells the user nothing they can check quickly. It also doesn't tell us whether the answer is supported at all.
Good Solution: Passage-Level Markers From the Prompt
Approach
Number the retrieved passages in the prompt and have the model cite them inline, as in the high-level design. Map markers to passages and highlight the whole passage in the viewer.
Challenges
Passages are a few hundred tokens, so the highlight covers a paragraph or two; the user still has to read it to find the supporting sentence. Models also sometimes cite the wrong number, especially among similar passages, or invent a number that wasn't provided.
Great Solution: Span-Level Citations With Verification
Approach
Ask the model to output, for each claim, the passage number and a short verbatim quote from it. After the claim is generated, a verifier:
- Checks that the passage number was provided.
- Finds the quote in the passage with a fuzzy string match (to tolerate whitespace and minor differences) and converts it to exact character offsets, so the viewer highlights just that sentence.
- Optionally runs a small entailment model on (quote, claim) to confirm the quote supports the claim.
Claims that fail verification are re-attributed (search the provided passages for the best-matching span) or shown without a citation chip, and the failure is logged. Structured output (the model returns JSON with claim text and citations, which the server renders) makes this easier than parsing free text, at the cost of a slightly less natural stream.
Challenges
Verification has to keep up with streaming. String matching is microseconds and can run per sentence; an entailment model adds tens of milliseconds per claim, so run it asynchronously and update the chip if it fails. Quotes add output tokens (maybe 20-30% more), which costs money and latency. Track citation precision over time with an evaluation set and sampled production answers; see LLM Evaluation.
4) How do we generate an audio overview?
An audio overview turns a notebook into a few minutes of two AI hosts discussing it. It's a good example of a multi-stage generation job, and interviewers sometimes ask about it because it's the most distinctive feature.
The pipeline:
- Understand the sources. For each source, use its stored summary; for large notebooks, run a map step that extracts key points per source, then a reduce step that picks the main themes, surprising findings and the questions a listener would have. This keeps each LLM call within a manageable context.
- Write a script. A strong LLM writes a dialogue between two hosts in structured form (speaker, line, and the passages each line draws on), with instructions for a natural conversation: questions, reactions, analogies, a clear arc. The passage references keep the content grounded; a check pass flags lines with no supporting passage.
- Synthesize speech. A multi-speaker text-to-speech model renders each line in the right voice, with prosody and small disfluencies that make it sound conversational. Lines are synthesized in parallel and concatenated with natural pauses.
- Store and notify. The audio file goes to object storage behind a CDN, the Artifact is marked
readyand the user is notified. We also keep the script, so the player can show a transcript and, later, link moments in the audio back to sources.
A 10-minute overview is roughly 1,500 spoken words. The LLM work is a few calls with tens of thousands of tokens each; the TTS is a few GPU-seconds per line. End to end, a few minutes is realistic, which is why this is an async job with a notification, not a request. Because it's expensive, limit it per user per day, cache it by source-set hash, and run it at lower priority than interactive chat on shared GPUs.
5) How do we store and serve a hundred million small indexes?
We worked out that each notebook's index is about a megabyte and that we never search across notebooks.
Bad Solution: One Global Vector Database With a Notebook Filter
Approach
Put every passage from every notebook in one large vector database and filter by notebook_id at query time.
Challenges
The filter matches about one in a hundred million rows. Approximate nearest-neighbor indexes like HNSW are built for searching the whole collection; with a filter that selective, the engine either scans most of the graph for nothing or falls back to brute force over the matching rows anyway. We'd be paying to keep a 120 TB index hot to serve queries that each touch 1 MB of it. A filter bug also leaks one user's documents into another's answers.
Good Solution: A Partition per Notebook in a Vector Database
Approach
Use a vector database's namespaces or partitions, one per notebook, so each query only touches its own data.
Challenges
Isolation is better, but most vector databases aren't designed for a hundred million partitions, mostly idle. Per-partition overhead (index structures, metadata, memory) adds up, and we're still paying for an ANN engine we don't need.
Great Solution: Per-Notebook Index Files in Object Storage, Cached Near the Chat Service
Approach
Store each notebook's passages and embeddings as a compact file in object storage: an array of int8 or float16 vectors plus a small table of passage IDs, source IDs and locations. The ingestion worker rewrites it (or appends a segment) when a source is added or removed.
When a user opens a notebook, the Chat Service loads the file (a megabyte from object storage takes tens of milliseconds) into an in-memory cache, and routes later requests for that notebook to the same instance with consistent hashing on notebook_id. Retrieval is a brute-force dot product with a filter on selected sources, which is exact (no recall loss from approximation) and takes well under a millisecond. Very large notebooks (tens of thousands of passages) still brute-force in a few milliseconds; for the rare extreme ones we can build a small HNSW index at ingestion time and store it in the same file.
Keyword matching works the same way: a tiny inverted index per notebook, stored alongside, or simply a scan over a few hundred passages' text.
Challenges
Cache sizing: 2M daily users with maybe 3M notebooks opened a day at ~1-2 MB is a few terabytes of working set at most, spread over the Chat Service fleet, and far less at any one moment. A notebook that's open on two devices with a source being added at the same time needs a version number on the index file, so a stale cache entry is reloaded when ingestion finishes. And deleting a notebook must delete its index file, text snapshots and cached copies, which a deletion job verifies.
Final Design
The full flow:
- A user adds a source. PDFs upload straight to object storage; URLs and videos are fetched by Ingestion Workers. The Source row starts as
processing. - Ingestion Workers extract normalized text with locations (pages and boxes, offsets, timestamps), chunk it, embed it, write a per-source summary, and update the notebook's index file in object storage. The source turns
ready. - A question goes to the Chat Service instance that owns the notebook, which loads the notebook's index file into memory if needed and routes the question: full context for small notebooks, retrieval for specific questions, summaries plus retrieval for global ones.
- The LLM streams an answer with passage numbers and quotes; the Citation Verifier checks each one, resolves exact spans and streams citation events to the client.
- Summaries, study guides and audio overviews run as Artifact jobs: map-reduce over sources, script generation and multi-speaker TTS for audio, with results in object storage behind a CDN.
What is Expected at Each Level?
Mid-level
You should design a working pipeline: upload, extract text, chunk, embed, store, retrieve top passages for a question, and generate an answer with citations. You should handle the three source types sensibly (PDF parsing, web page fetching, YouTube transcripts) and make ingestion asynchronous with a status per source.
Senior
You should notice that each notebook is tiny and independent, and use that: per-notebook indexes, brute-force search, no global vector database. Expect to compare long context with retrieval using real token math, keep locations through ingestion so citations land on the exact page or timestamp, and design generated outputs as cached async jobs.
Staff+
You should drive the trade-offs: per-question routing between full context, retrieval and summaries; span-level citation verification and how to measure citation precision; the cost model of audio overviews and how to cap it; and the storage design for a hundred million mostly cold indexes, including deletion guarantees and privacy. You should also be clear about the product line on grounding (refusing to answer from general knowledge) and why it matters for trust.