Download example.py from carlclausewitz/alert-turbo-cpu: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/carlclausewitz/alert-turbo-cpu/resolve/main/example.py
- Command line
-
hf download hf://carlclausewitz/alert-turbo-cpu/example.py
-
curl -L -o example.py https://huggingface.co/carlclausewitz/alert-turbo-cpu/resolve/main/example.py
1.09 kB
| """Score one bed card on CPU with Alert-Turbo. | |
| pip install -r requirements.txt | |
| python example.py | |
| Runs the minimal pair in examples/: two bed cards with identical 30-minute | |
| vitals. Only the text differs (history and nursing note). | |
| """ | |
| import json | |
| import sys | |
| from pathlib import Path | |
| HERE = Path(__file__).resolve().parent | |
| sys.path.insert(0, str(HERE)) | |
| from alert_ews.turbo.serve_turbo import AlertTurboEngine # noqa: E402 | |
| engine = AlertTurboEngine(str(HERE)) # loads int4 torso + mmap int8 embeddings + 5 heads | |
| pair = json.loads((HERE / "examples" / "note_only_pair.json").read_text(encoding="utf-8")) | |
| for card in pair: | |
| out = engine.score_state(card["state"]) | |
| p = {h: a["probability"] for h, a in out["answers"].items()} | |
| print(f"[{card['side']}] memo: {card['memo']}") | |
| print(f" P(deterioration in 5/15/30 min) = {p['urgent_5m']:.3f} / {p['urgent_15m']:.3f} / {p['urgent_30m']:.3f}") | |
| print(f" P(abnormal value is baseline or artifact) = {p['is_baseline_or_artifact']:.3f}") | |
| print(f" latency {out['latency_ms']:.0f} ms, RSS {out['rss_mb']:.0f} MB") | |