Release Banking77 Intent Error Predictor v1.0.0

#1
by ITheEqualizer - opened
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ model.skops filter=lfs diff=lfs merge=lfs -text
37
+ primary_baseline.skops filter=lfs diff=lfs merge=lfs -text
DATASET_LICENSE.txt ADDED
@@ -0,0 +1,395 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Attribution 4.0 International
2
+
3
+ =======================================================================
4
+
5
+ Creative Commons Corporation ("Creative Commons") is not a law firm and
6
+ does not provide legal services or legal advice. Distribution of
7
+ Creative Commons public licenses does not create a lawyer-client or
8
+ other relationship. Creative Commons makes its licenses and related
9
+ information available on an "as-is" basis. Creative Commons gives no
10
+ warranties regarding its licenses, any material licensed under their
11
+ terms and conditions, or any related information. Creative Commons
12
+ disclaims all liability for damages resulting from their use to the
13
+ fullest extent possible.
14
+
15
+ Using Creative Commons Public Licenses
16
+
17
+ Creative Commons public licenses provide a standard set of terms and
18
+ conditions that creators and other rights holders may use to share
19
+ original works of authorship and other material subject to copyright
20
+ and certain other rights specified in the public license below. The
21
+ following considerations are for informational purposes only, are not
22
+ exhaustive, and do not form part of our licenses.
23
+
24
+ Considerations for licensors: Our public licenses are
25
+ intended for use by those authorized to give the public
26
+ permission to use material in ways otherwise restricted by
27
+ copyright and certain other rights. Our licenses are
28
+ irrevocable. Licensors should read and understand the terms
29
+ and conditions of the license they choose before applying it.
30
+ Licensors should also secure all rights necessary before
31
+ applying our licenses so that the public can reuse the
32
+ material as expected. Licensors should clearly mark any
33
+ material not subject to the license. This includes other CC-
34
+ licensed material, or material used under an exception or
35
+ limitation to copyright. More considerations for licensors:
36
+ wiki.creativecommons.org/Considerations_for_licensors
37
+
38
+ Considerations for the public: By using one of our public
39
+ licenses, a licensor grants the public permission to use the
40
+ licensed material under specified terms and conditions. If
41
+ the licensor's permission is not necessary for any reason--for
42
+ example, because of any applicable exception or limitation to
43
+ copyright--then that use is not regulated by the license. Our
44
+ licenses grant only permissions under copyright and certain
45
+ other rights that a licensor has authority to grant. Use of
46
+ the licensed material may still be restricted for other
47
+ reasons, including because others have copyright or other
48
+ rights in the material. A licensor may make special requests,
49
+ such as asking that all changes be marked or described.
50
+ Although not required by our licenses, you are encouraged to
51
+ respect those requests where reasonable. More_considerations
52
+ for the public:
53
+ wiki.creativecommons.org/Considerations_for_licensees
54
+
55
+ =======================================================================
56
+
57
+ Creative Commons Attribution 4.0 International Public License
58
+
59
+ By exercising the Licensed Rights (defined below), You accept and agree
60
+ to be bound by the terms and conditions of this Creative Commons
61
+ Attribution 4.0 International Public License ("Public License"). To the
62
+ extent this Public License may be interpreted as a contract, You are
63
+ granted the Licensed Rights in consideration of Your acceptance of
64
+ these terms and conditions, and the Licensor grants You such rights in
65
+ consideration of benefits the Licensor receives from making the
66
+ Licensed Material available under these terms and conditions.
67
+
68
+
69
+ Section 1 -- Definitions.
70
+
71
+ a. Adapted Material means material subject to Copyright and Similar
72
+ Rights that is derived from or based upon the Licensed Material
73
+ and in which the Licensed Material is translated, altered,
74
+ arranged, transformed, or otherwise modified in a manner requiring
75
+ permission under the Copyright and Similar Rights held by the
76
+ Licensor. For purposes of this Public License, where the Licensed
77
+ Material is a musical work, performance, or sound recording,
78
+ Adapted Material is always produced where the Licensed Material is
79
+ synched in timed relation with a moving image.
80
+
81
+ b. Adapter's License means the license You apply to Your Copyright
82
+ and Similar Rights in Your contributions to Adapted Material in
83
+ accordance with the terms and conditions of this Public License.
84
+
85
+ c. Copyright and Similar Rights means copyright and/or similar rights
86
+ closely related to copyright including, without limitation,
87
+ performance, broadcast, sound recording, and Sui Generis Database
88
+ Rights, without regard to how the rights are labeled or
89
+ categorized. For purposes of this Public License, the rights
90
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
91
+ Rights.
92
+
93
+ d. Effective Technological Measures means those measures that, in the
94
+ absence of proper authority, may not be circumvented under laws
95
+ fulfilling obligations under Article 11 of the WIPO Copyright
96
+ Treaty adopted on December 20, 1996, and/or similar international
97
+ agreements.
98
+
99
+ e. Exceptions and Limitations means fair use, fair dealing, and/or
100
+ any other exception or limitation to Copyright and Similar Rights
101
+ that applies to Your use of the Licensed Material.
102
+
103
+ f. Licensed Material means the artistic or literary work, database,
104
+ or other material to which the Licensor applied this Public
105
+ License.
106
+
107
+ g. Licensed Rights means the rights granted to You subject to the
108
+ terms and conditions of this Public License, which are limited to
109
+ all Copyright and Similar Rights that apply to Your use of the
110
+ Licensed Material and that the Licensor has authority to license.
111
+
112
+ h. Licensor means the individual(s) or entity(ies) granting rights
113
+ under this Public License.
114
+
115
+ i. Share means to provide material to the public by any means or
116
+ process that requires permission under the Licensed Rights, such
117
+ as reproduction, public display, public performance, distribution,
118
+ dissemination, communication, or importation, and to make material
119
+ available to the public including in ways that members of the
120
+ public may access the material from a place and at a time
121
+ individually chosen by them.
122
+
123
+ j. Sui Generis Database Rights means rights other than copyright
124
+ resulting from Directive 96/9/EC of the European Parliament and of
125
+ the Council of 11 March 1996 on the legal protection of databases,
126
+ as amended and/or succeeded, as well as other essentially
127
+ equivalent rights anywhere in the world.
128
+
129
+ k. You means the individual or entity exercising the Licensed Rights
130
+ under this Public License. Your has a corresponding meaning.
131
+
132
+
133
+ Section 2 -- Scope.
134
+
135
+ a. License grant.
136
+
137
+ 1. Subject to the terms and conditions of this Public License,
138
+ the Licensor hereby grants You a worldwide, royalty-free,
139
+ non-sublicensable, non-exclusive, irrevocable license to
140
+ exercise the Licensed Rights in the Licensed Material to:
141
+
142
+ a. reproduce and Share the Licensed Material, in whole or
143
+ in part; and
144
+
145
+ b. produce, reproduce, and Share Adapted Material.
146
+
147
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
148
+ Exceptions and Limitations apply to Your use, this Public
149
+ License does not apply, and You do not need to comply with
150
+ its terms and conditions.
151
+
152
+ 3. Term. The term of this Public License is specified in Section
153
+ 6(a).
154
+
155
+ 4. Media and formats; technical modifications allowed. The
156
+ Licensor authorizes You to exercise the Licensed Rights in
157
+ all media and formats whether now known or hereafter created,
158
+ and to make technical modifications necessary to do so. The
159
+ Licensor waives and/or agrees not to assert any right or
160
+ authority to forbid You from making technical modifications
161
+ necessary to exercise the Licensed Rights, including
162
+ technical modifications necessary to circumvent Effective
163
+ Technological Measures. For purposes of this Public License,
164
+ simply making modifications authorized by this Section 2(a)
165
+ (4) never produces Adapted Material.
166
+
167
+ 5. Downstream recipients.
168
+
169
+ a. Offer from the Licensor -- Licensed Material. Every
170
+ recipient of the Licensed Material automatically
171
+ receives an offer from the Licensor to exercise the
172
+ Licensed Rights under the terms and conditions of this
173
+ Public License.
174
+
175
+ b. No downstream restrictions. You may not offer or impose
176
+ any additional or different terms or conditions on, or
177
+ apply any Effective Technological Measures to, the
178
+ Licensed Material if doing so restricts exercise of the
179
+ Licensed Rights by any recipient of the Licensed
180
+ Material.
181
+
182
+ 6. No endorsement. Nothing in this Public License constitutes or
183
+ may be construed as permission to assert or imply that You
184
+ are, or that Your use of the Licensed Material is, connected
185
+ with, or sponsored, endorsed, or granted official status by,
186
+ the Licensor or others designated to receive attribution as
187
+ provided in Section 3(a)(1)(A)(i).
188
+
189
+ b. Other rights.
190
+
191
+ 1. Moral rights, such as the right of integrity, are not
192
+ licensed under this Public License, nor are publicity,
193
+ privacy, and/or other similar personality rights; however, to
194
+ the extent possible, the Licensor waives and/or agrees not to
195
+ assert any such rights held by the Licensor to the limited
196
+ extent necessary to allow You to exercise the Licensed
197
+ Rights, but not otherwise.
198
+
199
+ 2. Patent and trademark rights are not licensed under this
200
+ Public License.
201
+
202
+ 3. To the extent possible, the Licensor waives any right to
203
+ collect royalties from You for the exercise of the Licensed
204
+ Rights, whether directly or through a collecting society
205
+ under any voluntary or waivable statutory or compulsory
206
+ licensing scheme. In all other cases the Licensor expressly
207
+ reserves any right to collect such royalties.
208
+
209
+
210
+ Section 3 -- License Conditions.
211
+
212
+ Your exercise of the Licensed Rights is expressly made subject to the
213
+ following conditions.
214
+
215
+ a. Attribution.
216
+
217
+ 1. If You Share the Licensed Material (including in modified
218
+ form), You must:
219
+
220
+ a. retain the following if it is supplied by the Licensor
221
+ with the Licensed Material:
222
+
223
+ i. identification of the creator(s) of the Licensed
224
+ Material and any others designated to receive
225
+ attribution, in any reasonable manner requested by
226
+ the Licensor (including by pseudonym if
227
+ designated);
228
+
229
+ ii. a copyright notice;
230
+
231
+ iii. a notice that refers to this Public License;
232
+
233
+ iv. a notice that refers to the disclaimer of
234
+ warranties;
235
+
236
+ v. a URI or hyperlink to the Licensed Material to the
237
+ extent reasonably practicable;
238
+
239
+ b. indicate if You modified the Licensed Material and
240
+ retain an indication of any previous modifications; and
241
+
242
+ c. indicate the Licensed Material is licensed under this
243
+ Public License, and include the text of, or the URI or
244
+ hyperlink to, this Public License.
245
+
246
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
247
+ reasonable manner based on the medium, means, and context in
248
+ which You Share the Licensed Material. For example, it may be
249
+ reasonable to satisfy the conditions by providing a URI or
250
+ hyperlink to a resource that includes the required
251
+ information.
252
+
253
+ 3. If requested by the Licensor, You must remove any of the
254
+ information required by Section 3(a)(1)(A) to the extent
255
+ reasonably practicable.
256
+
257
+ 4. If You Share Adapted Material You produce, the Adapter's
258
+ License You apply must not prevent recipients of the Adapted
259
+ Material from complying with this Public License.
260
+
261
+
262
+ Section 4 -- Sui Generis Database Rights.
263
+
264
+ Where the Licensed Rights include Sui Generis Database Rights that
265
+ apply to Your use of the Licensed Material:
266
+
267
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
268
+ to extract, reuse, reproduce, and Share all or a substantial
269
+ portion of the contents of the database;
270
+
271
+ b. if You include all or a substantial portion of the database
272
+ contents in a database in which You have Sui Generis Database
273
+ Rights, then the database in which You have Sui Generis Database
274
+ Rights (but not its individual contents) is Adapted Material; and
275
+
276
+ c. You must comply with the conditions in Section 3(a) if You Share
277
+ all or a substantial portion of the contents of the database.
278
+
279
+ For the avoidance of doubt, this Section 4 supplements and does not
280
+ replace Your obligations under this Public License where the Licensed
281
+ Rights include other Copyright and Similar Rights.
282
+
283
+
284
+ Section 5 -- Disclaimer of Warranties and Limitation of Liability.
285
+
286
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
287
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
288
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
289
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
290
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
291
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
292
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
293
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
294
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
295
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
296
+
297
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
298
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
299
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
300
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
301
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
302
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
303
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
304
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
305
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
306
+
307
+ c. The disclaimer of warranties and limitation of liability provided
308
+ above shall be interpreted in a manner that, to the extent
309
+ possible, most closely approximates an absolute disclaimer and
310
+ waiver of all liability.
311
+
312
+
313
+ Section 6 -- Term and Termination.
314
+
315
+ a. This Public License applies for the term of the Copyright and
316
+ Similar Rights licensed here. However, if You fail to comply with
317
+ this Public License, then Your rights under this Public License
318
+ terminate automatically.
319
+
320
+ b. Where Your right to use the Licensed Material has terminated under
321
+ Section 6(a), it reinstates:
322
+
323
+ 1. automatically as of the date the violation is cured, provided
324
+ it is cured within 30 days of Your discovery of the
325
+ violation; or
326
+
327
+ 2. upon express reinstatement by the Licensor.
328
+
329
+ For the avoidance of doubt, this Section 6(b) does not affect any
330
+ right the Licensor may have to seek remedies for Your violations
331
+ of this Public License.
332
+
333
+ c. For the avoidance of doubt, the Licensor may also offer the
334
+ Licensed Material under separate terms or conditions or stop
335
+ distributing the Licensed Material at any time; however, doing so
336
+ will not terminate this Public License.
337
+
338
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
339
+ License.
340
+
341
+
342
+ Section 7 -- Other Terms and Conditions.
343
+
344
+ a. The Licensor shall not be bound by any additional or different
345
+ terms or conditions communicated by You unless expressly agreed.
346
+
347
+ b. Any arrangements, understandings, or agreements regarding the
348
+ Licensed Material not stated herein are separate from and
349
+ independent of the terms and conditions of this Public License.
350
+
351
+
352
+ Section 8 -- Interpretation.
353
+
354
+ a. For the avoidance of doubt, this Public License does not, and
355
+ shall not be interpreted to, reduce, limit, restrict, or impose
356
+ conditions on any use of the Licensed Material that could lawfully
357
+ be made without permission under this Public License.
358
+
359
+ b. To the extent possible, if any provision of this Public License is
360
+ deemed unenforceable, it shall be automatically reformed to the
361
+ minimum extent necessary to make it enforceable. If the provision
362
+ cannot be reformed, it shall be severed from this Public License
363
+ without affecting the enforceability of the remaining terms and
364
+ conditions.
365
+
366
+ c. No term or condition of this Public License will be waived and no
367
+ failure to comply consented to unless expressly agreed to by the
368
+ Licensor.
369
+
370
+ d. Nothing in this Public License constitutes or may be interpreted
371
+ as a limitation upon, or waiver of, any privileges and immunities
372
+ that apply to the Licensor or You, including from the legal
373
+ processes of any jurisdiction or authority.
374
+
375
+
376
+ =======================================================================
377
+
378
+ Creative Commons is not a party to its public
379
+ licenses. Notwithstanding, Creative Commons may elect to apply one of
380
+ its public licenses to material it publishes and in those instances
381
+ will be considered the “Licensor.” The text of the Creative Commons
382
+ public licenses is dedicated to the public domain under the CC0 Public
383
+ Domain Dedication. Except for the limited purpose of indicating that
384
+ material is shared under a Creative Commons public license or as
385
+ otherwise permitted by the Creative Commons policies published at
386
+ creativecommons.org/policies, Creative Commons does not authorize the
387
+ use of the trademark "Creative Commons" or any other trademark or logo
388
+ of Creative Commons without its prior written consent including,
389
+ without limitation, in connection with any unauthorized modifications
390
+ to any of its public licenses or any other arrangements,
391
+ understandings, or agreements concerning use of licensed material. For
392
+ the avoidance of doubt, this paragraph does not form part of the
393
+ public licenses.
394
+
395
+ Creative Commons may be contacted at creativecommons.org.
LICENSE ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ali Zakaee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
README.md ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: sklearn
3
+ pipeline_tag: text-classification
4
+ tags:
5
+ - sklearn
6
+ - scikit-learn
7
+ - skops
8
+ - intent-classification
9
+ - selective-classification
10
+ - error-prediction
11
+ - banking
12
+ - advisory
13
+ - dataset:PolyAI/banking77
14
+ license: mit
15
+ model-index:
16
+ - name: Banking77 Intent Error Predictor
17
+ results: []
18
+ ---
19
+
20
+ # Banking77 Intent Error Predictor
21
+
22
+ Maintainer: Ali Zakaee (ITheEqualizer)
23
+
24
+ This is a compact advisory complement for the included 77-way banking-support intent router. It estimates when that primary router is likely to be wrong so a fixed review budget can be spent on the riskiest requests. It does not approve transactions, make financial decisions, or replace access control or human review.
25
+
26
+ ## Quickstart
27
+
28
+ ```bash
29
+ python -m venv .venv
30
+ . .venv/bin/activate
31
+ python -m pip install -r requirements.txt
32
+ python -m banking_intent_error_predictor.reference_consumer "I was charged twice for one transfer"
33
+ ```
34
+
35
+ The consumer returns either `enqueue_human_review` or an advisory `route_to_<intent>_handler` action and never executes that action.
36
+
37
+ Positive review example: a short or ambiguous request whose score geometry resembles a known primary-router error. Negative review example: a clear request such as “How do I activate my new card?” when the primary prediction is confident and the learned error risk stays below the reviewed threshold.
38
+
39
+ ## Task and data
40
+
41
+ The input is one non-empty English query of at most 512 characters. The bundled primary model produces probabilities in the exact 77-label BANKING77 order. The complement transforms those probabilities into class scores, predicted-intent one-hot features, top-score margin, normalized entropy, length, word count, digit count, question-mark presence, and a small negation indicator. It returns an error probability and recommends review at `0.27443790545050933` or above.
42
+
43
+ BANKING77 contains 13,083 author-released online-banking queries under CC BY 4.0. Data is pinned to source commit `57ec275d8078af65b7731c2a98be812d844a6d6b`; exact file hashes are in `dataset_manifest.json`. Normalized-text hashes create 60/20/20 primary-train, complement-train, and validation partitions. Seven official-test rows overlapping development text are removed; the other 3,073 official-test rows form the untouched lockbox. Duplicate normalized text cannot cross development partitions.
44
+
45
+ ## Architecture and measured results
46
+
47
+ The primary baseline is word/character TF-IDF plus multinomial logistic regression. The error predictor is histogram gradient boosting with 140 iterations, 15 leaves, learning rate 0.06, minimum leaf size 25, balanced binary loss, and L2 regularization 1.0. This was chosen over publishing another saturated primary intent classifier because the measured downstream decision is which requests deserve review.
48
+
49
+ At about 20% review on validation, the learned model caught 168 of 210 primary errors (80.0%) versus 158 of 210 (75.2%) for the top-two-margin rule. Routed accuracy was 97.38% at 79.97% coverage versus 96.75% for margin at the same coverage. On the untouched lockbox, it caught 263 of 335 errors (78.51%); 72 errors were missed and 326 correct predictions were unnecessarily reviewed. Routed accuracy was 97.10% at 80.83% coverage.
50
+
51
+ The contradictory result matters: ranking PR-AUC was 0.485 on validation and 0.520 on lockbox, below margin-only PR-AUC of 0.516 and 0.586. The release claim is therefore limited to the predeclared fixed review-budget operating point, not better global ranking or universal calibration. The lockbox error-recall Wilson 95% interval is approximately 73.8%–82.6%.
52
+
53
+ ## Prediction trace
54
+
55
+ For “I was charged twice for one transfer,” text is normalized with NFKC, case folding, and whitespace collapse. The primary TF-IDF model produces 77 probabilities and an intent. Those probabilities plus bounded shape features enter the gradient-boosted error model. Its score is compared with the fixed threshold; above threshold the reference consumer requests review, otherwise it exposes the primary intent route.
56
+
57
+ Model and threshold selection used validation only. The official-test lockbox was evaluated once for the selected specification. A second clean fit produced exactly identical validation and lockbox scores and decisions; serialization round-trip was exact.
58
+
59
+ ## Limitations and integration
60
+
61
+ - English only; label coverage reflects BANKING77 and is not a bank’s live taxonomy.
62
+ - The complement is specific to the bundled primary model, label order, preprocessing, and versioned checksums.
63
+ - BANKING77 is small and older than current products, policies, fraud patterns, and user language.
64
+ - Error-ranking PR-AUC is worse than the margin baseline even though the fixed-budget decision is better.
65
+ - Review recommendation is advisory. Never use it to approve, deny, block, refund, authenticate, or move money.
66
+ - Monitor review rate, per-intent misses, drift, and calibration on local labeled traffic. Roll back by disabling the complement and using the included margin-only baseline or sending all requests to the existing safe path.
67
+
68
+ ## Reproduction
69
+
70
+ ```bash
71
+ python -m pip install -r requirements-train.txt
72
+ python -m banking_intent_error_predictor.release_train --cache-dir cache --output-dir reproduced --reference reproduction_reference.npz
73
+ ```
74
+
75
+ The command downloads only immutable, checksummed public source files, fits locally, permits at most eight numeric threads, and requires exact decision-score reproduction.
76
+
77
+ ## Licensing
78
+
79
+ Code and newly fitted model weights are MIT licensed. BANKING77 is CC BY 4.0; attribution and source hashes are in `THIRD_PARTY_NOTICES.md` and `dataset_manifest.json`.
THIRD_PARTY_NOTICES.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Third-Party Notices
2
+
3
+ ## BANKING77
4
+
5
+ The training data is BANKING77 from PolyAI, pinned to source commit `57ec275d8078af65b7731c2a98be812d844a6d6b` and licensed under Creative Commons Attribution 4.0 International.
6
+
7
+ Citation: Iñigo Casanueva, Tadas Temčinas, Daniela Gerz, Matthew Henderson, and Ivan Vulić. “Efficient Intent Detection with Dual Sentence Encoders.” NLP for ConvAI, 2020.
8
+
9
+ Source: https://github.com/PolyAI-LDN/task-specific-datasets/tree/57ec275d8078af65b7731c2a98be812d844a6d6b/banking_data
10
+
11
+ License: https://github.com/PolyAI-LDN/task-specific-datasets/blob/57ec275d8078af65b7731c2a98be812d844a6d6b/LICENSE
banking_intent_error_predictor/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ """Compact error prediction for a BANKING77 intent router."""
banking_intent_error_predictor/predict.py ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import hashlib
4
+ import json
5
+ import math
6
+ import unicodedata
7
+ from pathlib import Path
8
+ from typing import Any, cast
9
+
10
+ import numpy as np
11
+ import skops.io as sio
12
+
13
+
14
+ def sha256_file(path: Path) -> str:
15
+ digest = hashlib.sha256()
16
+ with path.open("rb") as stream:
17
+ for chunk in iter(lambda: stream.read(1 << 20), b""):
18
+ digest.update(chunk)
19
+ return digest.hexdigest()
20
+
21
+
22
+ def normalize_text(value: str, maximum_characters: int) -> str:
23
+ if not isinstance(value, str):
24
+ raise TypeError("input must be a string")
25
+ if len(value) > maximum_characters:
26
+ raise ValueError(f"input must not exceed {maximum_characters} characters")
27
+ normalized = " ".join(unicodedata.normalize("NFKC", value).casefold().split())
28
+ if not normalized:
29
+ raise ValueError("input must not be empty")
30
+ return normalized
31
+
32
+
33
+ def risk_features(probabilities: np.ndarray, texts: list[str]) -> np.ndarray:
34
+ clipped = np.clip(probabilities, 1e-12, 1.0)
35
+ ordered = np.sort(clipped, axis=1)
36
+ top1 = ordered[:, -1]
37
+ top2 = ordered[:, -2]
38
+ entropy = -(clipped * np.log(clipped)).sum(axis=1) / math.log(clipped.shape[1])
39
+ shapes = np.asarray(
40
+ [
41
+ [
42
+ min(len(text), 512) / 512,
43
+ min(len(text.split()), 100) / 100,
44
+ min(sum(ch.isdigit() for ch in text), 20) / 20,
45
+ float("?" in text),
46
+ float(
47
+ any(
48
+ token in text.split()
49
+ for token in ("not", "no", "never", "wrong")
50
+ )
51
+ ),
52
+ ]
53
+ for text in texts
54
+ ],
55
+ dtype=np.float64,
56
+ )
57
+ predicted_one_hot = np.zeros_like(clipped)
58
+ predicted_one_hot[np.arange(len(clipped)), np.argmax(clipped, axis=1)] = 1.0
59
+ return np.column_stack(
60
+ [clipped, predicted_one_hot, top1, top2, top1 - top2, entropy, shapes]
61
+ )
62
+
63
+
64
+ def _load_checked(path: Path, expected_hash: str) -> dict[str, Any]:
65
+ if sha256_file(path) != expected_hash:
66
+ raise RuntimeError(f"artifact checksum mismatch: {path.name}")
67
+ untrusted = sio.get_untrusted_types(file=path)
68
+ if untrusted:
69
+ raise RuntimeError(f"artifact requires untrusted skops types: {untrusted}")
70
+ return cast(dict[str, Any], sio.load(path, trusted=[]))
71
+
72
+
73
+ def predict_text(
74
+ text: str,
75
+ *,
76
+ primary_path: Path = Path("primary_baseline.skops"),
77
+ risk_path: Path = Path("model.skops"),
78
+ config_path: Path = Path("config.json"),
79
+ ) -> dict[str, Any]:
80
+ config = cast(dict[str, Any], json.loads(config_path.read_text(encoding="utf-8")))
81
+ if config.get("schema_version") != "1.0":
82
+ raise RuntimeError("unsupported configuration schema")
83
+ normalized = normalize_text(text, int(config["input"]["maximum_characters"]))
84
+ primary = _load_checked(primary_path, str(config["primary_artifact_sha256"]))
85
+ candidate = _load_checked(risk_path, str(config["artifact_sha256"]))
86
+ labels = cast(list[str], config["labels"])
87
+ if labels != primary["labels"] or labels != candidate["labels"]:
88
+ raise RuntimeError("label mapping mismatch")
89
+ probabilities = np.asarray(
90
+ primary["classifier"].predict_proba(
91
+ primary["features"].transform([normalized])
92
+ ),
93
+ dtype=np.float64,
94
+ )
95
+ if probabilities.shape != (1, len(labels)) or not np.isfinite(probabilities).all():
96
+ raise RuntimeError("primary model returned invalid probabilities")
97
+ predicted = int(probabilities[0].argmax())
98
+ error_risk = float(
99
+ candidate["classifier"].predict_proba(
100
+ risk_features(probabilities, [normalized])
101
+ )[0, 1]
102
+ )
103
+ threshold = float(config["review_at_or_above_error_risk"])
104
+ return {
105
+ "intent": labels[predicted],
106
+ "intent_score": float(probabilities[0, predicted]),
107
+ "error_risk": error_risk,
108
+ "review": error_risk >= threshold,
109
+ "review_threshold": threshold,
110
+ "advisory_only": True,
111
+ "score_semantics": config["score_semantics"],
112
+ }
113
+
114
+
115
+ def main() -> None:
116
+ import argparse
117
+
118
+ parser = argparse.ArgumentParser(description="Route one banking-support query")
119
+ parser.add_argument("text")
120
+ parser.add_argument("--primary", type=Path, default=Path("primary_baseline.skops"))
121
+ parser.add_argument("--risk-model", type=Path, default=Path("model.skops"))
122
+ parser.add_argument("--config", type=Path, default=Path("config.json"))
123
+ args = parser.parse_args()
124
+ result = predict_text(
125
+ args.text,
126
+ primary_path=args.primary,
127
+ risk_path=args.risk_model,
128
+ config_path=args.config,
129
+ )
130
+ print(json.dumps(result, indent=2, sort_keys=True))
131
+
132
+
133
+ if __name__ == "__main__":
134
+ main()
banking_intent_error_predictor/reference_consumer.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import json
5
+ from pathlib import Path
6
+ from typing import Any
7
+
8
+ from banking_intent_error_predictor.predict import predict_text
9
+
10
+
11
+ def route_query(
12
+ text: str,
13
+ *,
14
+ primary_path: Path,
15
+ risk_path: Path,
16
+ config_path: Path,
17
+ ) -> dict[str, Any]:
18
+ prediction = predict_text(
19
+ text,
20
+ primary_path=primary_path,
21
+ risk_path=risk_path,
22
+ config_path=config_path,
23
+ )
24
+ action = (
25
+ "enqueue_human_review"
26
+ if prediction["review"]
27
+ else f"route_to_{prediction['intent']}_handler"
28
+ )
29
+ return {"action": action, "prediction": prediction, "executes_action": False}
30
+
31
+
32
+ def main() -> None:
33
+ parser = argparse.ArgumentParser(
34
+ description="Demonstrate advisory routing without executing an action"
35
+ )
36
+ parser.add_argument("text")
37
+ parser.add_argument("--primary", type=Path, default=Path("primary_baseline.skops"))
38
+ parser.add_argument("--risk-model", type=Path, default=Path("model.skops"))
39
+ parser.add_argument("--config", type=Path, default=Path("config.json"))
40
+ args = parser.parse_args()
41
+ result = route_query(
42
+ args.text,
43
+ primary_path=args.primary,
44
+ risk_path=args.risk_model,
45
+ config_path=args.config,
46
+ )
47
+ print(json.dumps(result, indent=2, sort_keys=True))
48
+
49
+
50
+ if __name__ == "__main__":
51
+ main()
banking_intent_error_predictor/release_train.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import json
5
+ import resource
6
+ import time
7
+ from pathlib import Path
8
+
9
+ import numpy as np
10
+ import skops.io as sio
11
+ from threadpoolctl import threadpool_limits
12
+
13
+ from banking_intent_error_predictor.training import (
14
+ SOURCE_REVISION,
15
+ download,
16
+ fit_once,
17
+ load_rows,
18
+ sha256_file,
19
+ )
20
+
21
+
22
+ def main() -> None:
23
+ parser = argparse.ArgumentParser(description="Reproduce the reviewed release")
24
+ parser.add_argument("--cache-dir", type=Path, required=True)
25
+ parser.add_argument("--output-dir", type=Path, required=True)
26
+ parser.add_argument("--reference", type=Path, required=True)
27
+ args = parser.parse_args()
28
+ args.output_dir.mkdir(parents=True, exist_ok=False)
29
+ train_rows = load_rows(download(args.cache_dir, "train.csv"))
30
+ test_rows = load_rows(download(args.cache_dir, "test.csv"))
31
+ download(args.cache_dir, "categories.json")
32
+ wall_start = time.perf_counter()
33
+ cpu_start = time.process_time()
34
+ with threadpool_limits(limits=8):
35
+ result = fit_once(train_rows, test_rows)
36
+ reference = result["reproduction_reference"]
37
+ with np.load(args.reference, allow_pickle=False) as expected:
38
+ exact = all(
39
+ np.array_equal(reference[key], expected[key]) for key in expected.files
40
+ )
41
+ if not exact:
42
+ raise RuntimeError("reproduced decision scores differ from v1.0.0")
43
+ primary_path = args.output_dir / "primary_baseline.skops"
44
+ candidate_path = args.output_dir / "model.skops"
45
+ sio.dump(
46
+ {
47
+ "features": result["models"]["feature_extractor"],
48
+ "classifier": result["models"]["primary"],
49
+ "labels": result["labels"],
50
+ },
51
+ primary_path,
52
+ )
53
+ sio.dump(
54
+ {
55
+ "classifier": result["models"]["candidate"],
56
+ "labels": result["labels"],
57
+ "review_rate": 0.20,
58
+ },
59
+ candidate_path,
60
+ )
61
+ for path in (primary_path, candidate_path):
62
+ if sio.get_untrusted_types(file=path):
63
+ raise RuntimeError(f"reproduced artifact requires untrusted types: {path}")
64
+ report = {
65
+ "dataset_revision": SOURCE_REVISION,
66
+ "reference_outputs_exact": exact,
67
+ "primary_artifact_sha256": sha256_file(primary_path),
68
+ "candidate_artifact_sha256": sha256_file(candidate_path),
69
+ "wall_seconds": time.perf_counter() - wall_start,
70
+ "cpu_seconds": time.process_time() - cpu_start,
71
+ "thread_limit": 8,
72
+ "peak_rss_bytes": int(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss),
73
+ }
74
+ (args.output_dir / "reproduction.json").write_text(
75
+ json.dumps(report, indent=2, sort_keys=True) + "\n", encoding="utf-8"
76
+ )
77
+ print(json.dumps(report, indent=2, sort_keys=True))
78
+
79
+
80
+ if __name__ == "__main__":
81
+ main()
banking_intent_error_predictor/training.py ADDED
@@ -0,0 +1,617 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import csv
4
+ import hashlib
5
+ import json
6
+ import math
7
+ import os
8
+ import resource
9
+ import time
10
+ import unicodedata
11
+ import urllib.request
12
+ from dataclasses import dataclass
13
+ from pathlib import Path
14
+ from typing import Any
15
+
16
+ import numpy as np
17
+ import skops.io as sio
18
+ from sklearn.ensemble import HistGradientBoostingClassifier
19
+ from sklearn.feature_extraction.text import TfidfVectorizer
20
+ from sklearn.linear_model import LogisticRegression
21
+ from sklearn.metrics import (
22
+ accuracy_score,
23
+ average_precision_score,
24
+ confusion_matrix,
25
+ f1_score,
26
+ precision_recall_fscore_support,
27
+ roc_auc_score,
28
+ )
29
+ from sklearn.pipeline import FeatureUnion
30
+
31
+ CAMPAIGN_ID = "banking77-intent-error-predictor-v1"
32
+ SOURCE_REVISION = "57ec275d8078af65b7731c2a98be812d844a6d6b"
33
+ HUB_REVISION = "90d4e2ee5521c04fc1488f065b8b083658768c57"
34
+ SOURCE_ROOT = (
35
+ "https://raw.githubusercontent.com/PolyAI-LDN/task-specific-datasets/"
36
+ f"{SOURCE_REVISION}/banking_data"
37
+ )
38
+ EXPECTED_SHA256 = {
39
+ "train.csv": "b06e26ac675513959a63135f11b94ea7786ed02da65db93a5650d8838cbc664b",
40
+ "test.csv": "d12d6e3bc4c3103966ae786dc435913c0c563dfa328f5a3646d0e62cfeeb474d",
41
+ "categories.json": (
42
+ "53261da888122daf2d120d925458631d9619e15d82e56052e7a42e535ce32b63"
43
+ ),
44
+ }
45
+ SEED = 20260811
46
+ THREAD_LIMIT = 8
47
+ REVIEW_RATE = 0.20
48
+
49
+
50
+ @dataclass(frozen=True)
51
+ class Row:
52
+ text: str
53
+ label: str
54
+
55
+
56
+ def sha256_file(path: Path) -> str:
57
+ digest = hashlib.sha256()
58
+ with path.open("rb") as handle:
59
+ for block in iter(lambda: handle.read(1 << 20), b""):
60
+ digest.update(block)
61
+ return digest.hexdigest()
62
+
63
+
64
+ def normalize(text: str) -> str:
65
+ return " ".join(unicodedata.normalize("NFKC", text).casefold().split())
66
+
67
+
68
+ def group_bucket(text: str) -> int:
69
+ return int(hashlib.sha256(normalize(text).encode()).hexdigest()[:8], 16) % 100
70
+
71
+
72
+ def download(cache_dir: Path, filename: str) -> Path:
73
+ path = cache_dir / "banking77" / SOURCE_REVISION / filename
74
+ if not path.exists():
75
+ path.parent.mkdir(parents=True, exist_ok=True)
76
+ request = urllib.request.Request(
77
+ f"{SOURCE_ROOT}/{filename}",
78
+ headers={"User-Agent": "ITheEqualizer-banking77-audit/0.1"},
79
+ )
80
+ temporary = path.with_suffix(path.suffix + ".partial")
81
+ with urllib.request.urlopen(request, timeout=60) as response:
82
+ temporary.write_bytes(response.read())
83
+ temporary.replace(path)
84
+ actual = sha256_file(path)
85
+ expected = EXPECTED_SHA256[filename]
86
+ if actual != expected:
87
+ raise RuntimeError(f"checksum mismatch for {filename}: {actual}")
88
+ return path
89
+
90
+
91
+ def load_rows(path: Path) -> list[Row]:
92
+ with path.open(newline="", encoding="utf-8") as handle:
93
+ rows = [
94
+ Row(text=row["text"], label=row["category"])
95
+ for row in csv.DictReader(handle)
96
+ ]
97
+ if not rows or any(not row.text.strip() or not row.label.strip() for row in rows):
98
+ raise RuntimeError(f"invalid or empty rows in {path.name}")
99
+ return rows
100
+
101
+
102
+ def build_primary() -> tuple[FeatureUnion, LogisticRegression]:
103
+ features = FeatureUnion(
104
+ [
105
+ (
106
+ "word",
107
+ TfidfVectorizer(
108
+ ngram_range=(1, 2),
109
+ min_df=2,
110
+ max_features=24000,
111
+ sublinear_tf=True,
112
+ strip_accents="unicode",
113
+ ),
114
+ ),
115
+ (
116
+ "char",
117
+ TfidfVectorizer(
118
+ analyzer="char_wb",
119
+ ngram_range=(3, 5),
120
+ min_df=2,
121
+ max_features=36000,
122
+ sublinear_tf=True,
123
+ strip_accents="unicode",
124
+ ),
125
+ ),
126
+ ]
127
+ )
128
+ model = LogisticRegression(
129
+ C=4.0,
130
+ max_iter=600,
131
+ solver="lbfgs",
132
+ random_state=SEED,
133
+ )
134
+ return features, model
135
+
136
+
137
+ def risk_features(probabilities: np.ndarray, texts: list[str]) -> np.ndarray:
138
+ clipped = np.clip(probabilities, 1e-12, 1.0)
139
+ ordered = np.sort(clipped, axis=1)
140
+ top1 = ordered[:, -1]
141
+ top2 = ordered[:, -2]
142
+ entropy = -(clipped * np.log(clipped)).sum(axis=1) / math.log(clipped.shape[1])
143
+ shapes = np.asarray(
144
+ [
145
+ [
146
+ min(len(text), 512) / 512,
147
+ min(len(text.split()), 100) / 100,
148
+ min(sum(ch.isdigit() for ch in text), 20) / 20,
149
+ float("?" in text),
150
+ float(
151
+ any(
152
+ token in normalize(text).split()
153
+ for token in ("not", "no", "never", "wrong")
154
+ )
155
+ ),
156
+ ]
157
+ for text in texts
158
+ ],
159
+ dtype=np.float64,
160
+ )
161
+ predicted_one_hot = np.zeros_like(clipped)
162
+ predicted_one_hot[np.arange(len(clipped)), np.argmax(clipped, axis=1)] = 1.0
163
+ return np.column_stack(
164
+ [clipped, predicted_one_hot, top1, top2, top1 - top2, entropy, shapes]
165
+ )
166
+
167
+
168
+ def error_metrics(
169
+ errors: np.ndarray,
170
+ risks: np.ndarray,
171
+ *,
172
+ threshold: float,
173
+ ) -> dict[str, Any]:
174
+ reviewed = risks >= threshold
175
+ tn, fp, fn, tp = confusion_matrix(errors, reviewed, labels=[0, 1]).ravel()
176
+ precision, recall, f1, _ = precision_recall_fscore_support(
177
+ errors, reviewed, average="binary", zero_division=0
178
+ )
179
+ routed = ~reviewed
180
+ return {
181
+ "error_prevalence": float(errors.mean()),
182
+ "roc_auc": float(roc_auc_score(errors, risks)),
183
+ "pr_auc": float(average_precision_score(errors, risks)),
184
+ "threshold": float(threshold),
185
+ "review_rate": float(reviewed.mean()),
186
+ "error_precision": float(precision),
187
+ "error_recall": float(recall),
188
+ "error_f1": float(f1),
189
+ "confusion": {"tn": int(tn), "fp": int(fp), "fn": int(fn), "tp": int(tp)},
190
+ "routed_accuracy": float(1.0 - errors[routed].mean()) if routed.any() else 0.0,
191
+ "coverage": float(routed.mean()),
192
+ }
193
+
194
+
195
+ def review_threshold(risks: np.ndarray) -> float:
196
+ return float(np.quantile(risks, 1.0 - REVIEW_RATE, method="higher"))
197
+
198
+
199
+ def dump_checked(model: Any, path: Path) -> dict[str, Any]:
200
+ sio.dump(model, path)
201
+ untrusted = sio.get_untrusted_types(file=path)
202
+ if untrusted:
203
+ raise RuntimeError(f"non-empty skops untrusted type set: {untrusted}")
204
+ return {
205
+ "path": path.name,
206
+ "bytes": path.stat().st_size,
207
+ "sha256": sha256_file(path),
208
+ "skops_untrusted_types": untrusted,
209
+ }
210
+
211
+
212
+ def fit_once(train_rows: list[Row], test_rows: list[Row]) -> dict[str, Any]:
213
+ primary_train = [row for row in train_rows if group_bucket(row.text) < 60]
214
+ complement_train = [row for row in train_rows if 60 <= group_bucket(row.text) < 80]
215
+ validation = [row for row in train_rows if group_bucket(row.text) >= 80]
216
+ primary_groups = {normalize(row.text) for row in primary_train}
217
+ complement_groups = {normalize(row.text) for row in complement_train}
218
+ validation_groups = {normalize(row.text) for row in validation}
219
+ if (
220
+ primary_groups & complement_groups
221
+ or primary_groups & validation_groups
222
+ or complement_groups & validation_groups
223
+ ):
224
+ raise RuntimeError("group leakage across development partitions")
225
+ lockbox = [
226
+ row
227
+ for row in test_rows
228
+ if normalize(row.text)
229
+ not in primary_groups | complement_groups | validation_groups
230
+ ]
231
+ labels = sorted({row.label for row in train_rows})
232
+ if len(labels) != 77 or any(
233
+ {row.label for row in part} != set(labels)
234
+ for part in (primary_train, complement_train, validation, lockbox)
235
+ ):
236
+ raise RuntimeError("all four partitions must contain all 77 labels")
237
+
238
+ features, primary = build_primary()
239
+ x_primary = features.fit_transform([row.text for row in primary_train])
240
+ primary.fit(x_primary, [row.label for row in primary_train])
241
+
242
+ def primary_outputs(rows: list[Row]) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
243
+ probs = primary.predict_proba(features.transform([row.text for row in rows]))
244
+ predictions = primary.classes_[np.argmax(probs, axis=1)]
245
+ truth = np.asarray([row.label for row in rows])
246
+ return probs, predictions, (predictions != truth).astype(np.int64)
247
+
248
+ complement_probs, _, complement_errors = primary_outputs(complement_train)
249
+ validation_probs, validation_predictions, validation_errors = primary_outputs(
250
+ validation
251
+ )
252
+ lockbox_probs, lockbox_predictions, lockbox_errors = primary_outputs(lockbox)
253
+
254
+ candidate = HistGradientBoostingClassifier(
255
+ learning_rate=0.06,
256
+ max_iter=140,
257
+ max_leaf_nodes=15,
258
+ min_samples_leaf=25,
259
+ l2_regularization=1.0,
260
+ class_weight="balanced",
261
+ random_state=SEED,
262
+ )
263
+ candidate.fit(
264
+ risk_features(complement_probs, [row.text for row in complement_train]),
265
+ complement_errors,
266
+ )
267
+ validation_risk = candidate.predict_proba(
268
+ risk_features(validation_probs, [row.text for row in validation])
269
+ )[:, 1]
270
+ lockbox_risk = candidate.predict_proba(
271
+ risk_features(lockbox_probs, [row.text for row in lockbox])
272
+ )[:, 1]
273
+ validation_margin_risk = (
274
+ 1.0
275
+ - np.partition(validation_probs, -2, axis=1)[:, -1]
276
+ + np.partition(validation_probs, -2, axis=1)[:, -2]
277
+ )
278
+ lockbox_margin_risk = (
279
+ 1.0
280
+ - np.partition(lockbox_probs, -2, axis=1)[:, -1]
281
+ + np.partition(lockbox_probs, -2, axis=1)[:, -2]
282
+ )
283
+ candidate_threshold = review_threshold(validation_risk)
284
+ margin_threshold = review_threshold(validation_margin_risk)
285
+
286
+ return {
287
+ "models": {
288
+ "feature_extractor": features,
289
+ "primary": primary,
290
+ "candidate": candidate,
291
+ },
292
+ "partitions": {
293
+ "primary_train": len(primary_train),
294
+ "complement_train": len(complement_train),
295
+ "validation": len(validation),
296
+ "lockbox": len(lockbox),
297
+ "lockbox_overlap_removed": len(test_rows) - len(lockbox),
298
+ },
299
+ "labels": labels,
300
+ "primary": {
301
+ "validation_accuracy": float(
302
+ accuracy_score(
303
+ [row.label for row in validation], validation_predictions
304
+ )
305
+ ),
306
+ "validation_macro_f1": float(
307
+ f1_score(
308
+ [row.label for row in validation],
309
+ validation_predictions,
310
+ average="macro",
311
+ )
312
+ ),
313
+ "lockbox_accuracy": float(
314
+ accuracy_score([row.label for row in lockbox], lockbox_predictions)
315
+ ),
316
+ "lockbox_macro_f1": float(
317
+ f1_score(
318
+ [row.label for row in lockbox], lockbox_predictions, average="macro"
319
+ )
320
+ ),
321
+ },
322
+ "validation": {
323
+ "candidate": error_metrics(
324
+ validation_errors, validation_risk, threshold=candidate_threshold
325
+ ),
326
+ "margin_baseline": error_metrics(
327
+ validation_errors, validation_margin_risk, threshold=margin_threshold
328
+ ),
329
+ },
330
+ "lockbox": {
331
+ "candidate": error_metrics(
332
+ lockbox_errors, lockbox_risk, threshold=candidate_threshold
333
+ ),
334
+ "margin_baseline": error_metrics(
335
+ lockbox_errors, lockbox_margin_risk, threshold=margin_threshold
336
+ ),
337
+ },
338
+ "reproduction_reference": {
339
+ "validation_candidate_risk": validation_risk,
340
+ "validation_candidate_predictions": validation_risk >= candidate_threshold,
341
+ "lockbox_candidate_risk": lockbox_risk,
342
+ "lockbox_candidate_predictions": lockbox_risk >= candidate_threshold,
343
+ },
344
+ }
345
+
346
+
347
+ def main() -> None:
348
+ import argparse
349
+
350
+ parser = argparse.ArgumentParser()
351
+ parser.add_argument("--output", type=Path, required=True)
352
+ parser.add_argument("--cache-dir", type=Path, required=True)
353
+ parser.add_argument("--ledger", type=Path, required=True)
354
+ parser.add_argument("--state", type=Path, required=True)
355
+ args = parser.parse_args()
356
+ args.output.mkdir(parents=True, exist_ok=False)
357
+ cache_before = (
358
+ sum(path.stat().st_size for path in args.cache_dir.rglob("*") if path.is_file())
359
+ if args.cache_dir.exists()
360
+ else 0
361
+ )
362
+ for name in (
363
+ "OMP_NUM_THREADS",
364
+ "OPENBLAS_NUM_THREADS",
365
+ "MKL_NUM_THREADS",
366
+ "VECLIB_MAXIMUM_THREADS",
367
+ "NUMEXPR_NUM_THREADS",
368
+ ):
369
+ os.environ[name] = str(THREAD_LIMIT)
370
+ train_path = download(args.cache_dir, "train.csv")
371
+ test_path = download(args.cache_dir, "test.csv")
372
+ categories_path = download(args.cache_dir, "categories.json")
373
+ categories = json.loads(categories_path.read_text(encoding="utf-8"))
374
+ train_rows = load_rows(train_path)
375
+ test_rows = load_rows(test_path)
376
+ if sorted(categories) != sorted({row.label for row in train_rows}):
377
+ raise RuntimeError("category manifest mismatch")
378
+
379
+ code_hash = sha256_file(Path(__file__))
380
+ specification = {
381
+ "campaign_id": CAMPAIGN_ID,
382
+ "candidate": "histogram_gradient_boosting_score_error_predictor",
383
+ "consumer": "banking-support intent router with a human review queue",
384
+ "task": "predict whether a fixed BANKING77 primary router is wrong",
385
+ "input_contract": (
386
+ "77 probabilities in sorted Banking77 label order plus bounded "
387
+ "text-shape features"
388
+ ),
389
+ "output_contract": "error probability and advisory review decision",
390
+ "dataset_hub_revision": HUB_REVISION,
391
+ "dataset_source_revision": SOURCE_REVISION,
392
+ "dataset_hashes": EXPECTED_SHA256,
393
+ "preprocessing": (
394
+ "NFKC casefold whitespace normalization for group hashing; TF-IDF "
395
+ "primary; score and text-shape candidate features"
396
+ ),
397
+ "split": (
398
+ "normalized-text SHA-256 grouped 60/20/20 development partitions; "
399
+ "official test untouched lockbox with overlap removal"
400
+ ),
401
+ "primary": (
402
+ "24k word plus 36k character TF-IDF with multinomial logistic "
403
+ "regression C=4"
404
+ ),
405
+ "architecture": (
406
+ "histogram gradient boosting over probabilities, predicted-intent "
407
+ "one-hot, confidence geometry, and five text-shape features"
408
+ ),
409
+ "objective": "balanced binary log loss for primary-router error prediction",
410
+ "hyperparameters": {
411
+ "learning_rate": 0.06,
412
+ "max_iter": 140,
413
+ "max_leaf_nodes": 15,
414
+ "min_samples_leaf": 25,
415
+ "l2_regularization": 1.0,
416
+ },
417
+ "seed": SEED,
418
+ "code_sha256": code_hash,
419
+ }
420
+ spec_hash = hashlib.sha256(
421
+ json.dumps(specification, sort_keys=True, separators=(",", ":")).encode()
422
+ ).hexdigest()
423
+ if any(
424
+ json.loads(line).get("experiment_spec_hash") == spec_hash
425
+ for line in args.ledger.read_text(encoding="utf-8").splitlines()
426
+ if line.strip()
427
+ ):
428
+ raise RuntimeError("experiment specification already exists in ledger")
429
+
430
+ wall_start = time.perf_counter()
431
+ cpu_start = time.process_time()
432
+ usage_start = resource.getrusage(resource.RUSAGE_SELF)
433
+ result = fit_once(train_rows, test_rows)
434
+ telemetry = {
435
+ "wall_seconds": time.perf_counter() - wall_start,
436
+ "cpu_seconds": time.process_time() - cpu_start,
437
+ "peak_rss_bytes": resource.getrusage(resource.RUSAGE_SELF).ru_maxrss,
438
+ "minor_page_fault_delta": resource.getrusage(resource.RUSAGE_SELF).ru_minflt
439
+ - usage_start.ru_minflt,
440
+ "thread_limit": THREAD_LIMIT,
441
+ "single_training_process": True,
442
+ }
443
+ primary_bundle = {
444
+ "features": result["models"]["feature_extractor"],
445
+ "classifier": result["models"]["primary"],
446
+ "labels": result["labels"],
447
+ }
448
+ primary_artifact = dump_checked(
449
+ primary_bundle, args.output / "primary_baseline.skops"
450
+ )
451
+ candidate_bundle = {
452
+ "classifier": result["models"]["candidate"],
453
+ "labels": result["labels"],
454
+ "review_rate": REVIEW_RATE,
455
+ }
456
+ candidate_artifact = dump_checked(candidate_bundle, args.output / "model.skops")
457
+
458
+ rerun = fit_once(train_rows, test_rows)
459
+ exact_scores = all(
460
+ np.array_equal(
461
+ result["reproduction_reference"][key], rerun["reproduction_reference"][key]
462
+ )
463
+ for key in ("validation_candidate_risk", "lockbox_candidate_risk")
464
+ )
465
+ exact_predictions = all(
466
+ np.array_equal(
467
+ result["reproduction_reference"][key], rerun["reproduction_reference"][key]
468
+ )
469
+ for key in ("validation_candidate_predictions", "lockbox_candidate_predictions")
470
+ )
471
+ loaded = sio.load(args.output / "model.skops", trusted=[])
472
+ serialization_scores_exact = np.array_equal(
473
+ loaded["classifier"].predict_proba(
474
+ risk_features(
475
+ rerun["models"]["primary"].predict_proba(
476
+ rerun["models"]["feature_extractor"].transform(
477
+ [
478
+ row.text
479
+ for row in [
480
+ r for r in train_rows if group_bucket(r.text) >= 80
481
+ ]
482
+ ]
483
+ )
484
+ ),
485
+ [
486
+ row.text
487
+ for row in [r for r in train_rows if group_bucket(r.text) >= 80]
488
+ ],
489
+ )
490
+ )[:, 1],
491
+ rerun["reproduction_reference"]["validation_candidate_risk"],
492
+ )
493
+ reproduction = {
494
+ "clean_refit_scores_exact": exact_scores,
495
+ "clean_refit_predictions_exact": exact_predictions,
496
+ "serialization_scores_exact": serialization_scores_exact,
497
+ }
498
+ validation_candidate = result["validation"]["candidate"]
499
+ validation_margin = result["validation"]["margin_baseline"]
500
+ lockbox_candidate = result["lockbox"]["candidate"]
501
+ acceptance = {
502
+ "validation_error_recall_margin_delta_at_least_0.02": validation_candidate[
503
+ "error_recall"
504
+ ]
505
+ >= validation_margin["error_recall"] + 0.02,
506
+ "validation_routed_accuracy_gain_at_least_0.03": validation_candidate[
507
+ "routed_accuracy"
508
+ ]
509
+ >= result["primary"]["validation_accuracy"] + 0.03,
510
+ "lockbox_error_recall_at_least_0.50": lockbox_candidate["error_recall"] >= 0.50,
511
+ "artifact_at_most_2_mb": candidate_artifact["bytes"] <= 2_000_000,
512
+ "empty_skops_untrusted_type_set": not candidate_artifact[
513
+ "skops_untrusted_types"
514
+ ],
515
+ "exact_reproduction": all(reproduction.values()),
516
+ }
517
+ decision = (
518
+ "release_work_pending" if all(acceptance.values()) else "measured_gates_failed"
519
+ )
520
+ cache_after = sum(
521
+ path.stat().st_size for path in args.cache_dir.rglob("*") if path.is_file()
522
+ )
523
+ metrics = {
524
+ "record_type": "fit",
525
+ "campaign_id": CAMPAIGN_ID,
526
+ "candidate": specification["candidate"],
527
+ "hypothesis": (
528
+ "learned score-shape and intent features improve error capture over "
529
+ "margin-only triage at equal review rate"
530
+ ),
531
+ "experiment_spec_hash": spec_hash,
532
+ "code_sha256": code_hash,
533
+ "dataset_revision": SOURCE_REVISION,
534
+ "base_model_revision": None,
535
+ "configuration": specification,
536
+ "partitions": result["partitions"],
537
+ "primary": result["primary"],
538
+ "validation": result["validation"],
539
+ "lockbox": result["lockbox"],
540
+ "artifacts": {
541
+ "primary_baseline": primary_artifact,
542
+ "candidate": candidate_artifact,
543
+ },
544
+ "acceptance": acceptance,
545
+ "acceptance_decision": decision,
546
+ "reproduction": reproduction,
547
+ "telemetry": {**telemetry, "cache_growth_bytes": cache_after - cache_before},
548
+ }
549
+ (args.output / "metrics.json").write_text(
550
+ json.dumps(metrics, indent=2, sort_keys=True) + "\n", encoding="utf-8"
551
+ )
552
+ temporary_disk_growth = sum(
553
+ path.stat().st_size for path in args.output.rglob("*") if path.is_file()
554
+ )
555
+ metrics["telemetry"]["temporary_disk_growth_bytes"] = temporary_disk_growth
556
+ (args.output / "metrics.json").write_text(
557
+ json.dumps(metrics, indent=2, sort_keys=True) + "\n", encoding="utf-8"
558
+ )
559
+ ledger_record = {**metrics, "telemetry": metrics["telemetry"]}
560
+ with args.ledger.open("a", encoding="utf-8") as handle:
561
+ handle.write(
562
+ json.dumps(ledger_record, sort_keys=True, separators=(",", ":")) + "\n"
563
+ )
564
+ handle.flush()
565
+ os.fsync(handle.fileno())
566
+ state = {
567
+ "campaign_id": CAMPAIGN_ID,
568
+ "created_at": "2026-08-11T13:25:00Z",
569
+ "status": decision,
570
+ "consumer": specification["consumer"],
571
+ "task": specification["task"],
572
+ "differentiator": (
573
+ "sub-2 MB model-specific selective-routing complement rather than "
574
+ "another primary intent classifier"
575
+ ),
576
+ "trend_snapshot": "campaign/trends/20260811T1300Z-v2.json",
577
+ "preflight": "campaign/trends/20260811T1325Z-banking-error-preflight.json",
578
+ "current_experiment": {
579
+ "candidate": specification["candidate"],
580
+ "experiment_spec_hash": spec_hash,
581
+ "hypothesis": ledger_record["hypothesis"],
582
+ },
583
+ "last_run": metrics,
584
+ "release_blocker": None
585
+ if decision == "release_work_pending"
586
+ else "learned error risk did not clear every predeclared usefulness gate",
587
+ "next_action": (
588
+ "run one error-driven candidate using class-conditional calibration "
589
+ "and confusion-neighborhood features, selected on validation only; "
590
+ "abandon if it still fails to beat margin triage"
591
+ ),
592
+ }
593
+ temporary_state = args.state.with_suffix(".json.tmp")
594
+ temporary_state.write_text(
595
+ json.dumps(state, indent=2, sort_keys=True) + "\n", encoding="utf-8"
596
+ )
597
+ temporary_state.replace(args.state)
598
+ print(
599
+ json.dumps(
600
+ {
601
+ "campaign_id": CAMPAIGN_ID,
602
+ "decision": decision,
603
+ "spec_hash": spec_hash,
604
+ "candidate_artifact": candidate_artifact,
605
+ "validation": result["validation"],
606
+ "lockbox": result["lockbox"],
607
+ "reproduction": reproduction,
608
+ "telemetry": metrics["telemetry"],
609
+ },
610
+ indent=2,
611
+ sort_keys=True,
612
+ )
613
+ )
614
+
615
+
616
+ if __name__ == "__main__":
617
+ main()
checksums.sha256 ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 7e7170e3cebf88a9f60c7b8421418323c09304da1af4d5e90f4da1dc1c8a2661 DATASET_LICENSE.txt
2
+ 467416515c08b60ef9ab26725c9b5274ef0c9a27d27df3c57809354585d52be9 LICENSE
3
+ ee2b7da6c94b4ecc06d9dcee1c13bb8f1bafec0f1f5871e7250c9f79c28c1220 README.md
4
+ d631b5f1c5bf3c0eed96fd8c3a54de9bca034b6b30c4158663a94e821d507f64 THIRD_PARTY_NOTICES.md
5
+ 90b33dfe9e877ffe98f36b1ef1f12b067ee80790e42cc80a048df7b55d996258 banking_intent_error_predictor/__init__.py
6
+ 4959067362dc69d8d64650eb778a9c96eea591f13a01497882d4edcfd5b83bb3 banking_intent_error_predictor/predict.py
7
+ 9a80f230ebc6ebf575d2c61cef3ceb0fac4cebdc517b7c0ba99426ac784dc5ed banking_intent_error_predictor/reference_consumer.py
8
+ 5cf2da52441f87a132e792029153bed74788b0a08d4a99d92af936fb42649644 banking_intent_error_predictor/release_train.py
9
+ 852699c3ee6b8e545f9f0fd6c4cf8ccce0bccdea3d67ae4ceceefcdda1404bd7 banking_intent_error_predictor/training.py
10
+ 66f01a807155f28f117d18eaf4b28d75569d16e4e30020de1f40a0009537234b config.json
11
+ 68577be2950e9c723d364651441d5e698791e5c00c3cc9bd77f37022a174a6a9 dataset_manifest.json
12
+ 047ac38d790bd894ca21cc141db044df79bd0fab42ad9658411eab4601c63c02 example.json
13
+ d277fd9c63eada32626aba8d738613871f0a87c1cdc89cd10aae1bb5c4347d9c metrics.json
14
+ 1d5a785c69b01135981c9052aa8d124cf3d423f7d15e558820502d37a18686b0 model.skops
15
+ 139c47e42e634b9e0e8b1a787e89c378a7175ebce761e5618a3deb74476b6bd2 model_manifest.json
16
+ f735dfa1e498fef3c6a0d0a87664cd2e77acaadc892af7875c7ab30148a0e020 primary_baseline.skops
17
+ 5c267e1874f2568facf64893e1bd1acd56b922a61e592e5014080da6897d488f reproduction_reference.npz
18
+ f4103e1d55fd231fb632fb5b2bf232c719b9d881fcfbeaf5849ba687eb0a8c2e requirements-train.txt
19
+ 6e4faa6fa81cd15034c467bf1a78aed2dcb31f91705d643314a420c7e6e69bd7 requirements.txt
config.json ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "advisory_only": true,
3
+ "artifact": "model.skops",
4
+ "artifact_sha256": "1d5a785c69b01135981c9052aa8d124cf3d423f7d15e558820502d37a18686b0",
5
+ "input": {
6
+ "language": "en",
7
+ "maximum_characters": 512,
8
+ "minimum_characters": 1,
9
+ "type": "string"
10
+ },
11
+ "labels": [
12
+ "Refund_not_showing_up",
13
+ "activate_my_card",
14
+ "age_limit",
15
+ "apple_pay_or_google_pay",
16
+ "atm_support",
17
+ "automatic_top_up",
18
+ "balance_not_updated_after_bank_transfer",
19
+ "balance_not_updated_after_cheque_or_cash_deposit",
20
+ "beneficiary_not_allowed",
21
+ "cancel_transfer",
22
+ "card_about_to_expire",
23
+ "card_acceptance",
24
+ "card_arrival",
25
+ "card_delivery_estimate",
26
+ "card_linking",
27
+ "card_not_working",
28
+ "card_payment_fee_charged",
29
+ "card_payment_not_recognised",
30
+ "card_payment_wrong_exchange_rate",
31
+ "card_swallowed",
32
+ "cash_withdrawal_charge",
33
+ "cash_withdrawal_not_recognised",
34
+ "change_pin",
35
+ "compromised_card",
36
+ "contactless_not_working",
37
+ "country_support",
38
+ "declined_card_payment",
39
+ "declined_cash_withdrawal",
40
+ "declined_transfer",
41
+ "direct_debit_payment_not_recognised",
42
+ "disposable_card_limits",
43
+ "edit_personal_details",
44
+ "exchange_charge",
45
+ "exchange_rate",
46
+ "exchange_via_app",
47
+ "extra_charge_on_statement",
48
+ "failed_transfer",
49
+ "fiat_currency_support",
50
+ "get_disposable_virtual_card",
51
+ "get_physical_card",
52
+ "getting_spare_card",
53
+ "getting_virtual_card",
54
+ "lost_or_stolen_card",
55
+ "lost_or_stolen_phone",
56
+ "order_physical_card",
57
+ "passcode_forgotten",
58
+ "pending_card_payment",
59
+ "pending_cash_withdrawal",
60
+ "pending_top_up",
61
+ "pending_transfer",
62
+ "pin_blocked",
63
+ "receiving_money",
64
+ "request_refund",
65
+ "reverted_card_payment?",
66
+ "supported_cards_and_currencies",
67
+ "terminate_account",
68
+ "top_up_by_bank_transfer_charge",
69
+ "top_up_by_card_charge",
70
+ "top_up_by_cash_or_cheque",
71
+ "top_up_failed",
72
+ "top_up_limits",
73
+ "top_up_reverted",
74
+ "topping_up_by_card",
75
+ "transaction_charged_twice",
76
+ "transfer_fee_charged",
77
+ "transfer_into_account",
78
+ "transfer_not_received_by_recipient",
79
+ "transfer_timing",
80
+ "unable_to_verify_identity",
81
+ "verify_my_identity",
82
+ "verify_source_of_funds",
83
+ "verify_top_up",
84
+ "virtual_card_not_working",
85
+ "visa_or_mastercard",
86
+ "why_verify_identity",
87
+ "wrong_amount_of_cash_received",
88
+ "wrong_exchange_rate_for_cash_withdrawal"
89
+ ],
90
+ "primary_artifact": "primary_baseline.skops",
91
+ "primary_artifact_sha256": "f735dfa1e498fef3c6a0d0a87664cd2e77acaadc892af7875c7ab30148a0e020",
92
+ "review_at_or_above_error_risk": 0.27443790545050933,
93
+ "schema_version": "1.0",
94
+ "score_semantics": "model-specific estimate that the bundled primary intent route is wrong"
95
+ }
dataset_manifest.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "files": {
3
+ "categories.json": "53261da888122daf2d120d925458631d9619e15d82e56052e7a42e535ce32b63",
4
+ "test.csv": "d12d6e3bc4c3103966ae786dc435913c0c563dfa328f5a3646d0e62cfeeb474d",
5
+ "train.csv": "b06e26ac675513959a63135f11b94ea7786ed02da65db93a5650d8838cbc664b"
6
+ },
7
+ "hub_revision": "90d4e2ee5521c04fc1488f065b8b083658768c57",
8
+ "license": "CC BY 4.0",
9
+ "license_sha256": "7e7170e3cebf88a9f60c7b8421418323c09304da1af4d5e90f4da1dc1c8a2661",
10
+ "pii_review": "short customer-service queries; no secret patterns were introduced; real-world origin and demographic representativeness are undocumented",
11
+ "repository": "PolyAI/banking77",
12
+ "rows": {
13
+ "official_test": 3080,
14
+ "train": 10003
15
+ },
16
+ "source_repository": "PolyAI-LDN/task-specific-datasets",
17
+ "source_revision": "57ec275d8078af65b7731c2a98be812d844a6d6b",
18
+ "split": {
19
+ "complement_train": 1951,
20
+ "lockbox": 3073,
21
+ "lockbox_overlap_removed": 7,
22
+ "primary_train": 6050,
23
+ "validation": 2002
24
+ }
25
+ }
example.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "expected": {
3
+ "advisory_only": true,
4
+ "error_risk": 0.011158242123685077,
5
+ "intent": "transaction_charged_twice",
6
+ "intent_score": 0.9511649716326432,
7
+ "review": false,
8
+ "review_threshold": 0.27443790545050933,
9
+ "score_semantics": "model-specific estimate that the bundled primary intent route is wrong"
10
+ },
11
+ "input": "I was charged twice for one transfer",
12
+ "source": "author-written"
13
+ }
metrics.json ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "acceptance": {
3
+ "artifact_at_most_2_mb": true,
4
+ "empty_skops_untrusted_type_set": true,
5
+ "exact_reproduction": true,
6
+ "lockbox_error_recall_at_least_0.50": true,
7
+ "validation_error_recall_margin_delta_at_least_0.02": true,
8
+ "validation_routed_accuracy_gain_at_least_0.03": true
9
+ },
10
+ "acceptance_decision": "release_work_pending",
11
+ "artifacts": {
12
+ "candidate": {
13
+ "bytes": 1104573,
14
+ "path": "model.skops",
15
+ "sha256": "1d5a785c69b01135981c9052aa8d124cf3d423f7d15e558820502d37a18686b0",
16
+ "skops_untrusted_types": []
17
+ },
18
+ "primary_baseline": {
19
+ "bytes": 28966090,
20
+ "path": "primary_baseline.skops",
21
+ "sha256": "f735dfa1e498fef3c6a0d0a87664cd2e77acaadc892af7875c7ab30148a0e020",
22
+ "skops_untrusted_types": []
23
+ }
24
+ },
25
+ "base_model_revision": null,
26
+ "campaign_id": "banking77-intent-error-predictor-v1",
27
+ "candidate": "histogram_gradient_boosting_score_error_predictor",
28
+ "code_sha256": "852699c3ee6b8e545f9f0fd6c4cf8ccce0bccdea3d67ae4ceceefcdda1404bd7",
29
+ "configuration": {
30
+ "architecture": "histogram gradient boosting over probabilities, predicted-intent one-hot, confidence geometry, and five text-shape features",
31
+ "campaign_id": "banking77-intent-error-predictor-v1",
32
+ "candidate": "histogram_gradient_boosting_score_error_predictor",
33
+ "code_sha256": "852699c3ee6b8e545f9f0fd6c4cf8ccce0bccdea3d67ae4ceceefcdda1404bd7",
34
+ "consumer": "banking-support intent router with a human review queue",
35
+ "dataset_hashes": {
36
+ "categories.json": "53261da888122daf2d120d925458631d9619e15d82e56052e7a42e535ce32b63",
37
+ "test.csv": "d12d6e3bc4c3103966ae786dc435913c0c563dfa328f5a3646d0e62cfeeb474d",
38
+ "train.csv": "b06e26ac675513959a63135f11b94ea7786ed02da65db93a5650d8838cbc664b"
39
+ },
40
+ "dataset_hub_revision": "90d4e2ee5521c04fc1488f065b8b083658768c57",
41
+ "dataset_source_revision": "57ec275d8078af65b7731c2a98be812d844a6d6b",
42
+ "hyperparameters": {
43
+ "l2_regularization": 1.0,
44
+ "learning_rate": 0.06,
45
+ "max_iter": 140,
46
+ "max_leaf_nodes": 15,
47
+ "min_samples_leaf": 25
48
+ },
49
+ "input_contract": "77 probabilities in sorted Banking77 label order plus bounded text-shape features",
50
+ "objective": "balanced binary log loss for primary-router error prediction",
51
+ "output_contract": "error probability and advisory review decision",
52
+ "preprocessing": "NFKC casefold whitespace normalization for group hashing; TF-IDF primary; score and text-shape candidate features",
53
+ "primary": "24k word plus 36k character TF-IDF with multinomial logistic regression C=4",
54
+ "seed": 20260811,
55
+ "split": "normalized-text SHA-256 grouped 60/20/20 development partitions; official test untouched lockbox with overlap removal",
56
+ "task": "predict whether a fixed BANKING77 primary router is wrong"
57
+ },
58
+ "dataset_revision": "57ec275d8078af65b7731c2a98be812d844a6d6b",
59
+ "experiment_spec_hash": "8a4c7e16a4a0ef3615735c7214e429df5268dc1610612ce6e833aa9e3829ccdc",
60
+ "hypothesis": "learned score-shape and intent features improve error capture over margin-only triage at equal review rate",
61
+ "lockbox": {
62
+ "candidate": {
63
+ "confusion": {
64
+ "fn": 72,
65
+ "fp": 326,
66
+ "tn": 2412,
67
+ "tp": 263
68
+ },
69
+ "coverage": 0.8083306215424666,
70
+ "error_f1": 0.5692640692640693,
71
+ "error_precision": 0.4465195246179966,
72
+ "error_prevalence": 0.10901399284087211,
73
+ "error_recall": 0.7850746268656716,
74
+ "pr_auc": 0.5199652272918066,
75
+ "review_rate": 0.19166937845753335,
76
+ "roc_auc": 0.9035912475605902,
77
+ "routed_accuracy": 0.9710144927536232,
78
+ "threshold": 0.27443790545050933
79
+ },
80
+ "margin_baseline": {
81
+ "confusion": {
82
+ "fn": 78,
83
+ "fp": 366,
84
+ "tn": 2372,
85
+ "tp": 257
86
+ },
87
+ "coverage": 0.7972665148063781,
88
+ "error_f1": 0.5365344467640919,
89
+ "error_precision": 0.41252006420545745,
90
+ "error_prevalence": 0.10901399284087211,
91
+ "error_recall": 0.7671641791044777,
92
+ "pr_auc": 0.5863979952872228,
93
+ "review_rate": 0.20273348519362186,
94
+ "roc_auc": 0.9092310543702234,
95
+ "routed_accuracy": 0.9681632653061224,
96
+ "threshold": 0.6936486958535751
97
+ }
98
+ },
99
+ "partitions": {
100
+ "complement_train": 1951,
101
+ "lockbox": 3073,
102
+ "lockbox_overlap_removed": 7,
103
+ "primary_train": 6050,
104
+ "validation": 2002
105
+ },
106
+ "primary": {
107
+ "lockbox_accuracy": 0.8909860071591279,
108
+ "lockbox_macro_f1": 0.8910051474654282,
109
+ "validation_accuracy": 0.8951048951048951,
110
+ "validation_macro_f1": 0.8919223884704242
111
+ },
112
+ "record_type": "fit",
113
+ "release_validation": {
114
+ "bounded_inference_api": true,
115
+ "lockbox_scores_persisted": true,
116
+ "reference_consumer": true,
117
+ "representative_example_passed": true
118
+ },
119
+ "reproduction": {
120
+ "clean_refit_predictions_exact": true,
121
+ "clean_refit_scores_exact": true,
122
+ "serialization_scores_exact": true
123
+ },
124
+ "telemetry": {
125
+ "cache_growth_bytes": 1081070,
126
+ "cpu_seconds": 14.953067,
127
+ "minor_page_fault_delta": 37952,
128
+ "peak_rss_bytes": 743817216,
129
+ "single_training_process": true,
130
+ "temporary_disk_growth_bytes": 30076757,
131
+ "thread_limit": 8,
132
+ "wall_seconds": 6.962122584000099
133
+ },
134
+ "validation": {
135
+ "candidate": {
136
+ "confusion": {
137
+ "fn": 42,
138
+ "fp": 233,
139
+ "tn": 1559,
140
+ "tp": 168
141
+ },
142
+ "coverage": 0.7997002997002997,
143
+ "error_f1": 0.5499181669394435,
144
+ "error_precision": 0.41895261845386533,
145
+ "error_prevalence": 0.1048951048951049,
146
+ "error_recall": 0.8,
147
+ "pr_auc": 0.48498408831658685,
148
+ "review_rate": 0.2002997002997003,
149
+ "roc_auc": 0.8968856292517007,
150
+ "routed_accuracy": 0.9737663960024985,
151
+ "threshold": 0.27443790545050933
152
+ },
153
+ "margin_baseline": {
154
+ "confusion": {
155
+ "fn": 52,
156
+ "fp": 243,
157
+ "tn": 1549,
158
+ "tp": 158
159
+ },
160
+ "coverage": 0.7997002997002997,
161
+ "error_f1": 0.5171849427168577,
162
+ "error_precision": 0.3940149625935162,
163
+ "error_prevalence": 0.1048951048951049,
164
+ "error_recall": 0.7523809523809524,
165
+ "pr_auc": 0.5163906717576305,
166
+ "review_rate": 0.2002997002997003,
167
+ "roc_auc": 0.8986208545918366,
168
+ "routed_accuracy": 0.9675202998126171,
169
+ "threshold": 0.6936486958535751
170
+ }
171
+ }
172
+ }
model.skops ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d5a785c69b01135981c9052aa8d124cf3d423f7d15e558820502d37a18686b0
3
+ size 1104573
model_manifest.json ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "artifact": "model.skops",
3
+ "artifact_bytes": 1104573,
4
+ "artifact_sha256": "1d5a785c69b01135981c9052aa8d124cf3d423f7d15e558820502d37a18686b0",
5
+ "base_model_revision": null,
6
+ "campaign_id": "banking77-intent-error-predictor-v1",
7
+ "dataset_revision": "57ec275d8078af65b7731c2a98be812d844a6d6b",
8
+ "experiment_spec_hash": "8a4c7e16a4a0ef3615735c7214e429df5268dc1610612ce6e833aa9e3829ccdc",
9
+ "labels": [
10
+ "Refund_not_showing_up",
11
+ "activate_my_card",
12
+ "age_limit",
13
+ "apple_pay_or_google_pay",
14
+ "atm_support",
15
+ "automatic_top_up",
16
+ "balance_not_updated_after_bank_transfer",
17
+ "balance_not_updated_after_cheque_or_cash_deposit",
18
+ "beneficiary_not_allowed",
19
+ "cancel_transfer",
20
+ "card_about_to_expire",
21
+ "card_acceptance",
22
+ "card_arrival",
23
+ "card_delivery_estimate",
24
+ "card_linking",
25
+ "card_not_working",
26
+ "card_payment_fee_charged",
27
+ "card_payment_not_recognised",
28
+ "card_payment_wrong_exchange_rate",
29
+ "card_swallowed",
30
+ "cash_withdrawal_charge",
31
+ "cash_withdrawal_not_recognised",
32
+ "change_pin",
33
+ "compromised_card",
34
+ "contactless_not_working",
35
+ "country_support",
36
+ "declined_card_payment",
37
+ "declined_cash_withdrawal",
38
+ "declined_transfer",
39
+ "direct_debit_payment_not_recognised",
40
+ "disposable_card_limits",
41
+ "edit_personal_details",
42
+ "exchange_charge",
43
+ "exchange_rate",
44
+ "exchange_via_app",
45
+ "extra_charge_on_statement",
46
+ "failed_transfer",
47
+ "fiat_currency_support",
48
+ "get_disposable_virtual_card",
49
+ "get_physical_card",
50
+ "getting_spare_card",
51
+ "getting_virtual_card",
52
+ "lost_or_stolen_card",
53
+ "lost_or_stolen_phone",
54
+ "order_physical_card",
55
+ "passcode_forgotten",
56
+ "pending_card_payment",
57
+ "pending_cash_withdrawal",
58
+ "pending_top_up",
59
+ "pending_transfer",
60
+ "pin_blocked",
61
+ "receiving_money",
62
+ "request_refund",
63
+ "reverted_card_payment?",
64
+ "supported_cards_and_currencies",
65
+ "terminate_account",
66
+ "top_up_by_bank_transfer_charge",
67
+ "top_up_by_card_charge",
68
+ "top_up_by_cash_or_cheque",
69
+ "top_up_failed",
70
+ "top_up_limits",
71
+ "top_up_reverted",
72
+ "topping_up_by_card",
73
+ "transaction_charged_twice",
74
+ "transfer_fee_charged",
75
+ "transfer_into_account",
76
+ "transfer_not_received_by_recipient",
77
+ "transfer_timing",
78
+ "unable_to_verify_identity",
79
+ "verify_my_identity",
80
+ "verify_source_of_funds",
81
+ "verify_top_up",
82
+ "virtual_card_not_working",
83
+ "visa_or_mastercard",
84
+ "why_verify_identity",
85
+ "wrong_amount_of_cash_received",
86
+ "wrong_exchange_rate_for_cash_withdrawal"
87
+ ],
88
+ "lockbox_error_recall": 0.7850746268656716,
89
+ "lockbox_routed_accuracy": 0.9710144927536232,
90
+ "maintainer": "Ali Zakaee (ITheEqualizer)",
91
+ "model_name": "Banking77 Intent Error Predictor",
92
+ "model_version": "1.0.0",
93
+ "primary_artifact_bytes": 28966090,
94
+ "primary_artifact_sha256": "f735dfa1e498fef3c6a0d0a87664cd2e77acaadc892af7875c7ab30148a0e020",
95
+ "release_summary": "New Banking77 primary-router error predictor with newly fitted weights, a fixed 20 percent review-budget contract, grouped development splits, an untouched official-test lockbox, and exact clean reproduction.",
96
+ "schema_version": "1.0",
97
+ "trusted_types": [],
98
+ "validation_error_recall": 0.8
99
+ }
primary_baseline.skops ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f735dfa1e498fef3c6a0d0a87664cd2e77acaadc892af7875c7ab30148a0e020
3
+ size 28966090
reproduction_reference.npz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5c267e1874f2568facf64893e1bd1acd56b922a61e592e5014080da6897d488f
3
+ size 40108
requirements-train.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ numpy==2.5.1
2
+ scikit-learn==1.9.0
3
+ skops==0.14.0
4
+ threadpoolctl==3.6.0
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ numpy==2.5.1
2
+ scikit-learn==1.9.0
3
+ skops==0.14.0