Add classic-ml-vs-llm module: Tribuo 4.3.2 and Smile 7.3.0 text classifiers, a zero-shot LLM client and a cost model

Seeded synthetic support tickets in five categories; Tribuo and Smile logistic regression and Smile naive Bayes against a
majority baseline; skewed classes, train/test duplicates, vocabulary drift and the three different answers to a ticket of
unseen words; a zero-shot client for OpenAI-compatible endpoints tested against a fake endpoint (no model was called) and
a cost formula with assumed prices. Every figure is written to output/ by the tests that assert it.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b69H5rTewUKPyhGS8r
This commit is contained in:
Claude
2026-12-01 23:57:00 +05:30
committed by asmhatre
parent dc94d7fece
commit 5323e6c71a
37 changed files with 1445 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
# The synthetic ticket set and its split
generator: seed 42, 3000 tickets, 15% carry a second complaint from another class, 12% have a typo,
3% have a randomly wrong label (human labelling noise)
## Class counts
class train test
BILLING 474 118
ACCESS 474 118
BUG 484 121
FEATURE 485 121
CANCEL 484 121
total 2401 599
## Exact duplicates between train and test
test tickets whose normalised text also appears in train: 122 of 599
## Six tickets, first six of the test set
BUG | Search returns an empty list although the data exists. Also, I was charged twice for this month.
BUG | Hello, The app freezes on the dashboard. The order number ends 4471. Thank you
BILLING | Good morning, My invoice shows the wrong amount. I am on the Pro plan. Thanks.
BUG | Hello, The app freezes on the dashboard. I am using Chrome on Windows. Please advise.
BILLING | Good morning, There is a charge on my statement I do not recognise. My account email is on file. Thank you
ACCESS | Urgent: The reset password email nevre arrives. Regards, Priya
+15
View File
@@ -0,0 +1,15 @@
# Three classic classifiers and a baseline on the same split
dataset: 3000 synthetic tickets, 2401 train / 599 test, 5 balanced classes (see 01-dataset.txt)
timings are from one run on one machine and drift between runs; accuracy and F1 do not
model accuracy macro-F1 train ms median us p99 us model KB
Majority-class baseline 0.2020 0.0672 5 0.1 0.4 -
Tribuo LogisticRegression (SGD) 0.9232 0.9233 1141 13.9 93.2 58.9
Smile LogisticRegression 0.9182 0.9182 2796 7.3 45.2 10.1
Smile DiscreteNaiveBayes 0.9048 0.9049 49 7.5 31.9 16.9
## Tribuo's own evaluator against ours
Tribuo LabelEvaluator accuracy : 0.9232
harness Metrics accuracy : 0.9232
Tribuo LabelEvaluator macro F1 : 0.9233
harness Metrics macro F1 : 0.9233
@@ -0,0 +1,15 @@
# Tribuo logistic regression: where the mistakes go
rows are the true category, columns the predicted one
actual\pred BILLING ACCESS BUG FEATURE CANCEL
BILLING 108 1 3 2 4
ACCESS 1 111 3 2 1
BUG 1 1 116 1 2
FEATURE 2 4 5 107 3
CANCEL 1 4 5 0 111
BILLING precision 0.956 recall 0.915 F1 0.935
ACCESS precision 0.917 recall 0.941 F1 0.929
BUG precision 0.879 recall 0.959 F1 0.917
FEATURE precision 0.955 recall 0.884 F1 0.918
CANCEL precision 0.917 recall 0.917 F1 0.917
@@ -0,0 +1,6 @@
# Skewed classes: accuracy against macro-F1
class mix 55% BILLING, 25% ACCESS, 12% BUG, 6% FEATURE, 2% CANCEL; 2399 train / 601 test
model accuracy macro-F1 CANCEL recall
Majority-class baseline 0.5308 0.1387 0.000
Tribuo LogisticRegression (SGD) 0.9318 0.9083 0.800
@@ -0,0 +1,6 @@
# Tickets the model has already seen
Tribuo logistic regression, balanced split from 02-models.txt
test tickets also in train : 122 accuracy 0.9836
test tickets never seen : 477 accuracy 0.9078
whole test set : 599 accuracy 0.9232
@@ -0,0 +1,8 @@
# Tickets that use words the model never saw
trained on the balanced set; tested on 1000 new tickets where ACCESS and BUG use new wording
(passkey, magic link, device verification, editor glitches, widget flickers, sync spinner)
model normal drifted ACCESS rec. BUG rec.
Tribuo LogisticRegression (SGD) 0.9232 0.6990 0.580 0.172
Smile LogisticRegression 0.9182 0.6970 0.488 0.263
Smile DiscreteNaiveBayes 0.9048 0.7190 0.605 0.239
@@ -0,0 +1,8 @@
# A ticket made only of words the model has never seen
input: "Device verification loops forever." (none of these words occur in the training tickets)
Tribuo LogisticRegression raw : throws IllegalArgumentException: No features found in Example ArrayExample(...)
Smile LogisticRegression raw : returns class index 1 (ACCESS), a guess from the intercepts alone
Smile DiscreteNaiveBayes raw : returns -2147483648 (Integer.MIN_VALUE, not a class index)
harness wrappers (predict) : null / null / null (null = no answer, counted as wrong)
@@ -0,0 +1,22 @@
# Zero-shot client against a fake endpoint (wiring only, no model)
NO LLM WAS CALLED. A local server returns scripted replies, so this shows request shape and reply handling.
## Reply guard, ZeroShotLlm.parse
"BILLING" -> BILLING (accepted)
"Access." -> ACCESS (accepted)
"The category is Bug" -> BUG (accepted)
"BILLING or CANCEL" -> (none) (rejected: two categories)
"I think this is a refund request" -> (none) (rejected: no category name)
"" -> (none) (rejected: empty)
## Five scripted replies through the real HTTP client
scripted: BILLING, ACCESS, Probably BUG., FEATURE or BILLING, CANCEL
right 4 of 5, unparseable 1 (the ambiguous reply counts as wrong, never as a guess)
## The first request body, verbatim
{"model":"any-model","temperature":0,"max_tokens":8,"messages":[{"role":"system","content":"You classify customer support tickets. Reply with exactly one word from this list and nothing else: BILLING, ACCESS, BUG, FEATURE, CANCEL. BILLING is about charges, invoices and refunds. ACCESS is about login, passwords and locked accounts. BUG is about something that is broken. FEATURE is a request for something new. CANCEL is about ending a subscription or account."},{"role":"user","content":"Ticket: I was charged twice for this month.\nCategory:"}]}
Authorization header: Bearer test-key
## Prompt size across the real test tickets (estimate: characters / 4)
instruction alone : 93 tokens
average per ticket : 117.9 tokens (instruction + ticket)
@@ -0,0 +1,18 @@
# What a million tickets cost: a formula, not a price list
EVERY PRICE BELOW IS AN ASSUMPTION. Replace the three rate cards with the ones you actually pay.
inputs: 117.9 prompt tokens per ticket (estimate), 3 output tokens, 1,000,000 tickets
## LLM, billed per token (output priced at 5x input in every row)
assumed $ per 1M input tokens $ per 1M tickets
0.10 13.29
1.00 132.92
3.00 398.76
## Classic model, in-process on one CPU core
measured median predict (Tribuo, 02-models.txt run): 13.9 microseconds
assumed core price: $0.05 per core-hour
core-seconds for 1M tickets: 13.9 cost: $0.0002
Not in either number: training and labelling for the classic model, retries and rate limits for the LLM,
and the engineer-hours for both. They usually decide the real comparison.
@@ -0,0 +1,5 @@
# The Java version each library's bytecode needs
class-file major version 52 = Java 8, 61 = Java 17, 65 = Java 21, 69 = Java 25
Tribuo 4.3.2 org.tribuo.Model major 52 (Java 8)
Smile 7.3.0 smile.classification.Maxent major 69 (Java 25)