Image Feature Extraction
Transformers
Safetensors
English
arcee_kda
kda
kimi-delta-attention
linear-attention
nope
hybrid-attention
distillation
research
custom_code
Instructions to use arcee-ai/AFM-4.5B-Base-KDA-NoPE with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use arcee-ai/AFM-4.5B-Base-KDA-NoPE with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-feature-extraction", model="arcee-ai/AFM-4.5B-Base-KDA-NoPE", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("arcee-ai/AFM-4.5B-Base-KDA-NoPE", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,199 +1,129 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
| 2 |
library_name: transformers
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
|
| 8 |
-
|
| 9 |
|
|
|
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
-
##
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
-
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
|
| 28 |
-
##
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
-
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
##
|
| 37 |
|
| 38 |
-
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
##
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
|
| 47 |
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
-
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 67 |
-
|
| 68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
-
|
| 70 |
-
## How to Get Started with the Model
|
| 71 |
-
|
| 72 |
-
Use the code below to get started with the model.
|
| 73 |
-
|
| 74 |
-
[More Information Needed]
|
| 75 |
|
| 76 |
## Training Details
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
[More Information Needed]
|
| 83 |
-
|
| 84 |
-
### Training Procedure
|
| 85 |
-
|
| 86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
-
|
| 88 |
-
#### Preprocessing [optional]
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
#### Training Hyperparameters
|
| 94 |
-
|
| 95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
-
|
| 97 |
-
#### Speeds, Sizes, Times [optional]
|
| 98 |
-
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
-
|
| 101 |
-
[More Information Needed]
|
| 102 |
-
|
| 103 |
-
## Evaluation
|
| 104 |
-
|
| 105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
-
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
-
|
| 115 |
-
#### Factors
|
| 116 |
-
|
| 117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
-
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
-
|
| 127 |
-
### Results
|
| 128 |
-
|
| 129 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
## Model Examination [optional]
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
-
|
| 139 |
-
[More Information Needed]
|
| 140 |
-
|
| 141 |
-
## Environmental Impact
|
| 142 |
-
|
| 143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
-
|
| 145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
-
|
| 147 |
-
- **Hardware Type:** [More Information Needed]
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
-
|
| 153 |
-
## Technical Specifications [optional]
|
| 154 |
-
|
| 155 |
-
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
-
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
-
|
| 173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
-
|
| 175 |
-
**BibTeX:**
|
| 176 |
-
|
| 177 |
-
[More Information Needed]
|
| 178 |
-
|
| 179 |
-
**APA:**
|
| 180 |
-
|
| 181 |
-
[More Information Needed]
|
| 182 |
-
|
| 183 |
-
## Glossary [optional]
|
| 184 |
-
|
| 185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
|
| 187 |
-
|
| 188 |
|
| 189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
|
| 191 |
-
|
| 192 |
|
| 193 |
-
##
|
| 194 |
|
| 195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
|
| 197 |
-
##
|
| 198 |
|
| 199 |
-
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
library_name: transformers
|
| 6 |
+
base_model:
|
| 7 |
+
- arcee-ai/AFM-4.5B-Base
|
| 8 |
+
tags:
|
| 9 |
+
- kda
|
| 10 |
+
- kimi-delta-attention
|
| 11 |
+
- linear-attention
|
| 12 |
+
- nope
|
| 13 |
+
- hybrid-attention
|
| 14 |
+
- distillation
|
| 15 |
+
- research
|
| 16 |
---
|
| 17 |
|
| 18 |
+
# AFM-4.5B-Base-KDA-NoPE
|
| 19 |
|
| 20 |
+
A hybrid attention variant of [AFM-4.5B-Base](https://huggingface.co/arcee-ai/AFM-4.5B-Base) combining Kimi Delta Attention (KDA) with NoPE (No Positional Encoding) full-attention layers in a 3:1 ratio. This architecture balances efficiency with performance through knowledge distillation.
|
| 21 |
|
| 22 |
+
> ⚠️ **Research Model**: This is an experimental model released for research purposes. For production use, see [AFM-4.5B](https://huggingface.co/arcee-ai/AFM-4.5B).
|
| 23 |
|
| 24 |
+
More details available in our blog post here: https://www.arcee.ai/blog/distilling-kimi-delta-attention-into-afm-4-5b-and-the-tool-we-used-to-do-it
|
| 25 |
|
| 26 |
+
## Overview
|
| 27 |
|
| 28 |
+
Following the Kimi Linear architecture pattern, this model interleaves KDA layers with periodic full-attention layers (using NoPE) in a 3:1 ratio. This hybrid structure reduces memory and KV-cache usage while preserving global information flow via the full attention layers.
|
| 29 |
|
| 30 |
+
**Key characteristics:**
|
| 31 |
+
- 3:1 KDA to full-attention ratio
|
| 32 |
+
- Full attention layers use NoPE (No Positional Encoding)
|
| 33 |
+
- Trained up to 32k sequence length
|
| 34 |
+
- Better short-context performance than pure KDA
|
| 35 |
+
- Reduced memory footprint compared to full attention
|
| 36 |
|
| 37 |
+
## Architecture
|
| 38 |
|
| 39 |
+
| Component | Details |
|
| 40 |
+
|-----------|---------|
|
| 41 |
+
| Parameters | 4.5B |
|
| 42 |
+
| Attention Pattern | 1 Full Attn (NoPE) : 3 KDA |
|
| 43 |
+
| Positional Encoding | NoPE on full attention layers |
|
| 44 |
+
| Max Training Length | 32k tokens |
|
| 45 |
+
| Base Model | AFM-4.5B-Base |
|
| 46 |
|
| 47 |
+
## Benchmark Results
|
| 48 |
|
| 49 |
+
Performance compared to the teacher model and other configurations:
|
| 50 |
|
| 51 |
+
| Benchmark | Teacher (Full Attn) | Hybrid (KDA-NoPE) | KDA-Only |
|
| 52 |
+
|-----------|:-------------------:|:-----------------:|:--------:|
|
| 53 |
+
| MMLU (Avg) | 63.1% | 55.1% | 55.8% |
|
| 54 |
+
| ARC-Challenge | 55.6% | 48.5% | 49.9% |
|
| 55 |
+
| HellaSwag (Norm) | 78.0% | 74.3% | 74.3% |
|
| 56 |
+
| GSM8K (Math) | 52.1% | 36.5% | 26.8% |
|
| 57 |
|
| 58 |
+
### Key Findings
|
| 59 |
|
| 60 |
+
- **Math advantage**: The hybrid recovers significantly more math performance (36.5%) than pure KDA (26.8%)
|
| 61 |
+
- **Knowledge benchmarks**: Performs comparably to KDA-Only on MMLU, ARC, and HellaSwag
|
| 62 |
+
- **Efficiency**: Maintains efficiency gains from KDA while preserving global reasoning via NoPE layers
|
| 63 |
|
| 64 |
+
## Long-Context Performance (NIAH)
|
| 65 |
|
| 66 |
+
The hybrid model shows distinct long-context behavior:
|
| 67 |
|
| 68 |
+
- 100% single-needle retrieval up to 32k
|
| 69 |
+
- Sharp performance cliff past 32k training length
|
| 70 |
+
- Near-zero performance beyond training context (vs. smooth degradation for KDA-Only)
|
| 71 |
|
| 72 |
+
The NoPE full-attention layers appear responsible for the hard cutoff—they haven't seen positions beyond 32k during training. KDA layers generalize more naturally to longer sequences.
|
| 73 |
|
| 74 |
+
## Usage
|
| 75 |
|
| 76 |
+
```python
|
| 77 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 78 |
+
import torch
|
| 79 |
|
| 80 |
+
model_id = "arcee-ai/AFM-4.5B-Base-KDA-NoPE"
|
| 81 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 82 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 83 |
+
model_id,
|
| 84 |
+
torch_dtype=torch.bfloat16,
|
| 85 |
+
device_map="auto"
|
| 86 |
+
)
|
| 87 |
|
| 88 |
+
prompt = "The theory of relativity states that"
|
| 89 |
+
input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(model.device)
|
| 90 |
|
| 91 |
+
outputs = model.generate(
|
| 92 |
+
input_ids,
|
| 93 |
+
max_new_tokens=100,
|
| 94 |
+
do_sample=True,
|
| 95 |
+
temperature=0.7,
|
| 96 |
+
top_p=0.95
|
| 97 |
+
)
|
| 98 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 99 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
## Training Details
|
| 102 |
|
| 103 |
+
- **Method**: Knowledge distillation from AFM-4.5B-Base using [DistillKit](https://github.com/arcee-ai/DistillKit)
|
| 104 |
+
- **Teacher**: AFM-4.5B-Base (full attention)
|
| 105 |
+
- **Student Architecture**: Hybrid 3:1 KDA:NoPE
|
| 106 |
+
- **Training Length**: 32k sequence length
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
+
## Comparison: Hybrid vs KDA-Only
|
| 109 |
|
| 110 |
+
| Aspect | Hybrid (KDA-NoPE) | KDA-Only |
|
| 111 |
+
|--------|:-----------------:|:--------:|
|
| 112 |
+
| Math (GSM8K) | 36.5% ✓ | 26.8% |
|
| 113 |
+
| Within-training NIAH | 100% | 100% |
|
| 114 |
+
| Beyond-training behavior | Hard cliff | Smooth degradation |
|
| 115 |
+
| Memory efficiency | ~75% reduction | ~100% reduction |
|
| 116 |
|
| 117 |
+
Choose **Hybrid** for better short-context reasoning, especially math. Choose **KDA-Only** for more predictable long-context degradation.
|
| 118 |
|
| 119 |
+
## Intended Use
|
| 120 |
|
| 121 |
+
This model is intended for:
|
| 122 |
+
- Research into hybrid attention architectures
|
| 123 |
+
- Studying linear/full attention tradeoffs
|
| 124 |
+
- Exploring NoPE attention in hybrid configurations
|
| 125 |
+
- Benchmarking efficiency vs. capability tradeoffs
|
| 126 |
|
| 127 |
+
## License
|
| 128 |
|
| 129 |
+
AFM-4.5B is released under the Apache-2.0 license.
|