Download example.py from CobuildX-AI/cbx-rag-context-utilization-68M: direct link, hf CLI and curl.
- Browser
- Download file 854 Bytes
-
https://huggingface.co/CobuildX-AI/cbx-rag-context-utilization-68M/resolve/main/example.py
- Command line
-
hf download hf://CobuildX-AI/cbx-rag-context-utilization-68M/example.py
-
curl -L -o example.py https://huggingface.co/CobuildX-AI/cbx-rag-context-utilization-68M/resolve/main/example.py
854 Bytes
| """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']}") | |