Instructions to use aneforge/gpt2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ANEForge
How to use aneforge/gpt2 with ANEForge:
# Run this model on the Apple Neural Engine, without CoreML. import aneforge as af from transformers import AutoTokenizer tok = AutoTokenizer.from_pretrained("aneforge/gpt2") model = af.load_llm("aneforge/gpt2") # prefill + resident-KV-cache decode on the ANE ids = tok.encode("The Neural Engine is") print(tok.decode(model.generate(ids, max_new_tokens=20))) - Notebooks
- Google Colab
- Kaggle
|
Download README.md from aneforge/gpt2: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/aneforge/gpt2/resolve/main/README.md
- Command line
-
hf download hf://aneforge/gpt2/README.md
-
curl -L -o README.md https://huggingface.co/aneforge/gpt2/resolve/main/README.md
1.14 kB
| library_name: aneforge | |
| license: mit | |
| base_model: openai-community/gpt2 | |
| pipeline_tag: text-generation | |
| tags: | |
| - aneforge | |
| - apple-neural-engine | |
| # GPT-2 (ANEForge) | |
| An unmodified duplicate of [`openai-community/gpt2`](https://huggingface.co/openai-community/gpt2), tagged for use with | |
| [**ANEForge**](https://github.com/sbryngelson/ANEForge) so the weights load and run directly on the | |
| Apple Neural Engine (no CoreML). Weights are byte-identical to the source; see the original repo for | |
| the model details. Licensed `mit` from the source. | |
| ## Use with ANEForge | |
| ```python | |
| # pip install "aneforge[models]" | |
| import aneforge as af | |
| from transformers import AutoTokenizer | |
| tok = AutoTokenizer.from_pretrained("aneforge/gpt2") | |
| model = af.load_llm("aneforge/gpt2") # prefill + resident-KV-cache decode on the ANE | |
| ids = tok.encode("The Neural Engine is") | |
| print(tok.decode(model.generate(ids, max_new_tokens=20))) | |
| ``` | |
| ANEForge compiles the model's graph into a single ANE program and streams the weights from this repo | |
| via `huggingface_hub`. See the [docs](https://aneforge.readthedocs.io) and the | |
| [paper](https://arxiv.org/abs/2606.17090). | |