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) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# 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
|
Download README.md from OpenRussianAI/andrey: direct link, hf CLI and curl.
- Browser
- Download file 3.72 kB
-
https://huggingface.co/OpenRussianAI/andrey/resolve/main/README.md
- Command line
-
hf download hf://OpenRussianAI/andrey/README.md
-
curl -L -o README.md https://huggingface.co/OpenRussianAI/andrey/resolve/main/README.md
3.72 kB
| 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 |