"""Which context sentences are relevant to the question? Run from this folder: python example.py""" from cbx_rag_eval import ContextRelevance judge = ContextRelevance(".") question = "What was the company's operating income in 2023?" passages = [ "The company was founded in 1998 and is headquartered in Ohio. It operates three plants.", "Operating income was $412 million in 2023, compared with $380 million in 2022. " "The increase reflects higher volumes.", "The board declared a quarterly dividend of $0.25 per share.", ] out = judge(question, passages) # several passages: also returns context precision print("relevance:", out["relevance"], "| context precision:", out.get("context_precision"), "| relevant passages:", out.get("passage_relevant")) for s in out["sentences"]: print(f" passage {s['passage']} relevant={s['relevant']!s:5} score={s['score']:.3f} {s['text']}")