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](https://huggingface.co/alea-institute/charboundary-medium (default)-onnx) 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-medium (default)", 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.631 | 0.722 | 0.842 |
| SCOTUS | 0.938 | 0.775 | 0.661 |
| Cyber Crime | 0.961 | 0.853 | 0.767 |
| BVA | 0.957 | 0.875 | 0.806 |
| Intellectual Property | 0.948 | 0.889 | 0.837 |
| 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}
}