Text Generation
Transformers
Safetensors
GGUF
Russian
qwen2
chat
conversational
text-generation-inference
Instructions to use salgr/SalgrAI_v2.1_Pro with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use salgr/SalgrAI_v2.1_Pro with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="salgr/SalgrAI_v2.1_Pro") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("salgr/SalgrAI_v2.1_Pro") model = AutoModelForCausalLM.from_pretrained("salgr/SalgrAI_v2.1_Pro", 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use salgr/SalgrAI_v2.1_Pro with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf salgr/SalgrAI_v2.1_Pro:F16 # Run inference directly in the terminal: llama cli -hf salgr/SalgrAI_v2.1_Pro:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf salgr/SalgrAI_v2.1_Pro:F16 # Run inference directly in the terminal: llama cli -hf salgr/SalgrAI_v2.1_Pro:F16
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf salgr/SalgrAI_v2.1_Pro:F16 # Run inference directly in the terminal: ./build/bin/llama cli -hf salgr/SalgrAI_v2.1_Pro:F16
Use Docker
docker model run hf.co/salgr/SalgrAI_v2.1_Pro:F16
- Llama new
- LM Studio
- Jan
- vLLM
How to use salgr/SalgrAI_v2.1_Pro with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "salgr/SalgrAI_v2.1_Pro" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "salgr/SalgrAI_v2.1_Pro", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/salgr/SalgrAI_v2.1_Pro:F16
- SGLang
How to use salgr/SalgrAI_v2.1_Pro 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 "salgr/SalgrAI_v2.1_Pro" \ --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": "salgr/SalgrAI_v2.1_Pro", "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 "salgr/SalgrAI_v2.1_Pro" \ --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": "salgr/SalgrAI_v2.1_Pro", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use salgr/SalgrAI_v2.1_Pro with Ollama:
ollama run hf.co/salgr/SalgrAI_v2.1_Pro:F16
- Unsloth Desktop
- Docker Model Runner
How to use salgr/SalgrAI_v2.1_Pro with Docker Model Runner:
docker model run hf.co/salgr/SalgrAI_v2.1_Pro:F16
- Lemonade
How to use salgr/SalgrAI_v2.1_Pro with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull salgr/SalgrAI_v2.1_Pro:F16
Run and chat with the model
lemonade run user.SalgrAI_v2.1_Pro-F16
List all available models
lemonade list
- Atomic Chat
Download chat_example.py from salgr/SalgrAI_v2.1_Pro: direct link, hf CLI and curl.
- Browser
- Download file 2.67 kB
-
https://huggingface.co/salgr/SalgrAI_v2.1_Pro/resolve/main/chat_example.py
- Command line
-
hf download hf://salgr/SalgrAI_v2.1_Pro/chat_example.py
-
curl -L -o chat_example.py https://huggingface.co/salgr/SalgrAI_v2.1_Pro/resolve/main/chat_example.py
2.67 kB
| """Локальный диалог с SalgrAI v2.1 Pro или Pro Coder в Transformers.""" | |
| import argparse | |
| import torch | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| def fit_history(tokenizer, messages, budget): | |
| """Сохранить последние полные пары, помещающиеся в контекст.""" | |
| history = messages | |
| while history: | |
| inputs = tokenizer.apply_chat_template( | |
| history, add_generation_prompt=True, tokenize=True, | |
| return_dict=True, return_tensors="pt", | |
| ) | |
| if inputs["input_ids"].shape[1] <= budget: | |
| return history, inputs | |
| history = history[2:] | |
| raise ValueError("Последнее сообщение превышает лимит контекста.") | |
| def main(): | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("model", nargs="?", default=".", help="Папка или репозиторий модели") | |
| parser.add_argument("--context", type=int, default=4096, help="Лимит токенов вместе с ответом") | |
| args = parser.parse_args() | |
| device = torch.device("cuda" if torch.cuda.is_available() else "cpu") | |
| dtype = torch.bfloat16 if device.type == "cuda" and torch.cuda.is_bf16_supported() else torch.float32 | |
| tokenizer = AutoTokenizer.from_pretrained(args.model) | |
| model = AutoModelForCausalLM.from_pretrained(args.model, dtype=dtype).to(device).eval() | |
| max_new = model.generation_config.max_new_tokens | |
| if not max_new or not max_new < args.context <= model.config.max_position_embeddings: | |
| parser.error("--context должен вмещать ответ и укладываться в лимит модели") | |
| history = [] | |
| while True: | |
| try: | |
| text = input("вы> ").strip() | |
| except (EOFError, KeyboardInterrupt): | |
| break | |
| if text == "/exit": | |
| break | |
| if text == "/reset": | |
| history = [] | |
| continue | |
| if not text: | |
| continue | |
| pending = history + [{"role": "user", "content": text}] | |
| try: | |
| history, inputs = fit_history(tokenizer, pending, args.context - max_new) | |
| except ValueError as exc: | |
| print(exc) | |
| continue | |
| inputs = inputs.to(device) | |
| with torch.inference_mode(): | |
| output = model.generate(**inputs) | |
| answer = tokenizer.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True).strip() | |
| history.append({"role": "assistant", "content": answer}) | |
| print("SalgrAI>", answer) | |
| if __name__ == "__main__": | |
| main() | |