
Corrective RAG retrieval router (Kamath Ch 7)
Source:R/kamath_llm2_native.R
morie_kamath_corrective_rag.RdGrades the retrieved documents, then keeps them, falls back to the web, or mixes.
Examples
morie_kamath_corrective_rag("q", list("d1", "d2", "d3"), function(q,
d) c(d1 = 0.9, d2 = 0.5, d3 = 0.1)[[d]], 0.8, 0.2)
#> $estimate
#> [1] 0.9
#>
#> $action
#> [1] "use_docs"
#>
#> $ctx
#> $ctx[[1]]
#> [1] "d1"
#>
#>
#> $scores
#> [1] 0.9 0.5 0.1
#>
#> $best_score
#> [1] 0.9
#>
#> $tau_hi
#> [1] 0.8
#>
#> $tau_lo
#> [1] 0.2
#>
#> $n
#> [1] 3
#>
#> $method
#> [1] "Corrective RAG retrieval router (Kamath Ch 7)"
#>