File size: 1,167 Bytes
63a14a0 db5db88 63a14a0 db5db88 63a14a0 db5db88 63a14a0 db5db88 63a14a0 db5db88 63a14a0 db5db88 63a14a0 db5db88 63a14a0 db5db88 63a14a0 | 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | """
example.py
Minimal usage example for the word-level hypervector intent router.
"""
from hv_intent import load_v2, predict, predict_batch
def main():
model = load_v2(".")
print("Single predictions:")
examples = [
"what is the weather today",
"remind me to call mom",
"calculate ten times three",
"what time is it",
"hello there",
"will it rain tomorrow",
"set an alarm for seven",
"how hot is it",
]
for phrase in examples:
pred = predict(model, phrase)
print(f" {phrase:<32} -> {pred}")
print()
print("Batch prediction:")
phrases = [
"good morning",
"what is two plus two",
"when is the meeting",
"is it cloudy outside",
]
preds = predict_batch(model, phrases)
for p, label in zip(phrases, preds):
print(f" {p:<28} -> {label}")
print()
print("Confidence scores:")
_, scores = predict(model, "what is the weather today", return_scores=True)
for label, s in zip(model["intent_labels"], scores):
print(f" {label:<10} {s:>8.2f}")
if __name__ == "__main__":
main() |