Documentation
¶
Index ¶
- func BPETokenizeWithMerges(tokenizer Tokenizer, text string) []string
- func ByteLevelPreTokenize(input string, addPrefixSpace bool) string
- func DeTokenise(tk Tokenizer, tokens []int) string
- func GetSystemInfoString() string
- func QuantizeModelFile(modelFilePathIn, modelFilePathOut string, formatName string) (bool, error)
- type AddedToken
- type Context
- type Decoder
- type Model
- type Normalizer
- type PostProcessor
- type PreTokenizer
- type RwkvState
- type Token
- type Tokenizer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BPETokenizeWithMerges ¶
func ByteLevelPreTokenize ¶
func DeTokenise ¶
func GetSystemInfoString ¶
func GetSystemInfoString() string
Types ¶
type AddedToken ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func (*Context) GetLogitsBufferElementCount ¶
func (*Context) GetStateBufferElementCount ¶
type Model ¶
type Model struct {
Type string `json:"type"`
Dropout float32 `json:"dropout"`
UnkToken string `json:"unk_token"`
ContinuingSubwordPrefix string `json:"continuing_subword_prefix"`
EndOfWordSuffix string `json:"end_of_word_suffix"`
FuseUnk bool `json:"fuse_unk"`
Vocab map[string]int `json:"vocab"`
Merges []string `json:"merges"`
}
type Normalizer ¶
type Normalizer struct {
Type string `json:"type"`
}
type PostProcessor ¶
type PreTokenizer ¶
type RwkvState ¶
type RwkvState struct {
// The context
Context *Context
State []float32
Logits []float32
Tokenizer *Tokenizer
}
func LoadFiles ¶
LoadFiles loads the model and tokenizer from the given files. modelFile is the path to the model file. This must be in ggml format. See the aimodels/ directory for examples. tokenFile is the path to the tokenizer file. This must be in json format. At the moment, only the 20B_tokenizer.json file from rwkv.cpp is supported.
func (*RwkvState) GenerateResponse ¶
func (r *RwkvState) GenerateResponse(maxTokens int, stopString string, temperature float32, top_p float32, tokenCallback func(s string) bool) string
Generate a response from the current state. The state will be changed by this function, in the process of generating the response. maxTokens is the maximum number of tokens to generate stopString is a string to stop at. If the response contains this string, the response will be truncated at this point.
func (*RwkvState) PredictNextToken ¶
Predict the next token from the current state. State will not be changed by this function.
func (*RwkvState) ProcessInput ¶
ProcessInput processes the input string, updating the state of the model.
type Token ¶
func ByteLevelDecode ¶
type Tokenizer ¶
type Tokenizer struct {
AddedTokens []AddedToken `json:"added_tokens"`
Normalizer Normalizer `json:"normalizer"`
PreTokenizer PreTokenizer `json:"pre_tokenizer"`
PostProcessor PostProcessor `json:"post_processor"`
Decoder Decoder `json:"decoder"`
Model Model `json:"model"`
}