e-naxosMAF COURSE / COURS
Français

MICROSOFT AGENT FRAMEWORK · 0.16.0-rc.1

Demo220 — Business Retrieval

Check the product fact and procedure before hybrid top-K.

Objectives

Prepare the demo

Start at the root of the complete distribution built in Release. Shared projects Maf.Rag and Maf.DemoConnection are required. SQLite storage is local. rebuild/probe/compare need real embeddings; answer additionally needs chat if evidence remains eligible. audit alone requires no model. The delivered profile separates embeddinggemma:300m from granite4:3b.

Projects
ProjectRole
demos/Demo220_BusinessRetrieval/Demo220.App.csprojApp
shared/Maf.Rag/Maf.Rag.csprojShared implementation
shared/Maf.DemoConnection/Maf.DemoConnection.csprojConnection

Launch from the root

Create the root only once for the RAG series; if Demo180 already ingested the corpus, retain its existing value and do not repeat the assignment below. Without a compatible index, rebuild is explicitly required.

$env:MAF_STATE_ROOT = Join-Path $env:TEMP ('maf-rag-' + [guid]::NewGuid().ToString('N'))
dotnet run --project demos/Demo220_BusinessRetrieval/Demo220.App.csproj -c Release --no-build -- --Rag:AsOf 2026-10-23

Modes and procedure

After ingestion: compare, then Which quality control procedure applies to GX-900 gears after heat treatment? Repeat for GX-999 and a cooking recipe question.

public static SearchHit[] Rank(string question, IEnumerable<SearchHit> candidates, float minCosine = MinCosine)
{
    if (!float.IsFinite(minCosine) || minCosine < -1 || minCosine > 1)
        throw new ArgumentOutOfRangeException(nameof(minCosine));
    var all = candidates.OrderByDescending(h => h.Cosine).ThenBy(h => h.Chunk.Id, StringComparer.Ordinal).ToArray();
    var terms = Terms(question);
    var lexical = all.Select(h => (h.Chunk.Id, Overlap: Terms(h.Chunk.Source.Title + " " + h.Chunk.Text).Intersect(terms).Count()))
        .Where(h => h.Overlap > 0).OrderByDescending(h => h.Overlap).ThenBy(h => h.Id, StringComparer.Ordinal)
        .Select((h, i) => (h.Id, Rank: i + 1)).ToDictionary(h => h.Id, h => h.Rank);
    return all.Select((h, i) => h with { Rank = 1.0 / (60 + i + 1)
            + (lexical.TryGetValue(h.Chunk.Id, out int rank) ? 1.0 / (60 + rank) : 0) })
        .Where(h => h.Cosine >= minCosine && lexical.ContainsKey(h.Chunk.Id))
        .OrderByDescending(h => h.Rank).ThenBy(h => h.Chunk.Id, StringComparer.Ordinal).Take(3).ToArray();

shared/Maf.Rag/RetrievalPolicy.cs · L12–L24 · 9a895c94534c

Source code · Maf.Rag · Folder

Results and useful failures

Check the product fact and procedure before hybrid top-K. A missing or retired product yields no usable context. Structured facts reside in RagProducts, not inferences from a semantically similar note.

These observations are expected from inspecting the linked public code revision. The site lot separately reruns deterministic tests: it does not present an unmeasured generated answer or provider score as observed output.

Persistence and limits

The index is shared under the selected root; startup does not reset it. rebuild deliberately replaces RAG tables and an incompatible embedding model, dimension, corpus or chunker fails explicitly. Changing chat alone does not change vectors. No universal erasure, general model qualification or production guarantee.

dotnet test tests/Maf.Rag.Tests/Maf.Rag.Tests.csproj -m:1 -c Release --no-build --no-restore

Continue and verify

Prerequisites

Continue reading

Complete demo folder · README

lot008-memory-rag-1 · 2026-10-24 · 9a895c94534cd5fc6f3da883e37e5f7856e588c1