Streaming AI Responses Without Breaking the User Experience
Design AI streaming around useful first output, stable rendering, reliable recovery, and a final state users can trust.
AI
Design a synthetic data pipeline that targets missing behaviors, tracks source permission, rejects faulty examples, and proves its value on independent evaluation.

Estimated reading time: 9 minutes
Read the Arabic edition: بيانات التدريب الاصطناعية: توسيع مجموعة البيانات دون مضاعفة أخطائها.
A team has 80 examples that teach a support model how to route requests. Most are straightforward. A generator can turn them into 8,000 polished examples by tomorrow. On inspection, nearly all the new rows still describe the same routine requests. Worse, the seed set contains one wrong rule about refunds. The generator repeats that rule in several languages and presents it as policy. The team has increased its coverage spreadsheet without improving coverage of the actual decisions.
Synthetic data is useful when the team knows which behavior it cannot reliably learn from its existing examples. It can supply hard-to-collect combinations, fill language gaps, and expose the model to confusing cases with controlled labels. To make that useful, keep the example generator, the source of truth, and the evaluation set separate. The generator proposes examples. A versioned rule, executable check, or qualified reviewer establishes correctness. A held-out evaluation tells you whether adding the examples improved the trained model.
Turn the gap into a specification before building the generation prompt. “Make 500 diverse tickets” invites stylistic variety while leaving the underlying problem unspecified. “Make ten distinct situations for each missing combination of language, intent, required evidence, and expected disposition” gives reviewers a contract they can check. Start from known failures and production observations you are allowed to use. When those signals are thin, ask a domain reviewer to nominate cases that matter because of their consequences, even if they are uncommon.
Useful dimensions include language and register; facts available or missing; the policy version; requested action; whether a decision requires clarification; and whether a user is authorized to ask for it. Add nuisance variation such as spelling mistakes, date formats, indirect phrasing, and sentence length within each slice. Keep nuisance variation separate from variation that actually changes the answer. Count unique scenarios and label distributions after filtering, not just distinct strings before filtering. Three ways to ask about the same damaged parcel may improve phrasing tolerance; they do not teach three new policies.
Maintain a gap matrix with a target and a reason for each slice. A balanced training slice can give a rare condition enough representation to learn it, but it does not make that condition common in the real world. Keep a representative held-out set for ordinary usage and a separately reported challenge set for costly, rare failures. If augmentation changes the label prior, check probability calibration against representative data before using confidence thresholds.
The workflow below treats generated rows as candidates. A rejected row should carry a reason code, so teams can tell whether a seed, prompt, source, or validator needs fixing. Store useful aggregate rejection data without retaining content that should never have been generated.
flowchart LR
A["Approved sources and coverage gaps"] --> B["Generate candidates by scenario"]
B --> C["Check schema and domain rules"]
C --> D["Group duplicates and check split overlap"]
D --> E["Audit sample and measure coverage"]
E --> F["Version accepted training data"]
F --> G["Train a controlled comparison"]
H["Independent held-out evaluation"] --> G
First define the format and the target. For a routing task, a strict enum and required evidence fields are more useful than a generated paragraph that sounds plausible. Reject malformed or inconsistent rows rather than silently coercing them. Then validate domain correctness. Schema validation can establish that a label is a known value; it cannot establish that the label is supported by the text. Whenever possible, produce scenario facts from a controlled fixture and compute the label from independent rules. For tasks that need judgment, use a short rubric, review a stratified sample, and give reviewers a way to report ambiguity rather than forcing a label.
Self-Instruct is one example of a pipeline that generates instruction examples and filters invalid or similar ones. Its setup and findings motivate separating candidate creation from acceptance; they do not supply a quality guarantee for a company's policy labels. An evaluator from the same model family may be useful for triage, but it can repeat the generator's misunderstanding. Review disputed rows and a random sample of rows that passed every automatic check. If reviewers disagree, examine the rule and the interface before assuming the generator is the only problem.
Consider a fictional retailer with three outputs: send a damaged shipment to claims, ask for a missing order ID, or escalate a disputed charge to billing. A reviewed rule applies only to this toy workflow: a damage report without an order ID must request the identifier first; it must not start a claim. That rule is stored separately from the writing prompt. Each scenario has a family ID, a policy version, a fact record, a locale, and an expected action computed from its facts.
| Inputs | Candidate decision | Validation result |
|---|---|---|
| Arabic report of a cracked item, no order ID | Ask for order ID | Accept after checking the Arabic text does not imply it has already been supplied |
| Same Arabic report with an order ID inserted | Ask for order ID | Reject: the added fact changes the target to claims |
| English report of an unknown charge, no damage claim | Billing escalation | Accept into the billing slice, not the damage slice |
| English translation of the first Arabic report | Ask for order ID | Accept for training if useful, but keep both translations in the same split |
Now create a pair that differs in exactly one fact and causes the expected disposition to change. This gives reviewers a stronger check than two unrelated examples. For output rows, keep labels in the dataset schema and keep label explanations out of model inputs unless the deployed model will actually receive them. A label copied into an input heading can yield an apparently excellent evaluation without teaching the ability you want.
Suppose a pilot batch contains 120 candidates across six cells. After checking meaning, labeling, and family overlap, 72 survive. The weakest cell still has only three independent scenario families despite 18 good-looking sentences. It needs new scenarios rather than more paraphrases. These are illustrative counts; the decision comes from coverage after acceptance, not from an arbitrary survival target. Track Arabic ambiguity and dialect mix separately if the workflow will serve both colloquial and formal requests, and have a bilingual reviewer check that critical facts survive translation.
A training set teaches a model to write SQL for inventory reports. In a toy database, product A has two order lines and three inventory adjustments; product B has none. Ask for the number of order lines per product, including products with zero. A candidate query joins both one-to-many tables before counting rows. It happens to pass a fixture with one adjustment. The richer fixture makes the multiplicative join visible: the wrong query returns six for A rather than two.
Run candidate answers against multiple isolated fixtures and compare with an independently authored reference result. Include the zero-row case, null values, and any relevant ties or time boundaries. If order is part of the task, compare sequence; if it is not, compare row multisets instead. Accept equivalent queries that satisfy the contract. Retain the fixture version and expected output in provenance so a correction to the exercise can invalidate related rows. Run examples with limited resources and read-only access to the disposable test database; never use application customer data as a convenient fixture.
This example also shows what a good paraphrase cannot fix. If every generated task uses the same join template, 500 correct variants may still teach one narrow method. Select scenario families for aggregation, filtering, and joins with different data relationships. Use separate families in evaluation to test that the model learned the rule rather than the table names.
Use a normalized hash to remove format-only duplicates, then lexical or embedding similarity to flag near matches for review. A threshold should generate candidates for investigation rather than make the final decision for every task. “Do not issue the refund” and “issue the refund” may look nearly identical while carrying opposite labels. A translation, machine paraphrase, or multiple rows generated from the same seed might look quite different while carrying the same hidden scenario. Keep shared seed, rule variant, and fixture identifiers to group related examples even when similarity misses them.
Lee et al. documented near duplicates and train–validation overlap in language-model datasets, giving a practical reason to check both within the training set and across split boundaries. Assign source families to splits before augmentation. Never let a held-out sample, its answer, or a close rewrite become a seed. After generation, recheck cross-split overlap; a generator can arrive at the same familiar situation independently. Rotate newly reviewed challenge cases if the team has tuned repeatedly against them, and preserve a separate final evaluation.
Generation does not remove obligations attached to the inputs. Keep a source manifest with origin, version, approved purposes, provider restrictions, and a policy for retention or withdrawal. A document approved for a retrieval system may not be approved for model training or for transfer to an external generator. Check both decisions independently. If you cannot establish permission, use a public source with verified terms or write a fictional fixture from scratch. Scan candidates for unintended personal data and long copied strings, then review exceptions before admitting them. Keep provenance sufficiently granular to exclude descendants of a withdrawn source and identify affected training snapshots. Datasheets for Datasets offers a useful structure for documenting motivation, composition, collection, and recommended uses.
Watch for systematic errors that validators miss. An unchecked seed can bias every descendant, and a teacher model can make rare cases less realistic each time outputs are reused as new inputs. Shumailov et al. show degradation under recursive training conditions; the result is a warning about how generated data is reused, not a prediction that every mixed dataset will fail. Keep trusted original data in the experiment, put a cap on rows per seed family, document how far examples are from human-reviewed sources, and monitor failures on rare slices separately.
Train a baseline on the original allowed data, then compare it with a version augmented by the candidates that passed. Keep the model, training budget, evaluation protocol, and evaluation split comparable. If the experiment changes how many examples are seen or how many passes the model makes, document that difference and add a size- or compute-matched control when feasible. Evaluate with the usual test set and the gap-specific challenge set. Report raw counts and check the most consequential slices, not just a single average. A gain in normal English tickets does not justify a regression in Arabic tickets that require clarification.
Before accepting the expanded dataset, check whether independent evaluation improved the target behavior, whether any high-cost slice got worse, and whether reviewers can trace a bad row back to its source and remove its relatives. Keep the baseline reproducible and record the dataset version, generator, filters, and acceptance decision. Start with one gap where the right answer can be checked reliably. The evidence that justifies expansion is better behavior on independent examples, not the number of rows a model can produce.
YOUR TAKE
Choose one reaction for this article.
A cookie helps limit repeat responses. Your feedback is private.