Make LLM output match a word processor's formatting
I was asked this
No reports yet. Sign in to say where you were asked it.
An AI system design interview question asked in Microsoft's system design round, last asked Jan 2026. It tests llm, formatting and evaluation.
A writing assistant inside a word processor generates text that must fit the document it goes into: the document's styles, heading levels, lists, tables and fonts. Design how you get the model to produce correctly structured output, convert it into the document's native format, repair it when it is wrong, and measure how well it matches.
Requirements
- Functional: generate content (drafts, rewrites, summaries) that uses the document's existing styles and structure; insert it as native document elements (not pasted plain text); handle tables, nested lists and headings; fall back gracefully when output is malformed.
- Non-functional: interactive latency, including while streaming; output is always valid for the document format; formatting is consistent with the surrounding document.
Clarifying questions
- Which elements must be supported: styles, headings, lists, tables, images, tracked changes?
- Does the model see the document's style definitions and neighbouring content?
- Is output streamed into the document as it is generated?
- What counts as "matching": exact style names, visual similarity, or user acceptance?
- Can we fine-tune the model, or only prompt it?
What a strong answer covers
- An intermediate representation the model is good at (constrained Markdown, or a small JSON schema of blocks with style ids) rather than the raw document XML.
- Giving the model the document's style catalogue and nearby content, and constraining its output with a grammar or schema (constrained decoding) so it cannot produce invalid structure.
- A converter from the intermediate form to native elements, mapping to existing styles, plus validation and repair (close unclosed lists, fix table shapes) and a plain-text fallback.
- Streaming: buffering incomplete structures (a table row) before rendering them, so the document never shows broken elements.
- Fine-tuning or preference tuning on pairs of instructions and correctly formatted outputs when prompting is not enough.
- Evaluation: schema validity rate, structural match against reference documents (style usage, heading levels, table shape), human ratings, and how often users undo or reformat inserted text.
Follow-ups
- The document uses custom style names like "Body Text Legal". How does the model pick them?
- A long table streams in row by row. What does the user see?
- How do you measure "looks right" automatically?
- Tracked changes are on: how do inserted elements appear?
Where it's asked
- Microsoft · System design · Last asked Jan 202660 min · Design discussion
What it tests
llm · formatting · evaluation
No official answer yet. Draw yours on the right; publish it and it shows under Community.
Nothing published yet. Publish your canvas and it shows here for others to open and remix.
