Instructions to use scrallex/structural-manifold-compression with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use scrallex/structural-manifold-compression with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="scrallex/structural-manifold-compression")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("scrallex/structural-manifold-compression") model = AutoModelForCausalLM.from_pretrained("scrallex/structural-manifold-compression", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use scrallex/structural-manifold-compression with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "scrallex/structural-manifold-compression" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "scrallex/structural-manifold-compression", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/scrallex/structural-manifold-compression
- SGLang
How to use scrallex/structural-manifold-compression with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "scrallex/structural-manifold-compression" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "scrallex/structural-manifold-compression", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "scrallex/structural-manifold-compression" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "scrallex/structural-manifold-compression", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use scrallex/structural-manifold-compression with Docker Model Runner:
docker model run hf.co/scrallex/structural-manifold-compression
Document finemath-124m revision
Browse files
README.md
CHANGED
|
@@ -29,6 +29,45 @@ Use this repo if you want to **benchmark manifold LMs** or integrate the encoder
|
|
| 29 |
|
| 30 |
---
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
## Quick Start & Best-Case Workloads
|
| 33 |
- **Optimised for structured text**: PDF/page OCR exports, news briefs, technical audits—any corpus where 512 B sliding windows capture repeated structure. Expect 30–60× token compression with 94–95 % token accuracy (Fox EN/CN/OmniDoc numbers from the main repo).
|
| 34 |
- **Reproduce on a sample corpus**:
|
|
|
|
| 29 |
|
| 30 |
---
|
| 31 |
|
| 32 |
+
## New: STM-FineMath 124M (revision `finemath-124m`)
|
| 33 |
+
- 12-layer (124M) manifold LM trained on the 10 GB FineMath STEM corpus using the same `window=512 B`, `stride=384 B`, `precision=3` codec. The builder yields 50 242 samples / 25.7 M manifold tokens (≈0.27 raw tokens per signature) and fits in ~66 minutes on a single RTX 3080 Ti.
|
| 34 |
+
- Final eval loss `6.506` -> manifold perplexity `6.69e2`, while GPT-2 medium on the identical math slice lands at `7.75e3` (11.7x worse). See `benchmarks/finemath_perplexity_compare.json` in the new branch.
|
| 35 |
+
- Exact-match signature accuracies on standard math QA benchmarks (strict metric) are now recorded:
|
| 36 |
+
|
| 37 |
+
| Benchmark | Split | Subset | #Problems | Accuracy |
|
| 38 |
+
|-----------|-------|--------|-----------|----------|
|
| 39 |
+
| dim/competition_math | train | Algebra | 200 | 0.5% |
|
| 40 |
+
| dim/competition_math | train | Number Theory | 200 | 0.5% |
|
| 41 |
+
| dim/competition_math | train | Geometry | 200 | 1.0% |
|
| 42 |
+
| dim/competition_math | train | Prealgebra | 200 | 0.0% |
|
| 43 |
+
| openai/gsm8k (main) | test | - | 200 | 0.5% |
|
| 44 |
+
|
| 45 |
+
Each JSON artifact (command + parameters) is stored under `benchmarks/` on the `finemath-124m` branch.
|
| 46 |
+
|
| 47 |
+
### Loading the math-focused checkpoint
|
| 48 |
+
```python
|
| 49 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 50 |
+
|
| 51 |
+
repo_id = "scrallex/structural-manifold-compression"
|
| 52 |
+
tokenizer = AutoTokenizer.from_pretrained(repo_id, revision="finemath-124m")
|
| 53 |
+
model = AutoModelForCausalLM.from_pretrained(repo_id, revision="finemath-124m")
|
| 54 |
+
```
|
| 55 |
+
You must supply structural-manifold signatures instead of raw text. Use `scripts/data/prepare_causal_dataset.py` or `scripts/experiments/math_qa_demo.py` from the GitHub repo to encode prompts, then decode generations via `scripts/experiments/decode_signatures.py` (requires a prototype cache built from a math corpus).
|
| 56 |
+
|
| 57 |
+
### Reproducing the posted math benchmarks
|
| 58 |
+
```
|
| 59 |
+
python scripts/experiments/eval_math_dataset.py \
|
| 60 |
+
--model output/training_runs/stm_finemath_10gb \
|
| 61 |
+
--dataset-vocab output/stm_stem_finemath_10gb/vocab.json \
|
| 62 |
+
--dataset dim/competition_math --split train --subset Algebra \
|
| 63 |
+
--max-problems 200 --text-root data/raw_math/finemath_4plus_10gb \
|
| 64 |
+
--cache output/training_runs/stm_finemath_10gb/prototype_cache.json \
|
| 65 |
+
--max-new-tokens 64 --match-mode signatures
|
| 66 |
+
```
|
| 67 |
+
Switch `--dataset openai/gsm8k --dataset-config main --split test --question-field question --answer-field answer` for GSM8K. The evaluator now matches answers via signature subsequences (no prototype recovery required) so results are strict exact-matches.
|
| 68 |
+
|
| 69 |
+
---
|
| 70 |
+
|
| 71 |
## Quick Start & Best-Case Workloads
|
| 72 |
- **Optimised for structured text**: PDF/page OCR exports, news briefs, technical audits—any corpus where 512 B sliding windows capture repeated structure. Expect 30–60× token compression with 94–95 % token accuracy (Fox EN/CN/OmniDoc numbers from the main repo).
|
| 73 |
- **Reproduce on a sample corpus**:
|