Download example.py from zeechimp/hv-context-v1: direct link, hf CLI and curl.
- Browser
- Download file 789 Bytes
-
https://huggingface.co/zeechimp/hv-context-v1/resolve/main/example.py
- Command line
-
hf download hf://zeechimp/hv-context-v1/example.py
-
curl -L -o example.py https://huggingface.co/zeechimp/hv-context-v1/resolve/main/example.py
789 Bytes
| """ | |
| example.py | |
| Minimal usage example for the HV Context selector. | |
| """ | |
| from hv_context import HVContext | |
| def main(): | |
| model = HVContext.load("context_model") | |
| queries = [ | |
| "what is the forecast for rome", | |
| "how do i debug a python function", | |
| "how much did i spend on groceries", | |
| "how do i cook soup", | |
| ] | |
| print("Top-3 relevant turns for each query:") | |
| print() | |
| for q in queries: | |
| idx, scores = model.retrieve(q, k=3) | |
| print(f"Query: {q}") | |
| for i, (j, s) in enumerate(zip(idx, scores)): | |
| topic = model.topics[j] | |
| text = model.texts[j][:60] | |
| print(f" top{i+1} [{topic:<10}] sim={s:.3f}") | |
| print(f" {text}...") | |
| print() | |
| if __name__ == "__main__": | |
| main() |