Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 10 min read Announcement easyNovice

Introducing RWKV - An RNN with the advantages of a transformer

RWKV is an attention-free language model architecture, derived from Apple's Attention Free Transformer, that trains in parallel like a GPT-style transformer but runs inference as an RNN. Each step needs only matrix-vector operations, memory stays constant as context grows, and ctx8192 models run as fast as ctx1024 ones with the same RAM. RWKV-4 checkpoints from ~170M to 14B parameters were trained on the Pile, alongside Raven chat fine-tunes. The architecture is now integrated into Hugging Face transformers, with pipeline and generate examples and a script for converting raw RWKV weights to HF format.

Assumes: transformer self-attentionrecurrent neural networks

Related posts

  • Optimizing your LLM in production

    Hugging Face mediumAdept

    Serving billion-parameter LLMs efficiently comes down to three levers: lower precision, Flash Attention, and inference-friendly architectures such as ALiBi, rotary embeddings, Multi-Query Attention and Grouped-Query Attention. Weights need roughly 2 GB of VRAM per billion parameters in bfloat16, and measurements on OctoCoder (~15B parameters) show peak memory dropping from about 29 GB in bfloat16 to 15 GB with 8-bit and 9.5 GB with 4-bit bitsandbytes quantization, with little output change but slightly slower inference. Flash Attention addresses self-attention's quadratic memory growth with sequence length by restructuring the computation to make better use of GPU memory. Code examples in Hugging Face Transformers accompany each technique.

  • Productizing Large Language Models

    Replit mediumAdept

    Replit runs transformer models from ~100M parameters (search, spam) through 1-10B (GhostWriter code autocomplete) to 100B+ in production, and shares lessons on making them usable. Nonsense and repetition loops are handled with temperature and frequency penalty tuning, cycle detection, multi-temperature sampling, reranking with a second model, and fine-tuning on user feedback. Quality is tracked with HumanEval, loop and nonsense rates, and A/B tests. Inference cost is cut with FasterTransformer, distillation and quantization, and GPUs are run at 70-80% utilization on Kubernetes so request queues stay bounded while autoscaling has headroom.

  • KV Cache from scratch in nanoVLM

    Hugging Face mediumAdept

    KV caching avoids recomputing keys and values for earlier tokens during autoregressive generation, and implementing it from scratch in the pure-PyTorch nanoVLM codebase gave a 38% speedup in generation. The walkthrough shows the redundancy in self-attention with small PyTorch examples. It then makes three changes: the grouped attention block appends new K/V to a per-layer cache, the language model tracks the cache per layer and uses start_pos to keep rotary position embeddings correct, and generation is split into a prefill phase and a token-by-token decode phase. The tradeoff is memory for speed, plus more complex code that makes schemes like beam search harder.

  • Transformers now runs llama.cpp quants

    Hugging Face mediumAdept

    Hugging Face transformers can now load GGUF (llama.cpp) quantized checkpoints via `from_pretrained(..., gguf_file=...)` and serve them through `transformers serve` with an OpenAI-compatible API. Weights stay packed on Apple Silicon, and ggml's Metal kernels are reused via the `kernels` library for quantized matmul, fused RMSNorm, flash attention, gated delta nets and MoE top-k routing. Two `generate` changes, dropping all-ones padding masks and deferring the stopping check asynchronously, cut CPU-GPU synchronization for all models. Benchmarks on an M2 Max show throughput close to llama-bench for Qwen3.5 dense and MoE checkpoints, though llama.cpp remains the recommended engine for pure local inference. The initial packed path is MPS-only, and padded batching is still slower.

  • Perceiver IO: a scalable, fully-attentional model that works on any modality

    Hugging Face hardMaster

    Perceiver IO avoids the quadratic cost of self-attention by running attention over a small fixed set of latent variables (e.g. 256×1280). Inputs of any modality enter only through cross-attention, where the latents supply the queries, and outputs are produced by cross-attention with trainable decoder queries. Walking through the Hugging Face Transformers implementation, the post traces tensor shapes through preprocessors, the latent encoder, decoders and postprocessors. Examples cover byte-level text classification and masked language modeling, which reaches 81.8 on GLUE without a tokenizer, and image classification with learned, Fourier or convolutional preprocessing.

The quest for software engineering knowledge.

Look:
Layout: