Download examples/quickstart.py from Endikavi/Ines-1: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/Endikavi/Ines-1/resolve/main/examples/quickstart.py
- Command line
-
hf download hf://Endikavi/Ines-1/examples/quickstart.py
-
curl -L -o quickstart.py https://huggingface.co/Endikavi/Ines-1/resolve/main/examples/quickstart.py
1.08 kB
| """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)) | |