tiktokenbpe

package
v2.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: AGPL-3.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tiktokenbpe loads tiktoken BPE rank files without SHA-1, so token counting works under GODEBUG=fips140=only.

github.com/pkoukk/tiktoken-go names its on-disk cache file after the SHA-1 of the rank file's URL, and crypto/sha1 panics in FIPS 140-only mode. In FIPS mode this package installs a BpeLoader that behaves like tiktoken-go's own (the same cache directory variables, download and file format) but names new cache files after the SHA-256 of the URL. It still reads a cache file stored under the SHA-1 name, such as a pre-seeded TIKTOKEN_CACHE_DIR in an air-gapped install, through a table of those names computed ahead of time, so no SHA-1 runs. Standard builds keep tiktoken-go's loader.

Import it for its side effect wherever tiktoken encodings are loaded.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loader

type Loader struct{}

Loader is a tiktoken.BpeLoader that never uses SHA-1.

func (Loader) LoadTiktokenBpe

func (Loader) LoadTiktokenBpe(blobpath string) (map[string]int, error)

LoadTiktokenBpe implements tiktoken.BpeLoader.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL