Download example.py from RayenFekih/JaisGuard-Frozen-0.9B: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/RayenFekih/JaisGuard-Frozen-0.9B/resolve/main/example.py
- Command line
-
hf download hf://RayenFekih/JaisGuard-Frozen-0.9B/example.py
-
curl -L -o example.py https://huggingface.co/RayenFekih/JaisGuard-Frozen-0.9B/resolve/main/example.py
1.01 kB
| """Run the explicitly supported checkpoint API from a downloaded model directory.""" | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| from jaisguard_model import JaisGuardClassifier | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--model", default=str(Path(__file__).resolve().parent)) | |
| parser.add_argument("--text", action="append", required=True) | |
| parser.add_argument("--precision", choices=("historical", "bf16", "fp16"), default="historical") | |
| parser.add_argument("--device", default="cuda") | |
| parser.add_argument("--operating-point", choices=("validation_locked", "default"), default="validation_locked") | |
| parser.add_argument("--local-files-only", action="store_true") | |
| args = parser.parse_args() | |
| classifier = JaisGuardClassifier.from_pretrained( | |
| args.model, device=args.device, precision=args.precision, local_files_only=args.local_files_only | |
| ) | |
| for text in args.text: | |
| print(json.dumps(classifier.predict(text, operating_point=args.operating_point), ensure_ascii=False)) | |