Transformers
GGUF
sparse-attention
approximate-nearest-neighbors
faiss
qwen3
long-context
conversational
Instructions to use datasysdev/ann-sparseattention with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use datasysdev/ann-sparseattention with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("datasysdev/ann-sparseattention", dtype="auto") - llama-cpp-python
How to use datasysdev/ann-sparseattention with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="datasysdev/ann-sparseattention", filename="gguf/Qwen3-4B-Instruct-2507-F16-ann-6layer-k128-v2.gguf", )
llm.create_chat_completion( messages = "No input example has been defined for this model task." )
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use datasysdev/ann-sparseattention with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf datasysdev/ann-sparseattention:F16 # Run inference directly in the terminal: llama-cli -hf datasysdev/ann-sparseattention:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf datasysdev/ann-sparseattention:F16 # Run inference directly in the terminal: llama-cli -hf datasysdev/ann-sparseattention:F16
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf datasysdev/ann-sparseattention:F16 # Run inference directly in the terminal: ./llama-cli -hf datasysdev/ann-sparseattention:F16
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf datasysdev/ann-sparseattention:F16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf datasysdev/ann-sparseattention:F16
Use Docker
docker model run hf.co/datasysdev/ann-sparseattention:F16
- LM Studio
- Jan
- Ollama
How to use datasysdev/ann-sparseattention with Ollama:
ollama run hf.co/datasysdev/ann-sparseattention:F16
- Unsloth Studio new
How to use datasysdev/ann-sparseattention with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for datasysdev/ann-sparseattention to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for datasysdev/ann-sparseattention to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for datasysdev/ann-sparseattention to start chatting
- Pi new
How to use datasysdev/ann-sparseattention with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf datasysdev/ann-sparseattention:F16
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "datasysdev/ann-sparseattention:F16" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use datasysdev/ann-sparseattention with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf datasysdev/ann-sparseattention:F16
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default datasysdev/ann-sparseattention:F16
Run Hermes
hermes
- Docker Model Runner
How to use datasysdev/ann-sparseattention with Docker Model Runner:
docker model run hf.co/datasysdev/ann-sparseattention:F16
- Lemonade
How to use datasysdev/ann-sparseattention with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull datasysdev/ann-sparseattention:F16
Run and chat with the model
lemonade run user.ann-sparseattention-F16
List all available models
lemonade list
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -70,22 +70,31 @@ Sanity checks pass: same input sequences for `ppl_full` vs `ppl_ann`,
|
|
| 70 |
intact causal mask in retrieval, single-softmax renormalization with no
|
| 71 |
wrapper leakage between iterations.
|
| 72 |
|
| 73 |
-
###
|
| 74 |
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
|
| 81 |
-
|
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
### Per-layer recall (pilot)
|
| 91 |
|
|
@@ -102,7 +111,24 @@ Early layers are harder for content-addressable retrieval — their attention
|
|
| 102 |
is more local/positional than semantic. Consistent across K, so it's a
|
| 103 |
property of the layer rather than noise.
|
| 104 |
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
## Files
|
| 108 |
|
|
@@ -144,7 +170,8 @@ the trained layers and run with FAISS HNSW retrieval at inference time.
|
|
| 144 |
## Training recipe
|
| 145 |
|
| 146 |
- Frozen base: Qwen3-4B-Instruct-2507 (36 layers, hidden 2560, GQA 32:8).
|
| 147 |
-
- Data: WikiText-103 raw,
|
|
|
|
| 148 |
- 2000 steps, batch 8, lr 1e-4 (cosine, 100-step warmup), AdamW.
|
| 149 |
- `α=β=1` (contrastive + KL distillation, both layers averaged).
|
| 150 |
- bf16 weights, fp32 loss math.
|
|
|
|
| 70 |
intact causal mask in retrieval, single-softmax renormalization with no
|
| 71 |
wrapper leakage between iterations.
|
| 72 |
|
| 73 |
+
### Compute / quality knobs (FLOP-counted)
|
| 74 |
|
| 75 |
+
`L = 4096`. Compute reduction is the attention scoring step, ≈ `L / K`.
|
| 76 |
+
These are FLOP estimates, not measured wall-clock — the FAISS path in this
|
| 77 |
+
repo is a research prototype that does CPU index builds and GPU↔CPU
|
| 78 |
+
transfers, so it is not the right thing to time.
|
| 79 |
+
|
| 80 |
+
| K | PPL gap | Attention scoring reduction |
|
| 81 |
+
|---|---|---|
|
| 82 |
+
| 512 | −2.89% | ~8× |
|
| 83 |
+
| 256 | −0.79% | ~16× |
|
| 84 |
+
| 128 | +0.82% | ~32× |
|
| 85 |
+
| 64 | +2.42% | ~64× |
|
| 86 |
+
| 32 | +4.51% | ~128× |
|
| 87 |
+
| 16 | +7.51% | ~256× |
|
| 88 |
+
|
| 89 |
+
Eval scope: 12 sequences × 4K tokens of WikiText-103 validation (~50K
|
| 90 |
+
tokens). Read these as "what we observed on this slice", not population-
|
| 91 |
+
level estimates.
|
| 92 |
+
|
| 93 |
+
The K-sweep recall numbers (24–41%) and the in-training `evaluate()` recall
|
| 94 |
+
(50.9% at K=128) come from different sampled subsets of the streaming split
|
| 95 |
+
and shouldn't be directly compared. The repo also reports `mass@K` (sum of
|
| 96 |
+
teacher attention probability captured by the search top-K) — that's the
|
| 97 |
+
more direct retrieval-quality metric when softmax is sharp.
|
| 98 |
|
| 99 |
### Per-layer recall (pilot)
|
| 100 |
|
|
|
|
| 111 |
is more local/positional than semantic. Consistent across K, so it's a
|
| 112 |
property of the layer rather than noise.
|
| 113 |
|
| 114 |
+
### Caveats / what's next
|
| 115 |
+
|
| 116 |
+
- **Packing**: pilot training and eval ran with sequence packing on (no
|
| 117 |
+
segment-level causal mask, since transformers' default forward doesn't
|
| 118 |
+
build them). The relative PPL gap between full and ANN is internally
|
| 119 |
+
consistent under this confound, but the negative gap at K≥256 has at
|
| 120 |
+
least three candidate explanations we haven't disentangled —
|
| 121 |
+
(a) sparse-softmax denoising, (b) ANN happening to filter cross-document
|
| 122 |
+
keys that full attention attends to, (c) sample noise on a small eval.
|
| 123 |
+
The default config now has packing off so the next run isolates (a).
|
| 124 |
+
- **Exact-topK oracle**: a four-way Pareto (full vs. exact top-K vs.
|
| 125 |
+
search-topK exact vs. search-ANN) is the natural follow-up to separate
|
| 126 |
+
"denoising from any sparsity" from "denoising from learned projections."
|
| 127 |
+
- **Wall-clock**: not measured. The FAISS path in the repo is a CPU-side
|
| 128 |
+
research prototype, not a deployable runtime. A GPU-resident topk kernel
|
| 129 |
+
is the next-step engineering.
|
| 130 |
+
- **34-layer headline** was queued (`make_headline_config()` is wired) and
|
| 131 |
+
will mirror its checkpoints here when it runs.
|
| 132 |
|
| 133 |
## Files
|
| 134 |
|
|
|
|
| 170 |
## Training recipe
|
| 171 |
|
| 172 |
- Frozen base: Qwen3-4B-Instruct-2507 (36 layers, hidden 2560, GQA 32:8).
|
| 173 |
+
- Data: WikiText-103 raw, 4K-token sequences (packing was on at training
|
| 174 |
+
time; default in the repo is now off — see Caveats).
|
| 175 |
- 2000 steps, batch 8, lr 1e-4 (cosine, 100-step warmup), AdamW.
|
| 176 |
- `α=β=1` (contrastive + KL distillation, both layers averaged).
|
| 177 |
- bf16 weights, fp32 loss math.
|