token_num_filter

Filter text samples by token count using HuggingFace tokenizer.

541|171|Updated May 3, 2018
One-click install
npx skills add https://github.com/cas-bigdatalab/piflow --skill token-num-filter
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: token_num_filter
Source: https://github.com/cas-bigdatalab/piflow/tree/main/workspace/skills/token_num_filter
Command: npx skills add https://github.com/cas-bigdatalab/piflow --skill token-num-filter

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires py-data-juicer, transformers, and includes scripts (resource) components.

What problem does it solve?

This Skill solves the problem of filtering text samples based on their token count, allowing users to retain samples within a specified range of token numbers.

Core Features & Use Cases

  • Token Count Filtering: Utilizes HuggingFace tokenizer to calculate token counts of text samples.
  • Range-Based Filtering: Retain samples with token counts within the specified minimum and maximum limits.
  • Use Case: When working with large text datasets and needing to filter out samples that are too short or too long.

Quick Start

Apply the token_num_filter skill to the 'example_input.jsonl' file, keeping text samples with a minimum of 10 tokens and no maximum limit.

Frequently Asked Questions about token_num_filter

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I filter text samples by token count in a dataset?

Filter text samples by token count using a HuggingFace tokenizer to retain only samples within a specified minimum and maximum token range. This process removes overly short or long text entries to streamline dataset preprocessing.

What is the best way to remove text entries that are too short or too long for model training?

The best way to remove overly short or long text entries is token range filtering, which calculates token counts via a HuggingFace tokenizer and retains only samples matching your defined limits for cleaner dataset trimming.

Do I need py-data-juicer and transformers to filter text by token range?

Yes, you need both py-data-juicer and transformers to filter text by token range. These dependencies provide the necessary tokenizer and filtering framework to calculate token counts and apply range limits to text samples.

Can I set a minimum token limit without specifying a maximum limit for text filtering?

Yes, you can set a minimum token limit without a maximum limit for text filtering. The filter retains samples with token counts above the specified minimum, allowing unlimited text length for samples exceeding the threshold.

Does token count filtering work with JSONL files for text preprocessing?

Token count filtering works with JSONL files for text preprocessing by reading text samples, calculating token counts using a HuggingFace tokenizer, and outputting only the samples that fall within the specified token range.

When should I use token counting instead of character length for filtering text samples?

Use token counting instead of character length when filtering text samples for model training, as tokenization aligns with how models process language and ensures samples match exact model input constraints rather than arbitrary character limits.