Skip to main content

A production-grade tokenizer for LLMs with perfect roundtrip accuracy

Project description

Julius Tokenizer

A high-performance tokenizer optimized for business and financial text processing with perfect roundtrip accuracy.

Python 3.8+ License: MIT

Overview

Julius Tokenizer is a state-of-the-art tokenization library designed specifically for business and financial text. It offers exceptional performance while providing perfect roundtrip accuracy through its innovative reversible mode.

Key Features

  • Perfect Roundtrip Accuracy: Optional reversible mode ensures 100% exact text reconstruction
  • Business Domain Optimization: Specially trained for financial and business terminology
  • Memory Efficient: Intelligent caching and memory management
  • PyTorch Integration: Seamless integration with PyTorch and Hugging Face Transformers

Installation

# Install from PyPI
pip install julius-nlp-tokenizer

# Or install from the current directory
pip install .

# Or install from a specific path
pip install /path/to/julius_tokenizer

Quick Start

from julius_tokenizer import JuliusTokenizer

# Load the pretrained tokenizer
tokenizer = JuliusTokenizer.from_pretrained("julius_tokenizer/data/models/julius-base")

# Encode text to token IDs
text = "EBITDA increased by 15% in Q3 2023, exceeding our projected KPIs."
tokens = tokenizer.encode(text)
print(f"Token count: {len(tokens)}")
print(f"Tokens: {tokens[:10]}...")

# Decode token IDs back to text
decoded_text = tokenizer.decode(tokens)
print(f"Decoded text: {decoded_text}")
print(f"Perfect roundtrip: {text == decoded_text}")

Example Usage

The package includes an example script that demonstrates how to use the tokenizer:

python example.py

API Reference

JuliusTokenizer

The main tokenizer class with the following methods:

Loading a Pretrained Tokenizer

tokenizer = JuliusTokenizer.from_pretrained("julius_tokenizer/data/models/julius-base")

Encoding Text

# Encode a single text
tokens = tokenizer.encode("Your text here")

# Batch encode multiple texts
batch_tokens = tokenizer.batch_encode(["Text 1", "Text 2", "Text 3"])

Decoding Tokens

# Decode a single sequence of tokens
text = tokenizer.decode([1, 308, 253, 152, 3473])

# Batch decode multiple sequences
texts = tokenizer.batch_decode([[1, 308, 253], [1, 456, 789]])

Reversible Mode

# Enable perfect roundtrip accuracy
tokenizer.set_reversible_mode(True)

# Disable for slightly faster processing
tokenizer.set_reversible_mode(False)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

julius_nlp_tokenizer-0.1.0.tar.gz (637.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

julius_nlp_tokenizer-0.1.0-py3-none-any.whl (657.3 kB view details)

Uploaded Python 3

File details

Details for the file julius_nlp_tokenizer-0.1.0.tar.gz.

File metadata

  • Download URL: julius_nlp_tokenizer-0.1.0.tar.gz
  • Upload date:
  • Size: 637.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.2

File hashes

Hashes for julius_nlp_tokenizer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c25e8b4efe62d93d4f800d3f633c8b405a823b4467e30649fdbc0f4fea18698a
MD5 e1bf3451567f8acea5c6a35b60baa3ed
BLAKE2b-256 8336e60cc29f81822a6ca4f4ae077c53bd2c34a759b5d011c79397347880f130

See more details on using hashes here.

File details

Details for the file julius_nlp_tokenizer-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for julius_nlp_tokenizer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a475b785363e21771d1ea9ed802e4404ab77fe0caf8bc121946d47ee93b9e25
MD5 c8706ad751c2bb831664ca9b2a2a3f9c
BLAKE2b-256 bb6de3d7cce6ff94be7c573fd5a68ca9448fd27216a49e0e50d12759e5bf8902

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page