Documentation ¶
Index ¶
- type Decoder
- type DecodingOptions
- type GeneratedToken
- type OutputDiversityControlFunc
- func OutputDiversityControl(temp float64, topK int, topP float64) (OutputDiversityControlFunc, error)
- func TemperatureFunc(temperature float64) OutputDiversityControlFunc
- func TopKFunc(topK int, filterValue float64) OutputDiversityControlFunc
- func TopPFunc[T float.DType](topP, filterValue T, minSize int) OutputDiversityControlFunc
- type OutputSelectionFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DecodingOptions ¶
type DecodingOptions struct { // MaxLen is the maximum number of tokens to generate. MaxLen int `json:"max_len" yaml:"max_len"` // MinLen is the minimum number of tokens to generate. MinLen int `json:"min_len" yaml:"min_len"` // StopSequencesIDs is a list of token ids that if generated, the generation process will stop. StopSequencesIDs [][]int `json:"stop_sequences_ids" yaml:"stop_sequences_ids"` // EndTokenID is the end-of-sequence token (default: 0). EndTokenID int `json:"end_token_id" yaml:"end_token_id"` // SkipEndTokenID when true, the end token is not added to the generated sequence. SkipEndTokenID bool `json:"skip_end_token_id" yaml:"skip_end_token_id"` // Temperature is the temperature used to control the randomness of the generated text. Temp float64 `json:"temp" yaml:"temp"` // TopK is the number of tokens to consider when sampling the next token. TopK int `json:"top_k" yaml:"top_k"` // TopP is the cumulative probability of the tokens to consider when sampling the next token. TopP float64 `json:"top_p" yaml:"top_p"` // UseSampling uses sampling to generate the next token. UseSampling bool `json:"use_sampling" yaml:"use_sampling"` }
DecodingOptions contains the options for the conditional text generation.
type GeneratedToken ¶
type GeneratedToken struct { // TokenID is the ID of the token predicted by the decoder at the current step. TokenID int // SumNegLogProbs is the sum of the negative log probabilities up to the current step. SumNegLogProbs float64 }
GeneratedToken is the result of a single step of the decoder.
type OutputDiversityControlFunc ¶
OutputDiversityControlFunc performs the pre-processing steps that are used to narrow down the set of candidate items before using greedy decoding or multinomial sampling to generate the final output.
func OutputDiversityControl ¶
func OutputDiversityControl(temp float64, topK int, topP float64) (OutputDiversityControlFunc, error)
OutputDiversityControl returns a function used to select the next token.
func TemperatureFunc ¶
func TemperatureFunc(temperature float64) OutputDiversityControlFunc
TemperatureFunc applies a temperature to a matrix of scores.
func TopKFunc ¶
func TopKFunc(topK int, filterValue float64) OutputDiversityControlFunc
TopKFunc applies a top-k filter to a matrix of scores.
type OutputSelectionFunc ¶
func GreedyDecoding ¶
func GreedyDecoding() OutputSelectionFunc
func MultinomialSampling ¶
func MultinomialSampling() OutputSelectionFunc
func OutputSelection ¶
func OutputSelection(sampling bool) OutputSelectionFunc
Click to show internal directories.
Click to hide internal directories.