Skip to main content

Advanced ML infrastructure and interface to load and run all Olaverse models

Project description

Olaverse

Advanced ML infrastructure and production-ready interface to load and run all Olaverse models.

PyPI Version License Platform

Standard NLP tools and model interfaces don't capture local nuances, custom tokenizers, or specific fine-tuned downstream configurations (like contract analysis & legal reasoning).

Olaverse is a unified Python package and developer interface designed to run all Olaverse model families—ranging from lightweight CPU-only local NLP modules to large enterprise-grade legal and reasoning models.


Key Features

  • 🏛️ Enterprise Legal AI: Built-in support and inference pipeline for olaverse/legal-peace-v1.0 (fine-tuned Mistral-7B for contract analysis and legal reasoning).
  • 🚀 GPU & CPU Optimized: Lazy-loading and custom CUDA/Unsloth optimization layers for large LLMs alongside hyper-efficient, 100% offline local NLP tools.
  • 📦 Optimized Tokenizers (OTK-BPE): Custom Byte-Level BPE tokenizers (e.g. olaverse/otk-bpe-50k) trained on dedicated Nigerian and African language corpora (up to 63% fewer tokens compared to GPT-4).
  • 🗣️ Advanced Diacritic Restoration:
    • Yoruba Diacritizer (dot-below only): 97.5% character accuracy.
    • Yoruba Diacritizer (full tonal): 90.0% word accuracy via Viterbi decoding.
    • Igbo Diacritizer: 95.2% character accuracy.
  • 🎭 Context-Aware Sentiment Analysis: Captures sentiment nuances in Pidgin English and regional languages (72% accuracy).
  • 🔒 Nigerian-specific PII Masking: Automatically masks emails, local +234/080 phone formats, BVN, and NIN.
  • 🇳🇬 Robust Language Detection: Accurately classifies text across 5 languages: Yoruba (yor), Hausa (hau), Igbo (ibo), Pidgin (pcm), and English (eng) with 98.12% accuracy (LIDLite5) and 98.96% accuracy (LIDNeural5).

Installation

Install core library (lightweight, CPU offline-first tokenizers & text helpers):

pip install olaverse

Install with transformer model dependencies (torch + transformers, for LIDNeural5):

pip install olaverse[deeplearning]

Install with legal model dependencies (unsloth, torch, etc. for GPU inference):

pip install olaverse[legal]

For development mode (with Jupyter notebooks and training dependencies):

pip install -e ".[dev]"

Quick Start

1. Legal & Contract Analysis (LegalPeace)

Direct interface for loading and running the olaverse/legal-peace-v1.0 model. Uses Unsloth under the hood for fast, memory-efficient inference.

from olaverse.llm import LegalPeace

# Instantiates the wrapper with default configurations (or enter custom model name/parameters)
model = LegalPeace(model_name="olaverse/legal-peace-v1.0")

# Loads model & tokenizer lazily (requires GPU and unsloth installed)
model.load()


prompt = "Analyze this contract clause: 'The parties agree that all disputes shall be resolved through binding arbitration in Delaware.' What are the key legal implications?"
response = model.generate(prompt, max_new_tokens=300, temperature=0.7)
print(response)

2. Custom Tokenizers (Tokenizer)

Use optimized Byte-Level BPE tokenizers without needing local .json file paths. Loads from Hugging Face Hub automatically if not cached. For details on performance and training, see the otk-bpe repository.

from olaverse.nlp import Tokenizer

# Load the 50k unified model
tok = Tokenizer("naija") 
# Or specific languages (e.g., "yo", "ig", "ha", "pcm", or full model name "otk-bpe-50k-yo")
# tok = Tokenizer("yo")

tokens = tok.encode("Ẹ kú àbọ̀")
print(tokens) # → [124, 381]

decoded = tok.decode(tokens)
print(decoded) # → "Ẹ kú àbọ̀"

3. Language Detection (LIDLite5 & LIDNeural5)

Identify whether text is Yoruba, Hausa, Igbo, Nigerian Pidgin, or English.

Option A: Lightweight (Zero-Dependency CPU)

from olaverse import LIDLite5

detector = LIDLite5()
print(detector.predict("How far, wetin dey happen?")) # → 'pcm'

# Get confidence scores across all 5 classes
probs = detector.predict_proba("How far, wetin dey happen?")
print(probs) # → {'eng': 0.0006, 'hau': 0.0014, ...}

Option B: Neural (Transformer GPU/CPU)

from olaverse import LIDNeural5

detector = LIDNeural5()
detector.load()  # Downloads and caches model from HF (olaverse/lid-neural-5)
                 # Requires: pip install olaverse[deeplearning]

print(detector.predict("How far, wetin dey happen?")) # → 'pcm'

4. Yoruba & Igbo Diacritizer

Restore missing diacritics in Yoruba or Igbo text.

from olaverse.nlp import diacritize_yoruba, diacritize_yoruba_dot_below, diacritize_igbo

# Dot-below only (no tones)
diacritize_yoruba_dot_below("Ojo lo si oja")
# → 'Ọjọ lo si ọja'

# Full tonal diacritics
diacritize_yoruba("Ojo lo si oja lana")
# → 'Ọjọ́ ló sí ọjà lànà'

# Igbo diacritics
diacritize_igbo("Kedu ka i mere")
# → 'Kedụ ka ị mere'

5. Sentiment Analysis

Analyze sentiment across English and Nigerian languages.

from olaverse.nlp import analyze_sentiment

analyze_sentiment("This film too sweet!")
# → {'label': 'positive', 'confidence': 0.74}

analyze_sentiment("I no like am at all")
# → {'label': 'negative', 'confidence': 0.68}

6. Text Preprocessing & PII Masking

Strip or mask sensitive data (NIN, BVN, phone numbers) while preserving Pidgin particles like "sha", "sef", "abeg".

from olaverse.nlp import mask_pii, is_pidgin_particle

mask_pii("Call me on 08012345678 or my BVN is 22233344455")
# → 'Call me on [PHONE] or my BVN is [BVN]'

is_pidgin_particle("sha")   # → True
is_pidgin_particle("sef")   # → True

7. Constants & Local Helpers

from olaverse.utils.constants import STATES, BANKS, format_naira, get_telco

STATES["Lagos"]              # → 'Ikeja'
BANKS["Guaranty Trust Bank"]  # → '058'
format_naira(1500000)        # → '₦1,500,000.00'
get_telco("08031234567")     # → 'MTN'

Design Philosophy

  1. Unified Interface: A single, clean library to access all Olaverse NLP, Tokenizer, and Large Language Models.
  2. Resource-Adaptive: Keeps local CPU helpers lightweight and fully offline-capable, while offering scalable legal and reasoning GPU wrappers.
  3. Honest Metrics & Benchmarks: We believe in sharing open, verifiable performance indicators of our tokenizers and classifiers against global baselines.

License

Apache License 2.0. See LICENSE 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

olaverse-0.1.0.tar.gz (32.1 kB view details)

Uploaded Source

Built Distribution

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

olaverse-0.1.0-py3-none-any.whl (29.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: olaverse-0.1.0.tar.gz
  • Upload date:
  • Size: 32.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for olaverse-0.1.0.tar.gz
Algorithm Hash digest
SHA256 91f71a0a1ad328ef243786b29cf0beb00a245d4fb250e64e42e0888f2b6d783a
MD5 93495585d762794c1db0602a603f29b8
BLAKE2b-256 4812518ad7fdfd14554a0e7ead550da205ccaaa9e3685b1e23305c5352094c97

See more details on using hashes here.

File details

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

File metadata

  • Download URL: olaverse-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 29.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for olaverse-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5449f1919f2fb5cf59a379aaceb56c80fced2e8b3f324f9c23c645fb56bb443c
MD5 daa9e104ec14219cbee1e20cc186ca77
BLAKE2b-256 ef048a8e59344a9b8e685ff00abd4b651d12c4a2259f3a9a1497c75e839ea591

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