MaxEnt CoreML classifiers powering iClaw's tool routing, follow-up detection, toxicity, response pathology, conversational intent, and user-fact memory.
Compiled models live in Sources/iClawCore/Resources/:
| Model | Labels | Examples | Val acc | Purpose |
|---|---|---|---|---|
ToolClassifier_MaxEnt_Merged.mlmodelc |
45 compound | ~90K | — | Tool routing (ToolRouter) |
FollowUpClassifier_MaxEnt.mlmodelc |
6 turn-relation | ~22K | — | Follow-up detection |
ToxicityClassifier_MaxEnt.mlmodel |
2 | small | — | Toxicity gate |
ResponsePathologyClassifier_MaxEnt.mlmodelc |
6 | 1,507 | 89% | Refusal / meta-leak / empty-stub detection |
ConversationIntentClassifier_MaxEnt.mlmodelc |
5 | 10,787 | 86% | Intent: tool / knowledge / conversation / refinement / meta |
UserFactClassifier_MaxEnt.mlmodelc |
7 | 2,696 | 81% | Life-fact persistence (name / age / dietary / family / location / work / preference) |
Each classifier has ONE consolidated source file (JSONL, one {text, label} per line):
| Source | Trainer config | Train / val output |
|---|---|---|
intent_data.jsonl |
intent |
intent_training.json / intent_validation.json |
pathology_data.jsonl |
pathology |
pathology_training.json / pathology_validation.json |
userfact_data.jsonl |
userfact |
userfact_training.json / userfact_validation.json |
training_data_compound.json (legacy schema) |
tool |
uses validation_data_compound.json directly |
followup_training.json (legacy schema) |
followup |
uses followup_validation.json directly |
toxicity_training_data.json (legacy schema) |
toxicity |
self-validated |
To grow a dataset, append new {"text": "...", "label
5650
": "..."} lines to the
corresponding *_data.jsonl file. Then run the matching merge script + trainer.
train_classifier.swift— unified trainer.xcrun swift train_classifier.swift tool|followup|toxicity|pathology|intent|userfactmerge_intent_data.py/merge_pathology_data.py/merge_userfact_data.py— read source.jsonl, dedupe, apply per-class caps + audit, stratified 85/15 split into the training/validation pairadd_language_prefix.swift— prepends[lang]tag to each example usingNLLanguageRecognizer.dominantLanguage. Run withxcrun swift add_language_prefix.swift <intent|userfact>and copy*_lp.jsonover the originals before training to enable language-conditioned featuresaudit_intent.py— flags mislabeled / ambiguous / low-quality entries intointent_audit.jsonl; the merge script applies them automaticallyGenerateFollowUpData.swift— generator for follow-up training data from templatesClassifierBenchmark.swift— held-out-set accuracy benchmarksbenchmark_results/— historical benchmark outputenglish_matching_audit.md— Phase-0 audit of English heuristics replaced by the new classifiersPHASE_2.5_RESULTS.md— intent classifier iteration history (76% → 86% val-acc)
Tool classifier labels use domain.action, e.g. email.read, math.arithmetic, search.web.
Sources/iClawCore/Resources/Config/LabelRegistry.json— maps labels → tool names + type +requiresConsentflagSources/iClawCore/Resources/Config/DomainRules.json— keyword signals for disambiguating within a domain (e.g. "check inbox" →email.read, "mortgage" →math.arithmetic, "miles to km" →math.conversion)DomainDisambiguator(inSources/iClawCore/Pipeline/) — resolves ambiguous labels when the top-2 ML results share a domain
When adding a tool that needs ML-based routing:
- Add ~2000 training examples to
training_data_compound.jsonwith a compounddomain.actionlabel. - Add ~30 validation examples to
validation_data_compound.json. - Add the label to
Sources/iClawCore/Resources/Config/LabelRegistry.jsonwith tool name, type, andrequiresConsent. - If the label is in a compound domain, add action rules to
Sources/iClawCore/Resources/Config/DomainRules.json. - Train:
cd MLTraining && swift train_classifier.swift tool - Compile:
xcrun coremlcompiler compile MLTraining/ToolClassifier_MaxEnt.mlmodel /tmp/mlmodel_output/ - Install:
cp -R /tmp/mlmodel_output/*.mlmodelc ../Sources/iClawCore/Resources/ToolClassifier_MaxEnt_Merged.mlmodelc - Add 10 test cases to
Tests/iClawTests/MLClassifierTests.swiftusing compound label names. - Verify:
swift test --filter MLClassifier— overall >90%, new label >70%.
When modifying follow-up detection:
- Edit templates in
GenerateFollowUpData.swift. - Regenerate:
swift GenerateFollowUpData.swift - Train:
swift train_classifier.swift followup - Compile + install to
Sources/iClawCore/Resources/FollowUpClassifier_MaxEnt.mlmodelc - Verify:
swift test --filter FollowUpClassifier— overall ≥85%.
Six follow-up outcomes: continuation, refinement, retry, drill_down, pivot, meta.
swift train_classifier.swift toxicity
Install to Sources/iClawCore/Resources/.
swift ClassifierBenchmark.swift
Results land in benchmark_results/. Compare against the last run before landing a change.