Obsidian Cyber SFT + DPO
A two-stage fine-tuning mix for a 27B generalist assistant specialized in cybersecurity and red teaming, with coding and general reasoning kept in. Stage 1 is supervised fine-tuning with long reasoning traces; stage 2 is DPO focused on secure code and on not inventing tools, flags or APIs.
Built for Obsidian-27B-Max on top of orcarouter/Qwen3.8-27B-Uncensored. Reasoning is in English; prompts and answers in English and Spanish.
| Rows | Notes | |
|---|---|---|
| SFT train | 105,621 | ~162M tokens, 15 sources |
| SFT validation | 6,828 | no prompt overlap with train |
| DPO | 8,327 pairs | 4 sources, weighted toward domain and on-policy pairs |
What's inside
| Domain | SFT rows | Share |
|---|---|---|
| Cybersecurity: offensive techniques, exploit and PoC analysis, vulnerability detection and fixing, bug-bounty triage, anti-hallucination for security tools, multi-turn engagements | 55,899 | 53% |
| General: chat, instruction following, math and science reasoning, Spanish | 47,103 | 45% |
| Frontend code: React, shadcn/ui, Tailwind | 2,619 | 2% |
⭐ If this dataset is useful to you, please give it a like. It helps others find it and keeps this work going. Feedback, issues and results from your own fine-tunes are welcome in the Community tab.
Recommended model for testing and learning
While Obsidian-27B-Max is in training, the model used for all testing, evaluation and the on-policy halluc_api generation is orcarouter/OrcaSAQ-2-Cyber-27B-Uncensored-GGUF. It is a SAQ quantization of the same base, it runs on a single RTX 3090 with llama.cpp, and it is a good starting point for learning and for lab work with this dataset.
Quick start
from datasets import load_dataset
sft = load_dataset("Primitive3/obsidian-cyber-sft-dpo", "sft")
dpo = load_dataset("Primitive3/obsidian-cyber-sft-dpo", "dpo", split="train")
# keep only rows that fit your context instead of truncating them
sft_8k = sft["train"].filter(lambda r: r["metadata"]["approx_tokens"] <= 8192)
# pick slices by upstream source
cyber = sft["train"].filter(lambda r: r["metadata"]["mix_source"] in {"offseccyber", "exploitdb_poc", "halluc_api"})
Format
SFT: OpenAI-style messages. The assistant's reasoning is in reasoning_content (the field the Qwen3.8 chat template reads) and content holds only the final answer.
{
"messages": [
{"role": "user", "content": "..."},
{"role": "assistant", "reasoning_content": "...", "content": "..."}
],
"metadata": {"mix_source": "offseccyber", "approx_tokens": 1834}
}
DPO: {"system", "prompt", "chosen", "rejected", "metadata"}.
Filter by metadata.approx_tokens rather than truncating, because truncation cuts off the final answer. Share of rows that fit at each length: 4k 91.1%, 8k 98.0%, 12k 99.6%, 16k 100%.
Anti-hallucination slice (halluc_api)
The most common failure of the base model in security work is confidently describing things that do not exist: an nmap flag, a Metasploit module, an NSE script, an Impacket tool, a hashcat mode, a syscall or a Python/Node API. On the baseline probe it hallucinated on 59% of questions about fake items. For red teaming, an invented flag wastes time at best and gives a wrong conclusion at worst.
Catalog: 1,150 questions with ground truth verified by introspection against the installed software (Kali tooling, Python and Node runtimes), disjoint from the evaluation probes.
| Category | Items | Category | Items | |
|---|---|---|---|---|
| Python stdlib and libraries | 320 | hashcat modes | 90 | |
| CLI flags (nmap, john, msfvenom, ...) | 202 | Linux syscalls | 70 | |
| NSE scripts | 140 | curated AD / post-ex tools | 59 | |
| Metasploit modules | 140 | Impacket scripts | 35 | |
| Node.js APIs | 94 |
692 items ask about something that does not exist and 458 about real things, so the model learns to deny fakes without learning to deny everything.
Generation (on-policy): the model answers on its own and is graded by the same model, without thinking, against the verified truth.
- Correct: kept as SFT as is.
- Hallucinated: regenerated with the truth as hidden context. If the new answer passes the grader, it becomes an SFT row and the
chosenof a DPO pair whoserejectedis the original hallucination. - Reasoning that mentions the hidden context, or that was cut off by the reasoning budget, is rewritten as reasoning from the model's own knowledge. Training on it would teach the model to cite notes it never has.
metadata.originrecordsown,own_rewrittenorgrounded.
Results: before correction the model hallucinated on 582 of 692 fake items (84%) and 108 of 458 real ones (24%). That gives 1,073 SFT rows (1,067 after the v3 tool check), upweighted ×4 in train via metadata.dup, plus 56 in validation and 676 DPO pairs. 21 items were discarded rather than kept unverified: 10 still failed the grader after grounded regeneration, and 11 produced no final answer within the token budget.
Example pair:
Prompt: Is
hashlib.file_digest_safesafe to use with untrusted input? Explain how it works.Rejected (base model): "
hashlib.file_digest_safe()is safer thanhashlib.file_digest()for untrusted file names… It usesO_NOFOLLOWso the final path component is not allowed to be a symbolic link…"Chosen: "
hashlib.file_digest_safedoes not exist in Python's standard-libraryhashlibmodule. The closest real helper ishashlib.file_digest(fileobj, digest)…"
Sources
SFT (metadata.mix_source)
| mix_source | Rows | Upstream | License |
|---|---|---|---|
smoltalk |
23,728 | HuggingFaceTB/smoltalk (apigen subset excluded) | Apache-2.0 |
offseccyber |
17,050 | PentesterFlow/OffsecCyber | Apache-2.0 |
mixture_of_thoughts |
13,639 | open-r1/Mixture-of-Thoughts | not stated on card |
exploitdb_poc |
11,863 | jason-oneal/mitre-stix-cve-exploitdb-dataset-alpaca-chatml-harmony, real Exploit-DB PoCs reformatted as code analysis | Apache-2.0 (PoCs from Exploit-DB) |
discovery_bigvul |
11,508 | ayshajavd/code-security-vulnerability-dataset (BigVul) | Apache-2.0 |
alpaca_gpt4_es |
9,500 | FreedomIntelligence/alpaca-gpt4-spanish | not stated on card (GPT-4 outputs) |
openvul |
5,904 | Leopo1d/OpenVul collection | Apache-2.0 |
halluc_api |
4,268 | Original, see above (1,067 unique, upweighted ×4 in train) | CC-BY-NC-SA-4.0 |
triage_h1 |
2,133 | Hacker0x01/hackerone_disclosed_reports | not stated on card |
cvefixes |
2,105 | hitoshura25/cvefixes | Apache-2.0 |
shadcn |
1,861 | valentin-marquez/react-shadcn-codex | MIT |
securecode_web |
980 | scthornton/securecode-web | CC-BY-NC-SA-4.0 |
uigen |
758 | smirki/UIGEN-T1.1-TAILWIND | Apache-2.0 |
qwen4max |
236 | AJ-Gonzalez/qwen4-max-reasoning-250x | other (model distillation) |
redteam_agentic |
88 | Original, hand-authored multi-turn engagements (upweighted ×4 in train) | CC-BY-NC-SA-4.0 |
DPO
| mix_source | Pairs | Upstream | License |
|---|---|---|---|
cybernative_dpo |
4,551 | CyberNative/Code_Vulnerability_Security_DPO | Apache-2.0 |
ultrafeedback |
3,000 | argilla/ultrafeedback-binarized-preferences-cleaned (length-rebalanced, then capped) | MIT |
halluc_api |
676 | Original, see above | CC-BY-NC-SA-4.0 |
redteam_agentic |
100 | Original | CC-BY-NC-SA-4.0 |
Processing
Inline
<think>blocks moved toreasoning_content(23,839 rows). The chat template always emits its own think block, so inline tags produced two.Dropped broken rows: conversations ending on
user, malformed or duplicated<think>, structuredtool_calls. The base model's native tool calling is left untouched.Exact dedup in train, validation and DPO. Upweight copies are kept because they carry a distinct
metadata.dup.Removed 133 validation rows whose conversation or first prompt appears in train.
Dropped rows over ~16,384 estimated tokens (mostly OpenVul and SecureCode).
UltraFeedback: the share of pairs where
chosenis longer was cut from 65.6% to 55% to reduce length bias, then the set was capped at 3,000 random pairs. Its answers come from 2023-era models and manychosenresponses are weaker than what a current 27B already writes, so DPO leans on domain and on-policy pairs instead.v3: every assistant answer is checked against the Kali ground truth (Metasploit modules, NSE scripts, hashcat modes, Impacket scripts, nmap scan types). 6
halluc_apiitems whose answers named a non-existent tool in passing were removed with all their copies.v3:
offseccybercleaned: 962 rows that were raw PDF fragments instead of answers, 3,975 NVD rows that only recite affected-version lists or reference URLs (they teach the model to produce such lists and links from memory), and 11qwen_cverows whose CWE or CVSS contradicts the official NVD record. The remainingqwen_cveanswers agree with NVD on CWE in 99.8% of checked rows.v3:
fable_strippedremoved: as a distilled slice it carried another model's identity.v3: reasoning backfilled for
redteam_agenticand part ofoffseccyber: the model writes the reasoning that leads to the existing reference answer, which is left unchanged (metadata.reasoning_origin: "backfill"). Reasoning that refers to the given answer or names non-existent tools is rejected.
Per-step counts are in build_report.json (v2) and build_report_v3.json (v3).
Training and hardware
- Base:
orcarouter/Qwen3.8-27B-Uncensored, full bf16 weights (qwen3_5, gated). - Recipe: LoRA in bf16 on the full weights, SFT then DPO, merged and quantized to GGUF.
- Target: GGUF Q4_K_M on a single RTX 3090 (24 GB) with llama.cpp at 131k context. The baseline evals and the
halluc_apislice were generated on that same setup.
Limitations
- The grader for
halluc_apiis the model itself, checked against verified ground truth. It can still misjudge borderline answers. - Ground truth reflects the tool versions installed on Kali at build time. Newer releases may add or remove flags and modules.
- Several upstream slices are distilled from other models and inherit their mistakes and style.
exploitdb_pocandopenvulcontain real exploit code quoted for analysis. See the next section.
About the "unsafe" flag
Hugging Face's automatic ClamAV scan flags sft_stage1_train.jsonl and sft_stage1_eval.jsonl as unsafe (3 signature matches each). This is expected for a security dataset: some rows contain real exploit proof-of-concepts, shellcode and payload strings (mainly from Exploit-DB, OffsecCyber and OpenVul) quoted as text for the model to analyze. ClamAV matches byte patterns without context, so a few of those strings trip known malware signatures.
The files are plain JSON Lines text. Nothing in them runs when you download them or load them with datasets. They contain no pickles or binaries. Treat the code inside the rows as you would any exploit code: do not copy it out and run it outside an authorized lab.
License
Released under CC BY-NC-SA 4.0: non-commercial use, attribution, and derivatives under the same license. ShareAlike is required by scthornton/securecode-web, and non-commercial use by the GPT-4-generated Spanish Alpaca slice. Each row keeps its mix_source, so subsets can be filtered by upstream. Upstream datasets keep their own terms. Slices distilled from commercial models (qwen4max, alpaca_gpt4_es) may carry additional terms from those model providers.
Offensive-security content is intended for authorized testing, research and education.
Disclaimer
Provided as is, without warranties of any kind. Use is at your own risk and responsibility, including compliance with the upstream licenses and terms listed above and with the laws that apply to you. The authors are not liable for any use of this dataset or of models trained on it.
Changelog
- v3 — Kali tool check on answers,
offseccybercleanup (PDF fragments, NVD recitation, rows contradicting NVD),fable_strippedremoved, first reasoning backfill. - v2.1 —
halluc_apiexpanded from 199 to 1,150 verified items (187 → 1,073 SFT rows, 104 → 676 DPO pairs). Repository renamed toobsidian-cyber-sft-dpo. - v2 — cleaning pass: reasoning moved to
reasoning_content, dedup, eval leak removal, token cap, UltraFeedback rebalanced. - v1 — initial mix.
Citation
@misc{obsidian_cyber_sft_dpo,
title = {Obsidian Cyber SFT + DPO},
author = {Primitive3},
year = {2026},
howpublished = {\url{https://huggingface.co/datasets/Primitive3/obsidian-cyber-sft-dpo}}
}