File size: 8,327 Bytes
50540ff
 
811d51e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50540ff
811d51e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
---
license: apache-2.0
language:
- en
pipeline_tag: text-classification
inference: false
tags:
- onnx
- onnxruntime
- browser
- local-inference
- prompt-classification
- task-classification
- complexity-estimation
- ai-routing
- green-ai
- veritiana
datasets:
- OpenAssistant/oasst1
- grammarly/coedit
- evalplus/mbppplus
- google/IFEval
metrics:
- accuracy
- f1
---

# Veritiana Prompt Task & Complexity Classifier

![Veritiana Prompt Classifier architecture](assets/veritiana-prompt-classifier-architecture.png)

A compact ONNX classifier from **Veritiana AI** that identifies the type of work requested by an AI prompt and estimates its complexity **before generative execution begins**.

The model runs locally, including directly in a browser through ONNX Runtime Web. It does not generate text and does not require prompt content to be sent to a remote classification service.

**Live browser test:** https://www.veritiana.com/prompt_classifier.html

## What it returns

The model produces two independent probability distributions.

### Task — 9 classes

`general_chat`, `writing`, `translation`, `summarization`, `research`, `coding`, `mathematics`, `document_analysis`, `high_stakes`

### Complexity — 3 classes

`low`, `medium`, `high`

Example result:

```text
task: coding
complexity: high
```

## Intended role

This release is a public recognition layer, not a complete AI router.

```text
Prompt
  → local feature extraction
  → ONNX task and complexity classifier
  → probabilities and confidence
  → future routing policy
  → model, tools, context, safeguards and budget
```

The open model answers **what kind of request this is** and **how demanding it appears**. Commercial routing value begins when those signals are combined with provider capabilities, prices, latency, organizational policies, tool access, execution quality and feedback history to decide how the request should be executed.

The classifier is also part of the product direction behind **Veritiana AI Meter**, where local recognition helps distinguish the type and estimated complexity of visible AI work.

## Model architecture

The input is a fixed vector of 1,544 float32 features:

- 1,024 hashed word and word-bigram bins
- 512 hashed character-trigram bins
- 8 numerical and structural features

Two independent multinomial logistic-regression heads produce task and complexity probabilities.

```text
input
  features                  float32 [batch, 1544]

outputs
  task_probabilities        float32 [batch, 9]
  complexity_probabilities  float32 [batch, 3]
```

The released ONNX model is approximately 75 KB and uses ONNX opset 13.

## Feature contract

The feature extractor is part of the model contract. Raw text cannot be passed directly to `model.onnx`.

The repository includes the exact implementation in `features.py`, with matching browser logic in `examples/browser/src/main.js`.

The eight numerical features encode:

1. normalized character length
2. normalized word count
3. question-mark count
4. newline count
5. technical-symbol count
6. URL presence
7. document/file-term presence
8. constant bias value

Hashing uses FNV-1a 32-bit over JavaScript UTF-16 code units so Python and browser implementations remain compatible.

## Internal evaluation

The recorded internal split contains 1,287 examples.

| Output | Accuracy | Macro-F1 |
|---|---:|---:|
| Task | 91.22% | 91.04% |
| Complexity | 86.79% | 87.24% |

These are **internal weak-label evaluation results**, not independently established real-world accuracy.

Important limitations:

- labels include source-fixed labels, deterministic weak rules and deterministic lexical augmentation
- augmented rows are variants, not independent human examples
- minority-class support is uneven
- the translation test support is only 4 examples and its reported score is not meaningful as a production claim
- multilingual behavior has not been independently benchmarked
- the classifier does not semantically reason like a large language model

Full per-class reports and confusion matrices are in `evaluation.json`.

## Training data

The original normalized import contained 19,087 prompts:

| Source | Imported rows | Recorded use |
|---|---:|---|
| OpenAssistant/oasst1 | 10,170 | filtered root prompter messages |
| grammarly/coedit | 8,000 | source text, task fixed to writing |
| evalplus/mbppplus | 376 | prompt field, task fixed to coding |
| google/IFEval | 541 | prompt field, weak task labels and instruction-count complexity signal |

After filtering, balancing and deterministic augmentation, the prepared set contained 6,349 rows.

The datasets themselves are not redistributed. Data provenance, row counts, SHA-256 values and the known revision limitation are documented in `dataset-manifest.json`.

## Browser use

A complete minimal Vite example is included in `examples/browser`.

```bash
cd examples/browser
npm install
npm run dev
```

The example loads `model.onnx`, reproduces the 1,544-feature contract and prints both probability distributions.

For the complete production interface, use the live Veritiana test:

https://www.veritiana.com/prompt_classifier.html

## Python use

```bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements-inference.txt
python examples/python/classify.py "Refactor this API and add rollback tests."
```

Expected output structure:

```json
{
  "task": {
    "label": "coding",
    "confidence": 0.0,
    "probabilities": {}
  },
  "complexity": {
    "label": "high",
    "confidence": 0.0,
    "probabilities": {}
  }
}
```

The numerical values depend on the supplied prompt. The example does not send data to an external service.

## Reproducing training

Exact reproduction requires either:

- `dataset.jsonl` with SHA-256 `1d56520b25809488fa8be91bcd14219accdb31146e1ca56686ff805d34c21649`, or
- prepared `training-balanced.jsonl` with SHA-256 `ab2665fcd75800b2350593b7af4222e81d8cc93a34f2bf67320514a92526f44c`.

The datasets are not included in this repository.

```bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements-training.txt

python prepare_training_set.py dataset.jsonl \
  --output training-balanced.jsonl \
  --report training-balanced-report.json \
  --seed 42 \
  --confidence 0.65 \
  --target-per-task 800 \
  --max-per-task 2000

python train.py training-balanced.jsonl \
  --output-dir reproduced-output \
  --version 3.1.0-multisource-balanced \
  --test-size 0.20 \
  --seed 42 \
  --c 4.0
```

Reference model SHA-256:

```text
dca7560742f19207d089d469c2907e7a1b7c06e2bbf14d2404a5d9359043f572
```

Exact byte reproduction can also depend on the numerical environment and BLAS implementation. The feature contract and output probabilities are the primary compatibility target.

## Repository contents

```text
README.md
model.onnx
config.json
classifier-meta.json
evaluation.json
dataset-manifest.json
training-config.json
features.py
prepare_training_set.py
train.py
requirements-inference.txt
requirements-training.txt
LICENSE
NOTICE
assets/
  veritiana-prompt-classifier-architecture.png
examples/
  python/
  browser/
upload_to_hub.py
```

## Appropriate uses

- local prompt analytics
- task-distribution measurement
- complexity estimation
- pre-routing signals
- browser-native AI usage instrumentation
- research and prototyping around deterministic pre-LLM decision layers

## Out-of-scope uses

Do not use the classifier as:

- a medical, legal, financial or safety decision maker
- proof that a prompt is safe
- a factual-answer evaluator
- an authorization layer
- a universal language detector
- a guaranteed model-selection engine
- a replacement for human review in high-stakes workflows

## Privacy

Inference can run entirely on the user device. The model itself does not upload, store or transmit prompt content. Integrators remain responsible for the behavior of the surrounding application.

## License

The model and repository code are released under Apache License 2.0. See `LICENSE` and `NOTICE`.

## Citation

```bibtex
@software{veritiana_prompt_classifier_2026,
  title        = {Veritiana Prompt Task and Complexity Classifier},
  author       = {Veritiana AI},
  year         = {2026},
  version      = {3.1.0},
  url          = {https://www.veritiana.com/prompt_classifier.html}
}
```