File size: 1,836 Bytes
7856156 fd1f8a1 7856156 fd1f8a1 7856156 7d2307a fd1f8a1 7d2307a fd1f8a1 |
1 2 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 |
---
language:
- en
- zh
license: apache-2.0
pipeline_tag: text-generation
library_name: transformers
---
# BlockFFN-Medium
This is the original 0.5B BlockFFN checkpoint used in the paper *BlockFFN: Towards End-Side Acceleration-Friendly Mixture-of-Experts with Chunk-Level Activation Sparsity* for acceleration tests.
Links: [[Paper](https://arxiv.org/pdf/2507.08771)] [[Codes](https://github.com/thunlp/BlockFFN)]
## Usage
You can load and use this model simply by using `AutoTokenizer` and `AutoModelForCausalLM` from the `transformers` library.
```python
from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
import torch
# Assuming the model ID is "SparseLLM/BlockFFN-Medium"
model_id = "SparseLLM/BlockFFN-Medium"
# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, trust_remote_code=True)
# Create a text generation pipeline
pipe = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
torch_dtype=torch.bfloat16,
device_map="auto",
)
# Example usage
prompt = "The quick brown fox jumps over the lazy"
result = pipe(prompt, max_new_tokens=50, do_sample=True, top_p=0.9, temperature=0.7)
print(result[0]["generated_text"])
```
## Citation
If you find our work useful for your research, please kindly cite our paper as follows:
```
@article{song2025blockffn,
title={{BlockFFN}: Towards End-Side Acceleration-Friendly Mixture-of-Experts with Chunk-Level Activation Sparsity},
author={Chenyang Song and Weilin Zhao and Xu Han and Chaojun Xiao and Yingfa Chen and Yuxuan Li and Zhiyuan Liu and Maosong Sun},
journal={arXiv preprint arXiv:2507.08771},
year={2025},
url={https://arxiv.org/pdf/2507.08771},
}
``` |