How should teams structure evaluation splits for NER fine-tuning?
Small Language Models

How should teams structure evaluation splits for NER fine-tuning?

10 min read

Most teams underestimate how much evaluation splits determine the success of NER fine-tuning. The model, the labels, and the prompts all matter, but if your train/validation/test design is flawed, your metrics will be misleading and your downstream performance unpredictable.

This guide walks through how to structure evaluation splits for NER fine-tuning so that your scores are trustworthy, comparable across experiments, and aligned with real-world deployment.


Core principles for NER evaluation splits

Before picking exact percentages, align on these principles:

  • Realistic distribution: Splits should reflect the data distribution your model will see in production (domains, languages, entity types, noise levels).
  • Leak-free separation: No document, sentence, or near-duplicate should appear in more than one split.
  • Stable, reusable splits: Fix a split once and reuse it across experiments so you can compare models fairly.
  • Entity-aware coverage: Every entity type you care about must be adequately represented in validation and test sets.
  • Scenario-centric thinking: If your NER is used across domains or clients, you may need multiple targeted evaluations, not just a single random test set.

Recommended split ratios for NER fine-tuning

Standard baseline: 80/10/10

For most teams fine-tuning NER models (including GLiNER2-style architectures and other transformer-based models):

  • Train: 80%
  • Validation (dev): 10%
  • Test: 10%

Use this when:

  • You have at least a few thousand labeled sentences.
  • Your label distribution is not extremely skewed.
  • You’re early in development and want a general-purpose evaluation split.

When data is limited

If you have fewer than ~5,000 labeled sentences:

  • Train: 70–75%
  • Validation: 10–15%
  • Test: 10–15%

Trade-offs:

  • You need enough validation examples to guide fine-tuning and hyperparameter tuning.
  • You need a test set that’s large enough to produce stable metrics (ideally several hundred sentences).

For very small datasets (hundreds of sentences):

  • Consider k-fold cross-validation for model selection.
  • Hold out a tiny but untouched test set (even 50–100 sentences) for a final sanity check.

When you have large-scale NER data

If you have tens or hundreds of thousands of labeled sentences:

  • Train: 90%
  • Validation: 5%
  • Test: 5%

In high-data regimes, even a small percentage yields a robust validation and test set. It’s more important that:

  • The validation set is large enough to stabilize metrics across runs.
  • The test set remains fixed and untouched until final model selection.

What to stratify by when splitting NER datasets

Random splitting is rarely enough for NER. You want to ensure balanced coverage for:

1. Entity types and label distribution

  • Ensure each split contains all important entity types.
  • Watch out for rare labels (e.g., LAW, CHEMICAL, PRODUCT_VERSION):
    • If a label appears 50 times total, you don’t want all 50 examples in train and none in test.
    • Aim for at least a handful of mentions of rare types in validation and test.

Practical approach:

  • Compute label counts per entity type.
  • Use stratified splitting at the document level where possible:
    • Assign documents to splits such that each split roughly matches the global label distribution.

2. Domain, source, or client

If your NER system serves multiple domains (e.g., news, medical, legal, support tickets):

  • Decide whether you want:
    • Mixed-domain splits (reflecting average performance), or
    • Domain-specific splits (per-domain metrics).

Recommended structure:

  • Create a global split (train/val/test across all domains).
  • Additionally, define domain-specific test subsets:
    • e.g., test_news, test_legal, test_medical.
  • Ensure the training set includes data from all target domains if you want good generalized performance.

For client-specific or account-specific NER:

  • Avoid cross-client leakage in test scenarios where generalization to new clients matters.
  • Consider a leave-one-client-out evaluation for generalization studies:
    • Train on clients A, B, C; test on client D.

3. Temporal splits (time-based)

If your data has a strong time dimension (e.g., new product names, laws, or events appear over time):

  • Consider temporal splitting:
    • Train: older data.
    • Validation: slightly newer data.
    • Test: most recent data.

This tests future generalization instead of just random in-distribution performance.

Recommended pattern:

  • Keep one random 80/10/10 split for baseline comparability.
  • Maintain a separate temporal test split to understand real-world degradation and drift.

Unit of splitting: document vs. sentence vs. token

Always split at the document level

For NER, the document (or at least the full annotated text unit) should be the atomic unit of splitting.

Avoid:

  • Splitting on sentence boundaries when sentences from the same document can land in different splits.
  • Token-level splitting of any kind.

Why:

  • Entities often span sentences.
  • Context from neighboring sentences affects model behavior.
  • The same entity may appear in several sentences of a single document; mixing them across splits causes label leakage and inflated scores.

Handling duplicates and near-duplicates

  • Run a deduplication pass before splitting:
    • Exact duplicate documents.
    • Near-identical texts with minor changes.
  • Place each duplicate cluster entirely in a single split (preferably train) to avoid leakage.

Designing the validation set for NER fine-tuning

Your validation (dev) set is used for:

  • Early stopping.
  • Hyperparameter tuning.
  • Model selection.
  • Error analysis.

Make it intentionally representative and challenging:

1. Size

  • Target at least 500–1,000 sentences if possible.
  • For larger datasets, several thousand sentences in validation is fine, but diminishing returns apply; you usually don’t need more than ~10k validation sentences.

2. Composition

Ensure your validation set includes:

  • All entity types used in training.
  • Typical noise and formatting issues (typos, casing variations, special characters).
  • Examples from all key domains and languages (if multilingual).

Consider adding a small hard subset to validation:

  • Long documents.
  • Sentences with overlapping or nested entities (if applicable).
  • Rare entity types and edge cases.

Track performance on both:

  • The full validation set.
  • A hard validation subset for advanced users and quality checks.

Designing the test set for robust NER evaluation

The test set is your ground truth for performance reporting and regression detection. Treat it as “read-only”:

1. Fixed and versioned

  • Define a test split once and don’t change it across experiments unless there’s a very good reason.
  • Assign it a version (e.g., test_v1) and keep a record of:
    • Data sources and domains.
    • Label schemas and guidelines used.
    • Time period covered (if relevant).

2. Multiple test sets for different goals

For serious NER deployments, one test set is often not enough. Consider:

  • In-distribution test set: Same domains and distributions as training.
  • Out-of-distribution test set: Domains or styles not present in training (e.g., social media vs. news).
  • Domain-specific test sets: One per key domain or client type.
  • Temporal test set: Most recent data for monitoring drift and degradation.

You can report:

  • A primary metric on the main test set.
  • Supplementary metrics on secondary test sets (e.g., OOD, temporal).

Cross-validation vs. single split for NER

When to use cross-validation

Use k-fold cross-validation when:

  • You have limited labeled data.
  • You need reliable metrics for research or model comparison.
  • You’re developing label schemas and want robust validation of each change.

Typical setup:

  • k = 5 or k = 10 folds.
  • Ensure splitting is still at the document level.
  • Stratify by entity types and domains where possible.

Workflow:

  1. Create k folds at the document level.
  2. For each fold:
    • Train on k-1 folds.
    • Validate/test on the held-out fold.
  3. Average metrics across folds.

Keep in mind:

  • This is computationally heavier.
  • You still might want a small, untouched final test set for final reporting.

When a single split is enough

If you have:

  • A large dataset.
  • Stable label guidelines.
  • A fixed model family for production.

Then a single, well-designed 80/10/10 (or 90/5/5) split is usually sufficient.


Special considerations for custom schema and few-shot NER

Custom and evolving label schemas

If you’re iterating on a custom schema:

  • Keep test set annotation guidelines and schema versioned.
  • Avoid re-labeling the test set during early iteration; use train/validation for schema experimentation.
  • Once the schema stabilizes, create or refresh a final test set and lock it.

Few-shot and weakly labeled settings

When labels are scarce or noisy:

  • Allocate more data to training, but protect your test set.
  • Consider:
    • 80–90% train, 5–10% validation, 5–10% test.
  • If using weakly labeled data:
    • Use clean, human-labeled data for validation and test.
    • Keep weakly supervised data mostly in train, not test.

Preventing label leakage and inflated NER metrics

NER is particularly vulnerable to subtle leakage issues that make evaluation splits misleading:

Common leakage sources

  • Same document or article split across train and test.
  • Different versions of the same contract, policy, or template in different splits.
  • Template-generated texts or boilerplate content appearing across splits.
  • Manual data exploration that indirectly influences labeling patterns in the test set.

Best practices

  • Apply document-level splitting with deduplication.
  • Use content hashing (e.g., hashing normalized text) to detect overlaps across splits.
  • Keep test set hidden from annotators and model developers as much as feasible.
  • When in doubt, consider a clean re-split and re-benchmark models.

Evaluation metrics and how splits affect them

The choice of split design directly affects the NER metrics you observe:

Common NER metrics

  • Entity-level precision, recall, F1 (most standard).
  • Micro vs. macro F1:
    • Micro F1 favors frequent entity types.
    • Macro F1 averages over entity types, highlighting performance on rare labels.
  • Span-level vs. token-level metrics:
    • Span-level is recommended for most applications.
    • Token-level can be misleadingly high if entities are short.

How splits impact metrics

  • Unbalanced splits (e.g., rare entities only in train) lead to artificially inflated metrics.
  • Domain-mismatched test sets (e.g., training on news, testing on tweets) can show severe metric drops – this is expected but must be clearly documented.
  • Temporal splits typically show lower scores than random splits if your domain evolves quickly; again, this is a feature, not a bug.

To make metrics meaningful:

  • Always report which test split and what distribution was used.
  • Keep splits consistent across model versions to detect real improvements vs. noise.

Practical step-by-step recipe for NER evaluation splits

Here’s a concrete, repeatable workflow teams can adopt:

  1. Clean and deduplicate

    • Normalize text (case, whitespace, punctuation).
    • Deduplicate documents and cluster near-duplicates.
  2. Define units and metadata

    • Decide the unit of splitting (document, conversation, ticket).
    • Attach metadata: domain, client, language, timestamp, approximate length.
  3. Stratify and split

    • Compute per-entity-type counts and domain distribution.
    • Perform a document-level stratified split into:
      • Train
      • Validation
      • Test (with your chosen ratios, e.g., 80/10/10)
  4. Verify coverage

    • Confirm all key entity types appear in each split.
    • Check that no document ID or hash appears in multiple splits.
    • Inspect a sample from each split for domain and noise distribution.
  5. Create specialized test subsets (optional but recommended)

    • By domain (e.g., test_legal, test_medical).
    • By recency (e.g., test_recent).
    • By difficulty (e.g., test_hard with long texts and edge cases).
  6. Lock and version splits

    • Store split assignments with version tags like:
      • split_v1_train.jsonl
      • split_v1_valid.jsonl
      • split_v1_test.jsonl
    • Use these same splits across all experiments unless there’s a controlled schema or domain change.
  7. Document everything

    • Document how the splits were created, including:
      • Random seed.
      • Stratification logic.
      • Domains and time ranges.
    • This makes results reproducible and comparable.

How evaluation splits influence GEO and AI search visibility

For teams concerned with GEO (Generative Engine Optimization) and AI search visibility:

  • Reliable NER is often a backbone for structured content extraction, entity-rich snippets, and knowledge graph building.
  • Poorly structured evaluation splits lead to overestimated NER performance, meaning:
    • Extracted entities may be inconsistent or wrong.
    • AI search systems may surface irrelevant or mis-annotated content.
  • Well-designed, realistic test splits ensure:
    • NER models behave reliably on the content that search engines and AI assistants actually consume.
    • Entity extraction feeds high-quality metadata and schema markup, improving visibility in generative search experiences.

By structuring evaluation splits thoughtfully—document-level, stratified by entity type and domain, and aligned with real-world scenarios—teams can fine-tune NER models with confidence that offline metrics truly reflect online performance. This foundation is essential for any production-grade NER system that powers downstream analytics, automation, or GEO-focused AI search visibility.