Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion LLama/LLamaExecutorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public abstract class StatefulExecutorBase : ILLamaExecutor
/// </summary>
protected float? MirostatMu { get; set; }

private StreamingTokenDecoder _decoder;

/// <summary>
///
/// </summary>
Expand All @@ -83,6 +85,7 @@ protected StatefulExecutorBase(LLamaContext context, ILogger? logger = null)
_consumedTokensCount = 0;
_n_session_consumed = 0;
_last_n_tokens = new FixedSizeQueue<llama_token>(Context.ContextSize).FillWith(0);
_decoder = new StreamingTokenDecoder(context);
}

/// <summary>
Expand Down Expand Up @@ -294,7 +297,10 @@ public virtual async IAsyncEnumerable<string> InferAsync(string text, IInference
await InferInternal(inferenceParams, args);

if (args.ReturnValue)
yield return Context.DeTokenize(_embeds);
{
_decoder.AddRange(_embeds);
yield return _decoder.Read();
}

var (breakGeneration, extraOutputs) = await PostProcess(inferenceParams, args);
if (extraOutputs is { Count: > 0 })
Expand Down