Go · Choices

Choices

import "github.com/unum-cloud/uform" 4.0.0-rc.1 · c58749fe

Ask your coding agent about this page, or add the docs server to it

curl -s 'https://www.unum.cloud/docs/uform/go/choices.md' | claude -p "How would this fit my code?"

TextChoose(texts, choices, ..) scores each item’s legal choices, one byte each, through one forward, and answers a TapeView of one float32 probability per choice that sums to one per item:

config := &uform.TextChooseConfig{TemperatureGroups: []uint32{0, 1}}
probabilities, err := model.TextChoose(uform.TapeOf([]string{"keep this candidate?", "expand which neighbour?"}),
	uform.TapeOf([]string{"yn", "ABCD"}), arena, config)
expand, err := uform.TapeEntry[float32](probabilities, 1) // the probabilities of 'A' through 'D'

Each group is a question type below the model’s ChoiceTemperatureGroups, and a model without the byte decoder answers StatusUnsupported.

API

Types

ChoicesChoices is the calibrated choices term over the byte decoder; a zero Weight trains none.
types.go:307 ↗
type Choices struct {
    Weight      float32
    BrierWeight float32
}

Mirrors uform_choices_t field for field.

TextChooseConfigTextChooseConfig holds the knobs of TextChoose; nil derives every field.
types.go:174 ↗
type TextChooseConfig struct {
    TemperatureGroups []uint32
    Progress ProgressCallback
    ProgressSteps uint
    Stats *TextEncodeStats
}

Mirrors the knobs of uform_text_choose_t.

Fields

TemperatureGroups[]uint32TemperatureGroups holds the question type of each item, below the model's ChoiceTemperatureGroups; empty puts every item in group zero.
ProgressProgressCallbackProgress hears the items scored and may stop the call.
ProgressStepsuintProgressSteps is the reports the call makes at most; zero derives ten.
Stats*TextEncodeStatsStats is the report the call overwrites, kept by the caller until it is final; nil skips it.