Text Generation
Transformers
PyTorch
ONNX
Russian
transformer
feature-extraction
chat
russian
easyformer
custom_code
conversational
Instructions to use OpenRussianAI/andrey with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenRussianAI/andrey with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OpenRussianAI/andrey", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("OpenRussianAI/andrey", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use OpenRussianAI/andrey with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenRussianAI/andrey" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenRussianAI/andrey", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/OpenRussianAI/andrey
- SGLang
How to use OpenRussianAI/andrey with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "OpenRussianAI/andrey" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenRussianAI/andrey", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "OpenRussianAI/andrey" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenRussianAI/andrey", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use OpenRussianAI/andrey with Docker Model Runner:
docker model run hf.co/OpenRussianAI/andrey
File size: 3,723 Bytes
ae15ee7 dbcb7ce ae15ee7 dbcb7ce ae15ee7 dbcb7ce a830a4e ae15ee7 1169df9 ae15ee7 1169df9 ae15ee7 1169df9 ae15ee7 1169df9 ae15ee7 d4a84d4 9b7644e ae15ee7 650ccc2 | 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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
---
language:
- ru
license: mit
library_name: transformers
pipeline_tag: text-generation
tags:
- text-generation
- chat
- russian
- transformer
- pytorch
- easyformer
- custom_code
- conversational
datasets:
- custom
model_type: transformer
base_model: OpenRussianAI/andrey
---
# Andrey — EasyFormer 1M
Лёгкий русскоязычный чат-бот на архитектуре EasyFormer.
Упрощённый decoder-only Transformer, ~1.5M параметров.
## О модели
Andrey — компактный русскоязычный чат-бот на собственной архитектуре EasyFormer.
Снаружи — классический decoder-only Transformer, внутри — упрощения для скорости:
single-head attention, RMSNorm, FFN×2, weight tying.
Модель обучается за минуты на CPU, помещается в 15 MB, работает на любом устройстве.
## Архитектура
| Параметр | Значение |
|---|---|
| Тип | decoder-only Transformer |
| Параметров | ~1.5M |
| Слоёв | 5 |
| d_model | 192 |
| Голов | 1 (single-head) |
| FFN | ×2, ReLU |
| Нормализация | RMSNorm |
| Контекст | 128 токенов |
| Токенизатор | char-level, 64 символа |
| Weight tying | lm_head ↔ tok_emb |
## Быстрый старт
```bash
pip install transformers torch huggingface_hub
```
```python
import json, torch
from transformers import AutoModelForCausalLM
from huggingface_hub import hf_hub_download
REPO = "OpenRussianAI/andrey"
model = AutoModelForCausalLM.from_pretrained(
REPO,
trust_remote_code=True,
dtype=torch.float32,
).eval()
d = json.load(open(hf_hub_download(REPO, "tokenizer.json"), encoding="utf-8"))
stoi, itos = d["stoi"], {int(k): v for k, v in d["itos"].items()}
enc = lambda s: [stoi[c] for c in s if c in stoi]
dec = lambda ids: "".join(itos[i] for i in ids)
def ask(q, max_new=40, temp=0.6, top_k=20):
ids = torch.tensor([enc(f"User: {q}\nBot:")], dtype=torch.long)
out = model.generate(ids, max_new_tokens=max_new, do_sample=True,
temperature=temp, top_k=top_k)
text = dec(out[0].tolist())
return text.split("Bot:", 1)[-1].split("User:", 1)[0].strip()
print(ask("привет"))
```
## Примеры диалогов
```
User: привет
Bot: привет, рад тебя видеть
User: как дела
Bot: хорошо, готов помочь
User: кто ты
Bot: я лёгкий чат-бот на EasyFormer
User: что умеешь
Bot: поддерживать простой разговор
User: ты работаешь на цп
Bot: да, я работаю на процессоре
User: сколько у тебя параметров
Bot: около миллиона
User: пока
Bot: до встречи
```
## Обучение
| Параметр | Значение |
|---|---|
| Диалогов | 500+ |
| Токенов | ~7 000 |
| Эпох | 150 |
| Батч | 32 |
| Оптимизатор | AdamW, lr=3e-3 |
| Устройство | Tesla T4 (CUDA) |
| Время | 5 минут ради ускорений |
| Финальный loss | 0.042 |
## Структура репо
```
OpenRussianAI/andrey/
├── README.md
├── config.json
├── configuration_easyformer.py
├── modeling_easyformer.py
├── pytorch_model.bin
└── tokenizer.json
```
## Ограничения
- С матешей плоховато
- Это не слово из датасета = мусор
## Лицензия
MIT
## Сайт Easyformer
https://sites.google.com/view/easyformer/home |