Skip to main content

Profile-Based Text Curation Pipelines For Hugging Face Datasets

Project description

text-curation

Profile-based text curation pipelines for Hugging Face Datasets

PyPI License GitHub release Python versions


Overview

text-curation is a Python library for building structured, profile-driven text curation pipelines designed to integrate naturally with Hugging Face Datasets.

The library focuses on deterministic, composable text transformations for preparing large-scale corpora used in NLP and LLM training workflows.

Rather than providing ad-hoc cleaning scripts, text-curation encourages explicit curation profiles that describe what transformations are applied and why.


Design Principles

  • Profile-driven pipelines
    Reusable, declarative profiles define how text is curated for a given domain (e.g. web, wiki, news).

  • Composable blocks
    Each transformation is implemented as an isolated block that can be enabled, disabled, or reordered.

  • Deterministic and non-destructive
    Transformations are conservative by default and designed to preserve semantic content.

  • Dataset-scale friendly
    Built to operate efficiently with Hugging Face Datasets.


Current Scope (v0.1.x)

This library currently focuses on low-level text normalization and formatting. Structural and semantic curation is intentionally staged for later releases.

Implemented blocks:

  • Normalization

    • Unicode normalization
    • Quote and dash normalization
    • Encoding cleanup
  • Formatting

    • Whitespace normalization
    • Punctuation spacing fixes
    • Readability-preserving formatting
  • Redaction

    • Structured redaction hooks for sensitive content
    • Non-destructive by design

Blocks under active development:

  • Structure-aware filtering
  • Deduplication
  • Semantic filtering

Installation

text-curation supports Python ≥ 3.9.

Install from PyPI:

pip install text-curation

Or install from source for development:

git clone https://github.com/Dhiraj309/text-curation.git
cd text-curation
pip install -e .

Quickstart

Curating a Hugging Face Dataset

from datasets import load_dataset
from text_curation import TextCurator

dataset = load_dataset(
    "allenai/c4",
    "en.noclean",
    split="train",
)

curator = TextCurator.from_profiles(profile_name="web_common_v1")

cleaned = dataset.map(
    curator,
    batched=True,
    num_proc=4,
)

The curator is a pure function that takes a batch dictionary and returns a dictionary with the same schema.


Profiles

Profiles define which blocks are applied and in what order.

Example (conceptual, simplified):

web_common_v1 = [
    NormalizationBlock(),
    FormattingBlock(),
    RedactionBlock(),
]

Profiles are versioned to ensure reproducibility and auditability.


Why text-curation?

  • Cleaning text is not just normalization
  • Ad-hoc scripts do not scale or reproduce
  • Dataset curation deserves the same rigor as model training
  • Explicit pipelines make data decisions inspectable

text-curation is designed to be the data-side analogue of model-definition libraries in the HF ecosystem.


When should you not use text-curation?

  • If you only need a one-off regex cleanup
  • If your data is already fully curated
  • If you require ML-based content classification (not in scope)

Versioning & Stability

This project follows semantic versioning.

  • 0.x releases may introduce breaking changes
  • Profiles are versioned explicitly (e.g. web_common_v1)
  • Stable APIs will be formalized before 1.0.0

Contributing

Contributions are welcome.

If you plan to add new blocks or profiles, please:

  • Keep transformations deterministic
  • Avoid destructive defaults
  • Include before/after examples

See CONTRIBUTING.md for details.


License

Apache 2.0. See LICENSE.


Acknowledgements

Inspired by large-scale dataset curation practices in the Hugging Face ecosystem.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

text_curation-0.1.1.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

text_curation-0.1.1-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file text_curation-0.1.1.tar.gz.

File metadata

  • Download URL: text_curation-0.1.1.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for text_curation-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6af361b68c1ba8d5e8019e48a65d5213e17fbc95dae2cdefd718beedfddfb92c
MD5 5f744c227c5e35534fa13344c1420092
BLAKE2b-256 0c1cdeb39421e96bad658184e2e1b82c5ec7a84eb01321f07baa24b466cbf890

See more details on using hashes here.

File details

Details for the file text_curation-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: text_curation-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for text_curation-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6725fc0dcaf23206b93219f781e02696bd7a75da2b4731e11fe81d2a35f91cf4
MD5 c2fc084d4951c1d3058010e43c98ee16
BLAKE2b-256 447a5ef5b38fae4f64dcbf8d9629f029ed891d0c7e990a4a52e9565767b6c7ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page