model

package
v0.0.0-...-e65ccaf Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Forward

func Forward(ctx ml.Context, m Model, opts Options) (ml.Tensor, error)

func Register

func Register(name string, f func(ml.Config) (Model, error))

Types

type Base

type Base struct {
	// contains filtered or unexported fields
}

func (*Base) Backend

func (m *Base) Backend() ml.Backend

func (*Base) Config

func (m *Base) Config() config

type BytePairEncoding

type BytePairEncoding struct {
	// contains filtered or unexported fields
}

func NewBytePairEncoding

func NewBytePairEncoding(pre string, vocab *Vocabulary) BytePairEncoding

func (BytePairEncoding) Decode

func (bpe BytePairEncoding) Decode(ids []int32) (string, error)

func (BytePairEncoding) Encode

func (bpe BytePairEncoding) Encode(s string) ([]int32, error)

func (BytePairEncoding) Is

func (bpe BytePairEncoding) Is(id int32, special Special) bool

type Model

type Model interface {
	Forward(ml.Context, Options) (ml.Tensor, error)

	Backend() ml.Backend
	Config() config
}

func New

func New(s string) (Model, error)

type Options

type Options struct {
	Inputs    []int32
	Positions []int32
	Sequences []int
	Outputs   []int32

	Images []image.Image
}

type Special

type Special int32
const (
	SpecialBOS Special = iota
	SpecialEOS
)

type Tag

type Tag struct {
	Name      string
	Alternate []string
}

func ParseTags

func ParseTags(s string) (tag Tag)

type TextProcessor

type TextProcessor interface {
	Encode(string) ([]int32, error)
	Decode([]int32) (string, error)
	Is(int32, Special) bool
}

type Vocabulary

type Vocabulary struct {
	Values []string
	Types  []uint32
	Scores []uint32
	Merges []string

	BOS, EOS int32
	// contains filtered or unexported fields
}

func (*Vocabulary) Decode

func (v *Vocabulary) Decode(id int32) string

func (*Vocabulary) Encode

func (v *Vocabulary) Encode(s string) int32

func (*Vocabulary) Is

func (v *Vocabulary) Is(id int32, special Special) bool

func (*Vocabulary) Merge

func (v *Vocabulary) Merge(left, right string) int

func (*Vocabulary) SpecialVocabulary

func (v *Vocabulary) SpecialVocabulary() []string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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