Zum Inhalt springen
Skillpedia
Analyse & Tabellen9.5k · #12269

xberg-chunking

Was er macht

Dieser Skill erklärt, wie langer Text in Abschnitte geschnitten wird, die in das Kontextfenster eines KI-Modells oder in eine Suchdatenbank passen. Er ist für Menschen gedacht, die KI-Suche oder Werkzeuge für Fragen zu Dokumenten bauen.

Wann du ihn nutzt

  • ✓Wenn du ein langes Dokument in ein KI-Werkzeug mit Größenbeschränkung einspeisen musst.
  • ✓Wenn du einen Suchindex oder ein RAG-System aus Dokumenten baust.
  • ✓Wenn du schon Text hast und ihn in Abschnitte einer festen Größe teilen willst.

Link zum Skill

https://github.com/xberg-io/xberg/blob/main/plugin/.ai-rulez/skills/xberg-chunking/SKILL.md

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/xberg-io/xberg/blob/main/plugin/.ai-rulez/skills/xberg-chunking/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Teile diesen 80-seitigen Bericht in Abschnitte von etwa 1000 Zeichen mit ein wenig Überlappung, damit ich ihn in meine KI-Suche laden kann.”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Der Agent schaltet das Zerteilen während der Extraktion ein oder nutzt den separaten Chunk-Befehl für Text, den du schon hast. Er legt Abschnittsgröße und Überlappung fest und prüft, dass die Überlappung kleiner als die Abschnittsgröße ist.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von GitHub.

Chunking

Use this when feeding documents into an LLM context window or a vector store. Xberg chunks two ways: inline during extraction (chunks land on each document's chunks field), or standalone via the chunk command for text you already have. Sizing is character-based by default, or token-based when a tokenizer model is supplied.

Inline during extraction

Turn on chunking with --chunk and the chunks appear on the structured result under chunks:

# 1000-char chunks, 200-char overlap (defaults when --chunk is on)
xberg extract report.pdf --chunk --format json | jq '.result.chunks | length'

# Explicit size + overlap
xberg extract report.pdf --chunk --chunk-size 1500 --chunk-overlap 300 --format json

Overlap must be smaller than chunk size — the CLI rejects --chunk-overlap >= --chunk-size. When you set only --chunk-overlap against an existing config, an overlap that exceeds the size is clamped to chunk_size / 4.

Standalone chunk command

Chunk text you already have, from --text or stdin. Output defaults to JSON:

# From a flag
xberg chunk --text "long document text ..." --chunk-size 800 --chunk-overlap 100

# From stdin (pipe extracted content straight in)
xberg extract notes.md | xberg chunk --chunk-size 500 --format json

JSON output carries chunks (array of strings), chunk_count, the resolved config (max_characters, overlap, chunker_type), and input_size_bytes. Use --format text for a human-readable dump with --- chunk N --- separators.

Note: in the JSON output, chunker_type is rendered capitalized ("Text", "Markdown", "Yaml", "Semantic") because it is emitted via Rust's Debug formatting, whereas the --chunker-type input flag is lowercase (text, markdown, yaml, semantic). Lowercase the value before comparing if you parse it back.

Chunker types

--chunker-type selects the splitting strategy (standalone chunk command):

Type Behavior
text Default. Plain character-window splitting with overlap.
markdown Markdown-aware — splits on structure (headings, blocks) where possible.
yaml YAML-aware splitting for structured config/data documents.
semantic Topic-boundary splitting driven by --topic-threshold (0.0–1.0, default 0.75).
# Markdown-aware chunking keeps headings and blocks intact
xberg chunk --text "$(cat README.md)" --chunker-type markdown

# Semantic chunking — lower threshold = more, smaller topic chunks
xberg chunk --text "$(cat transcript.txt)" --chunker-type semantic --topic-threshold 0.6

Token-based sizing

By default --chunk-size counts characters. To size chunks by tokens for a specific model, pass --chunking-tokenizer with a HuggingFace tokenizer id. On the extract command this implicitly enables chunking. Requires the chunking-tokenizers feature (present in the default CLI build).

# Size chunks by GPT-4o tokens during extraction
xberg extract report.pdf --chunking-tokenizer Xenova/gpt-4o --format json

# Or on the standalone command
xberg chunk --text "$(cat doc.txt)" --chunking-tokenizer Xenova/gpt-4o --chunk-size 512

With a tokenizer set, --chunk-size is interpreted in tokens, not characters.

Config file alternative

Field names in config files are snake_case under [chunking]:

[chunking]
max_characters = 1000
overlap = 200
chunker_type = "markdown"
xberg extract report.pdf --config xberg.toml --format json

CLI flags map to config fields as --chunk-size → max_characters and --chunk-overlap → overlap. In config files use the snake_case names.

Programmatic access

From Python, enable chunking on the config and read the chunks off the document in the result envelope (result.results[0].chunks):

from xberg import ExtractInput, extract, ExtractionConfig, ChunkingConfig

config = ExtractionConfig(
    chunking=ChunkingConfig(max_characters=1000, overlap=200),
)
result = await extract(ExtractInput(uri="report.pdf"), config)
for chunk in result.results[0].chunks or []:
    print(len(chunk.content))

The public Python ChunkingConfig (a dataclass) uses constructor kwargs max_characters / overlap; the Rust core struct fields are also max_characters / overlap. TOML/JSON conf

Häufige Fragen

Wofür dient die Überlappung?

Die Überlappung wiederholt etwas Text zwischen benachbarten Abschnitten, damit ein Satz, der an einer Grenze geteilt wird, in einem der Abschnitte vollständig erscheint.

Kann er Abschnitte nach Tokens bemessen?

Ja, wenn ein Tokenizer-Modell angegeben wird. Sonst werden die Größen in Zeichen gezählt.

Was ist, wenn die Überlappung zu groß ist?

Der Befehl lehnt eine Überlappung ab, die gleich groß oder größer als die Abschnittsgröße ist.

Details

Originalbeschreibung des Autors

Use when splitting extracted text into chunks for LLM context windows or RAG ingestion. Covers chunk size, overlap, markdown/yaml/semantic chunkers, tokenizer-based sizing, and the standalone `chunk` command.

repo: xberg-io/xberg

Beliebtheit

GitHub-Sterne
9.5k
Platz im Ranking
#12269
Lizenz
MIT
Aktualisiert
2.11.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills