optimizers

package
v0.0.0-...-ba96703 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BootstrapFewShot

type BootstrapFewShot struct {
	Metric          func(example map[string]any, prediction map[string]any, ctx context.Context) bool
	MaxBootstrapped int
	Config          *core.DSPYConfig
}

func NewBootstrapFewShot

func NewBootstrapFewShot(metric func(example map[string]any, prediction map[string]any, ctx context.Context) bool, maxBootstrapped int, config *core.DSPYConfig) *BootstrapFewShot

func (*BootstrapFewShot) Compile

func (b *BootstrapFewShot) Compile(ctx context.Context, student, teacher *core.Program, trainset []map[string]any) (*core.Program, error)

type Copro

type Copro struct {
	Metric          func(example, prediction map[string]any, ctx context.Context) bool
	MaxBootstrapped int
	SubOptimizer    core.Optimizer
	Config          *core.DSPYConfig
}

func NewCopro

func NewCopro(metric func(example, prediction map[string]any, ctx context.Context) bool, maxBootstrapped int, subOptimizer core.Optimizer, config *core.DSPYConfig) *Copro

func (*Copro) Compile

func (c *Copro) Compile(ctx context.Context, program *core.Program, dataset core.Dataset, metric core.Metric) (*core.Program, error)

Compile optimizes a program using the provided dataset and metric.

type MIPRO

type MIPRO struct {
	Metric               func(example, prediction map[string]any, ctx context.Context) float64
	NumCandidates        int
	MaxBootstrappedDemos int
	MaxLabeledDemos      int
	NumTrials            int
	PromptModel          core.LLM
	TaskModel            core.LLM
	MiniBatchSize        int
	FullEvalSteps        int
	Verbose              bool
}

func NewMIPRO

func NewMIPRO(metric func(example, prediction map[string]any, ctx context.Context) float64, opts ...MIPROOption) *MIPRO

func (*MIPRO) Compile

func (m *MIPRO) Compile(ctx context.Context, program *core.Program, dataset core.Dataset, metric core.Metric) (*core.Program, error)

type MIPROOption

type MIPROOption func(*MIPRO)

func WithFullEvalSteps

func WithFullEvalSteps(n int) MIPROOption

func WithMaxBootstrappedDemos

func WithMaxBootstrappedDemos(n int) MIPROOption

func WithMaxLabeledDemos

func WithMaxLabeledDemos(n int) MIPROOption

func WithMiniBatchSize

func WithMiniBatchSize(n int) MIPROOption

func WithNumCandidates

func WithNumCandidates(n int) MIPROOption

func WithNumTrials

func WithNumTrials(n int) MIPROOption

func WithPromptModel

func WithPromptModel(model core.LLM) MIPROOption

func WithTaskModel

func WithTaskModel(model core.LLM) MIPROOption

func WithVerbose

func WithVerbose(v bool) MIPROOption

type Trial

type Trial struct {
	Params map[string]int
	Score  float64
}

Jump to

Keyboard shortcuts

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