Skip to main content

Splintering

This repository contains the code used in Splintering Nonconcatenative Languages for Better Tokenization.

It contains the Splinter algorithm as well as the intrinsic evaluation code.

The downstream evaluation DictaBERT-Splinter models can be found here.

The following example trains Splinter on Hebrew Wikipedia, encodes the training corpus, and uses it to train a BPE tokenizer:

# Training:
from splintering.trainer import SplinterTrainer
from splintering.text_processors import TextProcessorWithEncoding
from splintering.utils.languages import LanguageUtilsFactory
from splintering.utils.path_utils import get_tokenizer_path, get_corpus_path
from splintering.utils.misc import get_corpus_name

language = 'he'
train_dataset_path = 'wikimedia/wikipedia'
train_dataset_name = f'20231101.{language}'
language_utils = LanguageUtilsFactory.get_by_language(language)

# - Create the reductions map, and map the reductions in it into new Unicode characters
splinter_trainer = SplinterTrainer(language_utils)
reductions_map, new_unicode_chars_map, _ = splinter_trainer.train(train_dataset_path, train_dataset_name, None)

# Application:
# - Splinter the corpus
text_processor = TextProcessorWithEncoding(language_utils, reductions_map, new_unicode_chars_map)
text_processor.save_corpus_as_text_file(train_dataset_path, train_dataset_name)

# - Train tokenizer on the splintered corpus 
tokenizer_corpus_path = get_corpus_path(get_corpus_name(train_dataset_path, train_dataset_name))
tokenizer_type = 'bpe'
vocab_size = 128_000

from scripts.train_tokenizer import train_tokenizer  # Thin wrapper around SentencePiece; you can use any package that takes a string corpus.
tokenizer_path = get_tokenizer_path(tokenizer_type=tokenizer_type, vocab_size=vocab_size)
train_tokenizer(tokenizer_type=tokenizer_type, vocab_size=vocab_size, input_path=tokenizer_corpus_path,
                output_path=tokenizer_path)                     

Citation

If you use Splinter in your research, please cite Splintering Nonconcatenative Languages for Better Tokenization:

@inproceedings{gazit-etal-2025-splintering,
    title = "Splintering Nonconcatenative Languages for Better Tokenization",
    author = "Gazit, Bar  and
      Shmidman, Shaltiel  and
      Shmidman, Avi  and
      Pinter, Yuval",
    editor = "Che, Wanxiang  and
      Nabende, Joyce  and
      Shutova, Ekaterina  and
      Pilehvar, Mohammad Taher",
    booktitle = "Findings of the {A}ssociation for {C}omputational {L}inguistics: {ACL} 2025",
    month = jul,
    year = "2025",
    address = "Vienna, Austria",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2025.findings-acl.1151/",
    doi = "10.18653/v1/2025.findings-acl.1151",
    pages = "22405--22417",
    ISBN = "979-8-89176-256-5"
}

Metadata

Release files for splintering 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for splintering 1.0.0
File Size Uploaded Provenance Actions
splintering-1.0.0.tar.gz 21.8 kB With provenance Details for splintering-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for splintering 1.0.0
File Interpreter ABI Platform Actions
splintering-1.0.0-py3-none-any.whl Python 3 none any Details for splintering-1.0.0-py3-none-any.whl

Total release size: 45.7 kB

Release files / splintering-1.0.0.tar.gz

Download URL splintering-1.0.0.tar.gz
Size 21.8 kB
Tags Source
SHA-256 checksum
How to use checksums
550cb3d8c4394538174342509ffcb89116ddc21c7a461bfb121c23fb66e3178a
BLAKE2b-256 checksum
How to use checksums
3dca9cd9680e0cf5631f51b726f678c1136ca10fd51a6f022b84a6efd0a0c1ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Release files / splintering-1.0.0-py3-none-any.whl

Download URL splintering-1.0.0-py3-none-any.whl
Size 23.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f7b117eccddef18bfb644ed0eb540300a6b55b1500448d663fbb30a626101362
BLAKE2b-256 checksum
How to use checksums
21ed536c8645e3f1a497aeb4f0ef68f469ee2b1d375a9f0624119253615da23e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Security for splintering 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for splintering-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page