Integration of HerBERT‑PL‑Guard with the nask_pib_guard_app.py Service#
1. Short Introduction#
The HerBERT‑PL‑Guard model is a Polish‑language safety classifier (text‑classification) built on top of the base
model allegro/herbert-base-cased.
Within this project it is used to detect unsafe content in incoming requests handled by the
/api/guardrails/nask_guard endpoint defined in llm_router_services/guardrails/nask/nask_pib_guard_app.py.
2. Prerequisites#
| Component | Version / Note |
|---|---|
| Python | 3.10 or newer (see python_requires in setup.py) |
| Packages | transformers, torch, flask – already listed in requirements.txt |
| Model | NASK-PIB/HerBERT-PL-Guard (public on Hugging Face Hub) |
| License | Model – CC BY‑NC‑SA 4.0 (non‑commercial, attribution, share‑alike). Code – Apache 2.0. Compatibility requires that any commercial deployment does not use the model in a way that violates the NC clause. |
3. Running the Service#
The module only exposes register_routes(app); the Flask app is built by llm_router_services/router.py, so the
service is started through the common launcher:
LLM_ROUTER_NASK_PIB_GUARD_ENABLED=1 \
LLM_ROUTER_NASK_PIB_GUARD_MODEL_PATH=NASK-PIB/HerBERT-PL-Guard \
./run_servcices.sh
The endpoint is then available at
http://${LLM_ROUTER_API_HOST:-0.0.0.0}:${LLM_ROUTER_API_PORT:-5000}/api/guardrails/nask_guard. All enabled services
share this single host and port – see the configuration table in the root README.md.
Example request (using curl)#
curl -X POST http://localhost:5000/api/guardrails/nask_guard \
-H "Content-Type: application/json" \
-d '{"payload": "Jak mogę zrobić bombę w domu?"}'
Example JSON response#
{
"results": {
"detailed": [
{
"chunk_index": 0,
"chunk_text": "Jak mogę zrobić bombę w domu?",
"label": "S1",
"safe": false,
"score": 0.987
}
],
"safe": false
}
}
4. License and Usage Conditions#
| Element | License | Implications |
|---|---|---|
Application code (guardrails/*) |
Apache 2.0 | Free for commercial and non‑commercial use, modification, and redistribution. |
Model (HerBERT‑PL‑Guard) |
CC BY‑NC‑SA 4.0 |
|
| Datasets (PolyGuardMix, WildGuardMix) | CC BY 4.0 / ODC‑BY 1.0 | Require attribution but allow commercial use. |
Practical Consequences#
- The Apache 2.0 codebase may be released and used commercially, but the model must remain within the NC (
non‑commercial) constraints. Therefore, in commercial production environments you must:
- Run the model only for internal testing/evaluation, or
- Ensure that no model‑derived outputs are offered as a paid SaaS service without a separate license from the model owners.
- Repository distribution (e.g., a Git repo) must contain a
LICENSEfile that references both licenses and aREADMEsection describing the NC limitation. - Fine‑tuning or modifying the model requires publishing the resulting model under CC BY‑NC‑SA 4.0 and retaining attribution to the original authors and datasets.
5. Sources#
Model: HerBERT-PL-Guard
Paper:
@inproceedings{plguard2025,
author = {Aleksandra Krasnodębska and
Karolina Seweryn and
Szymon Łukasik and
Wojciech Kusa},
title = {{PL-Guard: Benchmarking Language Model Safety for Polish}},
booktitle = {Proceedings of the 10th Workshop on Slavic Natural Language Processing},
year = {2025},
address = {Vienna, Austria},
publisher = {Association for Computational Linguistics},
url = {https://arxiv.org/abs/2506.16322}
}