ONNX Model Zoo

sekarkrishna/legalbert-int8

By sekarkrishna · ↓ 8 · ♥ 0 · Updated 2026-03-21

What's in this repo

This page lists the files in sekarkrishna/legalbert-int8, including model_quantized.onnx.

  • 1 ONNX models (.onnx files)
  • 10 files, including 5 .json, 1 .md, 1 .onnx, 1 .txt
  • Last updated 2026-03-21

ONNX files

File Size Download
model_quantized.onnx — Download

How to use

These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.

README

LegalBERT INT8 — ONNX Quantized

ONNX INT8 quantized version of nlpaueb/legal-bert-base-uncased for efficient legal text embeddings.

Model Details

Property Value
Base Model nlpaueb/legal-bert-base-uncased
Format ONNX
Quantization INT8 (dynamic quantization)
Embedding Dimension 768
Quantized by JustEmbed

What is this?

This is a quantized ONNX export of LEGAL-BERT, a BERT model pre-trained on 12GB of diverse legal text including EU legislation, UK legislation, European Court of Justice cases, and US court cases and contracts. The INT8 quantization reduces model size and improves inference speed while maintaining high accuracy for legal domain embeddings.

Use Cases

  • Legal document search and retrieval
  • Contract analysis
  • Case law similarity
  • Legal text classification
  • Regulatory compliance document matching

Files

  • model_quantized.onnx — INT8 quantized ONNX model
  • tokenizer.json — Fast tokenizer
  • vocab.txt — Vocabulary file
  • config.json — Model configuration

Usage with JustEmbed

from justembed import Embedder

embedder = Embedder("legalbert-int8")
vectors = embedder.embed(["breach of fiduciary duty"])

Usage with ONNX Runtime

import onnxruntime as ort
from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained(".")
session = ort.InferenceSession("model_quantized.onnx")

inputs = tokenizer("breach of fiduciary duty", return_tensors="np")
outputs = session.run(None, dict(inputs))

Quantization Details

  • Method: Dynamic INT8 quantization via ONNX Runtime
  • Source: Original PyTorch weights converted to ONNX, then quantized
  • Speed: ~2-3x faster inference than FP32
  • Size: ~4x smaller than FP32

License

This model is a derivative work of nlpaueb/legal-bert-base-uncased.

The original model is licensed under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0). This quantized version is distributed under the same license as required by the ShareAlike clause. See the LICENSE file for details.

Citation

@inproceedings{chalkidis2020legal,
  title={LEGAL-BERT: The Muppets straight out of Law School},
  author={Chalkidis, Ilias and Fergadiotis, Manos and Malakasiotis, Prodromos and Aletras, Nikolaos and Androutsopoulos, Ion},
  booktitle={Findings of EMNLP},
  year={2020}
}

Acknowledgments

Model info

feature-extraction onnxruntime
onnxruntime onnx bert int8 quantized legal embeddings justembed feature-extraction base_model:nlpaueb/legal-bert-base-uncased base_model:quantized:nlpaueb/legal-bert-base-uncased license:cc-by-sa-4.0
↓ 8 ♥ 0

Created: 2026-03-21

Updated: 2026-03-21

View on Hugging Face

Files (10)

.gitattributes
LICENSE
README.md
config.json
manifest.json
model_quantized.onnx ONNX
special_tokens_map.json
tokenizer.json
tokenizer_config.json
vocab.txt

Related models