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:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("datasysdev/ann-sparseattention", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use datasysdev/ann-sparseattention with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -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 serve -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
- Llama new
- LM Studio
- Jan
- Ollama
How to use datasysdev/ann-sparseattention with Ollama:
ollama run hf.co/datasysdev/ann-sparseattention:F16
- Unsloth Desktop
- Pi
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 serve -hf datasysdev/ann-sparseattention:F16
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/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
- 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
- Hermes Agent
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 serve -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
- Atomic Chat
- OpenClaw
How to use datasysdev/ann-sparseattention with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf datasysdev/ann-sparseattention:F16
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "datasysdev/ann-sparseattention:F16" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -29,31 +29,39 @@ replacing dense `O(L²)` attention with `O(L·K)` ANN-substituted attention.
|
|
| 29 |
|
| 30 |
Layers covered (pilot): `[4, 8, 12, 16, 20, 24]` — 6 of 36 layers, ~2M trainable params.
|
| 31 |
|
| 32 |
-
## Pilot results (
|
| 33 |
|
| 34 |
| Step | Recall@K=128 | PPL gap (full vs ANN) |
|
| 35 |
|---|---|---|
|
| 36 |
| 500 | 47.4% | 1.21% |
|
| 37 |
| 1000 | 50.7% | 0.68% |
|
|
|
|
|
|
|
| 38 |
|
| 39 |
PPL gap is the primary signal — at <1% relative gap, the model's output
|
| 40 |
-
quality is preserved under ANN substitution.
|
| 41 |
-
the
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
## Files
|
| 45 |
|
| 46 |
| File | What |
|
| 47 |
|---|---|
|
| 48 |
-
| `search_step_1000.pt` |
|
| 49 |
-
| `
|
|
|
|
|
|
|
| 50 |
|
| 51 |
## Loading
|
| 52 |
|
| 53 |
```python
|
| 54 |
import torch
|
| 55 |
from transformers import AutoModelForCausalLM
|
| 56 |
-
|
|
|
|
| 57 |
|
| 58 |
base = AutoModelForCausalLM.from_pretrained(
|
| 59 |
"Qwen/Qwen3-4B-Instruct-2507",
|
|
@@ -68,7 +76,7 @@ search = SearchProjectionModule(
|
|
| 68 |
use_mlp=False,
|
| 69 |
).to(base.device).to(torch.bfloat16)
|
| 70 |
|
| 71 |
-
ckpt = torch.load("
|
| 72 |
search.load_state_dict(ckpt["search_module"])
|
| 73 |
```
|
| 74 |
|
|
@@ -84,6 +92,7 @@ the trained layers and run with FAISS HNSW retrieval at inference time.
|
|
| 84 |
- bf16 weights, fp32 loss math.
|
| 85 |
- SDPA attention (B200, no flash-attn package needed).
|
| 86 |
- Liger fused RMSNorm/SwiGLU/RoPE on the frozen base.
|
|
|
|
| 87 |
|
| 88 |
## License
|
| 89 |
|
|
|
|
| 29 |
|
| 30 |
Layers covered (pilot): `[4, 8, 12, 16, 20, 24]` — 6 of 36 layers, ~2M trainable params.
|
| 31 |
|
| 32 |
+
## Pilot results (final, 2K steps on WikiText-103)
|
| 33 |
|
| 34 |
| Step | Recall@K=128 | PPL gap (full vs ANN) |
|
| 35 |
|---|---|---|
|
| 36 |
| 500 | 47.4% | 1.21% |
|
| 37 |
| 1000 | 50.7% | 0.68% |
|
| 38 |
+
| 1500 | 50.9% | 0.68% |
|
| 39 |
+
| **2000 (final)** | **50.9%** | **0.71%** |
|
| 40 |
|
| 41 |
PPL gap is the primary signal — at <1% relative gap, the model's output
|
| 42 |
+
quality is preserved under ANN substitution. Recall plateaus around step 1000
|
| 43 |
+
because the softmax-relevant keys concentrate in the top ~30; disagreement
|
| 44 |
+
on positions 30-128 is on near-zero-weight tail and doesn't affect output.
|
| 45 |
+
|
| 46 |
+
A K-retrieve Pareto sweep follows below; a 34-layer headline run on 8K context
|
| 47 |
+
extends the deployment story.
|
| 48 |
|
| 49 |
## Files
|
| 50 |
|
| 51 |
| File | What |
|
| 52 |
|---|---|
|
| 53 |
+
| `search_step_1000.pt` | Mid-training checkpoint (step 1000, 0.68% PPL gap) |
|
| 54 |
+
| `search_step_2000.pt` | Final pilot checkpoint (step 2000, 0.71% PPL gap) |
|
| 55 |
+
|
| 56 |
+
Each contains `{step, search_module: state_dict, optimizer, scheduler, config}`.
|
| 57 |
|
| 58 |
## Loading
|
| 59 |
|
| 60 |
```python
|
| 61 |
import torch
|
| 62 |
from transformers import AutoModelForCausalLM
|
| 63 |
+
# Search module class is in the GitHub repo (model.py)
|
| 64 |
+
from model import SearchProjectionModule
|
| 65 |
|
| 66 |
base = AutoModelForCausalLM.from_pretrained(
|
| 67 |
"Qwen/Qwen3-4B-Instruct-2507",
|
|
|
|
| 76 |
use_mlp=False,
|
| 77 |
).to(base.device).to(torch.bfloat16)
|
| 78 |
|
| 79 |
+
ckpt = torch.load("search_step_2000.pt", map_location="cpu", weights_only=False)
|
| 80 |
search.load_state_dict(ckpt["search_module"])
|
| 81 |
```
|
| 82 |
|
|
|
|
| 92 |
- bf16 weights, fp32 loss math.
|
| 93 |
- SDPA attention (B200, no flash-attn package needed).
|
| 94 |
- Liger fused RMSNorm/SwiGLU/RoPE on the frozen base.
|
| 95 |
+
- Total wall-clock: ~25 min on a single B200.
|
| 96 |
|
| 97 |
## License
|
| 98 |
|