scorerelevanceHow relevant is this passage to the question?
irrelevantweakusefuldirect answer
Retrieval pipeline
Score retrieved passages and filter irrelevant context before a generator sees it.
Use Laya after retrieval and before generation to keep obviously irrelevant passages out of the context window.
Question: What is the refund period? Passage: Annual subscriptions can be refunded within 30 days of the initial purchase.
scorerelevanceHow relevant is this passage to the question?
noulkeepShould this passage be kept for the downstream answer?
from laya import Router
router = Router(preload=True)
state = {"question": "What is the refund period?", "passage": "Annual subscriptions can be refunded within 30 days."}
questions = {
"relevance": {"type": "score", "instructions": "How relevant is this passage?", "criteria": ["irrelevant", "weak", "useful", "direct answer"]},
"keep": {"type": "noul", "instructions": "Should this passage be kept?"}
}
print(router.predict(state, questions))import { Laya } from "@receptron/laya";
const laya = await Laya.load();
const result = await laya.systemOne(
{ question: "What is the refund period?", passage: "Annual subscriptions can be refunded within 30 days." },
{
relevance: { type: "score", instructions: "How relevant is this passage?", criteria: ["irrelevant", "weak", "useful", "direct answer"] },
keep: { type: "noul", instructions: "Should this passage be kept?" },
},
);
console.log(result.answers);
await laya.close();