Instructions to use matthewagi/AI-Detector-0.8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use matthewagi/AI-Detector-0.8B with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download matthewagi/AI-Detector-0.8B --local-dir AI-Detector-0.8B
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Download gpu/token_head.py from matthewagi/AI-Detector-0.8B: direct link, hf CLI and curl.
- Browser
- Download file 746 Bytes
-
https://huggingface.co/matthewagi/AI-Detector-0.8B/resolve/main/gpu/token_head.py
- Command line
-
hf download hf://matthewagi/AI-Detector-0.8B/gpu/token_head.py
-
curl -L -o token_head.py https://huggingface.co/matthewagi/AI-Detector-0.8B/resolve/main/gpu/token_head.py
746 Bytes
| from torch import nn | |
| from torch.nn import functional as F | |
| class TokenHead(nn.Module): | |
| def __init__(self, width, decoder_stride): | |
| super().__init__() | |
| self.decoder_stride = decoder_stride | |
| self.token = nn.Linear(width, 128, bias=False) | |
| self.context = nn.Linear(width, 128, bias=False) | |
| self.norm = nn.LayerNorm(128) | |
| self.out = nn.Linear(128, 3) | |
| def forward(self, tokens, context): | |
| x = self.token(tokens) | |
| context = self.context(context) | |
| if self.decoder_stride > 1: | |
| context = context.repeat_interleave(self.decoder_stride, dim=1) | |
| return self.readout(x + context) | |
| def readout(self, features): | |
| return self.out(F.gelu(self.norm(features))) | |