NewMx — Lossless Input-Side Prompt Compression for LLMs
NewMx™ Path 1 Copyright © 2026 Daniel Ortega. All rights reserved except as expressly licensed.
Patent notice: NewMx™ Path 1 is the subject of U.S. Provisional Patent Application No. 64/059,223, filed by Daniel Ortega personally.
Ownership notice: This repository is published through the CCC Studios GitHub account for development and distribution purposes. No assignment of patent rights, trademark rights, or other intellectual property rights to CCC Studios Inc. is implied by this publication. Any future assignment, if any, will require a separate written agreement signed by Daniel Ortega.
Compress prompts before sending them to any LLM. ...
Compress prompts before sending them to any LLM. Save tokens, save money, save context window. Works with OpenAI, Anthropic, Google, DeepSeek, and any other LLM that accepts text — no model changes, no fine-tuning, no API integration. Just pip install and encode.
from newmx import Codec
codec = Codec()
encoded = codec.encode_with_table(
"google this for me and tell me what you find about quantum decoherence"
)
# Send `encoded` to your LLM API directly.
What it does
NewMx Path 1 replaces high-frequency phrases in your prompt with single Unicode glyphs that are 1 token in cl100k_base. A decode table is prepended so the model can interpret them.
Verified compression on a 1.46M-line real-world corpus (ShareGPT + OASST):
- +6.12% input tokens saved, lossless, fully model-independent
- No comprehension regression on DeepSeek-R1 across 30 prompts × 3 conditions
- Reduces failure rate on Gemini-2.5-Flash-Lite (cli5 stripper found a tokenizer-dependent comprehension bug)
Install
pip install newmx
Zero runtime dependencies. Pure Python. Works on Python 3.9+.
Usage
Quick encode (module-level)
import newmx
# For sending to an LLM (includes decode table preamble):
prompt = newmx.encode_with_table("write me a function in rust")
# Just the encoded text, no table:
short = newmx.encode("write me a function in rust")
# → "Ä in rust"
Working with a Codec instance
from newmx import Codec
codec = Codec() # bundled v005-rev4
print(codec.codec_version) # → "v005-rev4"
print(codec.num_mappings) # → 3135
encoded = codec.encode("how to install docker on ubuntu")
# → "µ install docker on ubuntu"
decoded = codec.decode(encoded)
# → "how to install docker on ubuntu"
result = codec.encode_detailed("rest of the article in the magazine")
# Returns EncodingResult with .raw, .normalized, .encoded, .replacements, .is_code
Full LLM-ready prompt with decode table
from openai import OpenAI
from newmx import Codec
codec = Codec()
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "user", "content": codec.encode_with_table(
"google this for me and tell me what you find about quantum decoherence"
)},
],
)
Important: amortizing the decode table
The decode table costs ~3,850 cl100k_base tokens. For a single one-shot prompt, NewMx is a net token loss. The savings come when you reuse the table across many prompts:
- Multi-turn conversations — table sent once at conversation start, savings compound across every subsequent encoded turn
- API prompt-caching (OpenAI, Anthropic) — the table is a stable prefix, automatically cached after first call
- System prompt installation — put the decode table in your system prompt once; user messages are then just the encoded text
Break-even point is roughly 60+ encoded prompts in a session. If you're using NewMx for a single API call, it will cost you tokens, not save them. This is a known tradeoff and the topic of the second half of the paper.
How it works
- Normalize — strip emojis, politeness fillers, instruction wrappers, AI-addressing greetings, trailing courtesy phrases
- Family-pass encode — replace intent phrases (38 categories) with family glyphs, with a fixed-point iteration over conjunction-aware boundaries
- Structural-pass encode — replace common phrase substitutions ("of the", "in the", "what is the difference between") with structural glyphs
- Pre-glyph-space strip (cli5) — collapse the BPE orphan-space cost at every glyph boundary
The codec is built on real frequency data from a 1.46M-line corpus of ShareGPT + OpenAssistant prompts. Glyphs are pre-validated as 1-token under cl100k_base.
What's in the box
newmx/maps/path1_en_b3_v005_rev4.json— the bundled production codec (3,135 mappings, 38 families)- Full encoder, decoder, normalizer
- Code-line detection (skips encoding for code/SQL/HTML)
- Multi-line prompt support
Honest tradeoffs
- Decode-table cost — see above. Not a fit for one-shot calls.
- Compression is best on intent-heavy prompts ("write me X", "what is the difference between A and B"). Pure prose paragraphs see modest savings.
- Family glyphs are lossy at decode — "tell me what you find" and "tell me what you found" both compress to the same glyph, and decode back to a canonical representative phrase. This is fine for LLM-side comprehension (which is what matters) but not for round-tripping arbitrary text.
- CJK-heavy decode table can prime non-English responses on some models. Working on a Latin-Extended-biased variant.
Citation
If you use NewMx in research, please cite:
@misc{ortega2026newmx,
author = {Ortega, Daniel},
title = {NewMx赤: Lossless Input-Side Prompt Compression via Phrase-to-Glyph Encoding},
year = {2026},
eprint = {arXiv:TBD},
}
License
Apache 2.0. See LICENSE.
Author
Daniel Ortega.
Metadata
Release files for newmx 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| newmx-0.1.1.tar.gz | 57.7 kB | Without provenance | Details for newmx-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| newmx-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for newmx-0.1.1-py3-none-any.whl |
Total release size: 115.7 kB
Release files / newmx-0.1.1.tar.gz
| Download URL | newmx-0.1.1.tar.gz |
|---|---|
| Size | 57.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
478e982a04bd9e96cea135f869a7bd9b7756938ef5bee9a772a195da6ad59e0b
|
|
BLAKE2b-256 checksum How to use checksums |
c5027d2cd2a300a9333d8fb316011b8994aa52b5ebe99506a7b6e0caba2d879a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / newmx-0.1.1-py3-none-any.whl
| Download URL | newmx-0.1.1-py3-none-any.whl |
|---|---|
| Size | 58.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a56cc85668fb5a557cc769d63e83f77fc47a9dd71d25974661c7b1bc0b411487
|
|
BLAKE2b-256 checksum How to use checksums |
6b2851b06210439a8510aed946eeaf4cd5d0ae26fc7b311669e2472af7bd2c11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Security for newmx 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.