Skip to content

Embeddings bpesplitstep

github-actions[bot] edited this page Aug 26, 2026 · 24 revisions

Development build. This page describes main, not a released package. The latest published Lodestar.Embeddings is 0.4.0 — read its documentation.

BpeSplitStep

A Split step ahead of ByteLevel, as a Llama-3 or Qwen2 file declares one.

public sealed record BpeSplitStep

PropertiesPattern is the regex. Behavior is the SplitBehavior applied to what it matches. Invert splits on what the pattern does not match instead.

Example — the step a Llama-3 file puts before ByteLevel.

using Lodestar.Embeddings.Tokenization;

var step = new BpeSplitStep(BpePatterns.Llama3, SplitBehavior.Isolated, Invert: false);

bool inverted = step.Invert;  // => False

Remarks — stock GPT-2 declares a bare ByteLevel pre-tokenizer with no Split in front of it. A Llama-3 or Qwen2 file declares a Sequence of Split then ByteLevel, and the Split's behaviour decides what happens to the text between matches — which is the whole reason this type exists rather than a bare pattern string.

Invert reads oddly and is what several shipped files use: it is easier to write a pattern for the text you want to keep than for the delimiters you want to cut on.

Where a model declares none, BpeVocabulary.PreSplit is null, and that is different from declaring one that matches nothing.

Applies to — net10.0, netstandard2.0.

See alsoSplitBehavior, BpeVocabulary.

Lodestar

Project

Clone this wiki locally