Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( CL100kBlob = "https://openaipublic.blob.core.windows.net/encodings/cl100k_base.tiktoken" CL100kHash = "223921b76ee99bde995b7ff738513eef100fb51d18c93597a113bcffe865b2a7" )
CL100kBlob and CL100kHash locate and verify the cl100k_base rank file
Functions ¶
func LoadRanks ¶
LoadRanks reads the rank file at a path or url through the cache, checked against a sha256 when one is given
func ParseRanks ¶
ParseRanks reads a rank file, one base64 token and its rank per line
func ReadFileCached ¶
ReadFileCached returns a rank file through the TIKTOKEN_CACHE_DIR, DATA_GYM_CACHE_DIR or temp data-gym-cache copy, fetched again on a hash mismatch
Types ¶
type Encoding ¶
type Encoding struct {
Name string
// contains filtered or unexported fields
}
Encoding is a BPE vocabulary with its pre-tokenizer pattern and special tokens
func CL100kBase ¶
CL100kBase returns the cl100k_base encoding, loaded once per process
func New ¶
New builds an encoding from a split pattern in regexp2 syntax, mergeable ranks and special tokens
func (*Encoding) Encode ¶
Encode returns the tokens of text, each special token in it as its id between ordinary runs
func (*Encoding) EncodeOrdinary ¶
EncodeOrdinary returns the tokens of text with special tokens read as plain text