Lightweight text-only RadFact metric with OpenAI and Ollama backends
Project description
radfact-lite
Lightweight, text-only RadFact with OpenAI and Ollama backends.
Parses reports into phrases, optionally filters negative findings, then scores bidirectional LLM entailment as logical precision / recall / F1.
Install
pip install radfact-lite
Usage
from radfact_lite import ModelConfig, PipelineModels, RadFactLitePipeline
cfg = ModelConfig(model="gpt-4o-mini", provider="openai") # reads OPENAI_API_KEY
models = PipelineModels(parse_model=cfg, entailment_model=cfg, filtering_model=cfg)
pipeline = RadFactLitePipeline(models)
aggregate, per_sample = pipeline.compute_radfact(
candidates_by_id={"id1": "No pleural effusion. Mild bibasilar atelectasis."},
references_by_id={"id1": "Mild bibasilar atelectasis. No pneumothorax."},
filter_negatives=True,
)
print(aggregate.logical_f1)
For Ollama: ModelConfig(model="llama3.1", provider="ollama") (default base URL http://localhost:11434/v1).
Pass pre-parsed phrase lists instead of narrative text with is_narrative_text=False.
New modalities
Add prompt files under src/prompts/{report_to_phrases,negative_filtering,entailment}/<modality>/ and a value to ReportType in src/rf_types.py.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file radfact_lite-0.1.0.tar.gz.
File metadata
- Download URL: radfact_lite-0.1.0.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cae0628c85b8c4e00f1448b013759d901890efbf3fe0b8097a3a558974d917f
|
|
| MD5 |
1ac206db849b1635a521b9e412e1ff29
|
|
| BLAKE2b-256 |
6f20ebda9fc4ee137aa8fdaf5e2825013a87e1ea2ba39f16139b294f4a4467f5
|
File details
Details for the file radfact_lite-0.1.0-py3-none-any.whl.
File metadata
- Download URL: radfact_lite-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
848bf6586ff257eb24b8f955743b28224c523e6f9870abab4a0d609261420e78
|
|
| MD5 |
c3e81abcb3c226ed14c2ba7cce9c453a
|
|
| BLAKE2b-256 |
35a5edacef577c7abbaca5e4f425263e93d90214146fc56c2f49795f00fbca63
|