microsoft / kernel-memory

RAG architecture: index and query any data using LLM and natural language, track sources, show citations, asynchronous memory patterns.
https://microsoft.github.io/kernel-memory
MIT License
1.34k stars 252 forks source link

KM evaluation refactorings #519

Closed kbeaugrand closed 1 month ago

kbeaugrand commented 1 month ago

High level description (Approach, Design)

xuzeyu91 commented 1 month ago

I tried using evaluation, but in the

        return this._serviceCollection.BuildServiceProvider()
            .GetRequiredService<TestSetGenerator>();

There is a dependency injection error here, and I am unable to directly inject TestSetGenerator. What should I do?

dluc commented 1 month ago

@kbeaugrand FYI

kbeaugrand commented 1 month ago

@xuzeyu91, please take a look at the readme. I'll create later a PR for an official documentation

xuzeyu91 commented 1 month ago

@xuzeyu91, please take a look at the readme. I'll create later a PR for an official documentation

I didn't understand how to inject this service, and I made the same mistake using the example of 401 directly

https://github.com/microsoft/kernel-memory/blob/main/examples/401-evaluation/Program.cs
xuzeyu91 commented 1 month ago

@kbeaugrand

kbeaugrand commented 1 month ago

@xuzeyu91,

Generator and evaluator are not added into the ServiceCollection by default. If this is needed, in your case you should add it on your own.

To instanciate a testSetGenerator you should follow the sample:


using Microsoft.KernelMemory.Evaluation;

var testSetGenerator = new TestSetGeneratorBuilder(memoryBuilder.Services)
                            .AddEvaluatorKernel(kernel)
                            .Build();

var distribution = new Distribution
{
    Simple = .5f,
    Reasoning = .16f,
    MultiContext = .17f,
    Conditioning = .17f
};

var testSet = testSetGenerator.GenerateTestSetsAsync(index: "default", count: 10, retryCount: 3, distribution: distribution);

await foreach (var test in testSet)
{
    Console.WriteLine(test.Question);
}

Maybe I don't understand correctly your issue. Can you give me more explanation about what your are intending to do?

xuzeyu91 commented 3 weeks ago

This doesn't work. Have you ever tested it?