Browse Source

Merge pull request #25 from mlof/fix-queue-typo

fix: typo in FixedSizeQueue
tags/v0.4.0
Rinne GitHub 2 years ago
parent
commit
fa9b5f7af6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 8 deletions
  1. +4
    -4
      LLama/Common/FixedSizeQueue.cs
  2. +2
    -2
      LLama/LLamaExecutorBase.cs
  3. +1
    -1
      LLama/LLamaInstructExecutor.cs
  4. +1
    -1
      LLama/LLamaInteractExecutor.cs

LLama/Common/FixedQuene.cs → LLama/Common/FixedSizeQueue.cs View File

@@ -10,14 +10,14 @@ namespace LLama.Common
/// A queue with fixed storage size.
/// Currently it's only a naive implementation and needs to be further optimized in the future.
/// </summary>
public class FixedSizeQuene<T>: IEnumerable<T>
public class FixedSizeQueue<T>: IEnumerable<T>
{
int _maxSize;
List<T> _storage;

public int Count => _storage.Count;
public int Capacity => _maxSize;
public FixedSizeQuene(int size)
public FixedSizeQueue(int size)
{
_maxSize = size;
_storage = new();
@@ -28,7 +28,7 @@ namespace LLama.Common
/// </summary>
/// <param name="size"></param>
/// <param name="data"></param>
public FixedSizeQuene(int size, IEnumerable<T> data)
public FixedSizeQueue(int size, IEnumerable<T> data)
{
_maxSize = size;
if(data.Count() > size)
@@ -38,7 +38,7 @@ namespace LLama.Common
_storage = new(data);
}

public FixedSizeQuene<T> FillWith(T value)
public FixedSizeQueue<T> FillWith(T value)
{
for(int i = 0; i < Count; i++)
{

+ 2
- 2
LLama/LLamaExecutorBase.cs View File

@@ -24,7 +24,7 @@ namespace LLama
protected List<llama_token> _embeds = new(); // embd
protected List<llama_token> _embed_inps = new();
protected List<llama_token> _session_tokens = new();
protected FixedSizeQuene<llama_token> _last_n_tokens;
protected FixedSizeQueue<llama_token> _last_n_tokens;
public LLamaModel Model => _model;
protected StatefulExecutorBase(LLamaModel model, ILLamaLogger? logger = null)
{
@@ -35,7 +35,7 @@ namespace LLama
_n_session_consumed = 0;
_embeds = new();
_embed_inps = new();
_last_n_tokens = new FixedSizeQuene<llama_token>(_model.ContextSize).FillWith(0);
_last_n_tokens = new FixedSizeQueue<llama_token>(_model.ContextSize).FillWith(0);
}

public unsafe StatefulExecutorBase WithSessionFile(string filename)


+ 1
- 1
LLama/LLamaInstructExecutor.cs View File

@@ -56,7 +56,7 @@ namespace LLama
_is_prompt_run = state.IsPromptRun;
_consumedTokensCount = state.ConsumedTokensCount;
_embeds = state.Embeds;
_last_n_tokens = new FixedSizeQuene<llama_token>(state.LastTokensCapacity, state.LastTokens);
_last_n_tokens = new FixedSizeQueue<llama_token>(state.LastTokensCapacity, state.LastTokens);
_inp_pfx = state.InputPrefixTokens;
_inp_sfx = state.InputSuffixTokens;
_n_matching_session_tokens = state.MatchingSessionTokensCount;


+ 1
- 1
LLama/LLamaInteractExecutor.cs View File

@@ -55,7 +55,7 @@ namespace LLama
_is_prompt_run = state.IsPromptRun;
_consumedTokensCount = state.ConsumedTokensCount;
_embeds = state.Embeds;
_last_n_tokens = new FixedSizeQuene<llama_token>(state.LastTokensCapacity, state.LastTokens);
_last_n_tokens = new FixedSizeQueue<llama_token>(state.LastTokensCapacity, state.LastTokens);
_llama_token_newline = state.LLamaNewlineTokens;
_n_matching_session_tokens = state.MatchingSessionTokensCount;
_pastTokensCount = state.PastTokensCount;


Loading…
Cancel
Save