You can use LLamaSharpEmbeddingGeneration to provide local embedding capabilities to Semantic Kernel. This is typically used when building a kernel with memory storage (e.g., VolatileMemoryStore). This implementation requires a LLamaEmbedder instance.
using var model = LLamaWeights.LoadFromFile(parameters);
var embedding = new LLamaEmbedder(model, parameters);
var kernelWithCustomDb = Kernel.Builder
.WithLoggerFactory(ConsoleLogger.LoggerFactory)
.WithAIService<ITextEmbeddingGeneration>("local-llama-embed", new LLamaSharpEmbeddingGeneration(embedding), true)
.WithMemoryStorage(new VolatileMemoryStore())
.Build();