Repository navigation
Conversation
Introduce SentencePiece Lite (`lite/`), a compact (~45 KB stripped binary, < 2k LOC), zero-dependency C++20 runtime engine designed to execute SentencePiece tokenization directly on memory-mapped FlatBuffers model binaries (`.spm.fb`). Key features: - Zero Runtime Dependencies: Requires only standard C++20 without runtime dependency on Protobuf or Abseil. - SQLite-Style Standalone Amalgamation: Provides `lite/amalgamate.py` to generate a self-contained 2-file distribution (`dist/sentencepiece_lite.h` and `dist/sentencepiece_lite.cc`) with FlatBuffers and rapidhash inlined. - Zero-Copy Memory-Mapped Startup: Operates directly on `.spm.fb` FlatBuffers blobs via `mmap` with only 1.2 KB heap memory overhead. - High-Throughput Token Caching (`CachedSentencePieceLite`): Optional 64-byte L1 cache-line aligned 2-way set-associative PLRU cache powered by `rapidhash` with 16-bit chunk tag validation. - Safe-Boundary Pre-Tokenization: Built-in character bigram co-occurrence Double-Array Trie analysis (`PretokenizeAtSafeBoundaries`) for lock-free parallel multi-threaded document tokenization. - CLI & Model Converter Tools: Includes `spm_to_fb` offline model converter and `spm_lite` command-line tokenizer, plus on-the-fly `ToFlatbuffer` C++ API. - Full Canonical Parity & Security Hardening: Byte-for-byte normalization and token ID equivalence with canonical SentencePiece (Unigram and BPE), hardened against malformed models with buffer alignment and bounds verification. - Build & CI Integration: Full CMake (`SPM_ENABLE_LITE`) and Bazel (`//lite:...`) build support, GitHub Actions CI workflow (`lite.yml`), and documentation site integration (`docs.yml`).
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce SentencePiece Lite (
lite/), a compact (~45 KB stripped binary, < 2k LOC), zero-dependency C++20 runtime engine designed to execute SentencePiece tokenization directly on memory-mapped FlatBuffers model binaries (.spm.fb).