Instructions to use meromorphic/YEN with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use meromorphic/YEN with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="meromorphic/YEN")# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("meromorphic/YEN", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download yen.py from meromorphic/YEN: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/meromorphic/YEN/resolve/main/yen.py
- Command line
-
hf download hf://meromorphic/YEN/yen.py
-
curl -L -o yen.py https://huggingface.co/meromorphic/YEN/resolve/main/yen.py
1.07 kB
| import torch, torch.nn as nn | |
| from huggingface_hub import hf_hub_download | |
| from safetensors.torch import load_file | |
| class OpenAI: | |
| def __init__(self, token=None): | |
| self.d = "cuda" if torch.cuda.is_available() else "cpu" | |
| class M(nn.Module): | |
| def __init__(self): | |
| super().__init__(); self.embedding = nn.Embedding(256, 1); self.classifier = nn.Linear(1, 2, bias=False) | |
| def forward(self, x): return self.classifier(self.embedding(x).float().mean(0)) | |
| self.m = M().to(self.d); self.m.load_state_dict(load_file(hf_hub_download("faunix/YEN", "model.safetensors", token=token))) | |
| self.chat = type('o', (object,), {"completions": type('o', (object,), {"create": self._c})()})() | |
| def _c(self, **k): | |
| t = torch.tensor([ord(c)%256 for c in k['messages'][-1]['content']], device=self.d) | |
| with torch.no_grad(): out = self.m(t); res = "Yes" if out[1] > out[0] else "No" | |
| return type('o', (object,), {"choices": [type('o', (object,), {"message": type('o', (object,), {"content": res})()})()]})() |