sdk

package
v0.0.0-...-23bd5ca Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxTokenSize = 1024
)

Functions

This section is empty.

Types

type Error

type Error uint32
const (
	ErrorNone Error = iota
	ErrorPredictionNotFound
	ErrorPredictionStopped
	ErrorPredictionKilled
	ErrorPredictionTimeout
	ErrorParsingStopPrompt
	ErrorGettingPredictionText
	ErrorReturnId
	ErrorMaximumCapacity
	ErrorEOF
	ErrorWith
)

func (Error) Error

func (e Error) Error() error

func (Error) String

func (e Error) String() string

type Option

type Option func(*Params)

func With

func With(p *Params) Option

func WithBatch

func WithBatch(size int32) Option

SetBatch sets the batch size.

func WithNKeep

func WithNKeep(n int32) Option

SetKeep sets the number of tokens from initial prompt to keep.

func WithPenalty

func WithPenalty(penalty float64) Option

SetPenalty sets the repetition penalty for text generation.

func WithRepeat

func WithRepeat(repeat int32) Option

SetRepeat sets the number of times to repeat text generation.

func WithSeed

func WithSeed(s int64) Option

SetSeed sets the random seed for sampling text generation.

func WithStopWords

func WithStopWords(stop ...string) Option

SetStopWords sets the prompts that will stop predictions.

func WithTemperature

func WithTemperature(temp float64) Option

SetTemperature sets the temperature value for text generation.

func WithTokens

func WithTokens(tokens int) Option

SetTokens sets the number of tokens to generate.

func WithTopK

func WithTopK(topK int64) Option

SetTopK sets the value for top-K sampling.

func WithTopP

func WithTopP(topP float64) Option

SetTopP sets the value for nucleus sampling.

type Params

type Params struct {
	Seed        int64
	TopK        int64
	TopP        float64
	StopWords   []string
	Tokens      int32
	Temperature float64
	Penalty     float64
	Repeat      int32
	Batch       int32
	NKeep       int32
}

type Prediction

type Prediction uint32

func Predict

func Predict(text string, options ...Option) (Prediction, error)

func (Prediction) Cancel

func (p Prediction) Cancel() error

func (Prediction) Next

func (p Prediction) Next() (string, error)

func (Prediction) NextWithTimeout

func (p Prediction) NextWithTimeout(timeout time.Duration) (string, error)

Jump to

Keyboard shortcuts

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