Views
No views yet
tokenizer.json, generated
from the canonical RWKV World byte vocabulary during conversion.chat_template.jinja supports system, multi-turn, thinking, and
strict model-generated tool-call prompts.inference/ bundle
provides PyTorch fallback and TileLang acceleration without changing the
standard model root.| Field | Value |
|---|---|
| Repository | aabbdev/RWKV7-1.5B-20260805 |
| Architecture class | Rwkv7ForCausalLM |
| Public size label | 1.5B |
| Source parameters | 1,527,668,736 |
| Serialized parameters | 1,527,668,736 |
| Synthesized compatibility tensors | 0 |
| Layers | 24 |
| Hidden / FFN size | 2048 / 8192 |
| Heads / head size | 32 / 64 |
| Vocabulary | 65536 |
| Training context | 16384 tokens |
| Weight dtype | bfloat16 |
| Numerical conversion | source dtype preserved |
| Metadata profile | g1i |
| Metadata provenance | locked-profile |
| Source checkpoint | BlinkDL/rwkv7-g1/rwkv7-g1i-1.5b-20260805-ctx16384.pth |
| Source SHA-256 | 32ef7b5bf4dc8bde843cf26dfad809a1f527e2e76a9e790e7d406e71bcd785da |
python -m pip install "transformers>=5.3,<6" "huggingface-hub>=1.5,<2"configuration_rwkv7.py and modeling_rwkv7.py, adapted
from the Transformers RWKV-7 integration at commit
4ad9ed0.
Review those files and pin a model-repository revision in production. Passing
trust_remote_code=True selects this bundled implementation even when the local
Transformers installation also provides native RWKV-7 support.1import torch
2from transformers import (
3 AutoModelForCausalLM,
4 AutoTokenizer,
5 PreTrainedConfig,
6)
7
8model_id = "aabbdev/RWKV7-1.5B-20260805"
9tokenizer = AutoTokenizer.from_pretrained(
10 model_id,
11 config=PreTrainedConfig(),
12)
13model = AutoModelForCausalLM.from_pretrained(
14 model_id,
15 trust_remote_code=True,
16 dtype=torch.bfloat16,
17)attention_mask for padded batches.1import re
2
3import torch
4from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedConfig
5
6
7THINK_RE = re.compile(r"\A<think>?\s*(.*?)\s*</think>?", re.DOTALL)
8
9
10def assistant_content(completion, thinking, *, close_incomplete=False):
11 prefix = "<think" if thinking else "<think></think>\n"
12 reply = prefix + completion
13 thinking_block = THINK_RE.match(reply)
14 if thinking:
15 if thinking_block is not None or not close_incomplete:
16 return reply.strip()
17 return f"{reply.rstrip()}\n</think>".strip()
18 return "" if thinking_block is None else reply[thinking_block.end():].strip()
19
20model_id = "aabbdev/RWKV7-1.5B-20260805"
21tokenizer = AutoTokenizer.from_pretrained(
22 model_id,
23 config=PreTrainedConfig(),
24)
25model = AutoModelForCausalLM.from_pretrained(
26 model_id,
27 trust_remote_code=True,
28 dtype=torch.bfloat16,
29).to("cuda")
30
31messages = [{"role": "user", "content": "Explain why RWKV uses constant state."}]
32thinking = False
33max_new_tokens = 256
34inputs = tokenizer.apply_chat_template(
35 messages,
36 tokenize=True,
37 add_generation_prompt=True,
38 thinking=thinking,
39 return_dict=True,
40 return_tensors="pt",
41).to(model.device)
42
43output = model.generate(
44 **inputs,
45 max_new_tokens=max_new_tokens,
46 do_sample=True,
47 temperature=1.0,
48 top_p=0.5,
49 eos_token_id=0,
50 pad_token_id=0,
51 stop_strings=["\n\nUser:"],
52 tokenizer=tokenizer,
53)
54completion = tokenizer.decode(
55 output[0, inputs["input_ids"].shape[1]:],
56 skip_special_tokens=True,
57)
58completion = completion.split("\n\nUser:", 1)[0]
59reached_token_limit = output.shape[1] - inputs["input_ids"].shape[1] >= max_new_tokens
60print(
61 assistant_content(
62 completion,
63 thinking,
64 close_incomplete=reached_token_limit,
65 )
66)thinking=True for the RWKV thinking prefix. The intentional generation
prefixes are Assistant: <think></think> followed by a newline and
Assistant: <think. Only the enabled thinking prefix intentionally leaves its opening
tag incomplete. The post-processing above reconstructs that prefix before removing an
empty thinking block or preserving an enabled one. If generation hits the token limit
inside thinking, it closes the displayed block before returning it.
Reference stops are token ID 0 and \n\nUser:.RWKV7-G1x-templates.txt.SFTTrainer, including its default
chunked_nll, gradient checkpointing, assistant-only loss, BFD packing, and PEFT
LoRA. Packing boundaries carried as reset position_ids are converted into RWKV
recurrent-state boundaries. Do not use the boundary-destroying wrapped packing
strategy.1from datasets import load_dataset
2from peft import LoraConfig
3from trl import SFTConfig, SFTTrainer
4
5# Reuse `model` and `tokenizer` loaded in the Transformers quickstart above.
6dataset = load_dataset("trl-lib/Capybara", split="train")
7trainer = SFTTrainer(
8 model=model,
9 processing_class=tokenizer,
10 train_dataset=dataset,
11 args=SFTConfig(
12 output_dir="rwkv7-sft",
13 max_length=2048,
14 packing=True,
15 packing_strategy="bfd",
16 assistant_only_loss=True,
17 use_cache=False,
18 gradient_checkpointing=True,
19 ),
20 peft_config=LoraConfig(
21 task_type="CAUSAL_LM",
22 r=8,
23 lora_alpha=16,
24 target_modules=["receptance", "key", "value", "output"],
25 ),
26)
27trainer.train()1python -m pip install -r inference/requirements.txt
2python inference/serve.py --host 127.0.0.1 --port 8000/v1/chat/completions, /v1/completions, and /v1/models.
Serving requires transformers[serving]>=5.15,<6; direct model loading remains
compatible with Transformers 5.3+.
It rejects continuous batching because RWKV carries recurrent state rather than a
paged KV cache.inference/requirements.txt, then run the bundled
interactive chat:python inference/generate.py --model aabbdev/RWKV7-1.5B-20260805 --backend auto --interactive1python inference/generate.py \
2 --model aabbdev/RWKV7-1.5B-20260805 \
3 --backend auto \
4 --input-file prompts.txt--backend auto uses validated exact optimized boundaries and otherwise falls
back to PyTorch. Full explicit TileLang execution can change floating-point
operation order and requires checkpoint-, dtype-, shape-, and device-specific
parity validation.tokenizer.json.
Textual vocab.json and rwkv_vocab_v20230424.txt files are intentionally omitted
because they would duplicate the tokenizer used by Transformers. The tokenizer is
loaded natively as PreTrainedTokenizerFast and never executes remote Python code.
The explicit generic config prevents AutoTokenizer from probing the remote model
configuration and emitting a harmless model-type fallback warning.auto configurations fall back to pure PyTorch.apache-2.0. The exported inference bundle is licensed separately under Apache-2.0. The bundled Transformers configuration and modeling modules
retain their Apache-2.0 headers. See NOTICE and the source checkpoint
link above for provenance.1@misc{peng2025250314456,
2 title = {RWKV-7 "Goose" with Expressive Dynamic State Evolution},
3 author = {Bo Peng and Ruichong Zhang and Daniel Goldstein and Eric Alcaide and Xingjian Du and Haowen Hou and Jiaju Lin and Jiaxing Liu and Janna Lu and William Merrill and Guangyu Song and Kaifeng Tan and Saiteja Utpala and Nathan Wilce and Johan S. Wind and Tianyi Wu and Daniel Wuttke and Christian Zhou-Zheng},
4 year = {2025},
5 eprint = {2503.14456v2},
6 archivePrefix = {arXiv},
7 primaryClass = {cs.CL},
8 url = {https://arxiv.org/abs/2503.14456v2},
9}