nicechester/finbert-sentiment-onnx-quantized
088
FinBERT Sentiment Analysis (INT8 ONNX Quantized)
INT8 quantized ONNX export of ProsusAI/finbert for 3-class financial sentiment classification (positive, negative, neutral).
Unlike other quantized FinBERT models that only export embeddings, this model preserves the classification head for direct sentiment inference.
Optimized for Node.js backends, edge environments, and in-browser inference using @huggingface/transformers (v3+).
Model Summary
Quick Start
Installation
npm install @huggingface/transformersNode.js / ESM
import { pipeline } from '@huggingface/transformers';
const classifier = await pipeline(
'text-classification',
'nicechester/finbert-sentiment-onnx-quantized',
{ model_file_name: 'model', dtype: 'q8' }
);
const result = await classifier('Revenue exceeded expectations by 15%.');
console.log(result);
// [{ label: 'positive', score: 0.9631 }]Batch Inference
const results = await classifier([
'Strong quarterly earnings driven by cloud growth.',
'Company announces layoffs amid declining sales.',
'Board approved regular dividend payment.'
]);
console.log(results);
// [
// { label: 'positive', score: 0.9245 },
// { label: 'negative', score: 0.8872 },
// { label: 'neutral', score: 0.7654 }
// ]Local Model (Offline)
import { pipeline, env } from '@huggingface/transformers';
env.localModelPath = '/path/to/models';
env.allowRemoteModels = false;
const classifier = await pipeline(
'text-classification',
'finbert-sentiment-onnx-quantized', // folder name under localModelPath
{ model_file_name: 'model', dtype: 'q8' }
);Required folder structure:
/path/to/models/finbert-sentiment-onnx-quantized/
├── config.json
├── tokenizer.json
├── tokenizer_config.json
├── vocab.txt
└── onnx/
└── model_quantized.onnxOutput Format
// Single text
[{ label: 'positive' | 'negative' | 'neutral', score: number }]
// Batch
[
{ label: 'positive', score: 0.92 },
{ label: 'negative', score: 0.85 },
...
]Use Cases
- Financial news sentiment analysis
- Earnings call transcript classification
- Market update sentiment scoring
- SEC filing analysis
- Real-time trading signal generation
Limitations
- English only - trained on English financial text
- Short/medium text - optimized for sentence-level classification (up to 512 tokens)
- Financial domain - may not generalize well to non-financial text
Model Conversion
Exported and quantized using Hugging Face Optimum:
# 1. Export to ONNX with classification head
optimum-cli export onnx \
--model ProsusAI/finbert \
--task text-classification \
./finbert-onnx/
# 2. Quantize to INT8
optimum-cli onnxruntime quantize \
--onnx_model ./finbert-onnx/ \
--arm64 \
-o ./finbert-quantized/Citation
@article{araci2019finbert,
title={FinBERT: Financial Sentiment Analysis with Pre-Trained Language Models},
author={Araci, Dogu},
journal={arXiv preprint arXiv:1908.10063},
year={2019}
}License
Apache 2.0 (same as base model)
