Documentation
¶
Index ¶
- func ClosePipeline[T pipelineBackends.Pipeline](s *Session, name string) error
- func DownloadModel(modelName string, destination string, options DownloadOptions) (string, error)
- func GetPipeline[T pipelineBackends.Pipeline](s *Session, name string) (T, error)
- func InitializePipeline[T pipelineBackends.Pipeline](p T, pipelineConfig pipelineBackends.PipelineConfig[T], ...) (T, string, error)
- func NewPipeline[T pipelineBackends.Pipeline](s *Session, pipelineConfig pipelineBackends.PipelineConfig[T]) (T, error)
- func TrainGoMLX(s *TrainingSession) error
- type CrossEncoderConfig
- type CrossEncoderOption
- type DownloadOptions
- type FeatureExtractionConfig
- type FeatureExtractionOption
- type GOMLXTrainingOptions
- type ImageClassificationConfig
- type ImageClassificationOption
- type Session
- type TextClassificationConfig
- type TextClassificationOption
- type TextGenerationConfig
- type TextGenerationOption
- type TokenClassificationConfig
- type TokenClassificationOption
- type TrainingConfig
- type TrainingOption
- type TrainingSession
- type TrainingStatistics
- type ZeroShotClassificationConfig
- type ZeroShotClassificationOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClosePipeline ¶ added in v0.3.3
func ClosePipeline[T pipelineBackends.Pipeline](s *Session, name string) error
func DownloadModel ¶ added in v0.2.0
func DownloadModel(modelName string, destination string, options DownloadOptions) (string, error)
DownloadModel can be used to download a model directly from huggingface. Before the model is downloaded, validation occurs to ensure there is an .onnx and tokenizers.json file. Hugot only works with onnx models.
func GetPipeline ¶ added in v0.0.9
func GetPipeline[T pipelineBackends.Pipeline](s *Session, name string) (T, error)
GetPipeline can be used to retrieve a pipeline of type T with the given name from the session
func InitializePipeline ¶ added in v0.3.0
func InitializePipeline[T pipelineBackends.Pipeline](p T, pipelineConfig pipelineBackends.PipelineConfig[T], options *options.Options, model *pipelineBackends.Model) (T, string, error)
func NewPipeline ¶ added in v0.0.9
func NewPipeline[T pipelineBackends.Pipeline](s *Session, pipelineConfig pipelineBackends.PipelineConfig[T]) (T, error)
NewPipeline can be used to create a new pipeline of type T. The initialised pipeline will be returned and it will also be stored in the session object so that all created pipelines can be destroyed with session.Destroy() at once.
func TrainGoMLX ¶ added in v0.4.0
func TrainGoMLX(s *TrainingSession) error
Types ¶
type CrossEncoderConfig ¶ added in v0.5.1
type CrossEncoderConfig = pipelineBackends.PipelineConfig[*pipelines.CrossEncoderPipeline]
CrossEncoderConfig is the configuration for a cross encoder pipeline
type CrossEncoderOption ¶ added in v0.5.1
type CrossEncoderOption = pipelineBackends.PipelineOption[*pipelines.CrossEncoderPipeline]
CrossEncoderOption is an option for a cross encoder pipeline
type DownloadOptions ¶ added in v0.0.7
type DownloadOptions struct { AuthToken string OnnxFilePath string ExternalDataPath string Branch string MaxRetries int RetryInterval int ConcurrentConnections int Verbose bool }
DownloadOptions is a struct of options that can be passed to DownloadModel.
func NewDownloadOptions ¶ added in v0.0.7
func NewDownloadOptions() DownloadOptions
NewDownloadOptions creates new DownloadOptions struct with default values. Override the values to specify different download options.
type FeatureExtractionConfig ¶ added in v0.0.9
type FeatureExtractionConfig = pipelineBackends.PipelineConfig[*pipelines.FeatureExtractionPipeline]
FeatureExtractionConfig is the configuration for a feature extraction pipeline
type FeatureExtractionOption ¶ added in v0.1.1
type FeatureExtractionOption = pipelineBackends.PipelineOption[*pipelines.FeatureExtractionPipeline]
FeatureExtractionOption is an option for a feature extraction pipeline
type GOMLXTrainingOptions ¶ added in v0.4.0
type GOMLXTrainingOptions struct { Optimizer optimizers.Interface Loss losses.LossFn }
type ImageClassificationConfig ¶ added in v0.5.1
type ImageClassificationConfig = pipelineBackends.PipelineConfig[*pipelines.ImageClassificationPipeline]
ImageClassificationConfig is the configuration for an image classification pipeline
type ImageClassificationOption ¶ added in v0.5.1
type ImageClassificationOption = pipelineBackends.PipelineOption[*pipelines.ImageClassificationPipeline]
ImageClassificationOption is an option for an image classification pipeline
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session allows for the creation of new pipelines and holds the pipeline already created.
func NewGoSession ¶ added in v0.4.0
func NewGoSession(opts ...options.WithOption) (*Session, error)
func NewORTSession ¶ added in v0.2.0
func NewORTSession(_ ...options.WithOption) (*Session, error)
func NewXLASession ¶ added in v0.4.0
func NewXLASession(_ ...options.WithOption) (*Session, error)
func (*Session) Destroy ¶
Destroy deletes the hugot session and onnxruntime environment and all initialized pipelines, freeing memory. A hugot session should be destroyed when not neeeded any more, preferably with a defer() call.
func (*Session) GetStats ¶
GetStats returns runtime statistics for all initialized pipelines for profiling purposes. We currently record for each pipeline: the total runtime of the tokenization step the number of batch calls to the tokenization step the average time per tokenization batch call the total runtime of the inference (i.e. onnxruntime) step the number of batch calls to the onnxruntime inference the average time per onnxruntime inference batch call
type TextClassificationConfig ¶ added in v0.0.9
type TextClassificationConfig = pipelineBackends.PipelineConfig[*pipelines.TextClassificationPipeline]
TextClassificationConfig is the configuration for a text classification pipeline
type TextClassificationOption ¶ added in v0.0.9
type TextClassificationOption = pipelineBackends.PipelineOption[*pipelines.TextClassificationPipeline]
TextClassificationOption is an option for a text classification pipeline
type TextGenerationConfig ¶ added in v0.5.1
type TextGenerationConfig = pipelineBackends.PipelineConfig[*pipelines.TextGenerationPipeline]
TextGenerationConfig is the configuration for a text generation pipeline
type TextGenerationOption ¶ added in v0.5.1
type TextGenerationOption = pipelineBackends.PipelineOption[*pipelines.TextGenerationPipeline]
TextGenerationOption is an option for a text generation pipeline
type TokenClassificationConfig ¶ added in v0.0.9
type TokenClassificationConfig = pipelineBackends.PipelineConfig[*pipelines.TokenClassificationPipeline]
TokenClassificationConfig is the configuration for a token classification pipeline
type TokenClassificationOption ¶ added in v0.0.9
type TokenClassificationOption = pipelineBackends.PipelineOption[*pipelines.TokenClassificationPipeline]
TokenClassificationOption is an option for a token classification pipeline
type TrainingConfig ¶ added in v0.3.0
type TrainingConfig struct { ModelPath string OnnxFilename string TrainDataset datasets.Dataset TrainEvalDataset datasets.Dataset // used to evaluate on training EvalDataset datasets.Dataset // optional, used for early stopping and eval metrics Options []TrainingOption Verbose bool GOMLXTrainingOptions *GOMLXTrainingOptions }
type TrainingOption ¶ added in v0.3.0
type TrainingOption func(eo *TrainingSession) error
func WithCuda ¶ added in v0.1.0
func WithCuda() TrainingOption
func WithEarlyStopping ¶ added in v0.5.1
func WithEarlyStopping() TrainingOption
func WithEarlyStoppingParams ¶ added in v0.5.1
func WithEarlyStoppingParams(patience int, tolerance float32) TrainingOption
func WithEpochs ¶ added in v0.5.1
func WithEpochs(epochs int) TrainingOption
func WithFreezeEmbeddings ¶ added in v0.5.1
func WithFreezeEmbeddings() TrainingOption
func WithFreezeLayers ¶ added in v0.5.1
func WithFreezeLayers(layers []int) TrainingOption
type TrainingSession ¶ added in v0.3.0
type TrainingSession struct {
// contains filtered or unexported fields
}
func NewGoTrainingSession ¶ added in v0.4.0
func NewGoTrainingSession[T pipelineBackends.Pipeline](config TrainingConfig) (*TrainingSession, error)
func NewXLATrainingSession ¶ added in v0.3.5
func NewXLATrainingSession[T pipelineBackends.Pipeline](config TrainingConfig) (*TrainingSession, error)
func (*TrainingSession) Destroy ¶ added in v0.3.2
func (s *TrainingSession) Destroy() error
func (*TrainingSession) GetPipeline ¶ added in v0.3.3
func (s *TrainingSession) GetPipeline() pipelineBackends.Pipeline
GetPipeline returns the pipeline used in the training session.
func (*TrainingSession) Save ¶ added in v0.3.0
func (s *TrainingSession) Save(path string) error
Save serializes the trained model as an onnx model. If a tokenizer is present, the tokenizer files are copied from the untrained model directory to the trained model. Path is the full path to the directory where the model will be saved.
func (*TrainingSession) Train ¶ added in v0.3.0
func (s *TrainingSession) Train() error
type TrainingStatistics ¶ added in v0.5.1
type ZeroShotClassificationConfig ¶ added in v0.1.4
type ZeroShotClassificationConfig = pipelineBackends.PipelineConfig[*pipelines.ZeroShotClassificationPipeline]
ZeroShotClassificationConfig is the configuration for a zero shot classification pipeline
type ZeroShotClassificationOption ¶ added in v0.3.0
type ZeroShotClassificationOption = pipelineBackends.PipelineOption[*pipelines.ZeroShotClassificationPipeline]
ZeroShotClassificationOption is an option for a zero shot classification pipeline