digitalsolutionsai/Synthelion
112
SynthelionML
Learned per-token keep/drop prompt compressor for Synthelion.
A small, fully offline transformer encoder trained on Wikipedia corpora (39 languages) to predict which tokens can be dropped while preserving meaning. The model is trained using self-distillation: the rule-based SYNTACTIC compressor provides ground-truth labels, and the encoder learns to generalise beyond simple rules by attending to surrounding token context.
Architecture
Char-ngram hashing -> word embedding + feature embedding -> positional encoding
-> 2-layer TransformerEncoder (d=128, h=4) -> Linear(2) keep/drop logitsFormats
Quick start
PyTorch (native)
from synthelion.synthelionml import SynthelionMLCompressor
compressor = SynthelionMLCompressor.get_instance()
compressed = compressor.compress("Your long prompt text here...")ONNX Runtime
import onnxruntime as ort
import numpy as np
sess = ort.InferenceSession("synthelionml.onnx")
word_ids = np.array([[...]], dtype=np.int64) # (1, seq_len)
features = np.random.randn(1, seq_len, 18).astype(np.float32)
mask = np.ones((1, seq_len), dtype=np.bool_)
logits = sess.run(None, {
"word_ids": word_ids,
"features": features,
"attention_mask": mask,
})[0] # (1, seq_len, 2) — logits for [drop, keep]SafeTensors (HuggingFace)
from safetensors.torch import load_file
weights = load_file("model.safetensors")
# keys use "/" separator: "_word_emb.weight", "_encoder.layers.0.self_attn.in_proj_weight", etc.Training
- Data: Synthelion's Wikipedia corpora (74,100 training examples, 3,900 eval)
- Labels: Self-distillation from the aggressive rule-based compressor
- Languages: 39 (see
config.json->trained_languages) - Min compression: 70% (rank-based ratio controller)
- Runtime: Fully offline, CPU-only
Files
License
MIT License. See LICENSE for details.
