From 7ec318aab5a989dddaea98065e9dbfd73f849dc5 Mon Sep 17 00:00:00 2001 From: Martin Evans Date: Thu, 19 Oct 2023 21:08:54 +0100 Subject: [PATCH] Added logging to embedder too --- LLama/LLamaEmbedder.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/LLama/LLamaEmbedder.cs b/LLama/LLamaEmbedder.cs index fde901b1..ee23cd39 100644 --- a/LLama/LLamaEmbedder.cs +++ b/LLama/LLamaEmbedder.cs @@ -2,6 +2,7 @@ using System; using LLama.Exceptions; using LLama.Abstractions; +using Microsoft.Extensions.Logging; namespace LLama { @@ -22,9 +23,10 @@ namespace LLama /// Create a new embedder (loading temporary weights) /// /// + /// [Obsolete("Preload LLamaWeights and use the constructor which accepts them")] - public LLamaEmbedder(ILLamaParams allParams) - : this(allParams, allParams) + public LLamaEmbedder(ILLamaParams allParams, ILogger? logger = null) + : this(allParams, allParams, logger) { } @@ -33,13 +35,14 @@ namespace LLama /// /// /// + /// [Obsolete("Preload LLamaWeights and use the constructor which accepts them")] - public LLamaEmbedder(IModelParams modelParams, IContextParams contextParams) + public LLamaEmbedder(IModelParams modelParams, IContextParams contextParams, ILogger? logger = null) { using var weights = LLamaWeights.LoadFromFile(modelParams); contextParams.EmbeddingMode = true; - _ctx = weights.CreateContext(contextParams); + _ctx = weights.CreateContext(contextParams, logger); } /// @@ -47,10 +50,11 @@ namespace LLama /// /// /// - public LLamaEmbedder(LLamaWeights weights, IContextParams @params) + /// + public LLamaEmbedder(LLamaWeights weights, IContextParams @params, ILogger? logger = null) { @params.EmbeddingMode = true; - _ctx = weights.CreateContext(@params); + _ctx = weights.CreateContext(@params, logger); } /// @@ -89,7 +93,6 @@ namespace LLama /// public float[] GetEmbeddings(string text, bool addBos) { - var embed_inp_array = _ctx.Tokenize(text, addBos); // TODO(Rinne): deal with log of prompt