"""Download pinned public encoder and exercise actual candidate pooling.""" import argparse import json from pathlib import Path import sys import time sys.stdout.reconfigure(encoding="utf-8") ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT / "src")) from decision_model.encoding import CandidateEncoder from decision_model.schemas import DecisionRequest parser = argparse.ArgumentParser() parser.add_argument("--device", default="cpu") args = parser.parse_args() started = time.perf_counter() encoder = CandidateEncoder(device=args.device) results = [] for text in ["Please refund the duplicate charge.", "Поверніть, будь ласка, подвійно списані кошти."]: request = DecisionRequest.model_validate({"state": text, "questions": { "refund": {"type": "noul", "instructions": "Клієнт явно просить повернути гроші? / Does the customer explicitly request a refund?"}}}) encoded = encoder.encode(request.state, request.questions["refund"]) results.append({"tokens": encoded.input_tokens, "shape": list(encoded.features.shape), "finite": bool(__import__('numpy').isfinite(encoded.features).all())}) report = {"encoder": encoder.model_id, "revision": encoder.revision, "device": args.device, "seconds_including_load": time.perf_counter() - started, "examples": results, "all_parameters_frozen": all(not p.requires_grad for p in encoder.model.parameters())} out = ROOT / "artifacts" / f"smoke-{args.device}.json" out.parent.mkdir(exist_ok=True) out.write_text(json.dumps(report, indent=2), encoding="utf-8") print(json.dumps(report, indent=2))