Skip to content
Back to skills

Jaccard Dedup Prediction Filter

ASecurity

Deduplicates extracted entity predictions by filtering out candidates whose Jaccard word-overlap with already-accepted labels exceeds a threshold.

  • 61 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 12, 2026
developmentpythonapi

Works with

  • api

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add wenmin-wu/ds-skills --skill jaccard-dedup-prediction-filter --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Jaccard Dedup Prediction Filter?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Jaccard Dedup Prediction Filter
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wenmin-wu-jaccard-dedup-prediction-filter/badge)](https://www.skillsdirectory.com/skills/wenmin-wu-jaccard-dedup-prediction-filter)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: nlp-jaccard-dedup-prediction-filter
description: >
  Deduplicates extracted entity predictions by filtering out candidates whose Jaccard word-overlap with already-accepted labels exceeds a threshold.
---
# Jaccard Dedup Prediction Filter

## Overview

NER and entity extraction pipelines often produce near-duplicate predictions ("National Health Survey" vs "National Health Survey Data"). Greedy Jaccard deduplication: sort candidates by length, accept each only if its word-level Jaccard similarity with all previously accepted labels is below a threshold. Removes redundant extractions while preserving distinct entities.

## Quick Start

```python
def jaccard_similarity(s1, s2):
    words1 = set(s1.lower().split())
    words2 = set(s2.lower().split())
    intersection = len(words1 & words2)
    union = len(words1 | words2)
    return intersection / union if union > 0 else 0.0

def dedup_entities(entities, threshold=0.75):
    filtered = []
    for entity in sorted(entities, key=len, reverse=True):
        if not filtered or all(
            jaccard_similarity(entity, kept) < threshold
            for kept in filtered
        ):
            filtered.append(entity)
    return filtered

# Usage:
raw_predictions = ["National Health Survey", "National Health Survey Data", "Census Bureau"]
clean = dedup_entities(raw_predictions, threshold=0.75)
# -> ["National Health Survey Data", "Census Bureau"]
```

## Workflow

1. Collect all raw entity predictions for a document
2. Sort by length (longest first to prefer more complete mentions)
3. Greedily accept each candidate if Jaccard < threshold vs all accepted
4. Output filtered set as pipe-delimited string or list

## Key Decisions

- **Threshold**: 0.5 = strict (keeps more variants); 0.75 = moderate; 1.0 = exact dedup only
- **Sort order**: Longest-first keeps the most informative mention; shortest-first is more conservative
- **Word-level vs char-level**: Word Jaccard is standard for entity dedup; char-level for typo handling
- **Case sensitivity**: Lowercase before comparison to catch capitalization variants

## References

- [Coleridge: Matching + BERT NER](https://www.kaggle.com/code/tungmphung/coleridge-matching-bert-ner)
- [External_Datasets_Matching + MLM](https://www.kaggle.com/code/chienhsianghung/external-datasets-matching-mlm)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.