BgGPT-Gemma-3
Collection
9 items • Updated • 7
How to use INSAIT-Institute/BgGPT-Gemma-3-27B-IT-GPTQ-W4A16 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-text-to-text", model="INSAIT-Institute/BgGPT-Gemma-3-27B-IT-GPTQ-W4A16")
messages = [
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
{"type": "text", "text": "What animal is on the candy?"}
]
},
]
pipe(text=messages) # Load model directly
from transformers import AutoProcessor, AutoModelForMultimodalLM
processor = AutoProcessor.from_pretrained("INSAIT-Institute/BgGPT-Gemma-3-27B-IT-GPTQ-W4A16")
model = AutoModelForMultimodalLM.from_pretrained("INSAIT-Institute/BgGPT-Gemma-3-27B-IT-GPTQ-W4A16")
messages = [
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
{"type": "text", "text": "What animal is on the candy?"}
]
},
]
inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use INSAIT-Institute/BgGPT-Gemma-3-27B-IT-GPTQ-W4A16 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "INSAIT-Institute/BgGPT-Gemma-3-27B-IT-GPTQ-W4A16"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "INSAIT-Institute/BgGPT-Gemma-3-27B-IT-GPTQ-W4A16",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
}
}
]
}
]
}'docker model run hf.co/INSAIT-Institute/BgGPT-Gemma-3-27B-IT-GPTQ-W4A16
How to use INSAIT-Institute/BgGPT-Gemma-3-27B-IT-GPTQ-W4A16 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "INSAIT-Institute/BgGPT-Gemma-3-27B-IT-GPTQ-W4A16" \
--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": "INSAIT-Institute/BgGPT-Gemma-3-27B-IT-GPTQ-W4A16",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
}
}
]
}
]
}'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 "INSAIT-Institute/BgGPT-Gemma-3-27B-IT-GPTQ-W4A16" \
--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": "INSAIT-Institute/BgGPT-Gemma-3-27B-IT-GPTQ-W4A16",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
}
}
]
}
]
}'How to use INSAIT-Institute/BgGPT-Gemma-3-27B-IT-GPTQ-W4A16 with Docker Model Runner:
docker model run hf.co/INSAIT-Institute/BgGPT-Gemma-3-27B-IT-GPTQ-W4A16
GPTQ W4A16 quantized version of BgGPT-Gemma-3-27B-IT. BgGPT 3.0 is a series of Bulgarian-adapted LLMs based on Gemma 3, developed by INSAIT.
Blog post: BgGPT-3 Release
from vllm import LLM, SamplingParams
llm = LLM(model="INSAIT-Institute/BgGPT-Gemma-3-27B-IT-gptq-w4a16")
params = SamplingParams(max_tokens=512, temperature=0.2)
messages = [
{
"role": "user",
"content": [{"type": "text", "text": "Кога е основан Софийският университет?"}],
},
]
outputs = llm.chat(messages, sampling_params=params)
print(outputs[0].outputs[0].text)
Serving with the OpenAI-compatible API:
vllm serve INSAIT-Institute/BgGPT-Gemma-3-27B-IT-gptq-w4a16
from transformers import AutoProcessor, Gemma3ForConditionalGeneration
import torch
model_id = "INSAIT-Institute/BgGPT-Gemma-3-27B-IT-gptq-w4a16"
processor = AutoProcessor.from_pretrained(model_id)
model = Gemma3ForConditionalGeneration.from_pretrained(
model_id, device_map="auto"
).eval()
messages = [
{
"role": "user",
"content": [{"type": "text", "text": "Кога е основан Софийският университет?"}],
},
]
inputs = processor.apply_chat_template(
messages, add_generation_prompt=True, tokenize=True,
return_dict=True, return_tensors="pt"
).to(model.device, dtype=torch.bfloat16)
input_len = inputs["input_ids"].shape[-1]
with torch.inference_mode():
generation = model.generate(**inputs, max_new_tokens=512, do_sample=True, temperature=0.2)
generation = generation[0][input_len:]
print(processor.decode(generation, skip_special_tokens=True))
BgGPT-Gemma-3-27B-IT-gptq-w4a16 is distributed under the Gemma Terms of Use.
Base model
INSAIT-Institute/BgGPT-Gemma-3-27B-IT