diff --git a/LLama.KernelMemory/BuilderExtensions.cs b/LLama.KernelMemory/BuilderExtensions.cs index 32fcf1bc..6b7412f4 100644 --- a/LLama.KernelMemory/BuilderExtensions.cs +++ b/LLama.KernelMemory/BuilderExtensions.cs @@ -81,15 +81,15 @@ namespace LLamaSharp.KernelMemory { var parameters = new ModelParams(config.ModelPath) { - ContextSize = config?.ContextSize ?? 2048, - Seed = config?.Seed ?? 0, - GpuLayerCount = config?.GpuLayerCount ?? 20, + ContextSize = config.ContextSize ?? 2048, + Seed = config.Seed ?? 0, + GpuLayerCount = config.GpuLayerCount ?? 20, Embeddings = true, - MainGpu = config?.MainGpu ?? 0, - SplitMode = config?.SplitMode ?? GPUSplitMode.None, + MainGpu = config.MainGpu, + SplitMode = config.SplitMode }; - if (weights == null) + if (weights == null || context == null) { weights = LLamaWeights.LoadFromFile(parameters); context = weights.CreateContext(parameters); diff --git a/LLama.KernelMemory/LLamaSharpTextEmbeddingGenerator.cs b/LLama.KernelMemory/LLamaSharpTextEmbeddingGenerator.cs index 53e851a1..42ba6dbc 100644 --- a/LLama.KernelMemory/LLamaSharpTextEmbeddingGenerator.cs +++ b/LLama.KernelMemory/LLamaSharpTextEmbeddingGenerator.cs @@ -30,12 +30,12 @@ namespace LLamaSharp.KernelMemory this._config = config; var @params = new ModelParams(_config.ModelPath) { - ContextSize = config?.ContextSize ?? 2048, - Seed = config?.Seed ?? 0, - GpuLayerCount = config?.GpuLayerCount ?? 20, + ContextSize = config.ContextSize ?? 2048, + Seed = config.Seed ?? 0, + GpuLayerCount = config.GpuLayerCount ?? 20, Embeddings = true, - MainGpu = _config?.MainGpu ?? 0, - SplitMode = _config?.SplitMode ?? GPUSplitMode.None + MainGpu = _config.MainGpu, + SplitMode = _config.SplitMode }; _weights = LLamaWeights.LoadFromFile(@params); _embedder = new LLamaEmbedder(_weights, @params); @@ -53,12 +53,12 @@ namespace LLamaSharp.KernelMemory this._config = config; var @params = new ModelParams(_config.ModelPath) { - ContextSize = config?.ContextSize ?? 2048, - Seed = config?.Seed ?? 0, - GpuLayerCount = config?.GpuLayerCount ?? 20, + ContextSize = config.ContextSize ?? 2048, + Seed = config.Seed ?? 0, + GpuLayerCount = config.GpuLayerCount ?? 20, Embeddings = true, - MainGpu = _config?.MainGpu ?? 0, - SplitMode = _config?.SplitMode ?? GPUSplitMode.None + MainGpu = _config.MainGpu, + SplitMode = _config.SplitMode }; _weights = weights; _embedder = new LLamaEmbedder(_weights, @params);