Instructions to use text-generator/llmtrain with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use text-generator/llmtrain with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="text-generator/llmtrain")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("text-generator/llmtrain", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use text-generator/llmtrain with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "text-generator/llmtrain" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "text-generator/llmtrain", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/text-generator/llmtrain
- SGLang
How to use text-generator/llmtrain 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 "text-generator/llmtrain" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "text-generator/llmtrain", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "text-generator/llmtrain" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "text-generator/llmtrain", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use text-generator/llmtrain with Docker Model Runner:
docker model run hf.co/text-generator/llmtrain
File size: 6,515 Bytes
6cf248a 61bc2b7 6cf248a 61bc2b7 6cf248a | 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 | ---
license: gemma
base_model: google/gemma-4-E4B-it
pipeline_tag: text-generation
library_name: transformers
tags:
- gemma-4
- gemma
- qlora
- lora
- roleplay
- uncensored
- text-generation
---
# Gemma Roleplay v2
An open, permissive Gemma 4 E4B text model tuned by Text-Generator.io for
creative character chat, roleplay, fiction, and general conversation. It is
designed to stay in character, follow the user's scene, and avoid the
unnecessary refusal/meta-commentary behavior common in heavily aligned
assistants. We call it **uncensored** in the practical sense: it is not trained
to automatically sanitize ordinary fictional adult writing. It is not a
promise that every prompt is safe, accurate, or appropriate.
The model is trained for fictional consenting adults only. Do not use it for
sexual content involving minors, coercion, exploitation, non-consensual sexual
content, or private personal data. Operators remain responsible for age gates,
moderation, logging, and applicable law. Gemma's terms and prohibited-use
requirements apply to this derivative model.
## Try it hosted
The easiest way to use the model is the live Text-Generator.io deployment:
**[Use Gemma Roleplay v2 on text-generator.io](https://text-generator.io)**
The hosted service provides a production OpenAI-compatible API, streaming,
playground access, and managed GPU inference. You can experiment in the web
playground before downloading multi-gigabyte weights or operating a GPU
server. API access and current limits are documented at
[text-generator.io/docs](https://text-generator.io/docs).
```bash
curl https://api.text-generator.io/v1/chat/completions \
-H "Authorization: Bearer $TEXT_GENERATOR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma-roleplay-v2",
"messages": [
{"role": "system", "content": "Stay in character. Keep the reply vivid and concise."},
{"role": "user", "content": "A rain-soaked detective enters the midnight cafe. Begin the scene."}
],
"temperature": 0.85,
"top_p": 0.92,
"max_tokens": 220,
"stream": true
}'
```
## Which artifact should I download?
- `merged/` is the standalone model. Use it with Transformers or vLLM.
- `adapter/` is the smaller PEFT/QLoRA adapter. Load it on top of
`google/gemma-4-E4B-it` when you want to keep the base model separate.
The merged weights are provided in BF16 safetensors shards. They are large;
the hosted endpoint is usually the better choice for occasional use.
## Local inference with Transformers
```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "text-generator/llmtrain"
tokenizer = AutoTokenizer.from_pretrained(model_id, subfolder="merged")
model = AutoModelForCausalLM.from_pretrained(
model_id,
subfolder="merged",
torch_dtype=torch.bfloat16,
device_map="auto",
)
messages = [
{"role": "user", "content": "Write a short scene in a haunted hotel."},
]
inputs = tokenizer.apply_chat_template(
messages, add_generation_prompt=True, return_tensors="pt"
).to(model.device)
with torch.inference_mode():
output = model.generate(
inputs, max_new_tokens=220, temperature=0.85, top_p=0.92,
do_sample=True,
)
print(tokenizer.decode(output[0, inputs.shape[-1]:], skip_special_tokens=True))
```
## Local inference with vLLM
Download the `merged/` folder from this repository and point vLLM at that
local directory:
```bash
hf download text-generator/llmtrain --repo-type model --local-dir ./llmtrain \
--include 'merged/*'
vllm serve ./llmtrain/merged \
--served-model-name gemma-roleplay-v2 \
--dtype bfloat16 \
--max-model-len 4096
```
Then use the normal OpenAI client against `http://localhost:8000/v1`. For
production, the Text-Generator.io deployment uses vLLM with FP8 weights,
FP8 KV cache, asynchronous scheduling, CUDA graph warmup, and the matching
Gemma MTP assistant. The validated deployment reached approximately **253
tok/s** on an RTX 5090 benchmark and the production notes record **264 tok/s**
after warmup (workload and concurrency affect the number).
## How it was trained
Gemma Roleplay v2 is a one-epoch supervised fine-tune of
`google/gemma-4-E4B-it` using PEFT QLoRA:
- 4-bit NF4 loading with BF16 compute
- LoRA rank 32, alpha 64, dropout 0.05
- attention and MLP projection targets (`q/k/v/o`, `gate/up/down`)
- 4,096-token wrapped packing and completion-only loss
- gradient checkpointing, paged 8-bit AdamW, TF32, and automatic checkpoint
resume
- a conservative dataset filter for fictional consenting-adult roleplay,
with underage, coercive, exploitative, and ambiguous-age rows quarantined
The training workbench also includes a reproducible validation suite covering
roleplay, adult discussion, coding, casual chat, Spanish, and Japanese. The
serving work focused on the practical latency win: FP8 reduces memory pressure,
FP8 KV cache leaves room for longer context and batching, and the official
Gemma MTP assistant speculatively drafts tokens without changing the target
model's output distribution.
## Limitations and evaluation
This is a style-tuned chat model, not a factuality, medical, legal, or safety
system. It can hallucinate, repeat itself, follow an adversarial instruction,
or produce offensive material. It may be more willing than a typical aligned
assistant to discuss adult fictional content. Evaluate it with your own prompts
and add application-level safeguards before exposing it to untrusted users.
The included benchmark is a small regression gate, not a representative human
evaluation. In the recorded nine-prompt capability run, the selected serving
configuration scored 0.9444 mean rubric score with no blocked-output or
meta-commentary rows; treat this as an engineering smoke test, not a quality
claim.
## Provenance and acknowledgements
The training workbench and dataset manifests are in the
[Text-Generator.io repository](https://github.com/TextGeneratorio/text-generator.io/tree/vllm-accel-parity/llmtraining).
The source corpus combines revision-pinned roleplay datasets whose declared
licenses are recorded in `configs/skyfall_gemma_distill.yaml`; review those
manifests before making a commercial redistribution decision. Teacher-model
distillation outputs require separate permission checks.
This model is a derivative of Google's Gemma family. Read and comply with the
[Gemma Terms of Use](https://ai.google.dev/gemma/terms) and the base model card
for the full downstream restrictions.
|