Designing LLM Features for Classification Without Data Leakage

Practical guide to designing LLM features, preventing data leakage and evaluating a text classifier.

A language model can turn a document into structured signals for a smaller classifier. The hard part is not only choosing the signals: the inputs, labels and evaluation must match the moment when the decision will be made. Otherwise, a strong-looking test result may depend on information that will not be available in production.

Define the decision and the prediction time

Suppose a team routes incoming support requests for human review. It wants to identify messages that describe a service outage. The decision is made when the request arrives, so a feature may use the original message and product area known at that time. A later resolution, agent response or final priority must not be included: those fields are consequences of the workflow, not information available at prediction time.

Write down the label definition, who assigns labels and how ambiguous requests are handled. Check that the label can be determined consistently. If some cases never receive a label, investigate whether those missing labels reflect a particular group or decision path.

Specify features before generating them

Use a short schema rather than an unconstrained explanation. For the outage example, request three fields: outage_mentioned (yes, no or unknown), affected_service (a name or unknown), and evidence (a short excerpt from the original message). These are illustrative fields, not a claim that they work for every task. Keep the raw message separate from the generated output, and validate the schema before using any field downstream.

Define a fallback for empty, invalid or delayed responses. A missing feature is not automatically a negative answer. The classifier can use a missing-value indicator, or the workflow can send the case to a person. Avoid including secrets or personal data unless the application is authorised to use them.

Split by the real-world boundary

Separate training, validation and test examples before selecting prompts or features. If several messages belong to the same incident or customer, put related messages in the same split; otherwise a near-duplicate in the test set can make performance look better than it is. A time-based test can be useful when the system will classify future requests. Choose the split to match the intended deployment rather than assuming one split works for every problem.

Generate features for each split using only the input available for that example. Fit preprocessing and the downstream classifier on training data. Use validation data for prompt selection, model settings and threshold selection; leave the final test set untouched until those choices are fixed. If labels are later revised, record the revision and reassess the split.

Compare against a baseline

Evaluate the same held-out cases with a simple baseline, such as a keyword rule or a direct model label, and with the feature-based pipeline. Report false positives, false negatives, precision and recall for the chosen threshold. Include timeouts, malformed responses and the selected fallback in the evaluation; excluding failed calls can conceal an operational weakness.

If the score is presented as a probability, check calibration on suitable held-out data. A logistic regression does not automatically produce calibrated probabilities in every deployment. Choose the action threshold on validation data according to the cost of a missed outage and an unnecessary review, then report test results without retuning on that test set.

Record the pipeline and watch for change

Record the prompt, feature schema, model version, downstream model, threshold and data period for each evaluation. When any of them changes, repeat the relevant checks. Monitor missing responses, input changes and review outcomes after deployment; changes in incoming requests or label practices can make earlier measurements less representative. Route uncertain cases to people when the consequences require it.

The benefit of a feature-based design is the ability to inspect and evaluate individual signals alongside the whole decision process. It adds complexity and is worth keeping only when its measured benefit justifies the extra calls and maintenance.

Discover Ailoot’s LLM API. One Ailoot-issued API key gives you 1,284 models and variants across 15 categories. That catalogue puts Ailoot among the world’s largest AI routers by model count. The same key covers GPT, Claude, Gemini, Grok, Qwen and DeepSeek, plus Nano Banana for photos, Veo for video, Eleven v4 for speech, Suno for music, Tripo3D for 3D and BGE for search.

Use Mercury Decide, Jev or Clef through Ailoot to add structured decisions to your workflow. Pair them with models that analyze documents and generate text.

Build your classification and routing features into an app with the Ailoot API. Monitor model usage across projects and manage company spend through one workspace.

Use new flagship models from day one on the same Ailoot balance. One subscription covers the full catalogue. Subscriptions and promo codes can bring model costs down by up to 50% compared with official provider API prices. Open your account at https://ailoot.ai/ or request a code from the team.

Originally published on the Ailoot technical blog.