From 33035c82bf6082e7d10756cd41be61e07f2c6d5e Mon Sep 17 00:00:00 2001 From: Martin Evans Date: Sun, 3 Sep 2023 18:22:39 +0100 Subject: [PATCH] - Removed `LLamaNewlineTokens` from `InteractiveExecutorState`. This is always set in the constructor from the context, so there's no point serializing it. --- LLama/LLamaInteractExecutor.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/LLama/LLamaInteractExecutor.cs b/LLama/LLamaInteractExecutor.cs index 38d6b443..4f29b998 100644 --- a/LLama/LLamaInteractExecutor.cs +++ b/LLama/LLamaInteractExecutor.cs @@ -17,8 +17,8 @@ namespace LLama /// public class InteractiveExecutor : StatefulExecutorBase { - bool _is_prompt_run = true; - llama_token[] _llama_token_newline; + private bool _is_prompt_run = true; + private readonly llama_token _llama_token_newline; /// /// @@ -26,7 +26,7 @@ namespace LLama /// public InteractiveExecutor(LLamaContext context) : base(context) { - _llama_token_newline = new [] { NativeApi.llama_token_nl(Context.NativeHandle) }; + _llama_token_newline = NativeApi.llama_token_nl(Context.NativeHandle); } /// @@ -40,7 +40,6 @@ namespace LLama ConsumedTokensCount = _consumedTokensCount, Embeds = _embeds, LastTokens = _last_n_tokens.ToArray(), - LLamaNewlineTokens = _llama_token_newline, MatchingSessionTokensCount = _n_matching_session_tokens, PastTokensCount = _pastTokensCount, SessionFilePath = _pathSession, @@ -61,7 +60,6 @@ namespace LLama _consumedTokensCount = state.ConsumedTokensCount; _embeds = state.Embeds; _last_n_tokens = new FixedSizeQueue(state.LastTokensCapacity, state.LastTokens); - _llama_token_newline = state.LLamaNewlineTokens; _n_matching_session_tokens = state.MatchingSessionTokensCount; _pastTokensCount = state.PastTokensCount; _pathSession = state.SessionFilePath; @@ -216,7 +214,7 @@ namespace LLama if (id == NativeApi.llama_token_eos(Context.NativeHandle)) { - id = _llama_token_newline.First(); + id = _llama_token_newline; if (args.Antiprompts is not null && args.Antiprompts.Count > 0) { var first_antiprompt = Context.Tokenize(args.Antiprompts[0], false); @@ -247,18 +245,14 @@ namespace LLama /// /// The descriptor of the state of the interactive executor. /// - public class InteractiveExecutorState : ExecutorBaseState + public class InteractiveExecutorState + : ExecutorBaseState { /// /// Whether the executor is running for the first time (running the prompt). /// [JsonPropertyName("is_prompt_run")] public bool IsPromptRun { get; set; } - /// - /// Tokens that represent a new line in with the current model. - /// - [JsonPropertyName("llama_token_newline")] - public llama_token[] LLamaNewlineTokens { get; set; } } } }