pub trait ChunkSizer {
// Required method
fn size(&self, chunk: &str) -> usize;
}Expand description
Determines the size of a given chunk.
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl ChunkSizer for CoreBPE
Available on crate feature tiktoken-rs only.
impl ChunkSizer for CoreBPE
Available on crate feature
tiktoken-rs only.Source§impl ChunkSizer for Tokenizer
Available on crate feature tokenizers only.
impl ChunkSizer for Tokenizer
Available on crate feature
tokenizers only.Source§fn size(&self, chunk: &str) -> usize
fn size(&self, chunk: &str) -> usize
Returns the number of tokens in a given text after tokenization.
If the tokenizer has truncation enabled, the returned size may be truncated by the tokenizer. Disable truncation on the tokenizer before constructing a splitter if you need chunk sizes to reflect the full input text.
§Panics
Will panic if you don’t have a byte-level tokenizer and the splitter encounters text it can’t tokenize.