Run this model with HF Jobs
Run FWKV/FWKV-ROSA on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/FWKV/FWKV-ROSA. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/FWKV/FWKV-ROSA on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/FWKV/FWKV-ROSA. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/FWKV/FWKV-ROSA. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
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)# pip install -U transformers accelerate # 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
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("FWKV/FWKV-ROSA", trust_remote_code=True, device_map="auto")FWKV-ROSA --- Read more here
A 56M‑parameter, from‑scratch recurrent language model that combines a per‑channel leaky integrator (FWKV) with the RWKV‑8 ROSA copy‑signal mechanism. It is a research experiment designed to explore how far purely recurrent architectures can go on small‑scale, curated conversational data.
The model was chat‑tuned on HuggingFaceH4/ultrachat_200k and uses a simple
two‑role template:
<|user|> Your message
<|assistant|> Model reply<|endoftext|>
Model Description
- Architecture: 14 stacked FWKV blocks. Each block replaces the standard attention with a fixed, data‑independent decayed accumulator:
stateₜ = W·stateₜ₋₁ + kₜ·vₜ, whereW = clamp(sigmoid(w), min=0.1). The recurrence is computed exactly via a vectorised parallel scan (no approximations). - 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. The ROSA signal is embedded and added to the input representation of each token.
- Factorised embedding/head: 128‑dimensional embedding space, projected to a 512‑dimensional model space, with tied weights.
- Context length: 1024 tokens. No positional embeddings are used, making the context window “free” in terms of parameters.
- Tokenizer: GPT‑2 tokenizer extended with the special tokens
<|user|>and<|assistant|>.
Uses
Direct Use
FWKV-ROSA is intended for research on efficient language models and for educational demonstrations of recurrent architectures. You can chat with it in a multi‑turn setting using the template above.
Out‑of‑Scope Use
- This model is not suitable for any production or safety‑critical application.
- It has not been aligned with RLHF or other safety methods and may generate inappropriate or harmful content.
- The limited size and training data mean it cannot be relied upon for factual knowledge or reasoning.
Bias, Risks, and Limitations
- Trained on a relatively small synthetic dataset, the model can produce repetitive or nonsensical output.
- The ROSA copy mechanism may occasionally copy large chunks of the user’s prompt verbatim.
- Biases present in the original UltraChat data are likely reflected in the model’s responses.
How to Get Started
The model relies on a custom architecture. To load it, you must provide the
modeling_fwkv.py file (found in the repository) and trust the remote code:
from transformers import AutoTokenizer, AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained(
"FlameF0X/FWKV-ROSA",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained("FWKV/FWKV-ROSA")
Then format your prompts exactly with the chat tokens:
device = "cuda" if torch.cuda.is_available() else "cpu"
model.to(device).eval()
prompt = "<|user|> What is the capital of France?\n<|assistant|>"
input_ids = tokenizer.encode(prompt)
# ROSA IDs must be computed – you can import `rosa` from modeling_fwkv
from modeling_fwkv import rosa
rosa_ids = torch.tensor([rosa(input_ids)], device=device)
out = model(input_ids=torch.tensor([input_ids], device=device),
rosa_ids=rosa_ids, use_cache=True)
# Continue autoregressive sampling…
For a fully working chat demo, see the Gradio app provided in the repository.
Training Details
Dataset
- Name: UltraChat 200k
- Splits:
train_sft(20,000 examples),test_sft(1,000 examples) - Format: multi‑turn conversations; only assistant tokens contribute to the loss.
Training Procedure
| Hyperparameter | Value |
|---|---|
| Architecture | 14 FWKV blocks, d_model=512, d_emb=128 |
| FFN multiplier | 4 |
| WKV decay floor | 0.1 |
| Batch size (per GPU) | 8 |
| Gradient accumulation | 4 |
| Effective batch size | 32 |
| Learning rate | 3×10⁻⁴ (cosine schedule) |
| Weight decay | 0.1 |
| Gradient clipping | 1.0 |
| Optimizer | AdamW (fused) |
| Precision | bfloat16 mixed |
| Epochs | 2 |
| Hardware | 1× NVIDIA T4 (15 GB) |
| Training time | ~2 hours |
| Speed | ~80,000 tokens/second |
Gradient checkpointing was enabled to fit the 1024‑token sequences in memory.
Evaluation
| Metric | Value |
|---|---|
| Validation loss | 4.216 |
| Validation perplexity | 67.78 |
The perplexity is relatively high due to the small model size and limited training data. It is comparable to other similarly‑sized recurrent LMs on UltraChat.
Environmental Impact
The training ran for about 2 hours on a single NVIDIA T4 GPU (maximum power draw ~70 W), resulting in an estimated 0.14 kWh of electricity consumption and approximately 0.06 kg CO₂eq (assuming a grid carbon intensity of 0.4 kg/kWh). This is a negligible footprint.
Technical Specifications
- Model type: Recurrent neural network (linear RNN)
- Parameters: 56.2 million
- Backbone (FWKV blocks + embeddings): ~50M
- ROSA embedding: ~6.2M
- Checkpoint format: PyTorch
safetensors - Required files in the repo:
config.jsonmodel.safetensors(orpytorch_model.bin)modeling_fwkv.pytokenizer.json/vocab.json/merges.txt
- Auto‑mapping: The
config.jsonincludes"auto_map": { "AutoModelForCausalLM": "modeling_fwkv.FWKVLanguageModel" }, so loading withtrust_remote_code=Truewill automatically locate the correct class.
Citation
If you use FWKV-ROSA in your research, please cite it as:
@misc{fwkv-rosa,
author = {FlameF0X},
title = {FWKV-ROSA: A 56M Recurrent Chat LM with RWKV-style Decay and ROSA Copy Signal},
year = {2025},
howpublished = {\url{https://huggingface.co/FWKV/FWKV-ROSA}},
}
Additional Information
This model was built as an experiment to test the combination of a simple leaky integrator with the ROSA copy signal on a small, clean conversational dataset. It demonstrates that a pure linear RNN can learn to produce coherent multi‑turn dialogue without any attention mechanisms. Feedback and contributions are welcome!
- Downloads last month
- 57
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="FWKV/FWKV-ROSA", trust_remote_code=True)