From b3ea0c4e1a38b2d2ae8baa4d89c8c886838f4112 Mon Sep 17 00:00:00 2001 From: zyxucp <286513187@qq.com> Date: Sat, 8 Jun 2024 11:04:14 +0800 Subject: [PATCH] =?UTF-8?q?add=20llamasharp=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +++- README.zh.md | 4 +++- src/AntSK.Domain/Domain/Other/LLamaConfig.cs | 7 ++++--- src/AntSK.Domain/Options/LLamaSharpOption.cs | 2 ++ src/AntSK/appsettings.json | 4 +++- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5a1409c..01eacd9 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,9 @@ model/xxx.gguf "DirectoryPath": "D:\\git\\AntBlazor\\model" }, "LLamaSharp": { - "RunType": "GPU" + "RunType": "GPU", + "ContextSize": 2048, + "GpuLayerCount": 20 }, "Login": { "User": "admin", diff --git a/README.zh.md b/README.zh.md index 5a28249..2bd6065 100644 --- a/README.zh.md +++ b/README.zh.md @@ -131,7 +131,9 @@ model/xxx.gguf "DirectoryPath": "D:\\git\\AntBlazor\\model" }, "LLamaSharp": { - "RunType": "GPU" + "RunType": "GPU", + "ContextSize": 2048, + "GpuLayerCount": 20 }, "Login": { "User": "admin", diff --git a/src/AntSK.Domain/Domain/Other/LLamaConfig.cs b/src/AntSK.Domain/Domain/Other/LLamaConfig.cs index cbfb780..59058ad 100644 --- a/src/AntSK.Domain/Domain/Other/LLamaConfig.cs +++ b/src/AntSK.Domain/Domain/Other/LLamaConfig.cs @@ -1,4 +1,5 @@ -using LLama; +using AntSK.Domain.Options; +using LLama; using LLama.Common; using LLamaSharp.KernelMemory; @@ -29,9 +30,9 @@ namespace AntSK.Domain.Domain.Other } var parameters = new ModelParams(lsConfig.ModelPath) { - ContextSize = lsConfig?.ContextSize ?? 2048, + ContextSize = LLamaSharpOption.ContextSize ?? 2048, Seed = lsConfig?.Seed ?? 0, - GpuLayerCount = lsConfig?.GpuLayerCount ?? 20, + GpuLayerCount = LLamaSharpOption.GpuLayerCount ?? 20, Embeddings = true }; var weights = LLamaWeights.LoadFromFile(parameters); diff --git a/src/AntSK.Domain/Options/LLamaSharpOption.cs b/src/AntSK.Domain/Options/LLamaSharpOption.cs index caa43c0..e6fa532 100644 --- a/src/AntSK.Domain/Options/LLamaSharpOption.cs +++ b/src/AntSK.Domain/Options/LLamaSharpOption.cs @@ -3,5 +3,7 @@ public class LLamaSharpOption { public static string RunType { get; set; } + public static uint? ContextSize { get; set; } + public static int? GpuLayerCount { get; set; } } } diff --git a/src/AntSK/appsettings.json b/src/AntSK/appsettings.json index dd8ab79..dab52a0 100644 --- a/src/AntSK/appsettings.json +++ b/src/AntSK/appsettings.json @@ -34,7 +34,9 @@ "TableNamePrefix": "km-" }, "LLamaSharp": { - "RunType": "GPU" + "RunType": "GPU", + "ContextSize": 2048, + "GpuLayerCount": 20 }, "FileDir": { "DirectoryPath": "D:\\model"