p3: map Brave LLM Context; RRF merge; per-source no_rerank
Live llm/context hits live in grounding.generic plus a URL-keyed sources map, not a sources array. Fan-in uses reciprocal-rank fusion instead of cosine. no_rerank keeps that source's own order as a prefix.
This commit is contained in:
@@ -121,8 +121,39 @@ func TestRerankFallbackStill200(t *testing.T) {
|
||||
if len(r.Hits) != 1 {
|
||||
t.Fatal(r.Hits)
|
||||
}
|
||||
if !strings.Contains(strings.Join(r.Warnings, " "), "rerank fell back") {
|
||||
t.Fatalf("%v", r.Warnings)
|
||||
if strings.Contains(strings.Join(r.Warnings, " "), "rerank fell back") {
|
||||
t.Fatalf("RRF must not depend on embed: %v", r.Warnings)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRRFInterleaveAndNoRerank(t *testing.T) {
|
||||
searx := []Hit{
|
||||
{URL: "https://a.example/s", Title: "s1", Source: NameSearxNG},
|
||||
{URL: "https://b.example/s", Title: "s2", Source: NameSearxNG},
|
||||
}
|
||||
tav := []Hit{
|
||||
{URL: "https://tavily.example/1", Title: "t1", Source: NameTavily},
|
||||
{URL: "https://a.example/s", Title: "t-dup", Snippet: "longer tavily snippet here", Source: NameTavily},
|
||||
}
|
||||
merged := rrfMerge([][]Hit{searx, tav})
|
||||
if len(merged) != 3 {
|
||||
t.Fatalf("%+v", merged)
|
||||
}
|
||||
if merged[0].URL != "https://a.example/s" {
|
||||
t.Fatalf("shared URL should rank first, got %+v", merged[0])
|
||||
}
|
||||
e := &Engine{
|
||||
Sources: []Source{
|
||||
fakeSrc{name: NameSearxNG, hits: searx},
|
||||
fakeSrc{name: NameTavily, hits: tav},
|
||||
},
|
||||
DefaultK: 8,
|
||||
RerankOn: true,
|
||||
NoRerank: map[string]bool{NameTavily: true},
|
||||
}
|
||||
r := e.Run(context.Background(), "q", 8, true, "titan", dcache.ClassFleet)
|
||||
if r.Hits[0].URL != "https://tavily.example/1" {
|
||||
t.Fatalf("no_rerank tavily should lead: %+v", r.Hits)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user