Browse Source

Fixed conflicts caused by merging of multi context PR

tags/v0.5.1
Martin Evans 2 years ago
parent
commit
1db7292b05
2 changed files with 29 additions and 4 deletions
  1. +17
    -1
      LLama.Unittest/BasicTest.cs
  2. +12
    -3
      LLama.Unittest/GrammarTest.cs

+ 17
- 1
LLama.Unittest/BasicTest.cs View File

@@ -1,13 +1,29 @@
using System.Text;
using LLama.Common;

namespace LLama.Unittest
{
public class BasicTest
: IDisposable
{
private readonly ModelParams _params;
private readonly LLamaWeights _model;

public BasicTest()
{
_params = new ModelParams("Models/llama-2-7b-chat.ggmlv3.q3_K_S.bin", contextSize: 2048);
_model = LLamaWeights.LoadFromFile(_params);
}

public void Dispose()
{
_model.Dispose();
}

[Fact]
public void LoadModel()
{
var model = new LLamaContext(new ModelParams("Models/llama-2-7b-chat.ggmlv3.q3_K_S.bin", contextSize: 256));
var model = _model.CreateContext(_params, Encoding.UTF8);
model.Dispose();
}
}

+ 12
- 3
LLama.Unittest/GrammarTest.cs View File

@@ -1,4 +1,5 @@
using LLama.Common;
using System.Text;
using LLama.Common;
using LLama.Native;

namespace LLama.Unittest
@@ -6,7 +7,14 @@ namespace LLama.Unittest
public sealed class GrammarTest
: IDisposable
{
private readonly LLamaModel _model = new(new ModelParams("Models/llama-2-7b-chat.ggmlv3.q3_K_S.bin", contextSize: 2048));
private readonly ModelParams _params;
private readonly LLamaWeights _model;

public GrammarTest()
{
_params = new ModelParams("Models/llama-2-7b-chat.ggmlv3.q3_K_S.bin", contextSize: 2048);
_model = LLamaWeights.LoadFromFile(_params);
}

public void Dispose()
{
@@ -46,7 +54,8 @@ namespace LLama.Unittest

using var grammar = SafeLLamaGrammarHandle.Create(rules, 0);

var executor = new StatelessExecutor(_model);
using var ctx = _model.CreateContext(_params, Encoding.UTF8);
var executor = new StatelessExecutor(ctx);
var inferenceParams = new InferenceParams
{
MaxTokens = 3,


Loading…
Cancel
Save