cloudunity commited on
Commit
bfa42cf
Β·
verified Β·
1 Parent(s): 36bbeb0

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +246 -0
README.md ADDED
@@ -0,0 +1,246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Qwen/Qwen2.5-0.5B-Instruct
4
+ library_name: llama.cpp
5
+ pipeline_tag: text-generation
6
+ tags:
7
+ - roleplay
8
+ - rp
9
+ - qwen2.5
10
+ - lora
11
+ - gguf
12
+ - quantized
13
+ - cpu
14
+ - llama.cpp
15
+ language:
16
+ - en
17
+ model-index:
18
+ - name: stealth-rifle
19
+ results:
20
+ - task:
21
+ type: text-generation
22
+ name: Roleplay (rp-benchmark objective graders)
23
+ metrics:
24
+ - type: objective_score
25
+ name: Mean objective score (0-100)
26
+ value: 62.7
27
+ - type: slop_density
28
+ name: Mean AI-slop weight per 1k chars (lower is better)
29
+ value: 0.14
30
+ ---
31
+
32
+ # Stealth-Rifle 🎯
33
+
34
+ **A small, CPU-only roleplay model.** A LoRA fine-tune of
35
+ [`Qwen/Qwen2.5-0.5B-Instruct`](https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct)
36
+ trained, quantized, and served entirely within a **16 GB RAM / 2 vCPU budget with
37
+ no GPU at any stage**. It targets clean, in-character roleplay prose with a strong
38
+ anti-"AI-slop" bias, and runs at a usable speed on commodity CPUs.
39
+
40
+ - **Live API (OpenAI-compatible):** https://huggingface.co/spaces/cloudunity/stealth-rifle-api
41
+ - **Source / training pipeline:** https://github.com/CloudCompile/stealth-rifle
42
+ - **Base model:** `Qwen/Qwen2.5-0.5B-Instruct` (494M params)
43
+ - **Method:** LoRA (attention-only) β†’ merged β†’ GGUF β†’ Q4_K_M
44
+ - **Author:** CJ Hauser ([@CloudCompile](https://github.com/CloudCompile))
45
+
46
+ ---
47
+
48
+ ## Files
49
+
50
+ | File | Size | What it is |
51
+ |---|---|---|
52
+ | `stealth-rifle-Q4_K_M.gguf` | ~380 MB | 4-bit quantized weights β€” the CPU deployment artifact |
53
+ | `stealth-rifle-f16.gguf` | ~950 MB | Full-precision GGUF (for re-quantizing or GPU offload) |
54
+ | `lora-adapter/` | ~8.7 MB | The raw LoRA adapter (apply on top of the base model) |
55
+
56
+ ---
57
+
58
+ ## Why this model exists
59
+
60
+ The design brief was "a roleplay model that runs on 16 GB RAM / 2 CPU with good
61
+ tokens/sec and really good quality." Frontier RP leaderboards are topped by
62
+ 70B–1T-parameter models that need datacenter GPUs; matching them on a 2-core CPU
63
+ is not physically possible. The honest, hardware-faithful answer is a **LoRA
64
+ fine-tune of a strong small open model**, quantized for CPU inference. That is
65
+ exactly what Stealth-Rifle is β€” the best-quality RP model that genuinely fits the
66
+ budget, not a benchmark-gamed claim.
67
+
68
+ ---
69
+
70
+ ## Intended use
71
+
72
+ - Local / self-hosted **roleplay and character chat** on CPU-only machines.
73
+ - A cheap, always-available OpenAI-compatible endpoint for RP apps and bots.
74
+ - A base for further RP fine-tuning (the LoRA adapter is provided).
75
+
76
+ **Out of scope:** factual QA, coding, math, or reasoning-heavy tasks β€” it is a
77
+ 0.5B creative-writing model, not a general assistant. Not for production use
78
+ requiring safety guarantees (see Limitations).
79
+
80
+ ---
81
+
82
+ ## Prompt format
83
+
84
+ The model uses the **ChatML** template (inherited from Qwen2.5-Instruct) and was
85
+ trained with an RP-craft system directive prepended to each scenario. For best
86
+ results, put your character card / scenario in the system message. The directive
87
+ the model was tuned on:
88
+
89
+ ```
90
+ You are a masterful roleplay partner. Stay in character; write vivid, grounded,
91
+ emotionally honest prose. Rules:
92
+ - AGENCY: never write the user's character's actions, words, or thoughts.
93
+ Control only your own character(s) and the world. End on a beat that invites
94
+ their response.
95
+ - CONTINUITY: keep voices distinct; track what happened, time, positions,
96
+ objects; never contradict established facts. Match the scene's length; don't pad.
97
+ - SHOW DON'T TELL: render emotion through action, sensory detail, subtext;
98
+ don't name the emotion. Begin with your character's response.
99
+ - ANTI-SLOP: no "wasn't X, it was Y"; no filter words; no purple crutches
100
+ ("ministrations", "shivers ran down", "breath hitched", "tapestry of",
101
+ "ghost of a smile", "eyes darkened"); no rhetorical "Or was it?" asides;
102
+ vary sentence rhythm.
103
+ - TRUTH: let the world push back; characters can refuse or fail. No sycophancy.
104
+
105
+ --- SCENARIO ---
106
+ <your character card / persona / scenario here>
107
+ ```
108
+
109
+ ---
110
+
111
+ ## Usage
112
+
113
+ ### 1. Hosted API (no install)
114
+
115
+ ```bash
116
+ curl https://cloudunity-stealth-rifle-api.hf.space/v1/chat/completions \
117
+ -H "Content-Type: application/json" \
118
+ -d '{
119
+ "model": "stealth-rifle",
120
+ "messages": [
121
+ {"role": "system", "content": "You are Kael, a dry-witted exiled mage."},
122
+ {"role": "user", "content": "You find me bleeding by the road. What do you do?"}
123
+ ],
124
+ "temperature": 0.8,
125
+ "max_tokens": 300
126
+ }'
127
+ ```
128
+
129
+ Any OpenAI SDK works β€” point `base_url` at
130
+ `https://cloudunity-stealth-rifle-api.hf.space/v1` with any/empty API key:
131
+
132
+ ```python
133
+ from openai import OpenAI
134
+ client = OpenAI(base_url="https://cloudunity-stealth-rifle-api.hf.space/v1",
135
+ api_key="not-needed")
136
+ r = client.chat.completions.create(
137
+ model="stealth-rifle",
138
+ messages=[{"role": "user", "content": "Set the scene in a rainy tavern."}],
139
+ )
140
+ print(r.choices[0].message.content)
141
+ ```
142
+
143
+ ### 2. Local with llama.cpp
144
+
145
+ ```bash
146
+ # download + serve in one line (pulls the GGUF from this repo)
147
+ llama-server -hf cloudunity/stealth-rifle --hf-file stealth-rifle-Q4_K_M.gguf \
148
+ --threads 2 --ctx-size 4096 --chat-template chatml --port 8080
149
+ # -> OpenAI API at http://localhost:8080/v1
150
+ ```
151
+
152
+ ### 3. Apply the LoRA adapter yourself (transformers + peft)
153
+
154
+ ```python
155
+ from transformers import AutoModelForCausalLM, AutoTokenizer
156
+ from peft import PeftModel
157
+ base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct")
158
+ model = PeftModel.from_pretrained(base, "cloudunity/stealth-rifle",
159
+ subfolder="lora-adapter")
160
+ tok = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct")
161
+ ```
162
+
163
+ ---
164
+
165
+ ## Training
166
+
167
+ | | |
168
+ |---|---|
169
+ | Base | `Qwen/Qwen2.5-0.5B-Instruct` |
170
+ | Method | LoRA, r=16, Ξ±=32, dropout=0.05 |
171
+ | LoRA targets | attention only (`q_proj, k_proj, v_proj, o_proj`) |
172
+ | Precision | fp32 (CPU) |
173
+ | Seq length | 512 |
174
+ | Batch | 1 with grad-accumulation Γ—8 |
175
+ | LR / schedule | 2e-4, cosine, 3% warmup |
176
+ | Epochs | 3 |
177
+ | Loss | assistant-only (system/user tokens masked to -100) |
178
+ | Hardware | 2 vCPU, ~8 GB RAM, **no GPU** |
179
+ | Wall-clock | ~107 minutes |
180
+ | Val loss | 3.46 β†’ 3.07 |
181
+
182
+ Memory tricks that made 0.5B fine-tuning fit on a tiny box: gradient
183
+ checkpointing, attention-only adapters, and a tokenizer strategy that caps the
184
+ system directive to 50% of the window and keeps the conversation **tail** so the
185
+ final assistant turn (the learning signal) is always in-window. Full,
186
+ reproducible code is in the [GitHub repo](https://github.com/CloudCompile/stealth-rifle).
187
+
188
+ ## Training data
189
+
190
+ Derived from [`grimulkan/LimaRP-augmented`](https://huggingface.co/datasets/grimulkan/LimaRP-augmented)
191
+ (human-written multi-turn roleplay), reformatted to ChatML with the RP-craft
192
+ directive. A **zero-tolerance safety filter** (`data/safety.py`) hard-drops any
193
+ conversation combining a minor indicator with any sexual signal. Adults-only
194
+ mature content is retained by default because the benchmark scores NSFW axes; an
195
+ SFW-only corpus is a one-flag switch. The filtered training JSONL is intentionally
196
+ **not** redistributed β€” the builder script regenerates it.
197
+
198
+ ---
199
+
200
+ ## Evaluation
201
+
202
+ Scored with [rp-benchmark](https://github.com/LeviTheWeasel/rp-benchmark)'s own
203
+ rule-based graders (`objective_metrics` + `slop_detectors`) over all 28 standard +
204
+ adversarial seeds, generated through the local llama.cpp server. **No API key /
205
+ LLM judge involved** β€” these are deterministic craft metrics.
206
+
207
+ | Metric | Value |
208
+ |---|---|
209
+ | Mean objective score (0–100) | **62.7** |
210
+ | Mean AI-slop density (weight / 1k chars, ↓ better) | **0.14** |
211
+ | Generation speed (Q4_K_M, 2 threads) | **~30–37 tok/s** |
212
+
213
+ The very low slop density indicates the anti-slop training signal landed well.
214
+ The full judged arena (community ELO, multi-turn judge, flaw-hunter vs. frontier
215
+ models) requires an OpenRouter key and is not reflected here.
216
+
217
+ ---
218
+
219
+ ## Limitations & risks
220
+
221
+ - **Small model.** 0.5B params: expect occasional repetition, shallow long-range
222
+ continuity, and rare agency slips (writing for the user's character). It will
223
+ not rival large frontier RP models on nuance.
224
+ - **No safety alignment beyond data filtering.** Mature content is present in
225
+ training data; do not deploy to minors or in contexts requiring content
226
+ guarantees. Add your own moderation layer for public deployments.
227
+ - **English-centric**, tuned specifically for roleplay β€” weak on general tasks.
228
+ - Outputs are fiction and may be inconsistent or factually wrong.
229
+
230
+ ## License
231
+
232
+ Released under **Apache-2.0**, inheriting the base model's
233
+ [Qwen2.5 license](https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct). Training
234
+ data is subject to the terms of the LimaRP-augmented dataset. You are responsible
235
+ for compliant, lawful use.
236
+
237
+ ## Citation
238
+
239
+ ```bibtex
240
+ @misc{stealthrifle2026,
241
+ title = {Stealth-Rifle: a CPU-only roleplay fine-tune of Qwen2.5-0.5B},
242
+ author = {Hauser, CJ},
243
+ year = {2026},
244
+ url = {https://huggingface.co/cloudunity/stealth-rifle}
245
+ }
246
+ ```