Buckets:

HuggingFaceDocBuilder's picture
|
download
raw
6.12 kB

generation/logits_sampler


generation/logits_sampler.LogitsSampler

Sampler is a base class for all sampling methods used for text generation.

Kind: static class of generation/logits_sampler


new LogitsSampler(generation_config)

Creates a new Sampler object with the specified generation config.

  ParamTypeDescription




generation_configGenerationConfigThe generation config.

  

logitsSampler._call(logits) ⇒ Promise.<Array>

Executes the sampler, using the specified logits.

Kind: instance method of LogitsSampler

  ParamType




logitsTensor
  

logitsSampler.sample(logits) ⇒ Promise.<Array>

Abstract method for sampling the logits.

Kind: instance method of LogitsSampler
Throws:

  • Error If not implemented in subclass.

    ParamType
    

    logitsTensor


logitsSampler.getLogits(logits, index) ⇒ Float32Array

Returns the specified logits as an array, with temperature applied.

Kind: instance method of LogitsSampler

  ParamType




logitsTensor

indexnumber
  

logitsSampler.randomSelect(probabilities) ⇒ number

Selects an item randomly based on the specified probabilities.

Kind: instance method of LogitsSampler
Returns: number - The index of the selected item.

  ParamTypeDescription




probabilitiesFloat32ArrayAn array of probabilities to use for selection.

  

LogitsSampler.getSampler(generation_config) ⇒ LogitsSampler

Returns a Sampler object based on the specified options.

Kind: static method of LogitsSampler
Returns: LogitsSampler - A Sampler object.

  ParamTypeDescription




generation_configGenerationConfigAn object containing options for the sampler.

  

generation/logits_sampler~GreedySampler

Class representing a Greedy Sampler.

Kind: inner class of generation/logits_sampler


greedySampler.sample(logits) ⇒ Promise.<Array>

Sample the maximum probability of a given logits tensor.

Kind: instance method of GreedySampler
Returns: Promise.<Array> - An array with a single tuple, containing the index of the maximum value and a meaningless score (since this is a greedy search).

  ParamType




logitsTensor
  

generation/logits_sampler~MultinomialSampler

Class representing a MultinomialSampler.

Kind: inner class of generation/logits_sampler


multinomialSampler.sample(logits) ⇒ Promise.<Array>

Sample from the logits.

Kind: instance method of MultinomialSampler

  ParamType




logitsTensor
  

generation/logits_sampler~BeamSearchSampler

Class representing a BeamSearchSampler.

Kind: inner class of generation/logits_sampler


beamSearchSampler.sample(logits) ⇒ Promise.<Array>

Sample from the logits.

Kind: instance method of BeamSearchSampler

  ParamType




logitsTensor
  

Xet Storage Details

Size:
6.12 kB
·
Xet hash:
fb60bbde421900f6a95ba934a501b725365a8cf2b5a662b132493747b086344d

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.