Skip to main content

Distilabel Steps Library

Note: This README was automatically generated by Claude-3.5-Sonnet. If you spot any errors or confusing sections, please file an issue or submit a PR!

A collection of utility steps for processing and manipulating data in distilabel pipelines.

Installation

pip install distilabel-steps-library

Available Steps

Chat Processing Steps

FormatPlaintextChatTranscript

Formats chat messages into a plaintext transcript format where each message is represented as ": " on a new line.

Input Columns:

  • messages (List[Dict[str, str]]): List of message dictionaries with 'role' and 'content' keys

Output Columns:

  • transcript (str): Plaintext representation of the chat messages

Example:

from distilabel_steps_library.chat import FormatPlaintextChatTranscript

format_transcript = FormatPlaintextChatTranscript()
result = next(
    format_transcript.process([{
        "messages": [
            {"role": "user", "content": "What's 2+2?"},
            {"role": "assistant", "content": "4"}
        ]
    }])
)
# Result includes: 'transcript': 'user: What's 2+2?\nassistant: 4'

FlipMessageRoles

Flips the roles in chat messages between 'user' and 'assistant' while preserving system messages.

Input Columns:

  • messages (List[Dict[str, str]]): List of message dictionaries

Output Columns:

  • flipped_messages (List[Dict[str, str]]): Messages with swapped roles

Example:

from distilabel_steps_library.chat import FlipMessageRoles

flip_roles = FlipMessageRoles()
result = next(
    flip_roles.process([{
        "messages": [
            {"role": "user", "content": "Hello"},
            {"role": "assistant", "content": "Hi"}
        ]
    }])
)
# Result includes flipped roles: user->assistant, assistant->user

InsertMessage

Inserts a new message into the chat messages at a specified index.

Input Columns:

  • messages (List[Dict[str, str]]): List of message dictionaries
  • content (str): Content for the message to be inserted

Output Columns:

  • messages (List[Dict[str, str]]): Modified list with the new message

Example:

from distilabel_steps_library.chat import InsertMessage

insert = InsertMessage(index=0, role="system")
result = next(
    insert.process([{
        "messages": [
            {"role": "user", "content": "Hi"}
        ],
        "content": "Be helpful"
    }])
)
# Inserts system message at the beginning

Data Cleaning Steps

DropEmpty

Filters out rows containing empty values in specified columns.

Input Columns:

  • Any columns specified in the columns parameter (or all columns if none specified)

Output Columns:

  • All input columns (for non-empty rows)

Example:

from distilabel_steps_library import DropEmpty

# Drop rows with empty values in specific columns
drop_step = DropEmpty(columns=["instruction", "response"])
result = next(
    drop_step.process([
        {"instruction": "Task", "response": ""},  # Will be dropped
        {"instruction": "Task 2", "response": "Answer"}  # Will be kept
    ])
)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

WTFPL.

Metadata

Release files for distilabel-steps-library 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for distilabel-steps-library 0.1.2
File Size Uploaded Provenance Actions
distilabel_steps_library-0.1.2.tar.gz 57.0 kB Without provenance Details for distilabel_steps_library-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for distilabel-steps-library 0.1.2
File Interpreter ABI Platform Actions
distilabel_steps_library-0.1.2-py3-none-any.whl Python 3 none any Details for distilabel_steps_library-0.1.2-py3-none-any.whl

Total release size: 67.3 kB

Release files / distilabel_steps_library-0.1.2.tar.gz

Download URL distilabel_steps_library-0.1.2.tar.gz
Size 57.0 kB
Tags Source
SHA-256 checksum
How to use checksums
544c5e09d615f7d2eba86504f8760a9ea535e0765bb6b06a7a3da8c2fe47feb2
BLAKE2b-256 checksum
How to use checksums
c43156d40ad81099222606a9c07bacb44214f088b4a85f7a720f43394a3f3164
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.5.27

Release files / distilabel_steps_library-0.1.2-py3-none-any.whl

Download URL distilabel_steps_library-0.1.2-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4ca5575643465288b96da361d321f329eb17125a6679b1aed9ce4979ec36595
BLAKE2b-256 checksum
How to use checksums
1f761f0ea79ef1eeff8c953c6f9acb618f672858ab75cfb0e7c12c1b024f9d5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.5.27

Security for distilabel-steps-library 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page