Skip to content
Merged
Show file tree
Hide file tree
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
23 changes: 16 additions & 7 deletions applications/tests/Evaluation.Tests/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,22 @@
"MaxRetries": 10
},
"LlamaSharp": {
// path to file, e.g. "llama-2-7b-chat.Q6_K.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
// "Seed": 1337,
"TextModel": {
// path to file, e.g. "llama-2-7b-chat.Q6_K.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
},
"EmbeddingModel": {
// path to file, e.g. "nomic-embed-text-v1.5.Q8_0.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
}
}
},
"DataIngestion": {
Expand Down
23 changes: 16 additions & 7 deletions examples/001-dotnet-WebClient/file9-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,22 @@
"MaxRetries": 10
},
"LlamaSharp": {
// path to file, e.g. "llama-2-7b-chat.Q6_K.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
// "Seed": 1337,
"TextModel": {
// path to file, e.g. "llama-2-7b-chat.Q6_K.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
},
"EmbeddingModel": {
// path to file, e.g. "nomic-embed-text-v1.5.Q8_0.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
}
},
"AzureAIDocIntel": {
// "APIKey" or "AzureIdentity".
Expand Down
23 changes: 16 additions & 7 deletions examples/002-dotnet-Serverless/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,22 @@
// "Endpoint": "https://s3.amazonaws.com"
},
"LlamaSharp": {
// path to file, e.g. "llama-2-7b-chat.Q6_K.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
// "Seed": 1337,
"TextModel": {
// path to file, e.g. "llama-2-7b-chat.Q6_K.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
},
"EmbeddingModel": {
// path to file, e.g. "nomic-embed-text-v1.5.Q8_0.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
}
}
},
"DataIngestion": {
Expand Down
23 changes: 16 additions & 7 deletions examples/002-dotnet-Serverless/file9-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,22 @@
"MaxRetries": 10
},
"LlamaSharp": {
// path to file, e.g. "llama-2-7b-chat.Q6_K.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
// "Seed": 1337,
"TextModel": {
// path to file, e.g. "llama-2-7b-chat.Q6_K.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
},
"EmbeddingModel": {
// path to file, e.g. "nomic-embed-text-v1.5.Q8_0.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
}
},
"AzureAIDocIntel": {
// "APIKey" or "AzureIdentity".
Expand Down
23 changes: 16 additions & 7 deletions examples/105-dotnet-serverless-llamasharp/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,22 @@
"KernelMemory": {
"Services": {
"LlamaSharp": {
// path to file, e.g. "llama-2-7b-chat.Q6_K.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
// "Seed": 1337,
"TextModel": {
// path to file, e.g. "llama-2-7b-chat.Q6_K.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
},
"EmbeddingModel": {
// path to file, e.g. "nomic-embed-text-v1.5.Q8_0.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
}
},
"AzureOpenAIEmbedding": {
// "ApiKey" or "AzureIdentity"
Expand Down
23 changes: 16 additions & 7 deletions examples/210-KM-without-builder/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,22 @@
"Replicas": 0
},
"LlamaSharp": {
// path to file, e.g. "llama-2-7b-chat.Q6_K.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
// "Seed": 1337,
"TextModel": {
// path to file, e.g. "llama-2-7b-chat.Q6_K.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
},
"EmbeddingModel": {
// path to file, e.g. "nomic-embed-text-v1.5.Q8_0.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
}
},
"MongoDbAtlas": {
"ConnectionString": "mongodb://root:root@localhost:27777/?authSource=admin",
Expand Down
23 changes: 16 additions & 7 deletions examples/401-evaluation/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,22 @@
"MaxEmbeddingBatchSize": 100
},
"LlamaSharp": {
// path to file, e.g. "llama-2-7b-chat.Q6_K.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
// "Seed": 1337,
"TextModel": {
// path to file, e.g. "llama-2-7b-chat.Q6_K.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
},
"EmbeddingModel": {
// path to file, e.g. "nomic-embed-text-v1.5.Q8_0.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
}
}
},
"DataIngestion": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (c) Microsoft. All rights reserved.

using Microsoft.KernelMemory;
using Microsoft.KernelMemory.AI.LlamaSharp;
using Microsoft.KM.TestHelpers;
using Xunit.Abstractions;

namespace Microsoft.LlamaSharp.FunctionalTests;

public sealed class LlamaSharpTextEmbeddingGeneratorTest : BaseFunctionalTestCase
{
private readonly LlamaSharpTextEmbeddingGenerator _target;

public LlamaSharpTextEmbeddingGeneratorTest(
IConfiguration cfg,
ITestOutputHelper output) : base(cfg, output)
{
this.LlamaSharpConfig.Validate();
this._target = new LlamaSharpTextEmbeddingGenerator(this.LlamaSharpConfig.EmbeddingModel, loggerFactory: null);
var modelFilename = this.LlamaSharpConfig.TextModel.ModelPath.Split('/').Last().Split('\\').Last();
Console.WriteLine($"Model in use: {modelFilename}");
}

[Fact]
[Trait("Category", "LlamaSharp")]
public async Task ItGeneratesEmbeddingVectors()
{
// Act
Embedding embedding = await this._target.GenerateEmbeddingAsync("some text");

// Assert
Console.WriteLine("Embedding size: " + embedding.Length);

// Expected result using nomic-embed-text-v1.5.Q8_0.gguf
Assert.Equal(768, embedding.Length);
}

protected override void Dispose(bool disposing)
{
if (disposing)
{
this._target.Dispose();
}

base.Dispose(disposing);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public LlamaSharpTextGeneratorTest(
this._timer = new Stopwatch();

this.LlamaSharpConfig.Validate();
this._target = new LlamaSharpTextGenerator(this.LlamaSharpConfig, loggerFactory: null);
var modelFilename = this.LlamaSharpConfig.ModelPath.Split('/').Last().Split('\\').Last();
this._target = new LlamaSharpTextGenerator(this.LlamaSharpConfig.TextModel, loggerFactory: null);
var modelFilename = this.LlamaSharpConfig.TextModel.ModelPath.Split('/').Last().Split('\\').Last();
Console.WriteLine($"Model in use: {modelFilename}");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public LlamaSharpTokenizerTest(
{
this.LlamaSharpConfig.Validate();

var modelFilename = this.LlamaSharpConfig.ModelPath.Split('/').Last().Split('\\').Last();
var modelFilename = this.LlamaSharpConfig.TextModel.ModelPath.Split('/').Last().Split('\\').Last();
Console.WriteLine($"Model in use: {modelFilename}");

var parameters = new ModelParams(this.LlamaSharpConfig.ModelPath)
var parameters = new ModelParams(this.LlamaSharpConfig.TextModel.ModelPath)
{
ContextSize = this.LlamaSharpConfig.MaxTokenTotal,
GpuLayerCount = this.LlamaSharpConfig.GpuLayerCount ?? 20,
ContextSize = this.LlamaSharpConfig.TextModel.MaxTokenTotal,
GpuLayerCount = this.LlamaSharpConfig.TextModel.GpuLayerCount ?? 20,
};

LLamaWeights model = LLamaWeights.LoadFromFile(parameters);
Expand Down
23 changes: 16 additions & 7 deletions extensions/LlamaSharp/LlamaSharp.FunctionalTests/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@
},
"Services": {
"LlamaSharp": {
// path to file, e.g. "llama-2-7b-chat.Q6_K.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
// "Seed": 1337,
"TextModel": {
// path to file, e.g. "llama-2-7b-chat.Q6_K.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
},
"EmbeddingModel": {
// path to file, e.g. "nomic-embed-text-v1.5.Q8_0.gguf"
"ModelPath": "",
// Max number of tokens supported by the model
"MaxTokenTotal": 4096
// Optional parameters
// "GpuLayerCount": 32,
}
},
"SimpleVectorDb": {
// Options: "Disk" or "Volatile". Volatile data is lost after each execution.
Expand Down
Loading