Instructions to use APEXE3HQ/sec10k-analyst-2b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use APEXE3HQ/sec10k-analyst-2b 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 APEXE3HQ/sec10k-analyst-2b:F16 # Run inference directly in the terminal: llama cli -hf APEXE3HQ/sec10k-analyst-2b:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf APEXE3HQ/sec10k-analyst-2b:F16 # Run inference directly in the terminal: llama cli -hf APEXE3HQ/sec10k-analyst-2b:F16
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf APEXE3HQ/sec10k-analyst-2b:F16 # Run inference directly in the terminal: ./build/bin/llama cli -hf APEXE3HQ/sec10k-analyst-2b:F16
Use Docker
docker model run hf.co/APEXE3HQ/sec10k-analyst-2b:F16
- Llama new
- LM Studio
- Jan
- Ollama
How to use APEXE3HQ/sec10k-analyst-2b with Ollama:
ollama run hf.co/APEXE3HQ/sec10k-analyst-2b:F16
- Unsloth Desktop
- Pi
How to use APEXE3HQ/sec10k-analyst-2b with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf APEXE3HQ/sec10k-analyst-2b: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:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "APEXE3HQ/sec10k-analyst-2b:F16" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use APEXE3HQ/sec10k-analyst-2b with Docker Model Runner:
docker model run hf.co/APEXE3HQ/sec10k-analyst-2b:F16
- Lemonade
How to use APEXE3HQ/sec10k-analyst-2b with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull APEXE3HQ/sec10k-analyst-2b:F16
Run and chat with the model
lemonade run user.sec10k-analyst-2b-F16
List all available models
lemonade list
- Hermes Agent
How to use APEXE3HQ/sec10k-analyst-2b with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf APEXE3HQ/sec10k-analyst-2b: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:9931/v1 hermes config set model.default APEXE3HQ/sec10k-analyst-2b:F16
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use APEXE3HQ/sec10k-analyst-2b with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf APEXE3HQ/sec10k-analyst-2b: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:9931/v1 \ --custom-model-id "APEXE3HQ/sec10k-analyst-2b: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"
File size: 16,254 Bytes
5073823 5352590 5073823 5352590 5073823 5352590 5073823 5352590 5073823 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | """Isolated one-base/four-LoRA prototype. Import never loads models or CUDA.
This is a different numerical architecture from quantized merged checkpoints.
It has no accuracy claim and is not wired into the running app or benchmark.
"""
from __future__ import annotations
from contextlib import contextmanager
import hashlib
import os
from pathlib import Path
import threading
ROLES = ("first", "tournament", "judge_bidir", "judge_causal")
BIDIRECTIONAL = frozenset(("tournament", "judge_bidir"))
INT32_MAX = 0x7FFFFFFF
def file_sha256(path):
digest = hashlib.sha256()
with Path(path).open("rb") as stream:
for chunk in iter(lambda: stream.read(8 * 1024 * 1024), b""):
digest.update(chunk)
return digest.hexdigest()
def validate_manifest(manifest):
"""Require explicit provenance and identities; never guess a common base."""
if manifest.get("common_base_verified") is not True:
raise ValueError("Exact original common base has not been verified")
base = manifest["base"]
if file_sha256(base["gguf_path"]) != base["gguf_sha256"]:
raise ValueError("Shared base GGUF hash mismatch")
roles = manifest["roles"]
if set(roles) != set(ROLES):
raise ValueError("Exactly the four frozen role mappings are required")
for role in ROLES:
row = roles[role]
if row["common_base_identity"] != base["original_hf_identity"]:
raise ValueError("Adapter common-base lineage mismatch: " + role)
if file_sha256(row["adapter_gguf_path"]) != row["adapter_gguf_sha256"]:
raise ValueError("Adapter GGUF hash mismatch: " + role)
if not row.get("original_adapter_provenance"):
raise ValueError("Missing original adapter provenance: " + role)
# HF tokenizer/config files determine the frozen prompt/temperature recipe.
for name, expected in row["metadata_sha256"].items():
if Path(name).name != name or not (name.endswith(".json") or name == "chat_template.jinja"):
raise ValueError("Metadata must name local JSON or chat template files")
if file_sha256(Path(row["metadata_dir"]) / name) != expected:
raise ValueError("Frozen role metadata hash mismatch: " + role)
if not {"tokenizer.json", "tokenizer_config.json", "decider_config.json"}.issubset(row["metadata_sha256"]):
raise ValueError("Missing tokenizer or decider configuration identity")
return manifest
class SharedBaseRuntime:
"""Four persistent adapters, two attention-mode contexts, one base handle.
Different attention modes can execute concurrently. Each physical context is locked.
There is no cross-request KV cache. Every request clears memory and specifies
all four scales; cleanup removes every adapter even on inference failure.
The backend owns model construction and must implement these small methods.
"""
def __init__(self, manifest, backend, *, validate=True, context_pool="by_attention"):
if context_pool not in ("per_role", "by_attention"):
raise ValueError("Unknown context pool policy")
self.manifest = validate_manifest(manifest) if validate else manifest
self.backend = backend
self._condition = threading.Condition()
self._closing = False
self._active = 0
self._closed = False
self.context_pool = context_pool
self._dependents = []
self._locks = {role: threading.Lock() for role in ROLES}
self._poisoned = set()
self.model = None
self.adapters = {}
self.contexts = {}
self._physical_contexts = []
try:
self.model = backend.load_model(manifest["base"]["gguf_path"], n_gpu_layers=0 if os.environ.get("SEC10K_DEVICE", "").lower() == "cpu" else INT32_MAX)
for role in ROLES:
row = manifest["roles"][role]
self.adapters[role] = backend.load_adapter(self.model, row["adapter_gguf_path"])
# Initialize sequentially. There is no process-wide attention monkeypatch.
for role in ROLES:
representative = ("tournament" if role in BIDIRECTIONAL else "first") if context_pool == "by_attention" else role
if representative in self.contexts:
self.contexts[role] = backend.create_role_view(
self.contexts[representative], role=role,
metadata_dir=manifest["roles"][role]["metadata_dir"])
self._locks[role] = self._locks[representative]
continue
self.contexts[role] = backend.create_context(
self.model, role=role, metadata_dir=manifest["roles"][role]["metadata_dir"],
n_ctx=8192 if role in BIDIRECTIONAL else 16384,
n_seq_max=1, n_threads=int(os.environ.get("SEC10K_THREADS", "8") or 8), causal=role not in BIDIRECTIONAL,
n_ubatch=8192 if role in BIDIRECTIONAL else 2048)
self._physical_contexts.append(self.contexts[role])
except BaseException:
self.close()
raise
@contextmanager
def _request_slot(self, role):
if role not in ROLES:
raise ValueError("Unknown frozen role")
with self._condition:
if self._closing or self._closed:
raise RuntimeError("Runtime is closing or closed")
self._active += 1
try:
with self._locks[role]:
if role in self._poisoned:
raise RuntimeError("Context failed cleanup and cannot be reused")
yield self.contexts[role]
finally:
with self._condition:
self._active -= 1
self._condition.notify_all()
def request(self, role, path, body=None):
if path != "/v1/systemone":
raise ValueError("Only frozen systemone calls are supported")
if not isinstance(body, dict) or set(body) != {"state", "questions"}:
raise ValueError("Expected exact state/questions payload")
scales = {name: float(name == role) for name in ROLES}
with self._request_slot(role) as context:
try:
self.backend.clear_adapters(context)
self.backend.clear_memory(context)
self.backend.set_adapters(context, self.adapters, scales)
self.backend.assert_attention(context, causal=role not in BIDIRECTIONAL)
return self.backend.system_one(context, body["state"], body["questions"])
finally:
try:
self.backend.clear_adapters(context)
self.backend.clear_memory(context)
except BaseException:
# Cleanup failure invalidates every view of this physical context.
self._poisoned.update(name for name in ROLES if self._locks[name] is self._locks[role])
raise
def close(self):
with self._condition:
if self._closed:
return
self._closing = True
while self._active:
self._condition.wait()
self._closed = True
for close_dependent in reversed(self._dependents):
close_dependent()
self._dependents.clear()
# Contexts refer to adapter/model handles: free them before their owners.
for context in reversed(self._physical_contexts):
self.backend.free_context(context)
self._physical_contexts.clear()
self.contexts.clear()
for adapter in reversed(list(self.adapters.values())):
self.backend.free_adapter(adapter)
self.adapters.clear()
if self.model is not None:
self.backend.free_model(self.model)
self.model = None
def register_dependent(self, close_callback):
"""Register an owner of borrowed contexts/adapters before base teardown.
A dependent must stop accepting requests and drain its active calls in
its close callback. Registration happens before serving requests.
"""
with self._condition:
if self._closing or self._closed:
raise RuntimeError("Cannot register after shutdown starts")
if close_callback in self._dependents:
raise ValueError("Dependent already registered")
self._dependents.append(close_callback)
def __enter__(self):
return self
def __exit__(self, *exc):
self.close()
class NativeBackend:
"""llama-cpp-python C API + unchanged Decider scoring/prompt methods.
Construction/import is explicit. This code has only source/mock validation
until an exact common base and all four original adapters are available.
"""
def __init__(self):
import llama_cpp
self.L = llama_cpp
required = ("llama_adapter_lora_init", "llama_set_adapters_lora",
"llama_memory_clear", "llama_get_memory", "llama_set_causal_attn",
"llama_get_causal_attn")
if any(not hasattr(self.L, name) for name in required):
raise RuntimeError("Installed llama.cpp lacks required context-local APIs")
if not self.L.llama_supports_gpu_offload() and not os.environ.get("SEC10K_DEVICE", "").lower() == "cpu":
raise RuntimeError("CUDA offload support is required for this prototype")
self.L.llama_backend_init()
def load_model(self, path, *, n_gpu_layers):
import os
params = self.L.llama_model_default_params()
params.n_gpu_layers = n_gpu_layers
params.main_gpu = 0
model = self.L.llama_model_load_from_file(os.fsencode(path), params)
if not model:
raise RuntimeError("Shared base model load failed")
return model
def load_adapter(self, model, path):
import os
adapter = self.L.llama_adapter_lora_init(model, os.fsencode(path))
if not adapter:
raise RuntimeError("LoRA load failed: " + str(path))
return adapter
def create_context(self, model, *, role, metadata_dir, n_ctx, n_seq_max, n_threads, causal, n_ubatch):
import numpy as np
from types import SimpleNamespace
from transformers import AutoTokenizer
from decider.prompt import letter_ids
import decider.engine_gguf as module
from decider.infer import Decider
L = self.L
class BorrowedEngine(module.GGUFEngine):
def __del__(self):
# Model and adapter ownership belongs exclusively to runtime.
pass
engine = BorrowedEngine.__new__(BorrowedEngine)
engine.L, engine.model = L, model
engine.ctx = engine.batch = None
try:
engine.tok = AutoTokenizer.from_pretrained(metadata_dir, local_files_only=True)
engine.letters = np.asarray(letter_ids(engine.tok))
engine.m = SimpleNamespace(tok=engine.tok)
params = L.llama_context_default_params()
params.n_ctx = params.n_batch = n_ctx
params.n_ubatch, params.n_seq_max = n_ubatch, n_seq_max
params.kv_unified = True
params.n_threads = params.n_threads_batch = n_threads
if not causal:
if not hasattr(params, "attention_type") or not hasattr(L, "LLAMA_ATTENTION_TYPE_NON_CAUSAL"):
raise RuntimeError("Noncausal context construction is unavailable")
params.attention_type = L.LLAMA_ATTENTION_TYPE_NON_CAUSAL
engine.ctx = L.llama_init_from_model(model, params)
if not engine.ctx:
raise RuntimeError("Context allocation failed: " + role)
L.llama_set_causal_attn(engine.ctx, causal)
engine.n_ctx, engine.n_batch, engine.n_seq_max = n_ctx, min(8192, n_ctx), n_seq_max
engine.n_vocab = L.llama_vocab_n_tokens(L.llama_model_get_vocab(model))
engine.batch = L.llama_batch_init(n_ctx, 0, n_seq_max)
engine.dev = "gguf"
engine.cfg = dict(backend="llama.cpp", n_ctx=n_ctx, n_seq_max=n_seq_max)
engine.stats = dict(forwards=0)
# Use unchanged Decider config/temperature/layout initialization, while
# supplying our already constructed engine instead of loading a model.
# Startup is sequential in this isolated process; restore immediately.
original = module.GGUFEngine
try:
module.GGUFEngine = lambda *args, **kwargs: engine
decider = Decider(metadata_dir, gguf_file="shared-model-owned-by-runtime.gguf",
gguf_options={"n_ctx": n_ctx, "n_seq_max": n_seq_max})
finally:
module.GGUFEngine = original
context = SimpleNamespace(engine=engine, decider=decider, role=role)
self.assert_attention(context, causal=causal)
return context
except BaseException:
if engine.batch is not None:
L.llama_batch_free(engine.batch)
if engine.ctx:
L.llama_free(engine.ctx)
raise
def create_role_view(self, context, *, role, metadata_dir):
"""Separate frozen config/tokenizer/temperatures, one attention-mode engine."""
import numpy as np
from types import SimpleNamespace
from transformers import AutoTokenizer
from decider.prompt import letter_ids
import decider.engine_gguf as module
from decider.infer import Decider
tokenizer = AutoTokenizer.from_pretrained(metadata_dir, local_files_only=True)
# A shared scoring engine has one letter-logit projection and vocabulary.
# Fail closed if role-specific metadata changes that projection/template.
if not np.array_equal(np.asarray(letter_ids(tokenizer)), context.engine.letters):
raise ValueError("Pooled role has different answer-letter token IDs")
if tokenizer.get_vocab() != context.engine.tok.get_vocab() or tokenizer.chat_template != context.engine.tok.chat_template:
raise ValueError("Pooled role tokenizer/template differs")
original = module.GGUFEngine
try:
module.GGUFEngine = lambda *args, **kwargs: context.engine
decider = Decider(metadata_dir, gguf_file="shared-model-owned-by-runtime.gguf")
finally:
module.GGUFEngine = original
return SimpleNamespace(engine=context.engine, decider=decider, role=role)
def set_adapters(self, context, adapters, scales):
import ctypes
pointer_type = self.L.llama_adapter_lora_p_ctypes
handles = (pointer_type * len(ROLES))(*(adapters[r] for r in ROLES))
values = (ctypes.c_float * len(ROLES))(*(scales[r] for r in ROLES))
if self.L.llama_set_adapters_lora(context.engine.ctx, handles, len(ROLES), values) != 0:
raise RuntimeError("Context adapter assignment failed")
def clear_adapters(self, context):
if self.L.llama_set_adapters_lora(context.engine.ctx, None, 0, None) != 0:
raise RuntimeError("Context adapter cleanup failed")
def clear_memory(self, context):
self.L.llama_memory_clear(self.L.llama_get_memory(context.engine.ctx), True)
def assert_attention(self, context, *, causal):
if bool(self.L.llama_get_causal_attn(context.engine.ctx)) != causal:
raise RuntimeError("Context attention mode mismatch")
def system_one(self, context, state, questions):
return context.decider.system_one(state, questions)
def free_context(self, context):
try:
self.clear_adapters(context)
finally:
self.L.llama_batch_free(context.engine.batch)
self.L.llama_free(context.engine.ctx)
context.engine.batch = context.engine.ctx = None
context.engine.model = None
def free_adapter(self, adapter):
self.L.llama_adapter_lora_free(adapter)
def free_model(self, model):
self.L.llama_model_free(model)
|