A text corpus needs stable document identity, a prediction clock and a label policy before tokenization or model fitting.
Text corpus contracts: identity, label timing and annotation rules
Define one document
A support ticket can contain an original message, replies and internal notes. Decide whether one record means a ticket at submission or a later conversation snapshot. Stable ticket IDs and revision numbers keep edits from becoming unrelated examples. Record created, observed and labeled times separately. If the model routes a ticket at submission, a later agent note cannot be a training feature. Feature availability] is the same boundary in tabular models.
Write the label rule
Define categories by the action they trigger, not by vague language. A billing question and a refund request may mention the same words but require different queues. Specify which label wins when multiple requests occur, or use a multi-label target. Store annotator identity, guideline version and disagreement resolution. Unknown and ambiguous cases should remain visible; forcing every case into a confident class hides policy uncertainty.
Control sensitive text
Raw tickets can contain names, account numbers and attachments. Limit access, remove or mask only under a versioned policy, and retain enough governed provenance to audit errors. A blanket digit deletion can remove invoice codes that distinguish tasks. Normalization] should preserve task-critical characters and must be applied consistently at training and serving.
Test the source contract
Create fixtures with one edited ticket, two tickets from one customer, a delayed label and a note added after the routing decision. Assert the intended record count and that no future text enters the model input. Review a small annotation disagreement sample before scaling data collection.
Implementation
def eligible_ticket(record, decision_time):
if not record.ticket_id or record.submitted_at > decision_time:
raise ValueError("invalid ticket identity or clock")
visible = [message.text for message in record.messages
if message.created_at <= decision_time
and message.visibility == "customer"]
if not visible:
raise ValueError("no customer text at decision time")
return "\n".join(visible)Performance and operating cost
Constructing one snapshot reads O(M) messages per ticket and copies O(C) characters. Retaining revisions increases storage; it also makes labels and prediction-time inputs auditable.
Common Mistakes
- Do not merge later agent notes into a submission-time input.
- Do not silently force ambiguous tickets into one category.
- Do not discard ticket revisions before an audit policy is defined.
Read next
- Unicode and tokenization: preserve meaning at the text boundary
- Text validation: split conversations, duplicates and time together
- Prediction-time feature availability: reject future information before training
- Data source contracts: preserve raw records before transformation
Continue the workflow: Project: ship an auditable support-entity extractor.
Continue the workflow: Text embeddings: pair labels, hard negatives and versioned vectors.
Continue the workflow: Adjudicate text labels before they become training truth.
Continue the workflow: Low-resource NLP: label budgets and transfer boundaries.
Continue the workflow: Weak label functions: coverage, conflict and abstention.
