Text Generation
Transformers
Safetensors
gpt_oss
russian
orthography-normalization
historical-text
unsloth
lora
sft
trl
4-bit precision
bitsandbytes
conversational
4-bit precision
Instructions to use ZennyKenny/novoyaz-20b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ZennyKenny/novoyaz-20b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ZennyKenny/novoyaz-20b") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ZennyKenny/novoyaz-20b") model = AutoModelForCausalLM.from_pretrained("ZennyKenny/novoyaz-20b", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ZennyKenny/novoyaz-20b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ZennyKenny/novoyaz-20b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ZennyKenny/novoyaz-20b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ZennyKenny/novoyaz-20b
- SGLang
How to use ZennyKenny/novoyaz-20b 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 "ZennyKenny/novoyaz-20b" \ --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": "ZennyKenny/novoyaz-20b", "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 "ZennyKenny/novoyaz-20b" \ --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": "ZennyKenny/novoyaz-20b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use ZennyKenny/novoyaz-20b with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for ZennyKenny/novoyaz-20b to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for ZennyKenny/novoyaz-20b to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for ZennyKenny/novoyaz-20b to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="ZennyKenny/novoyaz-20b", max_seq_length=2048, ) - Docker Model Runner
How to use ZennyKenny/novoyaz-20b with Docker Model Runner:
docker model run hf.co/ZennyKenny/novoyaz-20b
| # handler.py | |
| from __future__ import annotations | |
| import os | |
| from typing import Any, Dict, List, Union | |
| import torch | |
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| GEN_KW = { | |
| "temperature": float(os.getenv("GEN_TEMPERATURE", "0.2")), | |
| "do_sample": os.getenv("GEN_DO_SAMPLE", "false").lower() == "true", | |
| "max_new_tokens": int(os.getenv("GEN_MAX_NEW_TOKENS", "512")), | |
| "repetition_penalty": float(os.getenv("GEN_REP_PENALTY", "1.0")), | |
| } | |
| PROMPT_PREFIX = ( | |
| "Преобразуй дореформенный русский текст в современную орфографию, " | |
| "сохранив смысл и пунктуацию. Верни только преобразованный текст.\n\nТекст:\n" | |
| ) | |
| PROMPT_SUFFIX = "\n\nСовременный вариант:" | |
| def _to_list(x: Union[str, List[str]]) -> List[str]: | |
| if isinstance(x, list): | |
| return [str(t) for t in x] | |
| return [str(x)] | |
| class EndpointHandler: | |
| def __init__(self, model_dir: str): | |
| # model_dir is the local path downloaded by the endpoint | |
| self.device = "cuda" if torch.cuda.is_available() else "cpu" | |
| # IMPORTANT: trust_remote_code to load custom arch "gpt_oss" | |
| self.tokenizer = AutoTokenizer.from_pretrained( | |
| model_dir, use_fast=True, trust_remote_code=True | |
| ) | |
| self.model = AutoModelForCausalLM.from_pretrained( | |
| model_dir, | |
| torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32, | |
| device_map="auto" if torch.cuda.is_available() else None, | |
| trust_remote_code=True, | |
| ) | |
| if not torch.cuda.is_available(): | |
| # For safety on CPU, disable KV cache to reduce RAM spikes | |
| self.model.config.use_cache = False | |
| self.model.eval() | |
| def _prepare_inputs(self, texts: List[str]) -> Dict[str, Any]: | |
| prompts = [f"{PROMPT_PREFIX}{t}{PROMPT_SUFFIX}" for t in texts] | |
| toks = self.tokenizer( | |
| prompts, return_tensors="pt", padding=True, truncation=True | |
| ) | |
| return {k: v.to(self.model.device) for k, v in toks.items()} | |
| def __call__(self, data: Dict[str, Any]) -> List[Dict[str, str]]: | |
| """ | |
| Accepts { "inputs": "text" } or { "inputs": ["t1","t2",...] } | |
| Returns [{ "generated_text": "..." }, ...] | |
| """ | |
| if "inputs" not in data: | |
| return [{"error": "missing 'inputs'"}] | |
| texts = _to_list(data["inputs"]) | |
| inputs = self._prepare_inputs(texts) | |
| out = self.model.generate(**inputs, **GEN_KW) | |
| results: List[Dict[str, str]] = [] | |
| # decode only the newly generated part | |
| for i, seq in enumerate(out): | |
| inp_len = inputs["input_ids"][i].shape[-1] | |
| gen_part = seq[inp_len:] | |
| text = self.tokenizer.decode(gen_part, skip_special_tokens=True).strip() | |
| results.append({"generated_text": text}) | |
| return results | |