Text Generation
Transformers
Safetensors
English
weevil_recurrent
weevil
recurrent
gated-deltanet
custom_code
Instructions to use ELBennett/Weevil-Recurrent-16M-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ELBennett/Weevil-Recurrent-16M-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ELBennett/Weevil-Recurrent-16M-Base", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("ELBennett/Weevil-Recurrent-16M-Base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ELBennett/Weevil-Recurrent-16M-Base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ELBennett/Weevil-Recurrent-16M-Base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ELBennett/Weevil-Recurrent-16M-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ELBennett/Weevil-Recurrent-16M-Base
- SGLang
How to use ELBennett/Weevil-Recurrent-16M-Base 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 "ELBennett/Weevil-Recurrent-16M-Base" \ --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": "ELBennett/Weevil-Recurrent-16M-Base", "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 "ELBennett/Weevil-Recurrent-16M-Base" \ --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": "ELBennett/Weevil-Recurrent-16M-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ELBennett/Weevil-Recurrent-16M-Base with Docker Model Runner:
docker model run hf.co/ELBennett/Weevil-Recurrent-16M-Base
Add a checkpoint list and a model-details spec
Browse files
README.md
CHANGED
|
@@ -21,11 +21,36 @@ datasets:
|
|
| 21 |
|
| 22 |
A 16,085,568-parameter recurrent decoder with post-decay pretraining weights. [Weevil-Recurrent-16M-QA](https://huggingface.co/ELBennett/Weevil-Recurrent-16M-QA) is this model fine-tuned for multiple-choice questions.
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
##
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
```python
|
| 31 |
import torch
|
|
@@ -37,6 +62,17 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
| 37 |
tokenizer = AutoTokenizer.from_pretrained("ELBennett/Weevil-Recurrent-16M-Base")
|
| 38 |
model.eval()
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
choices = ["cat", "dog"]
|
| 41 |
prompt = "Which animal barks?\n\nA. cat\nB. dog\nAnswer:"
|
| 42 |
pause_id = tokenizer.convert_tokens_to_ids("[pause]")
|
|
@@ -53,18 +89,9 @@ print(choices[int(scores.argmax())], [round(score, 3) for score in scores.tolist
|
|
| 53 |
|
| 54 |
The prompt and pauses are prefilled once. Each choice is scored from its own copy of the recurrent state.
|
| 55 |
|
| 56 |
-
### Generate
|
| 57 |
-
|
| 58 |
-
Continue with the model, tokenizer, and prompt above. Pass unpadded rows: right-padding is consumed by the convolution.
|
| 59 |
-
|
| 60 |
-
```python
|
| 61 |
-
prompt_ids = torch.tensor([tokenizer.encode(prompt, add_special_tokens=False)])
|
| 62 |
-
print(model.generate(prompt_ids, max_new_tokens=16).shape)
|
| 63 |
-
```
|
| 64 |
-
|
| 65 |
### Reuse the recurrent state
|
| 66 |
|
| 67 |
-
`generate` prefills the GDN2 state and convolution windows, then advances them one token at a time. `past_key_values` and `recurrent_state` refer to the same object: one state matrix and one convolution window per mixer, with a separate copy for every core pass.
|
| 68 |
|
| 69 |
```python
|
| 70 |
out = model(prompt_ids, use_cache=True)
|
|
@@ -116,13 +143,6 @@ Together that is **10.5 billion** content tokens: 9.75 billion from the first mi
|
|
| 116 |
|
| 117 |
## Architecture
|
| 118 |
|
| 119 |
-
The model is a causal Gated DeltaNet-2 decoder with the same recurrence as the QA fine-tune.
|
| 120 |
-
|
| 121 |
-
- Vocabulary: 50,368.
|
| 122 |
-
- Factorized embedding: 128.
|
| 123 |
-
- Hidden size: 256.
|
| 124 |
-
- Stack: 2-layer prelude, 4-layer core, 2-layer coda.
|
| 125 |
-
|
| 126 |
`core_passes` repeats only the core. Each core pass adds `input_scale * prelude_output` back onto the residual. Each mixer and MLP branch has a 1-lane read/write gate. Next-token logits go back through the factorized embedding. Linears run in bfloat16.
|
| 127 |
|
| 128 |
`[pause]` is token id 50285. It is a special token, so the word "pause" in ordinary text is not rewritten to it. The model does not learn to emit pauses. Put them in the input.
|
|
|
|
| 21 |
|
| 22 |
A 16,085,568-parameter recurrent decoder with post-decay pretraining weights. [Weevil-Recurrent-16M-QA](https://huggingface.co/ELBennett/Weevil-Recurrent-16M-QA) is this model fine-tuned for multiple-choice questions.
|
| 23 |
|
| 24 |
+
## Checkpoints
|
| 25 |
+
|
| 26 |
+
| Model | Description |
|
| 27 |
+
|---|---|
|
| 28 |
+
| [ELBennett/Weevil-Recurrent-16M-Base](https://huggingface.co/ELBennett/Weevil-Recurrent-16M-Base) | Post-decay pretraining checkpoint. |
|
| 29 |
+
| [ELBennett/Weevil-Recurrent-16M-QA](https://huggingface.co/ELBennett/Weevil-Recurrent-16M-QA) | The Base checkpoint fine-tuned for multiple-choice questions. |
|
| 30 |
+
|
| 31 |
+
## Model details
|
| 32 |
+
|
| 33 |
+
| Property | Value |
|
| 34 |
+
|---|---|
|
| 35 |
+
| Parameters | 16,085,568 |
|
| 36 |
+
| Architecture | Causal Gated DeltaNet-2 |
|
| 37 |
+
| Vocabulary | 50,368 |
|
| 38 |
+
| Factorized embedding | 128 |
|
| 39 |
+
| Hidden size | 256 |
|
| 40 |
+
| Stack | 2-layer prelude + 4-layer core + 2-layer coda |
|
| 41 |
+
| Pretraining | 9.75B first-mix tokens + the entire 750M decay stage = 10.5B content tokens |
|
| 42 |
+
| Precision | Float32 stored weights; bfloat16 linears |
|
| 43 |
+
| Pause token | `[pause]`, token id 50285 |
|
| 44 |
+
|
| 45 |
+
## How to use
|
| 46 |
+
|
| 47 |
+
```bash
|
| 48 |
+
pip install torch transformers
|
| 49 |
+
```
|
| 50 |
|
| 51 |
+
### Generate
|
| 52 |
|
| 53 |
+
Pass unpadded rows: right-padding is consumed by the convolution.
|
| 54 |
|
| 55 |
```python
|
| 56 |
import torch
|
|
|
|
| 62 |
tokenizer = AutoTokenizer.from_pretrained("ELBennett/Weevil-Recurrent-16M-Base")
|
| 63 |
model.eval()
|
| 64 |
|
| 65 |
+
prompt = "The capital of France is"
|
| 66 |
+
prompt_ids = torch.tensor([tokenizer.encode(prompt, add_special_tokens=False)])
|
| 67 |
+
output_ids = model.generate(prompt_ids, max_new_tokens=16)
|
| 68 |
+
print(tokenizer.decode(output_ids[0], skip_special_tokens=True))
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
### Score choices
|
| 72 |
+
|
| 73 |
+
Continue with the model and tokenizer above.
|
| 74 |
+
|
| 75 |
+
```python
|
| 76 |
choices = ["cat", "dog"]
|
| 77 |
prompt = "Which animal barks?\n\nA. cat\nB. dog\nAnswer:"
|
| 78 |
pause_id = tokenizer.convert_tokens_to_ids("[pause]")
|
|
|
|
| 89 |
|
| 90 |
The prompt and pauses are prefilled once. Each choice is scored from its own copy of the recurrent state.
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
### Reuse the recurrent state
|
| 93 |
|
| 94 |
+
This continues the `prompt_ids` from the scoring example. `generate` prefills the GDN2 state and convolution windows, then advances them one token at a time. `past_key_values` and `recurrent_state` refer to the same object: one state matrix and one convolution window per mixer, with a separate copy for every core pass.
|
| 95 |
|
| 96 |
```python
|
| 97 |
out = model(prompt_ids, use_cache=True)
|
|
|
|
| 143 |
|
| 144 |
## Architecture
|
| 145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
`core_passes` repeats only the core. Each core pass adds `input_scale * prelude_output` back onto the residual. Each mixer and MLP branch has a 1-lane read/write gate. Next-token logits go back through the factorized embedding. Linears run in bfloat16.
|
| 147 |
|
| 148 |
`[pause]` is token id 50285. It is a special token, so the word "pause" in ordinary text is not rewritten to it. The model does not learn to emit pauses. Put them in the input.
|