FlameF0X commited on
Commit
a8bdb80
·
verified ·
1 Parent(s): 674f2b6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +84 -3
README.md CHANGED
@@ -1,10 +1,91 @@
 
 
 
1
  ---
2
  language: en
3
  license: apache-2.0
4
  tags:
5
  - fwkv
6
  - rosa
 
 
 
 
 
 
 
7
  ---
8
- # FWKV-56M + ROSA (chat)
9
- Factorised tied weights, vectorized decayed-accumulator recurrence, RWKV-8 ROSA copy signal, chat-tuned on HuggingFaceH4/ultrachat_200k.
10
- **Best val perplexity:** 67.78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.