File size: 2,369 Bytes
ec10e7a
cfa1533
 
 
 
ec10e7a
09dc826
 
ec10e7a
 
cfa1533
 
 
 
 
 
 
 
 
 
 
09dc826
cfa1533
09dc826
cfa1533
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: apache-2.0
base_model: distilroberta-base
language: en
pipeline_tag: text-classification
library_name: transformers
tags: [finance, accounting, spend-classification, procurement, onnx]
metrics: [accuracy, f1]
---

# SpendCoder: purchase line to spend category

Fine-tuned **distilroberta-base** that reads a short purchase or invoice line (for example
"ANNUAL MAINTENANCE OF HV SWITCHGEAR") and returns one of 14 spend categories, with a confidence score.
Low-confidence lines are meant to go to a person. Code, data preparation and tests: https://github.com/saeedm31/SpendCoder

## Results (test year, contracts the model never saw)

| Model | Accuracy | Macro F1 | Weighted F1 |
|---|---|---|---|
| TF-IDF + logistic regression (baseline) | 0.673 | 0.616 | 0.675 |
| Fine-tuned distilroberta-base | 0.665 | 0.569 | 0.664 |

At the chosen review threshold (0.99), 29.0% of test lines are coded automatically with 91.3% accuracy; the rest go to a person.

Train: 17,098 lines (contracts starting before Oct 2023). Validation: 2,065
(Oct 2023 to Sep 2024). Test: 1,547 (from Oct 2024). Test lines whose exact text appears in
training were removed.

## Categories
- Engineering & professional services
- Research & development
- Facility operations & management
- Construction & building maintenance
- Equipment maintenance & repair
- IT & telecom services
- Environmental services
- Utilities, security & housekeeping
- Other services
- IT hardware & software
- Electrical & power equipment
- Lab instruments & chemicals
- Vehicles & machinery
- Other goods

## Data
US Department of Energy contract descriptions and their Product and Service Codes from
[USAspending.gov](https://www.usaspending.gov) (public domain), grouped into the 14 categories above.

## Use
Suggest a spend category for purchase and invoice lines in accounts payable or procurement; send lines below the
review threshold to a person. Not for automatic posting without review. Trained on one public-sector buyer's
wording: before using it in another company, check it on that company's labelled lines and fine-tune further.

## Files
- PyTorch / Transformers weights at the repo root: `AutoModelForSequenceClassification.from_pretrained(...)`
- `onnx/`: `model.onnx`, `tokenizer.json`, `spendcoder.json` (labels, review threshold) for CPU serving with
  onnxruntime, no PyTorch needed