File size: 1,089 Bytes
8124243
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""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")