Browse Source

Fixed decoding of text "accumulating" over time (never properly clearing buffer)

tags/v0.7.0
Martin Evans 2 years ago
parent
commit
a03fe003de
3 changed files with 7 additions and 6 deletions
  1. +1
    -1
      LLama/LLamaStatelessExecutor.cs
  2. +0
    -4
      LLama/Native/SafeLlamaModelHandle.cs
  3. +6
    -1
      LLama/StreamingTokenDecoder.cs

+ 1
- 1
LLama/LLamaStatelessExecutor.cs View File

@@ -100,7 +100,7 @@ namespace LLama

decoder.Add(id);
var decoded = decoder.Read();
yield return decoder.Read();
yield return decoded;

tokens.Clear();
tokens.Add(id);


+ 0
- 4
LLama/Native/SafeLlamaModelHandle.cs View File

@@ -1,11 +1,7 @@
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
using LLama.Exceptions;
using LLama.Extensions;

namespace LLama.Native
{


+ 6
- 1
LLama/StreamingTokenDecoder.cs View File

@@ -155,7 +155,12 @@ public sealed class StreamingTokenDecoder
/// <returns></returns>
public string Read()
{
return string.Join("", _characters);
if (_characters.Count == 0)
return "";

var str = string.Join("", _characters);
_characters.Clear();
return str;
}

/// <summary>


Loading…
Cancel
Save