Text Generation
Transformers
Safetensors
GGUF
Russian
qwen2
code
html
javascript
chat
conversational
text-generation-inference
Instructions to use salgr/SalgrAI_v2.1_Coder_Pro with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use salgr/SalgrAI_v2.1_Coder_Pro with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="salgr/SalgrAI_v2.1_Coder_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_Coder_Pro") model = AutoModelForCausalLM.from_pretrained("salgr/SalgrAI_v2.1_Coder_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_Coder_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_Coder_Pro:F16 # Run inference directly in the terminal: llama cli -hf salgr/SalgrAI_v2.1_Coder_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_Coder_Pro:F16 # Run inference directly in the terminal: llama cli -hf salgr/SalgrAI_v2.1_Coder_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_Coder_Pro:F16 # Run inference directly in the terminal: ./build/bin/llama cli -hf salgr/SalgrAI_v2.1_Coder_Pro:F16
Use Docker
docker model run hf.co/salgr/SalgrAI_v2.1_Coder_Pro:F16
- Llama new
- LM Studio
- Jan
- vLLM
How to use salgr/SalgrAI_v2.1_Coder_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_Coder_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_Coder_Pro", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/salgr/SalgrAI_v2.1_Coder_Pro:F16
- SGLang
How to use salgr/SalgrAI_v2.1_Coder_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_Coder_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_Coder_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_Coder_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_Coder_Pro", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use salgr/SalgrAI_v2.1_Coder_Pro with Ollama:
ollama run hf.co/salgr/SalgrAI_v2.1_Coder_Pro:F16
- Unsloth Desktop
- Docker Model Runner
How to use salgr/SalgrAI_v2.1_Coder_Pro with Docker Model Runner:
docker model run hf.co/salgr/SalgrAI_v2.1_Coder_Pro:F16
- Lemonade
How to use salgr/SalgrAI_v2.1_Coder_Pro with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull salgr/SalgrAI_v2.1_Coder_Pro:F16
Run and chat with the model
lemonade run user.SalgrAI_v2.1_Coder_Pro-F16
List all available models
lemonade list
- Atomic Chat
File size: 2,667 Bytes
87713f8 | 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 | """Локальный диалог с 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()
|