Download examples/ask.py from fdemelo/jegue: direct link, hf CLI and curl.
- Browser
- Download file 1.77 kB
-
https://huggingface.co/fdemelo/jegue/resolve/main/examples/ask.py
- Command line
-
hf download hf://fdemelo/jegue/examples/ask.py
-
curl -L -o ask.py https://huggingface.co/fdemelo/jegue/resolve/main/examples/ask.py
1.77 kB
| """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}") | |