CoolFace
Modelpublic

nicechester/finbert-sentiment-onnx-quantized

sourceHugging Faceapache-2.0updated 14d agoView on Hugging Face
0likes88downloads
Model Card

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

PropertyValue
Base ModelProsusAI/finbert
TaskText Classification (3-class sentiment)
FormatONNX (INT8 dynamic quantization)
Model Size~110 MB (vs ~438 MB FP32)
Size Reduction~75%
Target HardwareARM64 & x86_64 CPUs

Quick Start

Installation

bash
npm install @huggingface/transformers

Node.js / ESM

javascript
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

javascript
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)

javascript
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.onnx

Output Format

javascript
// 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:

bash
# 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

bibtex
@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)

nicechester/finbert-sentiment-onnx-quantized · CoolFace