lee101 commited on
Commit
6cf248a
·
verified ·
1 Parent(s): fdb6cc4

Add Gemma Roleplay v2 model card and hosted inference guide

Browse files
Files changed (1) hide show
  1. README.md +162 -0
README.md ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: gemma
3
+ base_model: google/gemma-4-E4B-it
4
+ pipeline_tag: text-generation
5
+ library_name: transformers
6
+ tags:
7
+ - gemma-4
8
+ - gemma
9
+ - qlora
10
+ - lora
11
+ - roleplay
12
+ - uncensored
13
+ - text-generation
14
+ ---
15
+
16
+ # Gemma Roleplay v2
17
+
18
+ An open, permissive Gemma 4 E4B text model tuned by Text-Generator.io for
19
+ creative character chat, roleplay, fiction, and general conversation. It is
20
+ designed to stay in character, follow the user's scene, and avoid the
21
+ unnecessary refusal/meta-commentary behavior common in heavily aligned
22
+ assistants. We call it **uncensored** in the practical sense: it is not trained
23
+ to automatically sanitize ordinary fictional adult writing. It is not a
24
+ promise that every prompt is safe, accurate, or appropriate.
25
+
26
+ The model is trained for fictional consenting adults only. Do not use it for
27
+ sexual content involving minors, coercion, exploitation, non-consensual sexual
28
+ content, or private personal data. Operators remain responsible for age gates,
29
+ moderation, logging, and applicable law. Gemma's terms and prohibited-use
30
+ requirements apply to this derivative model.
31
+
32
+ ## Try it hosted
33
+
34
+ The easiest way to use the model is the live Text-Generator.io deployment:
35
+
36
+ **[Use Gemma Roleplay v2 on text-generator.io](https://text-generator.io)**
37
+
38
+ The hosted service provides a production OpenAI-compatible API, streaming,
39
+ playground access, and managed GPU inference. You can experiment in the web
40
+ playground before downloading multi-gigabyte weights or operating a GPU
41
+ server. API access and current limits are documented at
42
+ [text-generator.io/docs](https://text-generator.io/docs).
43
+
44
+ ```bash
45
+ curl https://api.text-generator.io/v1/chat/completions \
46
+ -H "Authorization: Bearer $TEXT_GENERATOR_API_KEY" \
47
+ -H "Content-Type: application/json" \
48
+ -d '{
49
+ "model": "gemma-roleplay-v2",
50
+ "messages": [
51
+ {"role": "system", "content": "Stay in character. Keep the reply vivid and concise."},
52
+ {"role": "user", "content": "A rain-soaked detective enters the midnight cafe. Begin the scene."}
53
+ ],
54
+ "temperature": 0.85,
55
+ "top_p": 0.92,
56
+ "max_tokens": 220,
57
+ "stream": true
58
+ }'
59
+ ```
60
+
61
+ ## Which artifact should I download?
62
+
63
+ - `merged/` is the standalone model. Use it with Transformers or vLLM.
64
+ - `adapter/` is the smaller PEFT/QLoRA adapter. Load it on top of
65
+ `google/gemma-4-E4B-it` when you want to keep the base model separate.
66
+
67
+ The merged weights are provided in BF16 safetensors shards. They are large;
68
+ the hosted endpoint is usually the better choice for occasional use.
69
+
70
+ ## Local inference with Transformers
71
+
72
+ ```python
73
+ import torch
74
+ from transformers import AutoModelForCausalLM, AutoTokenizer
75
+
76
+ model_id = "text-generator/llmtrain"
77
+ tokenizer = AutoTokenizer.from_pretrained(model_id, subfolder="merged")
78
+ model = AutoModelForCausalLM.from_pretrained(
79
+ model_id,
80
+ subfolder="merged",
81
+ torch_dtype=torch.bfloat16,
82
+ device_map="auto",
83
+ )
84
+
85
+ messages = [
86
+ {"role": "user", "content": "Write a short scene in a haunted hotel."},
87
+ ]
88
+ inputs = tokenizer.apply_chat_template(
89
+ messages, add_generation_prompt=True, return_tensors="pt"
90
+ ).to(model.device)
91
+ with torch.inference_mode():
92
+ output = model.generate(
93
+ inputs, max_new_tokens=220, temperature=0.85, top_p=0.92,
94
+ do_sample=True,
95
+ )
96
+ print(tokenizer.decode(output[0, inputs.shape[-1]:], skip_special_tokens=True))
97
+ ```
98
+
99
+ ## Local inference with vLLM
100
+
101
+ ```bash
102
+ vllm serve text-generator/llmtrain \
103
+ --served-model-name gemma-roleplay-v2 \
104
+ --subfolder merged \
105
+ --dtype bfloat16 \
106
+ --max-model-len 4096
107
+ ```
108
+
109
+ Then use the normal OpenAI client against `http://localhost:8000/v1`. For
110
+ production, the Text-Generator.io deployment uses vLLM with FP8 weights,
111
+ FP8 KV cache, asynchronous scheduling, CUDA graph warmup, and the matching
112
+ Gemma MTP assistant. The validated deployment reached approximately **253
113
+ tok/s** on an RTX 5090 benchmark and the production notes record **264 tok/s**
114
+ after warmup (workload and concurrency affect the number).
115
+
116
+ ## How it was trained
117
+
118
+ Gemma Roleplay v2 is a one-epoch supervised fine-tune of
119
+ `google/gemma-4-E4B-it` using PEFT QLoRA:
120
+
121
+ - 4-bit NF4 loading with BF16 compute
122
+ - LoRA rank 32, alpha 64, dropout 0.05
123
+ - attention and MLP projection targets (`q/k/v/o`, `gate/up/down`)
124
+ - 4,096-token wrapped packing and completion-only loss
125
+ - gradient checkpointing, paged 8-bit AdamW, TF32, and automatic checkpoint
126
+ resume
127
+ - a conservative dataset filter for fictional consenting-adult roleplay,
128
+ with underage, coercive, exploitative, and ambiguous-age rows quarantined
129
+
130
+ The training workbench also includes a reproducible validation suite covering
131
+ roleplay, adult discussion, coding, casual chat, Spanish, and Japanese. The
132
+ serving work focused on the practical latency win: FP8 reduces memory pressure,
133
+ FP8 KV cache leaves room for longer context and batching, and the official
134
+ Gemma MTP assistant speculatively drafts tokens without changing the target
135
+ model's output distribution.
136
+
137
+ ## Limitations and evaluation
138
+
139
+ This is a style-tuned chat model, not a factuality, medical, legal, or safety
140
+ system. It can hallucinate, repeat itself, follow an adversarial instruction,
141
+ or produce offensive material. It may be more willing than a typical aligned
142
+ assistant to discuss adult fictional content. Evaluate it with your own prompts
143
+ and add application-level safeguards before exposing it to untrusted users.
144
+
145
+ The included benchmark is a small regression gate, not a representative human
146
+ evaluation. In the recorded nine-prompt capability run, the selected serving
147
+ configuration scored 0.9444 mean rubric score with no blocked-output or
148
+ meta-commentary rows; treat this as an engineering smoke test, not a quality
149
+ claim.
150
+
151
+ ## Provenance and acknowledgements
152
+
153
+ The training workbench and dataset manifests are in the
154
+ [Text-Generator.io repository](https://github.com/TextGeneratorio/text-generator.io/tree/vllm-accel-parity/llmtraining).
155
+ The source corpus combines revision-pinned roleplay datasets whose declared
156
+ licenses are recorded in `configs/skyfall_gemma_distill.yaml`; review those
157
+ manifests before making a commercial redistribution decision. Teacher-model
158
+ distillation outputs require separate permission checks.
159
+
160
+ This model is a derivative of Google's Gemma family. Read and comply with the
161
+ [Gemma Terms of Use](https://ai.google.dev/gemma/terms) and the base model card
162
+ for the full downstream restrictions.