File size: 1,770 Bytes
454ccd7 | 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 | """Ask Jegue questions without the benchmark harness.
Needs one CUDA GPU (about 20 GB), the Decision Index kit installed (it provides decision_index.engines.base) and the base model
Qwen/Qwen3.5-9B in the Hugging Face cache. From the repo root:
PYTHONPATH=code python examples/ask.py
The engine takes a shared context ("state") and a dict of questions. A "choice" question has option keys and descriptions and
returns one probability per option; a "noul" question is a yes/no and returns the probability of yes.
"""
import os
import sys
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.dirname(HERE)
sys.path.insert(0, os.path.join(ROOT, "code"))
from decision_engine_dense import DenseSlotEngine # noqa: E402
WEIGHTS = os.path.join(ROOT, "weights")
engine = DenseSlotEngine(model="Qwen/Qwen3.5-9B", run=WEIGHTS, ckpt=WEIGHTS)
state = "Email from a customer: 'My parcel was due on Monday and it is Friday. Tracking has not changed since Tuesday. I want my money back.'"
questions = {
"intent": {
"type": "choice",
"instructions": "What does the customer mainly want?",
"criteria": {"refund": "A refund", "status": "An update on the delivery", "complaint": "To complain about the service", "other": "Something else"},
},
"urgent": {
"type": "noul",
"instructions": "Should this email be escalated to a human agent today?",
},
}
response, _ = engine(state, questions)
for qid, answer in response["answers"].items():
if answer["type"] == "choice":
ranked = sorted(answer["probabilities"].items(), key=lambda kv: -kv[1])
print(f"{qid}: {answer['choice']} " + " ".join(f"{k}={v:.2f}" for k, v in ranked))
else:
print(f"{qid}: P(yes)={answer['noul']:.2f}")
|