Instructions to use Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-Cyber with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-Cyber with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-Cyber", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-Cyber", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-Cyber with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-Cyber" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-Cyber", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-Cyber
- SGLang
How to use Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-Cyber 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 "Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-Cyber" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-Cyber", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-Cyber" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-Cyber", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-Cyber with Docker Model Runner:
docker model run hf.co/Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-Cyber
K2-Horizon-4x0.9B-MoE-Cyber
K2-Horizon-4x0.9B-MoE-heretic fine-tuned for cybersecurity questions: defense, detection, vulnerability analysis, MITRE ATT&CK.
Usage · Results · Training data · Training · Limits · Credits
| Base | Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-heretic (Apache-2.0) |
| Architecture | k2_horizon MoE: 4 experts per layer, top-1 routing, 3.06B total / 1.08B active parameters |
| Fine-tune | LoRA on 30,240 cybersecurity instruction rows, merged into the weights |
| Context | 128K (YaRN, as the base); trained on sequences up to 2,048 tokens |
| Precision | bf16, 6.1 GB |
| Try it | in your browser (runs locally with wllama) |
| Version | Repo | Runs with |
|---|---|---|
| bf16 (this card's model) | K2-Horizon-4x0.9B-MoE-Cyber | transformers (trust_remote_code) |
| MLX 8-bit | K2-Horizon-4x0.9B-MoE-Cyber-MLX-8bit | mlx-lm (--trust-remote-code) |
| MLX 4-bit | K2-Horizon-4x0.9B-MoE-Cyber-MLX-4bit | mlx-lm (--trust-remote-code) |
| GGUF BF16 / Q8_0 / Q6_K / Q5_K_M / Q4_K_M | K2-Horizon-4x0.9B-MoE-Cyber-GGUF | llama.cpp, LM Studio, Ollama (llama.cpp build 12110+) |
| Browser | K2-Horizon Cyber Chat | any recent desktop browser, runs locally |
Usage
Needs transformers 5.x and trust_remote_code=True (the architecture code ships with the repo).
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-Cyber"
device = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, dtype=torch.bfloat16, trust_remote_code=True).to(device)
msgs = [{"role": "user", "content": "How can a SOC detect Kerberoasting?"}]
text = tok.apply_chat_template(msgs, add_generation_prompt=True, tokenize=False) # reasoning_effort="none" is the default
ids = tok(text, return_tensors="pt", add_special_tokens=False).to(model.device)
out = model.generate(**ids, max_new_tokens=1024, do_sample=True, temperature=0.3, top_p=0.95)
print(tok.decode(out[0, ids["input_ids"].shape[1]:], skip_special_tokens=True))
Results
| Model | CyberMetric-500 | ARC-Easy (500) | Held-out answer loss |
|---|---|---|---|
| K2-Horizon-4x0.9B-MoE-heretic (base) | 0.714 | 0.782 | 1.686 |
| This model (bf16) | 0.732 | 0.770 | 1.020 |
| MLX 8-bit | 0.732 | – | 1.021 |
| MLX 4-bit | 0.684 | – | 1.162 |
Multiple choice is scored by the log-probability of each option letter right after Answer: in the
assistant turn, in no-think mode, with the same prompt for every model. CyberMetric-500 is
tihanyin/CyberMetric (Apache-2.0); ARC-Easy is the first 500
questions of the allenai/ai2_arc test split. The held-out loss is the mean answer-token loss on the
200 validation rows that were never trained on. Rows whose question matched a CyberMetric or ARC
question were removed from the training data. 500 questions give roughly ±0.02 (one standard error).
Reading the numbers. The held-out loss drop is large: the model learned the style and content of the training answers. The multiple-choice changes are small and within about one standard error, so they show that general ability (ARC-Easy) held up, not that cybersecurity knowledge clearly improved. The MLX 4-bit version loses noticeably; prefer 8-bit (MLX) or Q5_K_M and above (GGUF).
Training data
| Category | Share of training rows | Source |
|---|---|---|
| Defense instructions | 36% | defense-oriented Q&A written for a "cyber-defense assistant" system prompt (both datasets) |
| Causal security analysis | 16% | "Security Causal Analysis" answers (attack chain, evidence, detection, recommendations) |
| Vulnerability analysis | 14% | "Analyse this security vulnerability" rows: the advisory details are in the question |
| MITRE ATT&CK | 12% | technique, sub-technique and software explanations |
| CISA KEV | 8% | Known Exploited Vulnerabilities questions and advisories |
| Advisory cards (CVE / OSV / GHSA) | 10% | ID-only lookups, kept small on purpose |
| Kali tool commands | 4% | tool flags and example commands |
- Used: 30,240 rows (12.8M answer tokens), 1 epoch. Taken from a deduplicated pool of 34,892; the run used the first 30,240 rows, which keep the shares above.
- Left out on purpose:
- Security StackExchange posts (CC BY-SA 4.0, share-alike) and ExploitDB entries (raw exploit code), about 102,538 rows. Rows were kept only when their format was positively recognised, because the dataset's
sourcelabels are unreliable (StackExchange posts appear under other labels). - System prompts. Every row is trained as a plain user → assistant turn.
- Most templated CVE cards. The base has about 1B active parameters and can't memorise 1.6M CVE records; training on many of them mostly teaches it to invent CVE details.
- Security StackExchange posts (CC BY-SA 4.0, share-alike) and ExploitDB entries (raw exploit code), about 102,538 rows. Rows were kept only when their format was positively recognised, because the dataset's
- Cleaning:
- turned literal
\nescape sequences into real newlines; - removed duplicates across both datasets: 143,863 Vyber07 rows were already in Voidreaper;
- dropped rows over 2,048 tokens and answers under 20 tokens.
- turned literal
- The training row IDs (
dataset:line) are inbuild/train_ids.txt. The data itself is not re-uploaded.
Vyber07/cyber-security licence note. The dataset card says Apache-2.0, but the dataset's own LICENSE file says:
This dataset contains extracted content from publicly available PDF documents hosted on the official website. It is shared strictly for educational and research purposes under the principles of fair use. Commercial use is strictly prohibited. All original content and copyrights belong to owner of the repo.
Only its two instruction JSONL files were read, and about 94% of their rows turned out to be duplicates of Voidreaper rows. If you plan commercial use, review those terms first.
Training
| Method | LoRA, rank 16, scale 2.0, dropout 0.05, on attention q/k/v/o and every expert's gate/up/down (per-expert LoRA), merged into the bf16 weights |
| Router | frozen: with top-1 routing the chosen expert's weight is always exactly 1, so the router gets no gradient |
| Format | no-think: an empty `<ifm |
| Schedule | 15,120 micro-batches of 2 = 1,890 optimizer steps (grad accumulation 8), AdamW, LR 0.0001 cosine to 1e-06, 5% warmup, max length 2048 |
| Held-out answer loss | 1.686 (base) → 1.020 (fine-tuned) |
| Hardware | Modal L40S GPU for the first 7,968 of 15,120 micro-batches (73 min, PyTorch with an exact copy of the MLX LoRA/optimizer), then a MacBook Air M4 (16 GB, MLX) for the rest (about 7.3 h of training steps) |
| Port check | MLX port vs the model's own transformers code: top-1 agreement 1.000 in fp32 (max logit diff 3.8e-05); 0.982 on the whole model in bf16 |
Reproduce (commands)
The scripts are in build/.
./run.sh setup # venv (mlx-lm 0.32.2, transformers 5.22.2) + llama.cpp b12359 converter
./run.sh download # pinned base + datasets (+ sha256 check against the Hub)
./run.sh data # build the SFT set (allow-list, dedupe, no-think rendering)
./run.sh mlx-base # HF -> MLX layout via the custom k2_horizon_mlx.py
./run.sh check # round trip, fp32 parity, dry run, fuse/export test (no training)
./run.sh speedtest # local speed -> rows for one night on the Mac
python -m modal run scripts/modal_train.py --budget-usd 2.75 --local-rows N # GPU part, budget-capped
./run.sh train # continues the Modal checkpoint in MLX to the end (resumable)
./run.sh build # fuse, export, parity, MLX 8/4-bit, GGUF + checks
./run.sh eval # CyberMetric-500, ARC-Easy, held-out loss
Limits
- Small model. About 1B active parameters per token. Expect mistakes, especially exact CVE numbers, dates, versions and tool flags. Verify before you act on an answer.
- Confident errors seen in testing. In a spot check of 10 answers, the fine-tuned model described Kerberoasting's mechanism wrongly (it is an offline crack of a service ticket, not an HTTP request) and misread a CVSS vector. Answers sound fluent even when they are wrong.
- No-think by default. The default
reasoning_effortisnone(answers directly).high,mediumandlowstill exist from the base, but the fine-tune didn't train them. - Near-identical experts. As in the base, the 4 experts started as near-copies. The per-expert LoRA lets them drift apart, but routing was not retrained.
- Uncensored base. The base had refusals removed with Heretic, and the fine-tune didn't add them back. Use it for learning, defense and testing you are authorized to do. You are responsible for how you use it.
- English only (the training data is English).
Credits
- IFM for K2-Horizon-0.9B (Apache-2.0), and Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-heretic for the MoE + Heretic base.
- Voidreaper2026/cybersec-master-dataset (Apache-2.0; its sources keep their own licences: NVD and CISA KEV public domain, GitHub Advisory Database CC BY 4.0, MITRE ATT&CK, OSV, Vulners).
- Vyber07/cyber-security (see the licence note above).
- tihanyin/CyberMetric and allenai/ai2_arc for evaluation only.
- MLX / mlx-lm, llama.cpp, wllama.
- Downloads last month
- 37
Model tree for Lucasgitguy-co/K2-Horizon-4x0.9B-MoE-Cyber
Base model
IFM/K2-Horizon-0.9B