Text Classification
Transformers
Safetensors
German
English
bert
klarki
eu-ai-act
compliance
german
Eval Results (legacy)
Instructions to use s4nkar/klarki-bert-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use s4nkar/klarki-bert-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="s4nkar/klarki-bert-classifier")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("s4nkar/klarki-bert-classifier") model = AutoModelForSequenceClassification.from_pretrained("s4nkar/klarki-bert-classifier") - Notebooks
- Google Colab
- Kaggle
Add model card
Browse files
README.md
CHANGED
|
@@ -1,49 +1,179 @@
|
|
| 1 |
---
|
| 2 |
-
language:
|
|
|
|
|
|
|
| 3 |
license: mit
|
|
|
|
|
|
|
|
|
|
| 4 |
tags:
|
| 5 |
- klarki
|
|
|
|
|
|
|
|
|
|
| 6 |
- text-classification
|
| 7 |
- bert
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
compliance auditor. All inference runs on-device β no external API calls.
|
| 15 |
|
| 16 |
-
##
|
| 17 |
|
| 18 |
-
|
| 19 |
-
- `risk_management`: P=0.944 R=0.951 F1=0.947
|
| 20 |
-
- `data_governance`: P=0.959 R=0.967 F1=0.963
|
| 21 |
-
- `technical_documentation`: P=0.968 R=0.968 F1=0.968
|
| 22 |
-
- `record_keeping`: P=0.958 R=0.943 F1=0.950
|
| 23 |
-
- `transparency`: P=0.957 R=0.895 F1=0.925
|
| 24 |
-
- `human_oversight`: P=0.936 R=0.967 F1=0.952
|
| 25 |
-
- `security`: P=0.952 R=0.959 F1=0.956
|
| 26 |
-
- `unrelated`: P=0.959 R=0.983 F1=0.971
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
| 29 |
|
| 30 |
```bash
|
|
|
|
|
|
|
| 31 |
pip install huggingface-hub>=0.26.0
|
| 32 |
python scripts/download_pretrained.py --model bert
|
|
|
|
| 33 |
```
|
| 34 |
|
| 35 |
-
|
| 36 |
|
| 37 |
```python
|
| 38 |
-
from
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
| 40 |
```
|
| 41 |
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|---|---|
|
| 46 |
-
| Base model | deepset/gbert-base |
|
| 47 |
-
|
|
| 48 |
-
|
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- de
|
| 4 |
+
- en
|
| 5 |
license: mit
|
| 6 |
+
base_model: deepset/gbert-base
|
| 7 |
+
pipeline_tag: text-classification
|
| 8 |
+
library_name: transformers
|
| 9 |
tags:
|
| 10 |
- klarki
|
| 11 |
+
- eu-ai-act
|
| 12 |
+
- compliance
|
| 13 |
+
- german
|
| 14 |
- text-classification
|
| 15 |
- bert
|
| 16 |
+
model-index:
|
| 17 |
+
- name: klarki-bert-classifier
|
| 18 |
+
results:
|
| 19 |
+
- task:
|
| 20 |
+
type: text-classification
|
| 21 |
+
name: Text Classification
|
| 22 |
+
dataset:
|
| 23 |
+
name: KlarKI EU AI Act Regulatory Training Data
|
| 24 |
+
type: custom
|
| 25 |
+
metrics:
|
| 26 |
+
- type: f1
|
| 27 |
+
value: 0.954
|
| 28 |
+
name: Macro F1
|
| 29 |
+
verified: false
|
| 30 |
+
---
|
| 31 |
+
|
| 32 |
+
# KlarKI β EU AI Act Article Domain Classifier
|
| 33 |
+
|
| 34 |
+
> 8-class text classification β maps document chunks to EU AI Act article domains (Articles 9β15 + unrelated)
|
| 35 |
+
|
| 36 |
+
> [!NOTE]
|
| 37 |
+
> Part of **[KlarKI](https://github.com/s4nkar/klarki)** β a local-first EU AI Act + GDPR compliance auditor for German SMEs.
|
| 38 |
+
> All inference runs on-device. No data leaves your machine.
|
| 39 |
+
|
| 40 |
---
|
| 41 |
|
| 42 |
+
## Model Overview
|
| 43 |
+
|
| 44 |
+
| Property | Value |
|
| 45 |
+
|---|---|
|
| 46 |
+
| Base model | [deepset/gbert-base](https://huggingface.co/deepset/gbert-base) |
|
| 47 |
+
| Architecture | Transformers β `BertForSequenceClassification` |
|
| 48 |
+
| Parameters | ~110M parameters |
|
| 49 |
+
| Languages | German (primary), English |
|
| 50 |
+
| Training samples | 5536 train / 981 validation |
|
| 51 |
+
| License | MIT |
|
| 52 |
+
| Part of | [KlarKI](https://github.com/s4nkar/klarki) audit pipeline |
|
| 53 |
|
| 54 |
+
---
|
|
|
|
| 55 |
|
| 56 |
+
## Quickstart
|
| 57 |
|
| 58 |
+
### Option A β Via KlarKI (recommended)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
> [!TIP]
|
| 61 |
+
> Use this if you want the full audit pipeline. The download script places all 5 models
|
| 62 |
+
> exactly where KlarKI expects them.
|
| 63 |
|
| 64 |
```bash
|
| 65 |
+
git clone https://github.com/s4nkar/KlarKI-EU-AI-Act-compliance-auditor.git
|
| 66 |
+
cd KlarKI-EU-AI-Act-compliance-auditor
|
| 67 |
pip install huggingface-hub>=0.26.0
|
| 68 |
python scripts/download_pretrained.py --model bert
|
| 69 |
+
./run.sh up
|
| 70 |
```
|
| 71 |
|
| 72 |
+
### Option B β Direct usage
|
| 73 |
|
| 74 |
```python
|
| 75 |
+
from transformers import pipeline
|
| 76 |
+
|
| 77 |
+
classifier = pipeline("text-classification", model="s4nkar/klarki-bert-classifier")
|
| 78 |
+
result = classifier("The system must maintain a risk management system throughout the entire lifecycle of the AI system.")
|
| 79 |
+
# Output: [{'label': 'risk_management', 'score': 0.97}]
|
| 80 |
```
|
| 81 |
|
| 82 |
+
---
|
| 83 |
+
|
| 84 |
+
## Labels
|
| 85 |
+
|
| 86 |
+
| Label | Description |
|
| 87 |
+
|---|---|
|
| 88 |
+
| `risk_management` | Article 9 β Risk Management System |
|
| 89 |
+
| `data_governance` | Article 10 β Data and Data Governance |
|
| 90 |
+
| `technical_documentation` | Article 11 β Technical Documentation |
|
| 91 |
+
| `record_keeping` | Article 12 β Record-Keeping |
|
| 92 |
+
| `transparency` | Article 13 β Transparency and Provision of Information |
|
| 93 |
+
| `human_oversight` | Article 14 β Human Oversight |
|
| 94 |
+
| `security` | Article 15 β Accuracy, Robustness and Cybersecurity |
|
| 95 |
+
| `unrelated` | Not related to EU AI Act Articles 9β15 |
|
| 96 |
+
|
| 97 |
+
---
|
| 98 |
+
|
| 99 |
+
## Evaluation Results
|
| 100 |
+
|
| 101 |
+
**Overall**
|
| 102 |
+
|
| 103 |
+
| Macro F1 | Val samples |
|
| 104 |
+
|---|---|
|
| 105 |
+
| 0.9540 | 981 |
|
| 106 |
+
|
| 107 |
+
**Per-Class**
|
| 108 |
+
|
| 109 |
+
| Class | Precision | Recall | F1 | Support |
|
| 110 |
+
|---|---|---|---|---|
|
| 111 |
+
| `risk_management` | 0.9435 | 0.9512 | 0.9474 | 123 |
|
| 112 |
+
| `data_governance` | 0.9593 | 0.9672 | 0.9633 | 122 |
|
| 113 |
+
| `technical_documentation` | 0.9680 | 0.9680 | 0.9680 | 125 |
|
| 114 |
+
| `record_keeping` | 0.9583 | 0.9426 | 0.9504 | 122 |
|
| 115 |
+
| `transparency` | 0.9569 | 0.8952 | 0.9250 | 124 |
|
| 116 |
+
| `human_oversight` | 0.9365 | 0.9672 | 0.9516 | 122 |
|
| 117 |
+
| `security` | 0.9516 | 0.9593 | 0.9555 | 123 |
|
| 118 |
+
| `unrelated` | 0.9593 | 0.9833 | 0.9712 | 120 |
|
| 119 |
|
| 120 |
+
---
|
| 121 |
+
|
| 122 |
+
## Training Details
|
| 123 |
+
|
| 124 |
+
| Property | Value |
|
| 125 |
|---|---|
|
| 126 |
+
| Base model | `deepset/gbert-base` |
|
| 127 |
+
| Training epochs | 5 (AdamW, early stopping) |
|
| 128 |
+
| Batch size | 16 |
|
| 129 |
+
| Data split | 85% train / 15% validation, stratified, seed=42 |
|
| 130 |
+
| Data generation | Async Ollama-grounded synthesis (phi3:mini) + real regulatory text |
|
| 131 |
+
| Optimiser | AdamW |
|
| 132 |
+
| Training framework | Docker container (Python 3.11, isolated from host) |
|
| 133 |
+
|
| 134 |
+
---
|
| 135 |
+
|
| 136 |
+
## Intended Use
|
| 137 |
+
|
| 138 |
+
Routing document chunks to the correct article gap analyser inside the KlarKI audit pipeline. Each 512-character chunk is assigned to one of seven article domains or marked `unrelated`.
|
| 139 |
+
|
| 140 |
+
> [!WARNING]
|
| 141 |
+
> This model is a **decision-support tool**, not a substitute for qualified legal advice.
|
| 142 |
+
> EU AI Act compliance determinations should always be reviewed by a legal professional.
|
| 143 |
+
|
| 144 |
+
---
|
| 145 |
+
|
| 146 |
+
## Limitations
|
| 147 |
+
|
| 148 |
+
- Trained primarily on German regulatory text; performance may degrade on highly informal language.
|
| 149 |
+
- `unrelated` is a catch-all class; very short or ambiguous chunks may be misclassified.
|
| 150 |
+
- Designed for 512-character chunks, not full documents.
|
| 151 |
+
|
| 152 |
+
---
|
| 153 |
+
|
| 154 |
+
## Citation
|
| 155 |
+
|
| 156 |
+
```bibtex
|
| 157 |
+
@software{klarki2026,
|
| 158 |
+
author = {Sankar},
|
| 159 |
+
title = {KlarKI: Local-First EU AI Act and GDPR Compliance Auditor},
|
| 160 |
+
year = {2026},
|
| 161 |
+
url = {https://github.com/s4nkar/KlarKI-EU-AI-Act-compliance-auditor},
|
| 162 |
+
note = {Open-source compliance tooling for German SMEs}
|
| 163 |
+
}
|
| 164 |
+
```
|
| 165 |
+
|
| 166 |
+
---
|
| 167 |
+
|
| 168 |
+
## About KlarKI
|
| 169 |
+
|
| 170 |
+
KlarKI is an open-source, local-first EU AI Act + GDPR compliance auditor built for German SMEs.
|
| 171 |
+
Upload a policy document and receive a scored gap analysis against Articles 9β15 entirely on your own hardware.
|
| 172 |
+
|
| 173 |
+
**Key features:**
|
| 174 |
+
- Deterministic legal decision hierarchy (actor detection, Annex III applicability gate)
|
| 175 |
+
- Hybrid RAG retrieval (BM25 + ChromaDB vector + cross-encoder re-ranking)
|
| 176 |
+
- LangGraph multi-agent gap analysis (3-node per applicable article)
|
| 177 |
+
- Bilingual EN/DE support β all inference runs locally, no external API calls
|
| 178 |
+
|
| 179 |
+
[GitHub](https://github.com/s4nkar/KlarKI-EU-AI-Act-compliance-auditor) | [All KlarKI Models](https://huggingface.co/s4nkar)
|