using System;
using System.Collections.Generic;
namespace LLama.Common
{
using llama_token = Int32;
///
/// The paramters used for inference.
///
public class InferenceParams
{
///
/// number of tokens to keep from initial prompt
///
public int TokensKeep { get; set; } = 0;
///
/// how many new tokens to predict (n_predict), set to -1 to inifinitely generate response
/// until it complete.
///
public int MaxTokens { get; set; } = -1;
///
/// logit bias for specific tokens
///
public Dictionary? LogitBias { get; set; } = null;
///
/// Sequences where the model will stop generating further tokens.
///
public IEnumerable AntiPrompts { get; set; } = Array.Empty();
///
/// path to file for saving/loading model eval state
///
public string PathSession { get; set; } = string.Empty;
///
/// string to suffix user inputs with
///
public string InputSuffix { get; set; } = string.Empty;
///
/// string to prefix user inputs with
///
public string InputPrefix { get; set; } = string.Empty;
///
/// 0 or lower to use vocab size
///
public int TopK { get; set; } = 40;
///
/// 1.0 = disabled
///
public float TopP { get; set; } = 0.95f;
///
/// 1.0 = disabled
///
public float TfsZ { get; set; } = 1.0f;
///
/// 1.0 = disabled
///
public float TypicalP { get; set; } = 1.0f;
///
/// 1.0 = disabled
///
public float Temperature { get; set; } = 0.8f;
///
/// 1.0 = disabled
///
public float RepeatPenalty { get; set; } = 1.1f;
///
/// last n tokens to penalize (0 = disable penalty, -1 = context size) (repeat_last_n)
///
public int RepeatLastTokensCount { get; set; } = 64;
///
/// frequency penalty coefficient
/// 0.0 = disabled
///
public float FrequencyPenalty { get; set; } = .0f;
///
/// presence penalty coefficient
/// 0.0 = disabled
///
public float PresencePenalty { get; set; } = .0f;
///
/// Mirostat uses tokens instead of words.
/// algorithm described in the paper https://arxiv.org/abs/2007.14966.
/// 0 = disabled, 1 = mirostat, 2 = mirostat 2.0
///
public MirostatType Mirostat { get; set; } = MirostatType.Disable;
///
/// target entropy
///
public float MirostatTau { get; set; } = 5.0f;
///
/// learning rate
///
public float MirostatEta { get; set; } = 0.1f;
///
/// consider newlines as a repeatable token (penalize_nl)
///
public bool PenalizeNL { get; set; } = true;
}
///
/// Type of "mirostat" sampling to use.
/// https://github.com/basusourya/mirostat
///
public enum MirostatType
{
///
/// Disable Mirostat sampling
///
Disable = 0,
///
/// Original mirostat algorithm
///
Mirostat = 1,
///
/// Mirostat 2.0 algorithm
///
Mirostat2 = 2
}
}