Technical Writing and Documentation Questions
The craft of producing durable, reference-quality written artifacts and keeping them accurate: READMEs and quick-start guides, design docs, RFCs and technical proposals, runbooks and deployment guides, model cards, datasheets and data dictionaries, bug reports and reproducible examples, postmortem write-ups, handoff documents, pull request descriptions, code comments, release notes, experiment reports, and knowledge-base articles. Covers structure and information design, writing for a specific audience and for future readers (including plain language and accessibility), templates and style standards, docs-as-code workflows with CI checks, testing of examples and snippets, documentation review and quality checks, versioning and freshness checks on the documents you own, keeping sensitive data out of docs, and measuring whether documentation works. Architecture decision records, API reference docs, PRDs and PR/FAQs, and live presentations are covered elsewhere.
Compliance asks you for documentation about how a model uses personal data. How does what you write, and the way you write it, differ from the notes you would give fellow data scientists?
Sample Answer
Direct answer
For compliance I write a factual, complete, plain-language record of what personal data goes in, why, where it flows, who can see it, how long it is kept, and what controls exist, and I leave the legal conclusion ("this is lawful") to them. For fellow data scientists I write shorthand about features, experiments and pitfalls. The facts overlap; the reader, vocabulary, completeness and burden of proof differ.
How the two documents differ
| Dimension | Notes for data scientists | Document for compliance |
|---|---|---|
| Reader question | "How does it work and what should I watch out for?" | "What personal data do you use, on what basis (the legal reason you are allowed to use it, such as consent or contract), and can you show control?" |
| Vocabulary | Feature names, embeddings (lists of numbers a model uses to represent an item), shorthand | Defined plain terms; a feature name is always translated ("cust_age_bucket: customer age group, derived from date of birth") |
| Scope | What matters for modelling | Everything touching personal data, including data you consider incidental |
| Tone | Informal, exploratory | Precise, stable, dated and versioned; no marketing words like "anonymous" unless demonstrated |
| Evidence | "I believe it is fine" | A link to the access-control setting, retention job or test that proves each claim |
What the compliance document contains
- Purpose of the model, in one paragraph.
- Personal data inventory: each field, whether it is personal data (any information relating to an identifiable person) or sensitive (special categories such as health or religion that carry stricter legal rules), its source, and why the model needs it.
- Data flow: collection, storage, training, inference, outputs, third parties.
- Retention and deletion: how long training data and logs live, and how a person's deletion request is handled, including the honest answer if a trained model cannot be edited and must wait for a retrain.
- Access and security controls.
- Model outputs and decisions: whether a person is affected by an automated decision (a decision made by software with no human in the loop, such as an automatic loan refusal), and whether a human can review it.
- Known risks and mitigations, and open questions marked as open.
Worked example (excerpt)
"Field: postcode. Personal data: yes, can help identify a person in combination with other fields. Source: customer signup form. Purpose: regional demand feature. Stored in the feature table; access limited to the modelling team group. Retention: raw postcode deleted after 24 months by a retention job (a scheduled job that deletes data past its keep-until date; see linked ticket). The 24 months is an example value; the real period comes from the company's retention policy. Reduced to a 3-character region code before training." A data scientist note would just say "region_code, dropped postcode, re-identification risk with city" (re-identification risk: region code combined with city could narrow a record down to very few people; this is different from target leakage, where a feature carries information that would not exist at prediction time).
Pseudonymised versus anonymised: pseudonymised data has names or IDs replaced by codes, but someone holding the key or other fields can still work out who it is, so it is still personal data. Anonymised data cannot be traced back to a person by anyone with reasonable effort, which is a much higher bar. Calling pseudonymised data anonymised overstates the protection and can mean the wrong legal rules are assumed.
Pitfalls
Overclaiming ("fully compliant", "anonymised" for merely pseudonymised data), leaving gaps silently, and writing a legal argument yourself. If I do not know something, I write "unknown, owner X will confirm by date Y".
Analysts write metric definitions as free prose, while another proposal is a structured template with formula, SQL, owner and examples. Which would you adopt, and how would you handle the migration and enforcement?
Sample Answer
Direct answer
I would adopt the structured template (a fixed set of named fields per metric, stored as YAML, a plain-text key: value format), but keep one free-prose field inside it ("definition in plain English") so it does not become a form nobody reads. Prose alone cannot be checked by a machine and drifts between authors; a template alone can be filled with junk. Store it in Git, validate it in CI (continuous integration, automated checks that run on every change), migrate the metrics people actually use first, and enforce with a rule that only tightens over time.
Trade-offs
| Free prose | Structured template | |
|---|---|---|
| Ease of writing | Highest | A few minutes more per metric |
| Ambiguity | Common (unstated time window, filters) | Forced fields expose gaps |
| Checkable by CI | No | Yes: required fields, SQL runs, example matches |
| Reviewing a change | Reads as a text diff | Field-level diff shows exactly what changed |
| Searchable and comparable | Weak | Strong (same fields everywhere) |
| Main failure | Two versions of the truth | Placeholder text ("TBD") in required fields |
The template (real, runnable check)
Each metric is a small YAML file with name, owner, definition, sql, grain (the level of detail the metric is computed at: here one number per week, as opposed to per day or per user), and an example with an expected value. The validator refuses missing fields and placeholders, and it runs the SQL and compares it with the example (needs pip install pyyaml):
import sqlite3, yaml
SPEC = """
name: weekly_active_teams
owner: growth-analytics
definition: Distinct teams with at least one qualifying event in a Monday-to-Sunday UTC week.
sql: |
SELECT COUNT(DISTINCT team_id) FROM events
WHERE event_type IN ('login','edit')
AND event_ts >= :week_start AND event_ts < date(:week_start, '+7 days')
grain: week
example: {week_start: '2026-08-03', expected: 2}
"""
REQUIRED = ["name", "owner", "definition", "sql", "grain", "example"]
PLACEHOLDERS = {"", "tbd", "todo", "n/a"}
def validate(spec, db):
errors = [f"missing {k}" for k in REQUIRED if k not in spec]
errors += [f"placeholder in {k}" for k, v in spec.items() if str(v).strip().lower() in PLACEHOLDERS]
if not errors:
got = db.execute(spec["sql"], {"week_start": spec["example"]["week_start"]}).fetchone()[0] # the SQL must actually run
if got != spec["example"]["expected"]:
errors.append(f"example expects {spec['example']['expected']} but SQL returns {got}")
return errors
db = sqlite3.connect(":memory:")
db.executescript("""CREATE TABLE events (team_id INTEGER, event_type TEXT, event_ts TEXT);
INSERT INTO events VALUES (1,'login','2026-08-04'),(1,'edit','2026-08-05'),(2,'edit','2026-08-09'),
(3,'heartbeat','2026-08-06'),(4,'login','2026-08-10');""")
spec = yaml.safe_load(SPEC)
print("good spec:", validate(spec, db))
print("no owner:", validate({k: v for k, v in spec.items() if k != "owner"}, db))
print("placeholder:", validate({**spec, "definition": "TBD"}, db))
print("stale example:", validate({**spec, "example": {"week_start": "2026-08-03", "expected": 3}}, db))
Output:
good spec: []
no owner: ['missing owner']
placeholder: ['placeholder in definition']
stale example: ['example expects 3 but SQL returns 2']
The example.week_start value is fed into the SQL as :week_start, so the window is written once and the documented example and the query cannot quietly use different dates. The last line is the valuable one: if someone changes the SQL and forgets the documented example, the check fails, so the prose and the query cannot drift silently.
Migration plan (illustrative numbers)
Say there are 60 metrics. Do not migrate all 60.
- Rank them by use: export 90 days of views per dashboard, add up the views of every dashboard that uses each metric, and sort from highest to lowest (appearances in exec reports can break ties). Convert the top 10 first, each with its owner, in the first two weeks.
- Freeze the rest: legacy prose pages get an "unmigrated" tag and stay readable.
- Publish a coverage number where the team sees it. The 14 in "14 of 60 migrated" is the top 10 plus, say, 4 more metrics that were converted because someone happened to edit them (step 4).
- Convert a metric whenever someone next touches it, so the work follows real change.
Enforcement (carrot first, stick second)
- Immediately: a new metric cannot be merged without a spec that passes the check. This costs nothing to existing work.
- After the top 10 are migrated: a change to a metric's SQL requires the spec in the same pull request (a proposed change that teammates review), with the owner listed as reviewer in a CODEOWNERS file (a file that names who must approve changes to which paths).
- Ratchet (a rule that can only tighten, like a ratchet wrench that turns one way): the share of metrics that must be migrated rises each quarter and never drops back.
- Warn but do not block on subjective checks such as a
last_revieweddate older than 180 days (an optional field you would add to the template; the minimal one above does not have it).
How it gets gamed, and the guard
People type "TBD" or copy an example from another metric. The guards are the placeholder check, the requirement that the example is recomputed by CI, and a human owner who is accountable on review.
What would change my answer
With a team of three analysts and fewer than 15 metrics, a wiki page with a checklist is enough and CI machinery is overhead. If completion rates stay low after a month, the template is too long: cut fields before adding enforcement.
How do you document exploratory analysis and model experiments so another data scientist can reproduce your work six months later? What is the minimum you would always record?
Sample Answer
Direct answer
Reproducible means a stranger, with only what you left behind, can rebuild the same inputs, run the same code in the same environment and get the same result (or a result inside a stated tolerance). The minimum I always record is five things: the exact code version, the exact data version, the environment, the randomness controls, and the question plus the result and decision. Everything else can be found from those five.
The minimum record (one per experiment)
- Question and decision: what you were testing and what you concluded. Without this, six months later nobody knows why the run exists.
- Code: the git commit hash (a unique ID for a saved version of the code) and whether there were uncommitted changes. A notebook name alone is not a version.
- Data: a snapshot identifier or query plus date, row counts, and how the train/validation/test split was made. Provenance (where each input came from and how it was transformed) includes the feature pipeline: which script and commit built the features, since features are often rebuilt from a moving table.
- Environment: Python version and a lockfile (an exact list of package versions), plus hardware where it matters.
- Randomness: seeds (the number that starts a random generator, so shuffles and initial weights repeat) for every library used, and a note on operations that are not deterministic anyway (some GPU operations sum in a different order and vary in the last decimals).
Then the result (metric, baseline, tolerance, where the saved model or output lives).
Worked example (illustrative values)
Metric used below: recall@top10pct means rank customers by the model's predicted churn risk, flag the top 10%, and measure what share of the customers who actually churned were in that flagged group. 0.61 means 61% of real churners were caught.
experiment: churn-model-2026-09-14-run3
question: Does adding the 30-day support-ticket count improve churn recall on new customers?
code:
repo: github.com/example-org/churn-model
commit: 3f9a1c2
uncommitted_changes: none
environment:
python: "3.12.4"
lockfile: requirements.lock (sha256 a41c...e07)
hardware: 1x GPU, driver 550
data:
snapshot: warehouse.churn_features@2026-09-01
row_count: 184230
query_or_pipeline: pipelines/build_features.py @ 3f9a1c2
split: by customer_id hash, 80/10/10, seed 42
randomness:
numpy_seed: 42
model_seed: 42
nondeterministic_ops: GPU sum order (results vary in 4th decimal)
result:
metric: recall@top10pct
value: 0.61
baseline_value: 0.58
artifact: s3://ml-artifacts/churn/run3/model.pkl
decision: Keep feature; re-check on the Q4 snapshot.
This record is a short file stored next to the run (or in an experiment tracker such as MLflow or Weights & Biases; either tool is optional, a plain YAML file committed next to the code already meets the bar). Six months later, checking out commit 3f9a1c2, installing the lockfile, and rebuilding the 2026-09-01 snapshot reproduces the run within the stated tolerance.
Documenting a reproducible investigation of a claimed segment-level failure
Suppose a stakeholder says "the model is bad for customers on the annual plan". Write the investigation so it can be re-run:
- Claim in one sentence, with who made it and when.
- Definition of the segment as code or a query (not "annual customers"), plus its size.
- Same-snapshot comparison: the model's metric on the segment versus everyone else, computed on a named snapshot, with a confidence interval (a range the true value plausibly lies in, wider for small samples) or at least the segment's row count, because a small segment gives noisy numbers.
- What was ruled out: label quality (are the churn labels for this segment correct, or do annual customers show as "not churned" only because their contract has not ended yet), leakage (a feature that accidentally contains the answer, or information from after the prediction date, so offline scores look better than reality), a train/serve preprocessing mismatch, and a change in the data feed.
- Verdict and next action, and the exact command to reproduce the table.
Filled-in segment example (illustrative)
- Claim: "the model is bad for annual-plan customers" (raised by the retention lead, 2026-09-20).
- Segment:
plan_type = 'annual'onwarehouse.churn_features@2026-09-01; 1,840 customers, of whom 220 churned. - Result: the model flagged 108 of those 220 churners in its top 10%, so recall@top10pct = 108/220 = 0.49. Everyone else: 0.62.
- Uncertainty: with 220 churners, the rough 95% interval on 0.49 is about 0.42 to 0.56, which does not reach 0.62, so the gap is unlikely to be noise.
- Ruled out: labels re-checked on 50 sampled annual accounts (all correct); no leaked feature found; the same preprocessing function is used in serving.
- Verdict: real weakness. Next action: add annual-specific features and re-measure; reproduce the table with
python analysis/segment_recall.py --snapshot 2026-09-01.
Trade-offs and pitfalls
- Notebooks are the usual culprit: cells run out of order and hold hidden state. Re-run top to bottom before saving, and export the final analysis as a script or clean notebook.
- Over-documenting kills the habit. Automate capture (log the commit, lockfile hash and seed from code) so the human writes only the question and the decision.
- "Reproducible" has levels: same numbers exactly, same numbers within a tolerance, or same conclusion. Say which one you promise.
Draft the datasheet template for a new dataset used to train recommendation models. Which fields are mandatory and why, and how do you keep them accurate as the data changes?
Sample Answer
Direct answer
A datasheet (a structured description of a dataset, from the "Datasheets for Datasets" proposal, covering motivation, composition, collection, preprocessing, uses, distribution and maintenance) is a template every new dataset must fill in before anyone trains on it. (The "Datasheets for Datasets" proposal is useful background, not required knowledge; what matters is the habit of documenting a dataset before use.) Two terms used below: an impression is one instance of the system showing a recommendation to a user, and leakage is information from the test data seeping into training, which makes test scores look better than real-world performance. For recommendation data, I would make these mandatory: purpose, owner, source and collection method, time span, what one row is, consent and personal-data status, preprocessing, known biases, permitted and prohibited uses, refresh cadence, and the train, validation and test split rule (plus the snapshot ID and retention period listed in the table). To keep it accurate, store it in the repository beside the dataset's schema, version it with each snapshot, and check parts of it automatically.
Template (mandatory fields and why)
| Field | Why mandatory |
|---|---|
| Purpose and owner | Someone must answer questions and approve use |
| Source and collection method | Provenance drives legal and quality judgement |
| Time span and snapshot ID (a label naming one frozen copy of the data, like "2026-09-01") | Models must be reproducible against a fixed version |
| Row definition (for example one impression, one click, one purchase) | Prevents mis-joins and double counting |
| Personal data and consent basis (the permission or legal reason the data may be used) | Legal exposure and deletion obligations |
| Preprocessing steps | Others must reproduce or undo them |
| Known biases | Recommendation logs only record what the previous recommender chose to show, so popular items look better than they are (exposure and popularity bias). Example: an item shown 1,000 times collects many clicks, an item shown 10 times collects few, and an item never shown has no rows at all, so the log cannot say whether it would have done well |
| Train, validation and test split rule | Prevents leakage; a time-based split (train on older days, test on the newest days) is usual for logs, because a random split would let the model see the future |
| Permitted and prohibited uses | Stops quiet reuse |
| Refresh cadence and retention | Sets when the sheet is stale |
Feature-level provenance entry (readable by scientists and auditors)
feature: user_days_since_last_purchase
description: Whole days between the event time of a recommendation request and the user's most recent completed purchase made before that event time (a purchase after the event must never be used, or the feature leaks the future).
source: orders.purchases (completed status only)
ingested: daily batch at 02:00 UTC
transformations: convert timestamps to UTC; subtract; cap at 365; null when the user has no purchase
validation: value between 0 and 365 or null; null rate alert above 40 percent
owner: growth-data
consent_basis: order history used for personalisation under the terms accepted at signup
Reading it: a scientist sees the computation and cap; an auditor sees source, owner and consent basis.
How to keep it accurate as the data changes
- Store the datasheet as a file in the same repository as the pipeline, so a schema change and a datasheet change appear in one review.
- Version it with the dataset snapshot ID; each new snapshot gets a dated entry.
- Automate what can be automated: a continuous-integration check (an automated test that runs on every change) that fails if columns in the real schema are missing from the sheet, and a freshness check on the last ingestion date. For example, if the schema has
order_id,user_id,item_id,tsand someone addsdwell_ms, but the sheet lists only the first four, the check prints a message likeFAIL: column dwell_ms is missing from the datasheetand blocks the merge (illustrative message). - Assign a named owner and a review date; unreviewed sheets show a "stale" badge in the data catalog (the searchable inventory of datasets).
- Tie changes to triggers: a new source, a changed filter or a changed consent policy forces an update.
Pitfalls
- A long template nobody completes; keep mandatory fields short and make the rest optional. If adoption is poor, the fields I would protect first are owner, personal data and consent, and permitted uses, since those carry legal risk.
- Free-text fields that drift from reality; prefer structured fields that can be checked.
- Documenting the data once and never after schema changes.
How would you document the calculation of a metric like monthly active users so another analyst or an auditor can reproduce the exact number?
Sample Answer
Direct answer
Write the metric as a versioned definition that an outsider can execute without asking you anything: a plain-English sentence, the exact query, the time boundaries, what is excluded, where the data comes from, who owns it, and one small worked example with a known answer. MAU (monthly active users) is a good test case because "active", "user" and "month" each hide a choice, and two analysts will pick different ones unless the document forces a single reading.
This kind of write-up is a KPI (key performance indicator) definition: the agreed recipe for a number the business tracks.
What the definition must pin down
- Unit: distinct
user_id, not accounts, devices or sessions. - "Active": the exact event types that count (say
login,page_view,purchase) and the ones that do not (backgroundheartbeatpings). - Time window: calendar month in UTC, written as a half-open range (start included, next month's start excluded), so an event at exactly midnight cannot land in two months.
- Exclusions: internal and test accounts, and events with no user id (anonymous traffic).
- Source and freshness: which tables, and the "data as of" timestamp of the run, because late-arriving events can change last month's number after you reported it. State the restatement policy (for example, "the prior month is re-run for five days, then frozen").
- Owner, version and changelog: who to ask, and a changelog (a dated list of what changed and why), one note each time the definition changes, so an old figure can be matched to the definition that produced it.
- Worked example: a tiny dataset with the expected result, so a reviewer can check the definition without production data.
Worked example (run against the tiny dataset below)
metric: monthly_active_users
definition: Distinct non-internal users with at least one qualifying event in a calendar month (UTC).
qualifying_events: [login, page_view, purchase]
window: "event_ts >= month_start AND event_ts < next_month_start"
excludes: [internal accounts, events with NULL user_id, heartbeat events]
owner: product-analytics
version: 3 # v3: heartbeat events stopped counting
import sqlite3
db = sqlite3.connect(":memory:")
db.executescript("""
CREATE TABLE users (user_id INTEGER PRIMARY KEY, is_internal INTEGER NOT NULL);
CREATE TABLE events (user_id INTEGER, event_type TEXT NOT NULL, event_ts TEXT NOT NULL);
INSERT INTO users VALUES (1,0),(2,0),(3,0),(4,1),(5,0),(6,0),(8,0);
INSERT INTO events VALUES
(1,'login','2026-08-03T09:00:00'), (1,'purchase','2026-08-20T12:00:00'),
(2,'page_view','2026-08-31T23:30:00'),
(3,'heartbeat','2026-08-10T10:00:00'),
(4,'login','2026-08-11T10:00:00'),
(5,'login','2026-07-31T23:59:59'),
(6,'login','2026-09-01T00:00:00'),
(NULL,'login','2026-08-12T10:00:00'),
(8,'login','2026-08-15T08:00:00');
""")
MAU_SQL = """
SELECT COUNT(DISTINCT e.user_id)
FROM events e JOIN users u ON u.user_id = e.user_id
WHERE u.is_internal = 0
AND e.event_type IN ('login','page_view','purchase')
AND e.event_ts >= :month_start AND e.event_ts < :next_month_start
"""
print("MAU 2026-08:", db.execute(MAU_SQL, {"month_start": "2026-08-01T00:00:00",
"next_month_start": "2026-09-01T00:00:00"}).fetchone()[0])
Output:
MAU 2026-08: 3
Why 3: users 1, 2 and 8 count (user 1 has two events but is counted once). User 3 only sent heartbeats, user 4 is internal, user 5's event is 23:59:59 on 31 July, user 6's event is exactly 00:00:00 on 1 September (both outside August), and the NULL-id row is anonymous. Each exclusion is a documented rule, so an auditor who reruns the query gets 3, and can see why every other row was left out.
Variant: a new KPI such as net revenue retention (NRR)
NRR measures how much recurring revenue you keep from customers you already had, including upgrades. MRR is monthly recurring revenue. In the formula below, expansion is extra MRR from upgrades by existing customers, contraction is MRR lost to downgrades, and churn is MRR lost to cancellations. A production definition needs these elements, each for a reason:
| Element | Why it is there |
|---|---|
| Business question | Stops the metric being reused for something it does not answer. |
| Formula with named inputs | Removes arithmetic ambiguity. |
| Cohort rule (which customers count: those with MRR above zero at period start) | Decides who is in the denominator. New customers are excluded, or NRR turns into a growth figure. |
| Inclusions and exclusions (one-time fees, currency conversion date) | The usual source of unexplained differences between two analysts. |
| Source tables and lineage (the chain of upstream tables and transformations the number was built from) | Lets an auditor trace the number back to raw records. |
| Owner and approver | Someone is accountable when it changes. |
| Refresh and restatement policy (restatement: re-publishing a past figure after late data arrives) | Says when the number moves and when it is final. |
| Version, changelog, test value | Ties each published figure to a definition and gives a check on every change. |
NRR=MRRstartMRRstart+expansion−contraction−churn
100,000100,000+8,000−3,000−5,000=100,000100,000=1.00
That means the starting customers are worth exactly what they were a period ago (100%): upgrades of 8,000 cancelled out downgrades of 3,000 plus cancellations of 5,000.
A finished NRR definition, in the same style as the MAU one (illustrative):
metric: net_revenue_retention
question: How much recurring revenue do we keep from last quarter's customers, upgrades included?
formula: (mrr_start + expansion - contraction - churn) / mrr_start
cohort: customers with mrr > 0 on the first day of the quarter (new customers excluded)
excludes: [one-time fees, usage overage]
currency: converted at the rate on the last day of the quarter
sources: billing.subscriptions, billing.invoice_lines
owner: finance-analytics
approver: vp-finance
restatement: recomputed for 10 days after quarter end, then frozen
version: 2 # v2: overage excluded
test_value: "start 100000, +8000, -3000, -5000 => 1.00"
Pitfalls
- A definition that lives only in prose or in someone's head cannot be re-run. Keep the definition and the query in one place.
- Leaving the time zone or boundary unstated is the most common cause of "our numbers are off by a few".
- Documenting the query but not the data snapshot means you can no longer reproduce a number after late data lands.
Unlock Full Question Bank
Get access to all 30 Technical Writing and Documentation interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.