Class LogitBias
Optional. Modify the likelihood of specified tokens appearing in the completion.
Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling.
The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. Defaults to null.
Inherited Members
Namespace: Glitch9.AIDevKit
Assembly: Glitch9.AIDevKit.dll
Syntax
[JsonConverter(typeof(LogitBiasConverter))]
public class LogitBias
Properties
| Edit this page View SourceBiasMap
Read-only access to the bias map.
Declaration
public IReadOnlyDictionary<int, int> BiasMap { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyDictionary<int, int> |
IsEmpty
Whether any logit biases are defined.
Declaration
public bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
| Edit this page View SourceClear()
Clear all token biases.
Declaration
public void Clear()
Get(int)
Get bias value for a specific token. Returns null if not set.
Declaration
public int? Get(int tokenId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | tokenId |
Returns
| Type | Description |
|---|---|
| int? |
Remove(int)
Remove bias for a specific token.
Declaration
public bool Remove(int tokenId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | tokenId |
Returns
| Type | Description |
|---|---|
| bool |
Set(int, int)
Add or update a bias for a specific token.
Declaration
public void Set(int tokenId, int bias)
Parameters
| Type | Name | Description |
|---|---|---|
| int | tokenId | Token ID in the tokenizer. |
| int | bias | Bias value (-100 to 100). |