Vikhr: The Family of Open-Source Instruction-Tuned Large Language Models for Russian
Paper • 2405.13929 • Published • 55
How to use Vikhrmodels/Vikhr-2-VL-2b-Instruct-experimental with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-text-to-text", model="Vikhrmodels/Vikhr-2-VL-2b-Instruct-experimental")
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, AutoModelForImageTextToText
processor = AutoProcessor.from_pretrained("Vikhrmodels/Vikhr-2-VL-2b-Instruct-experimental")
model = AutoModelForImageTextToText.from_pretrained("Vikhrmodels/Vikhr-2-VL-2b-Instruct-experimental")
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 Vikhrmodels/Vikhr-2-VL-2b-Instruct-experimental with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Vikhrmodels/Vikhr-2-VL-2b-Instruct-experimental"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Vikhrmodels/Vikhr-2-VL-2b-Instruct-experimental",
"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/Vikhrmodels/Vikhr-2-VL-2b-Instruct-experimental
How to use Vikhrmodels/Vikhr-2-VL-2b-Instruct-experimental with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Vikhrmodels/Vikhr-2-VL-2b-Instruct-experimental" \
--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": "Vikhrmodels/Vikhr-2-VL-2b-Instruct-experimental",
"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 "Vikhrmodels/Vikhr-2-VL-2b-Instruct-experimental" \
--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": "Vikhrmodels/Vikhr-2-VL-2b-Instruct-experimental",
"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 Vikhrmodels/Vikhr-2-VL-2b-Instruct-experimental with Docker Model Runner:
docker model run hf.co/Vikhrmodels/Vikhr-2-VL-2b-Instruct-experimental
Vikhr-2-VL-2b-Instruct-experimental — это компактная VLM модель на базе Qwen2-VL-2B-Instruct, обученная на переведенном датасете LLAVA-150K, специально доученная для обработки на русском языке. Дообученная модель является эксперементальной и не всегда будет работать ожидаемо (особенно OCR). Для обратной связи используйте Vikhr Models
@inproceedings{nikolich2024vikhr,
title={Vikhr: Constructing a State-of-the-art Bilingual Open-Source Instruction-Following Large Language Model for {Russian}},
author={Aleksandr Nikolich and Konstantin Korolev and Sergei Bratchikov and Nikolay Kompanets and Igor Kiselev and Artem Shelmanov },
booktitle = {Proceedings of the 4rd Workshop on Multilingual Representation Learning (MRL) @ EMNLP-2024}
year={2024},
publisher = {Association for Computational Linguistics},
url={https://arxiv.org/pdf/2405.13929}
}