Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadConfig ¶
func LoadConfig(config pretrained.Config, modelNameOrPath string, customParams map[string]interface{}) error
LoadConfig loads pretrained configuration data from local or remote file.
Parameters: - `config` pretrained.Config (any model config that implements pretrained `Config` interface) - `modelNameOrPath` is a string of either
- Model name or
- File name or path or
- URL to remote file
If `modelNameOrPath` is resolved, function will cache data using `TransformerCache` environment if existing, otherwise it will be cached in `$HOME/.cache/transformers/` directory. If `modleNameOrPath` is valid URL, file will be downloaded and cached. Finally, configuration data will be loaded to `config` parameter.
Example ¶
package main import ( "fmt" "log" "github.com/yinziyang/transformer" "github.com/yinziyang/transformer/bert" ) func main() { modelNameOrPath := "bert-base-uncased" var config bert.BertConfig err := transformer.LoadConfig(&config, modelNameOrPath, nil) if err != nil { log.Fatal(err) } fmt.Println(config.VocabSize) }
Output: 30522
func LoadModel ¶
func LoadModel(model pretrained.Model, modelNameOrPath string, config pretrained.Config, customParams map[string]interface{}, device gotch.Device) error
LoadConfig loads pretrained model data from local or remote file.
Parameters: - `model` pretrained Model (any model type that implements pretrained `Model` interface) - `modelNameOrPath` is a string of either
- Model name or
- File name or path or
- URL to remote file
If `modelNameOrPath` is resolved, function will cache data using `TransformerCache` environment if existing, otherwise it will be cached in `$HOME/.cache/transformers/` directory. If `modleNameOrPath` is valid URL, file will be downloaded and cached. Finally, model weights will be loaded to `varstore`.
func LoadTokenizer ¶
func LoadTokenizer(tk pretrained.Tokenizer, modelNameOrPath string, customParams map[string]interface{}) error
LoadTokenizer loads pretrained tokenizer from local or remote file.
Parameters: - `tk` pretrained.Tokenizer (any tokenizer model that implements pretrained `Tokenizer` interface) - `modelNameOrPath` is a string of either
- Model name or
- File name or path or
- URL to remote file
If `modelNameOrPath` is resolved, function will cache data using `TransformerCache` environment if existing, otherwise it will be cached in `$HOME/.cache/transformers/` directory. If `modleNameOrPath` is valid URL, file will be downloaded and cached. Finally, vocab data will be loaded to `tk`.
Types ¶
This section is empty.