Skip to content

Embedding Generator Batch Input

This example assumes using Ollama; is in scope and apiKey contains your Ollama API key.

1
2
3
4
5
6
7
8
9
await using var environment = await Environment.PrepareAsync(TestModels.Embeddings);

IEmbeddingGenerator<string, Embedding<float>> generator = environment.Client;
var result = await generator.GenerateAsync(
    values: ["Hello, world!", "Goodbye, world!"],
    options: new EmbeddingGenerationOptions
    {
        ModelId = TestModels.Embeddings,
    });