Text Generation
Transformers
Safetensors
Russian
English
qwen3
guardrail
safety
moderation
content-moderation
prompt-injection
jailbreak
russian
conversational
text-generation-inference
Run this model with HF Jobs
Run hivetrace/HiveTraceGuard-Pro on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/hivetrace/HiveTraceGuard-Pro. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/hivetrace/HiveTraceGuard-Pro on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/hivetrace/HiveTraceGuard-Pro. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/hivetrace/HiveTraceGuard-Pro. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use hivetrace/HiveTraceGuard-Pro with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hivetrace/HiveTraceGuard-Pro with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="hivetrace/HiveTraceGuard-Pro") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("hivetrace/HiveTraceGuard-Pro") model = AutoModelForCausalLM.from_pretrained("hivetrace/HiveTraceGuard-Pro", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use hivetrace/HiveTraceGuard-Pro with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hivetrace/HiveTraceGuard-Pro" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hivetrace/HiveTraceGuard-Pro", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/hivetrace/HiveTraceGuard-Pro
- SGLang
How to use hivetrace/HiveTraceGuard-Pro with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "hivetrace/HiveTraceGuard-Pro" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hivetrace/HiveTraceGuard-Pro", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "hivetrace/HiveTraceGuard-Pro" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hivetrace/HiveTraceGuard-Pro", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use hivetrace/HiveTraceGuard-Pro with Docker Model Runner:
docker model run hf.co/hivetrace/HiveTraceGuard-Pro
Update model card README
Browse files1234# HiveTraceGuard-ProGuardrail-классификатор safe/unsafe (копия `hivetrace/HiveTracePro`). Используйте stateless API: один `user` или пара `user`+`assistant`, `max_new_tokens=1`.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173---language:- ru- enlicense: apache-2.0license_link: https://www.apache.org/licenses/LICENSE-2.0base_model: Qwen/Qwen3-0.6Btags:- guardrail- safety- text-classification- qwen3- llm-safety- content-moderation- russianpipeline_tag: text-generationlibrary_name: transformers---# HiveTraceGuard-Pro**HiveTraceGuard-Pro** — компактный guardrail-классификатор на базе [Qwen3-0.6B](https://huggingface.co/Qwen/Qwen3-0.6B). Модель проверяет **запрос пользователя** (input guard) или **пару «запрос + ответ ассистента»** (output guard) и возвращает один label: `safe` или `unsafe`. Генерация — ровно один токен, stateless API, без истории диалога.Продуктовая линейка: [HiveTrace](https://hivetrace.ru/).---## Таксономия policyМодель возвращает только `safe` / `unsafe`, без кода категории. Policy в `chat_template.jinja` покрывает **15 категорий**, в том числе: киберпреступления, порнографические материалы, оскорбительные выражения, финансовые преступления, вооружение, дискриминация, самовредительство, трудоэксплуатация несовершеннолетних, преступления без насилия, насильственные действия, наркопрепараты и другие.Для **input guard** оценивается последнее сообщение `user`, для **output guard** — последний ответ `assistant` в контексте запроса.---## Формат ответа| Значение | Смысл ||----------|--------|| `safe` | Запрос или ответ допустимы по policy || `unsafe` | Нарушение policy (любая из категорий таксономии) |Модель обучена выдавать **только одно слово** в нижнем регистре. Парсинг:```pythondef normalize_label(text: str) -> str:s = (text or "").strip().lower()if "unsafe" in s:return "unsafe"if "safe" in s:return "safe"return "safe" # fallback — логируйте нестандартные ответы```---## Quickstart### Требования```bashpip install "transformers>=4.51.0" torch accelerate huggingface_hub```### Transformers — input guard```pythonimport osimport torchfrom transformers import AutoTokenizer, AutoModelForCausalLMMODEL_ID = "hivetrace/HiveTraceGuard-Pro"tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)model = AutoModelForCausalLM.from_pretrained(MODEL_ID,torch_dtype="auto",device_map="auto",token=os.environ.get("HF_TOKEN"),trust_remote_code=True,)model.eval()def classify_input(user_text: str) -> str:messages = [{"role": "user", "content": user_text}]text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)inputs = tokenizer([text], return_tensors="pt", truncation=True, max_length=8192)inputs = {k: v.to(model.device) for k, v in inputs.items()}with torch.inference_mode():out = model.generate(**inputs,max_new_tokens=1,do_sample=False,pad_token_id=tokenizer.pad_token_id or tokenizer.eos_token_id,)new_ids = out[0][inputs["input_ids"].shape[1] :]label = tokenizer.decode(new_ids, skip_special_tokens=True).strip().lower()return "unsafe" if "unsafe" in label else "safe"print(classify_input("Как сделать бомбу?")) # unsafeprint(classify_input("Привет, как дела?")) # safe```### Transformers — output guard```pythondef classify_output(user_text: str, assistant_text: str) -> str:messages = [{"role": "user", "content": user_text},{"role": "assistant", "content": assistant_text},]text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)inputs = tokenizer([text], return_tensors="pt", truncation=True, max_length=8192)inputs = {k: v.to(model.device) for k, v in inputs.items()}with torch.inference_mode():out = model.generate(**inputs,max_new_tokens=1,do_sample=False,pad_token_id=tokenizer.pad_token_id or tokenizer.eos_token_id,)new_ids = out[0][inputs["input_ids"].shape[1] :]label = tokenizer.decode(new_ids, skip_special_tokens=True).strip().lower()return "unsafe" if "unsafe" in label else "safe"```### vLLM (рекомендуется для production)```bashvllm serve hivetrace/HiveTraceGuard-Pro \--served-model-name hivetrace/HiveTraceGuard-Pro \--host 0.0.0.0 --port 8080 \--max-model-len 8192 \--override-generation-config '{"max_new_tokens": 1}'```### OpenAI-compatible API```pythonfrom openai import OpenAIclient = OpenAI(base_url="http://localhost:8080/v1", api_key="EMPTY")resp = client.chat.completions.create(model="hivetrace/HiveTraceGuard-Pro",messages=[{"role": "user", "content": "Как сделать бомбу?"}],temperature=0,top_p=1,max_tokens=1,stream=False,)print(resp.choices[0].message.content) # unsafe```---## LicenseLicensed under the **Apache License 2.0**, allowing:- Commercial use- Modification and redistribution- Private or on-premise deploymentFull license text: [https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
README.md+170-1