File size: 1,011 Bytes
169fe46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""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))