Browse Source

Using `StreamingTextDecoder` in `LLama/LLamaExecutorBase.cs`. This should fix weird text decoding issues with multi token characters.

tags/v0.8.1
Martin Evans 2 years ago
parent
commit
3ce0f7d003
1 changed files with 7 additions and 1 deletions
  1. +7
    -1
      LLama/LLamaExecutorBase.cs

+ 7
- 1
LLama/LLamaExecutorBase.cs View File

@@ -70,6 +70,8 @@ namespace LLama
/// </summary>
protected float? MirostatMu { get; set; }

private StreamingTokenDecoder _decoder;

/// <summary>
///
/// </summary>
@@ -83,6 +85,7 @@ namespace LLama
_consumedTokensCount = 0;
_n_session_consumed = 0;
_last_n_tokens = new FixedSizeQueue<llama_token>(Context.ContextSize).FillWith(0);
_decoder = new StreamingTokenDecoder(context);
}

/// <summary>
@@ -294,7 +297,10 @@ namespace LLama
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 })


Loading…
Cancel
Save