namespace Gpt4All.Bindings; /// /// Wrapper around the llmodel_prompt_context structure for holding the prompt context. /// /// /// The implementation takes care of all the memory handling of the raw logits pointer and the /// raw tokens pointer.Attempting to resize them or modify them in any way can lead to undefined behavior /// public unsafe class LLModelPromptContext { private llmodel_prompt_context _ctx; internal ref llmodel_prompt_context UnderlyingContext => ref _ctx; public LLModelPromptContext() { _ctx = new(); } /// /// logits of current context /// public Span Logits => new(_ctx.logits, (int)_ctx.logits_size); /// /// the size of the raw logits vector /// public nuint LogitsSize { get => _ctx.logits_size; set => _ctx.logits_size = value; } /// /// current tokens in the context window /// public Span Tokens => new(_ctx.tokens, (int)_ctx.tokens_size); /// /// the size of the raw tokens vector /// public nuint TokensSize { get => _ctx.tokens_size; set => _ctx.tokens_size = value; } /// /// top k logits to sample from /// public int TopK { get => _ctx.top_k; set => _ctx.top_k = value; } /// /// nucleus sampling probability threshold /// public float TopP { get => _ctx.top_p; set => _ctx.top_p = value; } /// /// temperature to adjust model's output distribution /// public float Temperature { get => _ctx.temp; set => _ctx.temp = value; } /// /// number of tokens in past conversation /// public int PastNum { get => _ctx.n_past; set => _ctx.n_past = value; } /// /// number of predictions to generate in parallel /// public int Batches { get => _ctx.n_batch; set => _ctx.n_batch = value; } /// /// number of tokens to predict /// public int TokensToPredict { get => _ctx.n_predict; set => _ctx.n_predict = value; } /// /// penalty factor for repeated tokens /// public float RepeatPenalty { get => _ctx.repeat_penalty; set => _ctx.repeat_penalty = value; } /// /// last n tokens to penalize /// public int RepeatLastN { get => _ctx.repeat_last_n; set => _ctx.repeat_last_n = value; } /// /// number of tokens possible in context window /// public int ContextSize { get => _ctx.n_ctx; set => _ctx.n_ctx = value; } /// /// percent of context to erase if we exceed the context window /// public float ContextErase { get => _ctx.context_erase; set => _ctx.context_erase = value; } }