File size: 854 Bytes
041950a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""Which context sentences did the answer use? Run from this folder: python example.py"""
from cbx_rag_eval import ContextUtilization

judge = ContextUtilization(".")
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.",
]
answer = "Operating income was $412 million in 2023."
out = judge(question, passages, answer)
print("utilization:", out["utilization"], "| sentences scored:", out["sentences_scored"])
for s in out["sentences"]:
    print(f"  passage {s['passage']}  utilized={s['utilized']!s:5}  score={s['score']:.3f}  {s['text']}")