Text Classification
Transformers
ONNX
Safetensors
English
roberta
finance
accounting
spend-classification
procurement
text-embeddings-inference
Instructions to use Saeedhoj/spendcoder-distilroberta with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Saeedhoj/spendcoder-distilroberta with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Saeedhoj/spendcoder-distilroberta")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("Saeedhoj/spendcoder-distilroberta") model = AutoModelForSequenceClassification.from_pretrained("Saeedhoj/spendcoder-distilroberta", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from Saeedhoj/spendcoder-distilroberta: direct link, hf CLI and curl.
- Browser
- Download file 2.37 kB
-
https://huggingface.co/Saeedhoj/spendcoder-distilroberta/resolve/main/README.md
- Command line
-
hf download hf://Saeedhoj/spendcoder-distilroberta/README.md
-
curl -L -o README.md https://huggingface.co/Saeedhoj/spendcoder-distilroberta/resolve/main/README.md
2.37 kB
| 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 | |