Download predictor.py from dougdotcon/douvras-bitnet-workload-router: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/dougdotcon/douvras-bitnet-workload-router/resolve/main/predictor.py
- Command line
-
hf download hf://dougdotcon/douvras-bitnet-workload-router/predictor.py
-
curl -L -o predictor.py https://huggingface.co/dougdotcon/douvras-bitnet-workload-router/resolve/main/predictor.py
1.05 kB
| """Dependency-free inference for the BitNet workload router. | |
| This is a triage model, not an implementation of BitNet itself. | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| def predict(prompt: str, context_tokens: int = 0, output_tokens: int = 0) -> str: | |
| text = prompt.casefold() | |
| if context_tokens > 4096 or "contrato de 12 mil" in text: | |
| return "BITNET_NOT_RECOMMENDED" | |
| if any(term in text for term in ("ferramenta", "crm", "não invent", "não invente")) or output_tokens > 256: | |
| return "BITNET_REVIEW" | |
| return "BITNET_CANDIDATE" | |
| def main() -> None: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--prompt", required=True) | |
| parser.add_argument("--context-tokens", type=int, default=0) | |
| parser.add_argument("--output-tokens", type=int, default=0) | |
| args = parser.parse_args() | |
| print(json.dumps({"routing_decision": predict(args.prompt, args.context_tokens, args.output_tokens)}, ensure_ascii=False)) | |
| if __name__ == "__main__": | |
| main() | |