Add GetVectors batch interface.
This commit is contained in:
parent
a4f5af93f7
commit
38bf2cdf4e
|
|
@ -4,4 +4,5 @@ public interface ITextEmbedding
|
|||
{
|
||||
int Dimension { get; }
|
||||
float[] GetVector(string text);
|
||||
List<float[]> GetVectors(List<string> texts);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,4 +26,9 @@ public class TextEmbeddingProvider : ITextEmbedding
|
|||
|
||||
return _embedder.GetEmbeddings(text);
|
||||
}
|
||||
|
||||
public List<float[]> GetVectors(List<string> texts)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using BotSharp.Abstraction.MLTasks;
|
||||
using BotSharp.Plugin.MetaAI.Settings;
|
||||
using FastText.NetWrapper;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace BotSharp.Plugin.MetaAI.Providers;
|
||||
|
|
@ -42,4 +43,14 @@ public class fastTextEmbeddingProvider : ITextEmbedding
|
|||
|
||||
return _fastText.GetSentenceVector(text);
|
||||
}
|
||||
|
||||
public List<float[]> GetVectors(List<string> texts)
|
||||
{
|
||||
var vectors = new List<float[]>();
|
||||
for (int i = 0; i < texts.Count; i++)
|
||||
{
|
||||
vectors.Add(GetVector(texts[i]));
|
||||
}
|
||||
return vectors;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue