Text Generation
Transformers
Safetensors
RWKV
English
fwkv
rosa
linear-transformer
recurrent-neural-network
chat
ultrachat
custom-architecture
custom_code
Instructions to use FWKV/FWKV-ROSA with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use FWKV/FWKV-ROSA with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="FWKV/FWKV-ROSA", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("FWKV/FWKV-ROSA", trust_remote_code=True, device_map="auto") - RWKV
How to use FWKV/FWKV-ROSA with RWKV:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use FWKV/FWKV-ROSA with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "FWKV/FWKV-ROSA" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FWKV/FWKV-ROSA", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/FWKV/FWKV-ROSA
- SGLang
How to use FWKV/FWKV-ROSA 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 "FWKV/FWKV-ROSA" \ --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": "FWKV/FWKV-ROSA", "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 "FWKV/FWKV-ROSA" \ --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": "FWKV/FWKV-ROSA", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use FWKV/FWKV-ROSA with Docker Model Runner:
docker model run hf.co/FWKV/FWKV-ROSA
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,10 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
language: en
|
| 3 |
license: apache-2.0
|
| 4 |
tags:
|
| 5 |
- fwkv
|
| 6 |
- rosa
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
---
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Here’s a proper, detailed README for your model repository. It covers the architecture, training, usage, and performance.
|
| 2 |
+
|
| 3 |
+
```markdown
|
| 4 |
---
|
| 5 |
language: en
|
| 6 |
license: apache-2.0
|
| 7 |
tags:
|
| 8 |
- fwkv
|
| 9 |
- rosa
|
| 10 |
+
- rwkv
|
| 11 |
+
- linear-transformer
|
| 12 |
+
- recurrent-neural-network
|
| 13 |
+
- chat
|
| 14 |
+
- ultrachat
|
| 15 |
+
- pytorch
|
| 16 |
+
- custom-architecture
|
| 17 |
---
|
| 18 |
+
|
| 19 |
+
# FWKV-ROSA
|
| 20 |
+
|
| 21 |
+
A **56M‑parameter**, from‑scratch recurrent language model combining a **per‑channel leaky integrator (FWKV)** with the **RWKV‑8 ROSA copy‑signal** mechanism.
|
| 22 |
+
Chat‑tuned on `HuggingFaceH4/ultrachat_200k` with a simple two‑role template.
|
| 23 |
+
|
| 24 |
+
## Model description
|
| 25 |
+
|
| 26 |
+
- **Architecture:** 14‑layer FWKV blocks with a factorised tied embedding/head (512‑dim model, 128‑dim embedding) and an exact vectorised parallel scan for the constant‑decay recurrence.
|
| 27 |
+
- **ROSA (Rapid Online Suffix Automaton):** A parameter‑free, causal predictor that injects the token that historically followed the longest matching suffix of the current context. Implemented as an embedding added to the early hidden state.
|
| 28 |
+
- **Training data:** [UltraChat 200k](https://huggingface.co/datasets/HuggingFaceH4/ultrachat_200k) (`train_sft` / `test_sft` splits), 20k training examples, 1k validation examples.
|
| 29 |
+
- **Context length:** 1024 tokens (no positional embeddings – context is free parameter‑wise).
|
| 30 |
+
- **Tokenizer:** GPT‑2 tokenizer extended with `<|user|>` and `<|assistant|>` special tokens.
|
| 31 |
+
- **Training precision:** bfloat16 mixed precision on a single NVIDIA T4 (batch size 8, gradient accumulation 4, effective batch 32). Training took ~2 hours.
|
| 32 |
+
|
| 33 |
+
## Performance
|
| 34 |
+
|
| 35 |
+
| Metric | Value |
|
| 36 |
+
|--------|-------|
|
| 37 |
+
| **Validation perplexity** | 67.78 |
|
| 38 |
+
| **Validation loss** | 4.216 |
|
| 39 |
+
|
| 40 |
+
*Note:* With only 56M parameters and a fairly simple linear recurrence, the model is intended as a research experiment. It can generate coherent multi‑turn conversations but may occasionally produce repetitive or factual errors.
|
| 41 |
+
|
| 42 |
+
## How to use
|
| 43 |
+
|
| 44 |
+
### Load directly with Transformers
|
| 45 |
+
|
| 46 |
+
```python
|
| 47 |
+
import torch
|
| 48 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 49 |
+
|
| 50 |
+
# The architecture is custom – you need the model definition from the repository.
|
| 51 |
+
# The simplest way is to use the same class definition as in the training script,
|
| 52 |
+
# or rely on the provided `modeling_fwkv.py` (if you upload it) and `trust_remote_code=True`.
|
| 53 |
+
|
| 54 |
+
model = AutoModelForCausalLM.from_pretrained("FlameF0X/FWKV-ROSA", trust_remote_code=True)
|
| 55 |
+
tokenizer = AutoTokenizer.from_pretrained("FlameF0X/FWKV-ROSA")
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
**Chat template:**
|
| 59 |
+
|
| 60 |
+
```
|
| 61 |
+
<|user|> Your prompt here
|
| 62 |
+
<|assistant|> The model reply <eos>
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
Make sure to use the special tokens as shown above. The model was trained to generate after the `<|assistant|>` tag, and the loss is only computed on assistant tokens.
|
| 66 |
+
|
| 67 |
+
## Training details
|
| 68 |
+
|
| 69 |
+
| Hyperparameter | Value |
|
| 70 |
+
|----------------|-------|
|
| 71 |
+
| Layers | 14 |
|
| 72 |
+
| Model dim | 512 |
|
| 73 |
+
| Embedding dim | 128 |
|
| 74 |
+
| FFN multiplier | 4 |
|
| 75 |
+
| WKV decay floor | 0.1 |
|
| 76 |
+
| Batch size (per step) | 8 |
|
| 77 |
+
| Gradient accumulation | 4 |
|
| 78 |
+
| Effective batch size | 32 |
|
| 79 |
+
| Learning rate | 3e‑4 (cosine schedule) |
|
| 80 |
+
| Weight decay | 0.1 |
|
| 81 |
+
| Gradient clipping | 1.0 |
|
| 82 |
+
| Epochs | 2 |
|
| 83 |
+
| Optimizer | AdamW (fused) |
|
| 84 |
+
|
| 85 |
+
Training was done on a single T4 GPU (Kaggle, 2x T4 available but only one used). Gradient checkpointing and bfloat16 autocast were essential to fit the 1024‑token sequences within 15 GB of VRAM. The parallel scan over time is exact (not an approximation) and fully vectorised, yielding a training speed of ~80K tokens/second.
|
| 86 |
+
|
| 87 |
+
## Limitations & Bias
|
| 88 |
+
|
| 89 |
+
- This is a small model trained on a curated synthetic dialogue dataset. It may not generalise well to factual knowledge or long‑form reasoning.
|
| 90 |
+
- The ROSA copy mechanism helps with repeating patterns but can sometimes cause the model to inappropriately copy parts of the user’s message.
|
| 91 |
+
- No alignment or safety filtering was performed beyond what’s implicit in the dataset.
|