sample — Split long texts into optimized chunks using 3 strategies
load_dataset — Load sample rows from HuggingFace datasets via the Datasets Server API
sample Tool
Parameters
Parameter
Type
Default
Description
text
string (req)
—
Input text to chunk
strategy
string
"priority"
"priority" (keyword frequency + position), "relevance" (BM25 vs query), "length" (fixed-size)
chunkSize
number
2000
Target chars per chunk
overlap
number
0
Overlapping chars between chunks (length only)
maxChunks
number
unlimited
Max chunks to return
query
string
—
Required for "relevance" strategy
Output
Use Cases
priority: Extract the most information-dense segments from long articles
relevance: Find segments matching a specific query (e.g. "budget figures")
length: Split into uniform segments for parallel processing
load_dataset Tool
Parameters
Parameter
Type
Default
Description
dataset
string (req)
—
HF dataset name (e.g. "squad", "imdb", "ibm/duorc")
split
string
"train"
Dataset split ("train", "test", "validation")
config
string
auto-detect
Dataset config/subset (required if multiple configs exist)
max_samples
number
5
Number of rows to fetch (max 100)
query
string
—
Optional BM25 search query to filter rows
format
string
"text"
"text" (key: value lines), "json" (raw JSON), "prompt" (=== Sample N ===), "fewshot" (Input:/Output: pairs)
template
Output
API Used
The tool uses the HuggingFace Datasets Server (datasets-server.huggingface.co) REST API — no extra npm dependencies. Public datasets are accessible without authentication.
Use Cases
Load few-shot examples from SQuAD, IMDB, or custom datasets
Inject dataset samples into prompts for in-context learning
Search across dataset rows with BM25 full-text search
Pick specific rows by index (indices) for curated example sets
Format samples as few-shot Input:/Output: pairs ready to paste into a prompt (format: "fewshot")
Few-Shot Prompt Injection (fewshot format)
format: "fewshot" renders each row as labeled Input Column: value / Output Column: value
lines — ready to be pasted into a system or user prompt as in-context examples:
input_columns selects which fields appear as inputs (default: all except the output column)
output_column selects the answer field (default: the last column in the row)
Combine with indices: "3,17,42" to curate exactly which examples enter the prompt
Tips
The load_dataset tool auto-discovers the dataset config if not specified. If multiple configs exist, it asks you to specify one.
The sample tool's "relevance" strategy pairs well with load_dataset — load samples, then chunk the context field.
For rate limiting: the HF Datasets Server has a max of 100 rows per call. Make multiple calls for more samples.
string
—
Custom template with {text} placeholder for each sample (text format only)
indices
string
—
Comma/space-separated row indices to fetch, e.g. "0,5,10" — takes precedence over max_samples
input_columns
string[]
all but out
Columns to treat as input (fewshot format only)
output_column
string
last column
Column to treat as output/answer (fewshot format only)
Question: To whom did the Virgin Mary allegedly appear in 1858?Context: Architecturally, the school has a Catholic character...Answers: Bernadette SoubirousQuestion: What is the Grotto at Notre Dame?Context: ...Answers: a Marian place of prayer and reflection