GigaChat Lite
Collection
8 items • Updated • 5
How to use ai-sage/GigaChat-20B-A3B-instruct-bf16 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="ai-sage/GigaChat-20B-A3B-instruct-bf16", trust_remote_code=True)
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("ai-sage/GigaChat-20B-A3B-instruct-bf16", trust_remote_code=True, dtype="auto")How to use ai-sage/GigaChat-20B-A3B-instruct-bf16 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "ai-sage/GigaChat-20B-A3B-instruct-bf16"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "ai-sage/GigaChat-20B-A3B-instruct-bf16",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/ai-sage/GigaChat-20B-A3B-instruct-bf16
How to use ai-sage/GigaChat-20B-A3B-instruct-bf16 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "ai-sage/GigaChat-20B-A3B-instruct-bf16" \
--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": "ai-sage/GigaChat-20B-A3B-instruct-bf16",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "ai-sage/GigaChat-20B-A3B-instruct-bf16" \
--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": "ai-sage/GigaChat-20B-A3B-instruct-bf16",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use ai-sage/GigaChat-20B-A3B-instruct-bf16 with Docker Model Runner:
docker model run hf.co/ai-sage/GigaChat-20B-A3B-instruct-bf16
This model is part of the GigaChat family of Russian LLMs, based on ai-sage/GigaChat-20B-A3B-instruct. It supports a context length of 131,000 tokens.
More details are available in this habr article and the original instruct model card. The model was presented in GigaChat Family: Efficient Russian Language Modeling Through Mixture of Experts Architecture.
pip install --upgrade transformers torch accelerate bitsandbytes
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
model_name = "ai-sage/GigaChat-20B-A3B-instruct-bf16"
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True, device_map="auto", torch_dtype=torch.bfloat16)
model.generation_config = GenerationConfig.from_pretrained(model_name)
messages = [
{"role": "user", "content": "Докажи теорему о неподвижной точке"}
]
input_tensor = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
outputs = model.generate(input_tensor.to(model.device))
result = tokenizer.decode(outputs[0][input_tensor.shape[1]:], skip_special_tokens=False)
print(result)
Base model
ai-sage/GigaChat-20B-A3B-base