Download example.py from zeechimp/hv-router-v1: direct link, hf CLI and curl.
- Browser
- Download file 904 Bytes
-
https://huggingface.co/zeechimp/hv-router-v1/resolve/main/example.py
- Command line
-
hf download hf://zeechimp/hv-router-v1/example.py
-
curl -L -o example.py https://huggingface.co/zeechimp/hv-router-v1/resolve/main/example.py
904 Bytes
| """ | |
| example.py | |
| Minimal usage example. | |
| """ | |
| from hv_router import HVRouter | |
| def main(): | |
| router = HVRouter.load("router_model") | |
| print("Single predictions:") | |
| for q in [ | |
| "what is the weather today", | |
| "remind me to buy milk", | |
| "play some jazz", | |
| "how do i get to the airport", | |
| "transfer money to savings", | |
| ]: | |
| print(f" {q:<35} -> {router.route(q)}") | |
| print() | |
| print("Top-3 with confidence:") | |
| for q in ["draft an email to sarah", "what time is it"]: | |
| print(f" {q}") | |
| for label, conf in router.route_topk(q, k=3): | |
| print(f" {label:<14} {conf:.3f}") | |
| print() | |
| print("Batch:") | |
| queries = ["hello", "what time is it", "play jazz", "tell me a joke"] | |
| preds = router.route_batch(queries) | |
| for q, p in zip(queries, preds): | |
| print(f" {q:<20} -> {p}") | |
| if __name__ == "__main__": | |
| main() |