Views
No views yet
Important: When loading models from Hugging Face Hub, you must settrust_model=Trueto allow loading custom class types.Security Note: The ONNX model variants are recommended in security-sensitive environments as they don't require bypassing skops security measures withtrust_model=True. See the ONNX versions for a safer alternative.
1# pip install charboundary
2from huggingface_hub import hf_hub_download
3from charboundary import TextSegmenter
4
5# Download the model
6model_path = hf_hub_download(repo_id="alea-institute/charboundary-large", filename="model.pkl")
7
8# Load the model (trust_model=True is required when loading from external sources)
9segmenter = TextSegmenter.load(model_path, trust_model=True)
10
11# Use the model
12text = "This is a test sentence. Here's another one!"
13sentences = segmenter.segment_to_sentences(text)
14print(sentences)
15# Output: ['This is a test sentence.', " Here's another one!"]
16
17# Segment to spans
18sentence_spans = segmenter.get_sentence_spans(text)
19print(sentence_spans)
20# Output: [(0, 24), (24, 44)]| Dataset | Precision | F1 | Recall |
|---|---|---|---|
| ALEA SBD Benchmark | 0.637 | 0.727 | 0.847 |
| SCOTUS | 0.950 | 0.778 | 0.658 |
| Cyber Crime | 0.968 | 0.853 | 0.762 |
| BVA | 0.963 | 0.881 | 0.813 |
| Intellectual Property | 0.954 | 0.890 | 0.834 |
| Model | Format | Size (MB) | Memory (MB) | Throughput (chars/sec) | F1 Score |
|---|---|---|---|---|---|
| Small | SKOPS / ONNX | 3.0 / 0.5 | 1,026 | ~748K | 0.773 |
| Medium | SKOPS / ONNX | 13.0 / 2.6 | 1,897 | ~587K | 0.779 |
| Large | SKOPS / ONNX | 60.0 / 13.0 | 5,734 | ~518K | 0.782 |
@article{bommarito2025precise,
title={Precise Legal Sentence Boundary Detection for Retrieval at Scale: NUPunkt and CharBoundary},
author={Bommarito, Michael J and Katz, Daniel Martin and Bommarito, Jillian},
journal={arXiv preprint arXiv:2504.04131},
year={2025}
}