rwkv-architecture
Agent skill fromOrchestra-Research/AI-Research-SKILLs
RNN+Transformer hybrid with O(n) inference. Linear time, infinite context, no KV cache. Train like GPT (parallel), infer like RNN (sequential). Linux Foundation AI project. Production at Windows, Office, NeMo. RWKV-7 (March 2025). Models up to 14B parameters.
How to install rwkv-architecture
install rwkv-architecture
# install the AI-Research-SKILLs pack with the skills CLI
npx skills add Orchestra-Research/AI-Research-SKILLs# or add only this skill to Claude Code: copy the folder
01-model-architecture/rwkv/
# into
~/.claude/skills/rwkv/ (all projects)
.claude/skills/rwkv/ (one project)
1# RWKV - Receptance Weighted Key Value23## Quick start45RWKV (RwaKuv) combines Transformer parallelization (training) with RNN efficiency (inference).67**Installation**:8```bash9# Install PyTorch10pip install torch --upgrade --extra-index-url https://download.pytorch.org/whl/cu1211112# Install dependencies13pip install pytorch-lightning==1.9.5 deepspeed wandb ninja --upgrade1415# Install RWKV16pip install rwkv17```1819**Basic usage** (GPT mode + RNN mode):20```python21import os22from rwkv.model import RWKV2324os.environ["RWKV_JIT_ON"] = '1'25os.environ["RWKV_CUDA_ON"] = '1' # Use CUDA kernel for speed2627# Load model28model = RWKV(29 model='/path/to/RWKV-4-Pile-1B5-20220903-8040',30 strategy='cuda fp16'31)3233# GPT mode (parallel processing)34out, state = model.forward([187, 510, 1563, 310, 247], None)35print(out.detach().cpu().numpy()) # Logits3637# RNN mode (sequential processing, same result)38out, state = model.forward([187, 510], None) # First 2 tokens39out, state = model.forward([1563], state) # Next token40out, state = model.forward([310, 247], state) # Last tokens41print(out.detach().cpu().numpy()) # Same logits as above!42```4344## Common workflows4546### Workflow 1: Text generation (streaming)4748**Efficient token-by-token generation**:49```python50from rwkv.model import RWKV51from rwkv.utils import PIPELINE5253model = RWKV(model='RWKV-4-Pile-14B-20230313-ctx8192-test1050', strategy='cuda fp16')54pipeline = PIPELINE(model, "20B_tokenizer.json")5556# Initial prompt57prompt = "The future of AI is"58…
Excerpt shown under the repository's MIT license.
