Transformers.js 文件

generation/logits_sampler

您正在檢視的是需要從原始碼安裝。如果您希望進行常規 npm 安裝,請檢視最新的穩定版本 (v3.0.0)。
Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

generation/logits_sampler


generation/logits_sampler.LogitsSampler

Sampler 是所有用於文字生成的取樣方法的基礎類。

型別generation/logits_sampler 的靜態類


new LogitsSampler(generation_config)

使用指定的生成配置建立一個新的 Sampler 物件。

引數量型別描述
generation_configGenerationConfig

生成配置。


logitsSampler._call(logits) ⇒ <code> * </code>

執行取樣器,使用指定的 logits。

型別LogitsSampler 的例項方法

引數量型別
logits張量

logitsSampler.sample(logits) ⇒ <code> * </code>

抽象方法,用於對 logits 進行取樣。

型別LogitsSampler 的例項方法
丟擲:

  • Error 如果在子類中未實現。
引數量型別
logits張量

logitsSampler.getLogits(logits, index) ⇒ <code> Float32Array </code>

將指定的 logits 作為陣列返回,並應用了溫度。

型別LogitsSampler 的例項方法

引數量型別
logits張量
索引數字

logitsSampler.randomSelect(probabilities) ⇒ <code> number </code>

根據指定的機率隨機選擇一個專案。

型別LogitsSampler 的例項方法
返回number - 所選專案的索引。

引數量型別描述
probabilities*

用於選擇的機率陣列。


LogitsSampler.getSampler(generation_config) ⇒ <code> LogitsSampler </code>

根據指定的選項返回一個 Sampler 物件。

型別LogitsSampler 的靜態方法
返回LogitsSampler - 一個 Sampler 物件。

引數量型別描述
generation_configGenerationConfig

一個包含取樣器選項的物件。


generation/logits_sampler~GreedySampler

表示貪婪取樣器的類。

型別generation/logits_sampler 的內部類


greedySampler.sample(logits) ⇒ <code> * </code>

對給定 logits 張量的最大機率進行取樣。

型別GreedySampler 的例項方法
返回* - 包含最大值索引和無意義分數(因為這是貪婪搜尋)的單個元組陣列。

引數量型別
logits張量

generation/logits_sampler~MultinomialSampler

表示多項式取樣器的類。

型別generation/logits_sampler 的內部類


multinomialSampler.sample(logits) ⇒ <code> * </code>

從 logits 中取樣。

型別MultinomialSampler 的例項方法

引數量型別
logits張量

generation/logits_sampler~BeamSearchSampler

表示 BeamSearchSampler 的類。

型別generation/logits_sampler 的內部類


beamSearchSampler.sample(logits) ⇒ <code> * </code>

從 logits 中取樣。

型別BeamSearchSampler 的例項方法

引數量型別
logits張量

< > 在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.