Three-layer semantic compression for LLM prompts (L1+L2+L3 + Lean Mode + Columnar JSON)
Project description
SyntEx
Semantic Prompt Compression Protocol — Three-layer compression for LLM system prompts.
Why SyntEx?
| Feature | SyntEx | Plain Text | Savings |
|---|---|---|---|
| Multi-agent prompts (3+ agents) | 35-40 tokens | 100+ tokens | 60-71% |
| RAG context chunks | 50-60% | 100% | 50-60% |
| System prompts (repetitive boilerplate) | 50-60% | 100% | 50-60% |
| JSON-heavy payloads | 36-40% | 100% | 60-68% |
Target: 50% token reduction — SyntEx v1.2 achieves 60-68% on typical multi-agent and JSON use cases.
Benchmark Results (v1.2.0)
| Corpus Type | Original | Compressed | Reduction |
|---|---|---|---|
| Standard (repetitive) | 4,654 tokens | 2,405 tokens | 48.3% |
| + lorem ipsum | 10,468 tokens | 3,406 tokens | 67.5% |
| JSON-heavy (30 msgs) | 2,100 tokens | 764 tokens | 63.6% |
| Multi-agent boilerplate | 3,730 tokens | 1,964 tokens | 47.3% |
| Unique content (worst) | 1,847 tokens | 1,626 tokens | 12.0% |
Average: 46.4% | Peak: 67.5%
Configuration
SyntEx v1.2+ is fully configurable via syntex.yaml:
# thresholds.yaml
version: "1.2.0"
thresholds:
skip_cft: 25 # Text shorter triggers SKIP mode
l1_cft: 80 # L1-only vs L1+L2 boundary
min_l2_tokens: 30 # Minimum tokens for L2 compression
mirror:
ttl_minutes: 1440 # Entry TTL (24 hours)
max_capacity: 500 # Max mirror entries
pipeline:
auto_minify: true # Auto-minify JSON, Markdown, etc.
two_pass_compression: true
use_clustering: false
Quick Start
pip install syntex
Python API
from syntex import SintExSession
session = SintExSession()
result = session.compile("Your long system prompt here...")
print(f"Compressed: {result.compressed_tokens} tokens (was {result.original_tokens})")
CLI
python -m syntex compile myprompt.sx -o output.sxc
python -m syntex bench myprompt.sx
Architecture
┌─────────────────────────────────────────────────────────────────────────┐
│ SyntEx Pipeline │
├─────────────────────────────────────────────────────────────────────────┤
│ L1: Global Vocabulary → 72 Unicode symbols (Greek + Braille) │
│ L2: Local Dictionary → N-gram compression (corpus-specific) │
│ L3: Clustering → Semantic normalization (variant merge) │
└─────────────────────────────────────────────────────────────────────────┘
Core Components
| Module | Purpose |
|---|---|
SintExSession |
Main API for compile/decompile |
SintExMirror |
Shared dictionary for multi-agent communication |
AutoVocab |
ROI-based vocabulary auto-promotion |
SintExGateway |
Proxy LLM with automatic compression |
Telemetry |
Track token savings and cost ($) |
Features
Three-Layer Compression
from syntex import SintExSession
session = SintExSession(seed=["domain-specific term"])
# L1 + L2 + L3 compression
result = session.compile(system_prompt)
# Decompress
original = session.decompile(result.sxc)
Lean Mode (No Header)
# For multi-agent: send only compressed body, no header overhead
lean = session.compile_lean(system_prompt)
# Returns: body only, 2-3 token savings vs full format
Multi-Agent Communication (SintExMirror)
from syntex import SintExMirror
mirror = SintExMirror()
# Agent 1: Add candidates, build shared dictionary
candidates = ["Act as a senior architect", "Design scalable systems"]
mirror.add_candidates(candidates)
mirror.build_dict()
# Agent 2: Use same dictionary
compressed = mirror.compress(agent1_prompt, lean_mode=True)
decompressed = mirror.decompress(compressed)
AutoVocab (Automatic ROI-Based Promotion)
from syntex import AutoVocab
av = AutoVocab(threshold_roi=2.0)
av.feed(agent_interactions)
av.promote_top(max_promotions=5)
# Auto-promotes phrases with best token savings
Gateway (LLM Proxy)
from syntex import SintExGateway
gateway = SintExGateway(
api_key="sk-...",
model="gpt-4",
base_url="https://api.openai.com/v1"
)
# Compression automatic
response = gateway.chat.completions.create(
messages=[{"role": "system", "content": long_prompt}]
)
Telemetry
from syntex import Telemetry
t = Telemetry()
t.track("prompt_1", original_tokens=500, compressed_tokens=200)
t.report()
# Shows: savings %, dollars saved, ROI
CLI
syntex compile <file.sx> # Compile .sx → .sxc
syntex decompile <file.sxc> # Decompile → text
syntex bench <file.sx> # Benchmark compression
syntex tokens <file> # Count tokens
syntex version # Show version
Format
Input .sx
$role=Act as a senior software architect
@system_architect
- $role
- Design scalable systems
- Consider trade-offs
@system_reviewer
- $role
- Review designs critically
Output .sxc
[SXC]
[DICT]
$a=Act as a senior software architect
[/DICT]
[BODY]
@system_architect
- $a
- Design scalable systems
...
[/BODY]
[/SXC]
Lean Mode (no header)
[DICT]
$a=Act as a senior software architect
[/DICT]
[BODY]
@system_architect
- $a
...
[/BODY]
Changelog
v1.2.0 (current)
- Config-Driven: All magic numbers extracted to
syntex.yaml - Columnar JSON: Automatic transformation of repetitive JSON to columnar format
- Data Optimizations: Integer scaling, delta timestamps, enum encoding
- JSON Compression: 0.2% → 63.6% on JSON-heavy payloads
- Config Tests: Full test coverage for configuration system
v1.1.0
- SintExMirror: Multi-agent shared dictionary with consensus
- Lean Mode: Compression without header (2-3 token savings)
- AutoVocab: ROI-based automatic vocabulary promotion
- Thread-Safety: Locking and snapshot for concurrent ops
- Graceful Fallbacks: Auto-recovery on decompression failure
v1.0
- Full L1+L2+L3 pipeline
- 72 global vocabulary entries (Greek + Braille)
- Telemetry tracking
v0.9.x
- Initial releases with dual-layer compression
Enterprise: Solve the Rate Limit Problem
The Problem: Every LLM provider (OpenAI, Anthropic, Google) has strict rate limits. Companies running multi-agent systems burn through tokens faster than they can scale.
The Solution: SyntEx reduces token usage by 50-70% automatically.
| Metric | Before SyntEx | After SyntEx |
|---|---|---|
| 10-agents prompts | ~8,000 tokens | ~3,200 tokens |
| API calls/day (budget) | 50,000 | 20,000 |
| Monthly cost (est. $10/1M) | $500 | $200 |
| Rate limit risk | High | Eliminated |
Enterprise Features
- SintExGateway: Drop-in proxy that compresses automatically
- Telemetry: Track savings in dollars, not just tokens
- SLA Guarantee: Zero data loss (100% round-trip integrity)
- On-premise option: Your data never leaves your infrastructure
Quick Integration
from syntex import SintExGateway
gateway = SintExGateway(api_key="sk-...")
gateway.chat.completions.create(
messages=[{"role": "system", "content": large_prompt}]
)
# Automatically compressed → 50-70% fewer tokens
License
MIT — See LICENSE and LEGAL_NOTICE.md
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file syntex_protocol-1.2.4.tar.gz.
File metadata
- Download URL: syntex_protocol-1.2.4.tar.gz
- Upload date:
- Size: 132.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87fb1f1016a2c1ed7f2d4100b710f8244755edefe78d425002be801aba856a0f
|
|
| MD5 |
18203c91d80c162a25c49e9f8add13f8
|
|
| BLAKE2b-256 |
8ebea1ab2465443d3fa3ec0a1d229716e2602863eb8fc542db4772cdd5d77f12
|
Provenance
The following attestation bundles were made for syntex_protocol-1.2.4.tar.gz:
Publisher:
publish.yml on SyntEx-Protocol/SyntEx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
syntex_protocol-1.2.4.tar.gz -
Subject digest:
87fb1f1016a2c1ed7f2d4100b710f8244755edefe78d425002be801aba856a0f - Sigstore transparency entry: 1441778565
- Sigstore integration time:
-
Permalink:
SyntEx-Protocol/SyntEx@c893d2e6742bcc07f548ec283ba77d97a6f97308 -
Branch / Tag:
refs/tags/v1.2.4 - Owner: https://github.com/SyntEx-Protocol
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c893d2e6742bcc07f548ec283ba77d97a6f97308 -
Trigger Event:
release
-
Statement type:
File details
Details for the file syntex_protocol-1.2.4-py2.py3-none-any.whl.
File metadata
- Download URL: syntex_protocol-1.2.4-py2.py3-none-any.whl
- Upload date:
- Size: 202.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00392a18f469410b02fbafcd14799900c18f08ff0f2675148fe69ebe27464e61
|
|
| MD5 |
f9adf63bfc76e40dbdc6933d37a92ee1
|
|
| BLAKE2b-256 |
421e432ae5a226b9c592fc98c77444f4c89075b2a913500e865124d8a0fa9340
|
Provenance
The following attestation bundles were made for syntex_protocol-1.2.4-py2.py3-none-any.whl:
Publisher:
publish.yml on SyntEx-Protocol/SyntEx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
syntex_protocol-1.2.4-py2.py3-none-any.whl -
Subject digest:
00392a18f469410b02fbafcd14799900c18f08ff0f2675148fe69ebe27464e61 - Sigstore transparency entry: 1441778664
- Sigstore integration time:
-
Permalink:
SyntEx-Protocol/SyntEx@c893d2e6742bcc07f548ec283ba77d97a6f97308 -
Branch / Tag:
refs/tags/v1.2.4 - Owner: https://github.com/SyntEx-Protocol
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c893d2e6742bcc07f548ec283ba77d97a6f97308 -
Trigger Event:
release
-
Statement type: