NVIDIA-NeMo / NVIDIA-NeMo/Curator

[FEA] Add Sampling-Based Clustering in SemDedup

Open
#538 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement jira
Dominant language
Python
Stars
1.8k
Forks
328
Avg merge
4d 5h
Merged PRs (30d)
30

Description

Description
We should add an option to perform clustering based on sampling in SemDedup, considering GPU memory constraints. Specifically, if sample_for_clustering=True, the system should:

  1. Perform sampling before clustering. The sampling ratio should be configurable, but by default, it should be dynamically inferred at runtime based on available GPU memory to optimize performance.
  2. Use the sampled data to fit a KMeans model.
  3. Apply the fitted KMeans model to cluster all of the data

This approach will enhance scalability and efficiency when dealing with large datasets.

Proposed Changes
Introduce a sample_for_clustering parameter in ClusteringModel to enable sampling-based clustering.

  1. If sample_for_clustering=True, extract a representative sample from the embeddings dataset before fitting the KMeans model.
  2. Train KMeans on the sampled embeddings.
  3. Use the trained model to predict cluster assignments for the full dataset.
  4. Ensure this functionality is compatible with the current partitioning and memory management strategies.

Future Direction
Explore the possibility of integrating sampling-based clustering directly within K-Means, eliminating the need for a two-step process.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at ClusteringModel and trace the existing partitioning, memory-management, and KMeans flow for embeddings. Determine where a configurable sample ratio and runtime GPU-memory default belong, then verify that sampled fitting and full-dataset prediction preserve current behavior. Done means the option works with existing partitioning and memory constraints, with coverage for sampling enabled and disabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data, machine-learning, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.