tasks

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: BSD-2-Clause Imports: 21 Imported by: 61 modules, 56 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load[T any](conf *Config) (T, error)

Load loads a model from file.

func LoadModelForQuestionAnswering

func LoadModelForQuestionAnswering(conf *Config) (questionanswering.Interface, error)

func LoadModelForTextClassification

func LoadModelForTextClassification(conf *Config) (textclassification.Interface, error)

func LoadModelForTextEncoding

func LoadModelForTextEncoding(conf *Config) (textencoding.Interface, error)

func LoadModelForTextGeneration

func LoadModelForTextGeneration(conf *Config) (textgeneration.Interface, error)

func LoadModelForTokenClassification

func LoadModelForTokenClassification(conf *Config) (tokenclassification.Interface, error)

func LoadModelForZeroShotTextClassification

func LoadModelForZeroShotTextClassification(conf *Config) (zeroshotclassifier.Interface, error)

func LoadModelLanguageModeling added in v0.1.2

func LoadModelLanguageModeling(conf *Config) (languagemodeling.Interface, error)

Types

type Config

type Config struct {
	// ModelsDir is the directory where the models are stored.
	ModelsDir string
	// ModelName is the name of the model (format: <org>/<model>).
	ModelName string
	// HubAccessToken is the access token for the Hugging Face Hub.
	HubAccessToken string
	// DownloadPolicy is the policy for downloading the model (default missing)
	DownloadPolicy DownloadPolicy
	// ConversionPolicy is the policy for converting the model (default missing)
	ConversionPolicy ConversionPolicy
	// ConversionPrecision is the floating-point precision of the converted model (default 32)
	ConversionPrecision FloatPrecision
}

Config is the configuration for the loader.

func (*Config) FullModelPath

func (c *Config) FullModelPath() string

FullModelPath returns the full model path.

type ConversionPolicy

type ConversionPolicy int

ConversionPolicy is a policy for converting a pre-trained model.

const (
	// ConvertMissing converts the model only if it does not exist.
	ConvertMissing ConversionPolicy = iota
	// ConvertAlways converts the model even if it already exists.
	ConvertAlways
	// ConvertNever does not convert the model.
	ConvertNever
)

func ParseConversionPolicy

func ParseConversionPolicy(s string) (ConversionPolicy, error)

ParseConversionPolicy parses a string into a conversion policy.

type DownloadPolicy

type DownloadPolicy int

DownloadPolicy is a policy for downloading a model.

const (
	// DownloadMissing means that the model will be downloaded only if it doesn't exist.
	DownloadMissing DownloadPolicy = iota
	// DownloadAlways means that the model will be downloaded even if it already exists.
	DownloadAlways
	// DownloadNever means that the model will not be downloaded.
	DownloadNever
)

func ParseDownloadPolicy

func ParseDownloadPolicy(s string) (DownloadPolicy, error)

ParseDownloadPolicy parses a string into a download policy.

type FloatPrecision

type FloatPrecision int

FloatPrecision is the floating-point precision of the converted model.

const (
	// F32 is the 32 floating-point precision.
	F32 FloatPrecision = iota
	// F64 is the 64 floating-point precision.
	F64
)

func ParseFloatPrecision

func ParseFloatPrecision(s string) (FloatPrecision, error)

ParseFloatPrecision parses a string into a FloatPrecision precision type.

Jump to

Keyboard shortcuts

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