File size: 1,079 Bytes
61b6fb9
 
 
 
 
 
 
bc5b068
61b6fb9
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Ines-1 minimal example, from a local copy of the repository: python examples/quickstart.py

One typed question per model prompt: build the question, read the probability of every option, print the argmax.
"""
import sys
from pathlib import Path

ROOT = Path(__file__).absolute().parent.parent  # not resolve(): in the Hugging Face cache files are symlinks to blobs
sys.path.insert(0, str(ROOT))

from mini_v41_jev import Decider  # noqa: E402

decider = Decider(ROOT)  # CUDA if available (bf16 + autocast, the canonical path), otherwise CPU (fp32)
question = {"type": "choice",
            "instructions": "Which department should handle this ticket?",
            "criteria": {"billing": "payments and invoices", "tech": "outages and bugs", "legal": "disputes"}}
state = "The invoice was charged twice and the customer wants the money back today."

answer = decider.decide(state, {"dept": question}, lang="en")["dept"]
print("argmax:", answer["choice"])
for option, p in sorted(answer["probabilities"].items(), key=lambda kv: -kv[1]):
    print("  %-8s %.3f" % (option, p))