Skip to main content

JengaNLP

Open In Colab

Config-driven multi-task NLP. Train one shared transformer encoder with many task heads — classification, sentiment, NER, regression and checklist-style QA scoring — from a single YAML file, then serve it with a load-once inference pipeline.

Status: alpha (2.1.0). The core text workflow — config → train → evaluate → predict → InferencePipeline — is tested and is the supported path. Everything else is marked experimental below.

What JengaNLP is, honestly

JengaNLP is built on PyTorch and Hugging Face Transformers. For a single classifier, the Hugging Face Trainer is a fine choice, and JengaNLP is mostly a convenience layer on top of the same ideas.

Where JengaNLP does more than a training wrapper:

  • Multi-task models are the default, not a research project. One encoder, several tasks, several heads per task, per-head loss weights, and task sampling strategies (round_robin, proportional, temperature) — all declared in YAML.
  • Checklist QA scoring (qa_scoring). Score call-centre transcripts against weighted rubric sections (opening, listening, resolution, …) as multi-head binary checklists — a task type you would otherwise hand-build.
  • Production inference included. InferencePipeline loads once, predicts single or batch, returns structured per-head results with confidences, and flags PII in inputs.
  • One artefact layout. Training, evaluation, resume, checkpoints and inference all read the same saved config and model directory.

What is not here yet: pretrained JengaNLP checkpoints, published benchmarks, and African-language base models and datasets. Those are the roadmap, not current features — see Roadmap.

Install

pip install jenga-nlp

Requires Python 3.10+. Optional extras:

Extra Installs When you need it
jenga-nlp[asr] accelerate, peft, librosa, soundfile Whisper ASR workflows (experimental)
jenga-nlp[wandb] wandb Weights & Biases experiment tracking
jenga-nlp[dev] pytest, ruff, mypy Working on JengaNLP itself

From source:

git clone https://github.com/Rogendo/JengaNLP.git
cd JengaNLP
pip install -e ".[dev]"

Quickstart (5 minutes, CPU)

Try it in your browser first: the starter notebook installs jenga-nlp in Google Colab and trains a Swahili/Sheng M-PESA fraud classifier, then a two-task model, with no local setup. The same steps on your own machine:

1. Data — JSONL, JSON or CSV with a text column and a label column:

mkdir -p jenganlp_demo
cat > jenganlp_demo/messages.jsonl <<'JSONL'
{"text":"Urgent M-PESA reversal request. Share your PIN now.","label":1}
{"text":"Your payment has been received successfully.","label":0}
{"text":"Congratulations, send your PIN to claim the prize.","label":1}
{"text":"Please visit the nearest branch for help.","label":0}
{"text":"Account blocked. Reply with your secret code.","label":1}
{"text":"Your statement is ready for download.","label":0}
JSONL

2. Config — run every command from the folder that contains jenganlp_demo/:

cat > jenganlp_demo/config.yaml <<'YAML'
project_name: demo_mpesa_fraud
model:
  base_model: distilbert-base-uncased
tokenizer:
  max_length: 64
tasks:
  - name: mpesa_fraud_detection
    type: single_label_classification
    data_path: jenganlp_demo/messages.jsonl
    text_column: text
    label_column: label
    heads:
      - name: fraud_head
        num_labels: 2
training:
  output_dir: jenganlp_demo/model
  batch_size: 2
  num_epochs: 3
  device: cpu
  logging:
    service: none
  data:
    test_size: 0.33
YAML

3. Train, evaluate, predict:

jenga-nlp train    --config jenganlp_demo/config.yaml
jenga-nlp evaluate --config jenganlp_demo/config.yaml --model-dir jenganlp_demo/model
jenga-nlp predict  --config jenganlp_demo/config.yaml --model-dir jenganlp_demo/model \
  --task-name mpesa_fraud_detection --text "Urgent M-PESA reversal request asking for PIN"

4. Load once in Python (notebooks, batch jobs, services):

from jenga_nlp.inference.pipeline import InferencePipeline

pipeline = InferencePipeline.from_checkpoint(
    model_dir="jenganlp_demo/model",
    config_path="jenganlp_demo/config.yaml",
    device="cpu",
)
print(pipeline.predict(text="Urgent M-PESA reversal request asking for PIN",
                       task_name="mpesa_fraud_detection").to_dict())

Six examples prove the pipeline works, not that the model is good. A perfect score on a handful of eval samples is meaningless — use hundreds of labelled examples per class before trusting predictions.

Task types

type Labels look like Example use
single_label_classification 1 Fraud vs legitimate message
multi_label_classification {"risk_tags": [1, 1, 0, 1]} Several risk tags per message
sentiment 2 Negative / neutral / positive
ner entity spans Names, amounts, phone numbers
regression 0.73 Risk or quality score
qa_scoring {"opening": [1], "resolution": [1, 0, 1, 1, 0]} Call-centre QA checklists

Multi-task: list several tasks under tasks: — they share the encoder. See examples/configs/fixture_multitask_cpu.yaml.

Stable vs experimental

Area Status
YAML config, text training, evaluation, resume, checkpoints Stable — covered by tests
InferencePipeline (single + batch), CLI predict Stable — covered by tests
MLflow / TensorBoard logging Stable
Hugging Face Hub export Experimental
Whisper ASR fine-tuning and serving Experimental — not yet validated on real audio/GPU; needs ffmpeg installed to read audio files
Domain-adaptive MLM pretraining (jenga-nlp mlm) Experimental — tested on CPU with small models; not yet run on GPU-scale corpora
Weights & Biases, Label Studio adapters Experimental
Explainability, human-in-the-loop routing, audit logging Experimental

Experimental features may change or move out of the core package.

Documentation

Full documentation: https://rogendo.github.io/JengaNLP/

Roadmap

  1. African-language base models — adapt an African-language encoder (AfriBERTa / AfroXLMR) to Swahili, Sheng and Swahili–English code-switched text. The training workflow is available as jenga-nlp mlm (experimental); adapted models and their evaluations are next.
  2. Benchmarks — public results on African-language datasets, including multi-task vs single-task baselines.
  3. Ready-made templates with pretrained checkpoints — mobile-money fraud, call-centre QA, Swahili sentiment, on the Hugging Face Hub.

License

MIT — see LICENSE.

Metadata

Release files for jenga-nlp 2.1.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 jenga-nlp 2.1.0
File Size Uploaded Provenance Actions
jenga_nlp-2.1.0.tar.gz 174.6 kB With provenance Details for jenga_nlp-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jenga-nlp 2.1.0
File Interpreter ABI Platform Actions
jenga_nlp-2.1.0-py3-none-any.whl Python 3 none any Details for jenga_nlp-2.1.0-py3-none-any.whl

Total release size: 310.5 kB

Release files / jenga_nlp-2.1.0.tar.gz

Download URL jenga_nlp-2.1.0.tar.gz
Size 174.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5ecb0c1d21c436f0eba42dda6b750fcd4fc81319172459199e51d68c557e2a75
BLAKE2b-256 checksum
How to use checksums
bd9ddb6113784a87def982be2a6d2affd4ac1141d442650e239244cc392d1a72
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 17, 2026.

Transparency log

Release files / jenga_nlp-2.1.0-py3-none-any.whl

Download URL jenga_nlp-2.1.0-py3-none-any.whl
Size 135.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e3bf241287cdcbc92df15ce3e15b631de5182e6b69856f77d2be1f8da05d99d
BLAKE2b-256 checksum
How to use checksums
fe7563db63b46226d82be5b61a4d7cfc5261f6174adf69c7201380c7c87ee347
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 17, 2026.

Transparency log

Security for jenga-nlp 2.1.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 jenga_nlp-2.1.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 17, 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.

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files Full provenance

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