Multimodal Models·Question 42 of 67Advanced

Design file upload for a chat assistant. A user drops a 500-page PDF, a 20-minute video and a spreadsheet into one conversation. How does each one get into the model's context, and what do you do when it does not fit?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Separate ingestion from context assembly. Ingestion turns each file into representations at several granularities, once, asynchronously. Context assembly decides, per turn, what to put in front of the model.

Full worked answer with diagram

Separate ingestion from context assembly. Ingestion turns each file into representations at several granularities, once, asynchronously. Context assembly decides, per turn, what to put in front of the model.

Ingestion common to all files:

  • Resumable chunked upload with size limits.
  • Type detection by content, not extension.
  • Malware scanning, and for spreadsheets, stripping macros.
  • Decompression limits against archive bombs.
  • Per-tenant storage with retention and deletion that actually cascades to derived artefacts and indexes.

Show progress per file, and let the user start chatting before processing finishes.

The 500-page PDF:

  • Born-digital pages: extract text with page and position anchors.
  • Scanned pages, or pages with charts and tables: OCR or VLM extraction, plus page images.
  • Cost: as page images alone, 500 pages is hundreds of thousands of tokens (Gemini's default is 560 tokens per PDF page, and high-resolution image tiers cost more). As text, it is often 250K to 350K tokens.
  • If the model's window and budget allow, put the text in a stable prefix so prompt caching makes follow-up questions cheap.
  • Otherwise chunk and index per page for retrieval, keep a per-section summary, and send page images only for pages whose content is visual.

The 20-minute video:

  • Transcribe the audio with timestamps and diarisation. Speech carries most of the information in most uploads.
  • Sample frames: Gemini's default 1 frame per second is 1,200 frames, about 84K tokens at 70 tokens per frame. For other models, sample keyframes or scene changes and caption them.
  • Store an aligned timeline (transcript segments plus frame captions), so the model can answer "what was on the slide at 12:40" and cite timestamps.

The spreadsheet:

  • Never dump cells as tokens. Parse sheets into tables, resolving merged cells, header rows, formulas and multiple sheets.
  • Give the model a schema per sheet, a few sample rows and summary statistics.
  • Give it a code-execution or SQL tool over the real data. Arithmetic over 50K rows belongs in pandas, not in attention.

When it does not fit:

  • Keep a manifest in every prompt: each file's name, type, size, one-paragraph summary and what was indexed.
  • Expose retrieval and file-reading tools, so the model fetches pages, time ranges or queries on demand.
  • For whole-document tasks ("summarise all of it"), use map-reduce over sections.
  • Be honest in the UI about coverage, for example "read pages 1 to 500, 12 pages were unreadable scans".

Safety and cost. Uploaded files are untrusted input, so text inside them can carry prompt injection. Keep their content in a data role and gate tool actions. Budget tokens per conversation, and make derived representations reusable across turns so you pay ingestion once.

Worth sketching. Optional, but it separates the one-time ingestion path from the per-turn assembly path.

flowchart LR
    U["Upload"] --> S["Scan, type detect, store"]
    S --> P["PDF: text, OCR, page images"]
    S --> V["Video: transcript, sampled frames"]
    S --> X["Sheet: parsed tables, schema"]
    P --> I["Per-conversation index and manifest"]
    V --> I
    X --> I
    I --> C["Per-turn context assembly and tools"]

What a good answer covers

  • Separate ingestion from context assembly
  • Ingestion turns each file into representations at several granularities, once, asynchronously
  • Context assembly decides, per turn, what to put in front of the model
  • Resumable chunked upload with size limits
  • Type detection by content, not extension

Key terms: Ingestion common to all files · The 500-page PDF · The 20-minute video · The spreadsheet · When it does not fit · Safety and cost

Interviewer follow-ups to expect

  1. How do you keep a follow-up question cheap when the PDF is in context?

  2. What do you show the user when 40 pages fail OCR?

  3. How would you stop instructions hidden in the spreadsheet from triggering tool calls?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep