Instructions to use 5CD-AI/Vintern-3B-R-beta with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use 5CD-AI/Vintern-3B-R-beta with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="5CD-AI/Vintern-3B-R-beta", trust_remote_code=True) 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("5CD-AI/Vintern-3B-R-beta", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use 5CD-AI/Vintern-3B-R-beta with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "5CD-AI/Vintern-3B-R-beta" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "5CD-AI/Vintern-3B-R-beta", "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" } } ] } ] }'Use Docker
docker model run hf.co/5CD-AI/Vintern-3B-R-beta
- SGLang
How to use 5CD-AI/Vintern-3B-R-beta 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 "5CD-AI/Vintern-3B-R-beta" \ --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": "5CD-AI/Vintern-3B-R-beta", "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" } } ] } ] }'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 "5CD-AI/Vintern-3B-R-beta" \ --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": "5CD-AI/Vintern-3B-R-beta", "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 Runner
How to use 5CD-AI/Vintern-3B-R-beta with Docker Model Runner:
docker model run hf.co/5CD-AI/Vintern-3B-R-beta
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 "5CD-AI/Vintern-3B-R-beta" \
--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": "5CD-AI/Vintern-3B-R-beta",
"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"
}
}
]
}
]
}'This is our basic reasoning model before enhanced by Reinforcement Learning.
Multimodal LLM x Reasoning Model π π§ π
After more than six months since creating the 5CD-AI/LLaVA-CoT-o1-Instruct datasetβone of Hugging Faceβs most liked datasets of 2024 πβwe have just completed the "base" version of the Vintern Reasoning Model!
- This model can perform long and complex reasoning based on images, breaking down each reasoning step into multiple sub-steps while keeping hallucinations under control.
- Despite the difficulty of balancing multiple tasks alongside reasoning, Vintern-3B-R-beta has outperformed all previous versions across various benchmarks!
When should you choose Vintern-1B-v3_5 vs Vintern-3B-R-beta? π€
- Vintern-1B-v3_5: Fast β‘ and good for Vietnamese OCR with simple text formatting. π Highly reliable. β
- Vintern-3B-R-beta: Better for complex questions and complex structured doc image. ππ OCR performance on blurred or unclear text may be slightly affected due to our training focus on reasoning. ππ€
π The next step? Training and enhancing its reasoning ability by Reinforcement Learning!
Benchmarks π
Example 1:
<SUMMARY>Δα» bΓ i toΓ‘n yΓͺu cαΊ§u xΓ‘c Δα»nh mΓ³n Δn cΓ³ giΓ‘ cao nhαΊ₯t trong danh sΓ‘ch cΓ‘c mΓ³n Δn Δược liα»t kΓͺ trΓͺn menu cα»§a mα»t quΓ‘n Δn.
Δα» giαΊ£i quyαΊΏt vαΊ₯n Δα» nΓ y, cαΊ§n phΓ’n tΓch giΓ‘ cα»§a tα»«ng mΓ³n Δn tα»« menu vΓ so sΓ‘nh Δα» tΓ¬m ra mΓ³n cΓ³ giΓ‘ cao nhαΊ₯t.</SUMMARY>
<CAPTION>αΊ’nh chα»₯p mα»t phαΊ§n menu cα»§a quΓ‘n Δn, hiα»n thα» danh sΓ‘ch cΓ‘c mΓ³n Δn kΓ¨m theo giΓ‘ tiα»n.
Menu Δược chia thΓ nh hai cα»t, mα»i cα»t liα»t kΓͺ cΓ‘c mΓ³n Δn khΓ‘c nhau vα»i giΓ‘ tiα»n tΖ°Ζ‘ng α»©ng.</CAPTION>
<FIND_CANDIDATES_REASONING>Δα» tΓ¬m ra mΓ³n Δn cΓ³ giΓ‘ cao nhαΊ₯t, chΓΊng ta cαΊ§n thα»±c hiα»n cΓ‘c bΖ°α»c sau:
1. **XΓ‘c Δα»nh danh sΓ‘ch cΓ‘c mΓ³n Δn:** Menu cung cαΊ₯p danh sΓ‘ch ΔαΊ§y Δα»§ cΓ‘c mΓ³n Δn, bao gα»m: αΊΏch xΓ o sαΊ£ α»t, αΊΏch chiΓͺn mαΊ―m, gΓ nΖ°α»ng α»t, gΓ chiΓͺn mαΊ―m, α»c bΖ°Ζ‘u xΓ o sαΊ£ α»t, α»c cΓ na xΓ o sαΊ£ α»t, α»c cΓ na xΓ o bΖ‘ tα»i, α»c hΖ°Ζ‘ng xΓ o sαΊ£ α»t, α»c hΖ°Ζ‘ng xΓ o bΖ‘ tα»i, chαΊ£ cua mα»ng tΖ‘i, bao tα» cΓ‘ ba sa xΓ o nghα», ba chα» nΖ°α»ng α»t, thα»t ΔΓ Δiα»u xΓ o sαΊ£ α»t, thα»t ΔΓ Δiα»u xΓ o thΖ‘m cΓ , thα»t nai xΓ o sαΊ£ α»t, thα»t nai xΓ o thΖ‘m cΓ , cΓ‘ bαΊ£ trαΊ§u nΖ°α»ng cuα»n cαΊ£i (2 con), cΓ‘ bαΊ£ trαΊ§u nΖ°α»ng α»t xanh (2 con), lαΊ©u gΓ lΓ‘ giang, lαΊ©u αΊΏch lΓ‘ giang, lαΊ©u mα»±c, lαΊ©u bΓ².
2. **XΓ‘c Δα»nh giΓ‘ cα»§a tα»«ng mΓ³n Δn:** Mα»i mΓ³n Δn Δα»u cΓ³ giΓ‘ tiα»n Δược ghi rΓ΅ rΓ ng bΓͺn cαΊ‘nh tΓͺn mΓ³n Δn. VΓ dα»₯, αΊΏch xΓ o sαΊ£ α»t cΓ³ giΓ‘ 55k, αΊΏch chiΓͺn mαΊ―m cΓ³ giΓ‘ 55k, gΓ nΖ°α»ng α»t cΓ³ giΓ‘ 50k, v.v.
3. **So sΓ‘nh giΓ‘ cα»§a cΓ‘c mΓ³n Δn:** So sΓ‘nh giΓ‘ cα»§a tα»«ng mΓ³n Δn Δα» tΓ¬m ra mΓ³n cΓ³ giΓ‘ cao nhαΊ₯t. QuΓ‘ trΓ¬nh nΓ y ΔΓ²i hα»i sα»± cαΊ©n thαΊn Δα» ΔαΊ£m bαΊ£o khΓ΄ng bα» sΓ³t bαΊ₯t kα»³ mΓ³n nΓ o.</FIND_CANDIDATES_REASONING>
<TOP3_CANDIDATES>
1. CΓ‘ bαΊ£ trαΊ§u nΖ°α»ng cuα»n cαΊ£i (2 con) 65k
2. CΓ‘ bαΊ£ trαΊ§u nΖ°α»ng α»t xanh (2 con) 65k
3. LαΊ©u bΓ² 69k
</TOP3_CANDIDATES>
<REASONING>Δα» xΓ‘c Δα»nh mΓ³n Δn cΓ³ giΓ‘ cao nhαΊ₯t, chΓΊng ta cαΊ§n so sΓ‘nh giΓ‘ cα»§a tαΊ₯t cαΊ£ cΓ‘c mΓ³n Δn trΓͺn menu. Dα»±a trΓͺn thΓ΄ng tin trong αΊ£nh, chΓΊng ta cΓ³ thα» lαΊp bαΊ£ng giΓ‘ nhΖ° sau:
| MΓ³n Δn | GiΓ‘ (VNΔ) |
|-------------------------------|--------|
| αΊΎch xΓ o sαΊ£ α»t | 55k |
| αΊΎch chiΓͺn mαΊ―m | 55k |
| GΓ nΖ°α»ng α»t | 50k |
| GΓ chiΓͺn mαΊ―m | 50k |
| α»c bΖ°Ζ‘u xΓ o sαΊ£ α»t | 45k |
| α»c cΓ na xΓ o sαΊ£ α»t | 49k |
| α»c cΓ na xΓ o bΖ‘ tα»i | 49k |
| α»c hΖ°Ζ‘ng xΓ o sαΊ£ α»t | 59k |
| α»c hΖ°Ζ‘ng xΓ o bΖ‘ tα»i | 59k |
| ChαΊ£ cua mα»ng tΖ‘i | 55k |
| Bao tα» cΓ‘ ba sa xΓ o nghα» | 55k |
| Ba chα» nΖ°α»ng α»t | 50k |
| Thα»t ΔΓ Δiα»u xΓ o sαΊ£ α»t | 55k |
| Thα»t ΔΓ Δiα»u xΓ o thΖ‘m cΓ | 55k |
| Thα»t nai xΓ o sαΊ£ α»t | 55k |
| Thα»t nai xΓ o thΖ‘m cΓ | 55k |
| CΓ‘ bαΊ£ trαΊ§u nΖ°α»ng cuα»n cαΊ£i (2 con) | 65k |
| CΓ‘ bαΊ£ trαΊ§u nΖ°α»ng α»t xanh (2 con) | 65k |
| LαΊ©u gΓ lΓ‘ giang | 59k |
| LαΊ©u αΊΏch lΓ‘ giang | 65k |
| LαΊ©u mα»±c | 65k |
| LαΊ©u bΓ² | 69k |
Sau khi so sΓ‘nh, mΓ³n Δn cΓ³ giΓ‘ cao nhαΊ₯t lΓ LαΊ©u bΓ² vα»i giΓ‘ 69k.</REASONING>
<COUNTER_ARGUMENTS>Nhα»―ng ngΖ°α»i phαΊ£n Δα»i cΓ³ thα» ΔΖ°a ra cΓ‘c lαΊp luαΊn nhΖ° sau:
- **Mα»t sα» mΓ³n Δn cΓ³ giΓ‘ thαΊ₯p hΖ‘n:** Mα»t sα» mΓ³n Δn cΓ³ giΓ‘ thαΊ₯p hΖ‘n, vΓ dα»₯ nhΖ° αΊΏch xΓ o sαΊ£ α»t, αΊΏch chiΓͺn mαΊ―m, gΓ nΖ°α»ng α»t, gΓ chiΓͺn mαΊ―m, α»c bΖ°Ζ‘u xΓ o sαΊ£ α»t, α»c cΓ na xΓ o sαΊ£ α»t, α»c cΓ na xΓ o bΖ‘ tα»i, α»c hΖ°Ζ‘ng xΓ o sαΊ£ α»t, α»c hΖ°Ζ‘ng xΓ o bΖ‘ tα»i, chαΊ£ cua mα»ng tΖ‘i, bao tα» cΓ‘ ba sa xΓ o nghα», ba chα» nΖ°α»ng α»t, thα»t ΔΓ Δiα»u xΓ o sαΊ£ α»t, thα»t ΔΓ Δiα»u xΓ o thΖ‘m cΓ , thα»t nai xΓ o sαΊ£ α»t, thα»t nai xΓ o thΖ‘m cΓ , cΓ‘ bαΊ£ trαΊ§u nΖ°α»ng cuα»n cαΊ£i (2 con), cΓ‘ bαΊ£ trαΊ§u nΖ°α»ng α»t xanh (2 con), lαΊ©u gΓ lΓ‘ giang, lαΊ©u αΊΏch lΓ‘ giang, lαΊ©u mα»±c.
- **GiΓ‘ cΓ³ thα» thay Δα»i:** GiΓ‘ cα»§a cΓ‘c mΓ³n Δn cΓ³ thα» thay Δα»i tΓΉy thuα»c vΓ o thα»i Δiα»m vΓ Δα»a Δiα»m. Viα»c so sΓ‘nh giΓ‘ dα»±a trΓͺn thΓ΄ng tin trong αΊ£nh cΓ³ thα» khΓ΄ng phαΊ£n Γ‘nh chΓnh xΓ‘c giΓ‘ thα»±c tαΊΏ.</COUNTER_ARGUMENTS>
<REASONING>Nhα»―ng lαΊp luαΊn phαΊ£n Δα»i tαΊp trung vΓ o viα»c so sΓ‘nh giΓ‘ cα»§a cΓ‘c mΓ³n Δn cΓ³ giΓ‘ thαΊ₯p hΖ‘n. Tuy nhiΓͺn, mα»₯c ΔΓch cα»§a bΓ i toΓ‘n lΓ xΓ‘c Δα»nh mΓ³n Δn cΓ³ giΓ‘ cao nhαΊ₯t, khΓ΄ng phαΊ£i so sΓ‘nh giΓ‘ cα»§a tαΊ₯t cαΊ£ cΓ‘c mΓ³n Δn. ChΓΊng ta ΔΓ£ so sΓ‘nh giΓ‘ cα»§a tαΊ₯t cαΊ£ cΓ‘c mΓ³n Δn vΓ kαΊΏt luαΊn mΓ³n Δn cΓ³ giΓ‘ cao nhαΊ₯t lΓ LαΊ©u bΓ² vα»i giΓ‘ 69k.</REASONING>
<CONCLUSION>LαΊ©u bΓ²</CONCLUSION>
Example 2:
User: <image>
Liα»t kΓͺ toΓ n bα» vΔn bαΊ£n.
Assistant: CHΓNH PHỦ
Sα»: 626/QΔ-TTg
Cα»NG HΓA XΓ Hα»I CHỦ NGHΔ¨A VIα»T NAM
Δα»c lαΊp - Tα»± do - HαΊ‘nh phΓΊc
HΓ Nα»i, ngΓ y 29 thΓ‘ng 7 nΔm 2002
QUYαΊΎT Δα»NH CỦA THỦ TΖ―α»NG CHΓNH PHỦ
PhΓͺ duyα»t BΓ‘o cΓ‘o nghiΓͺn cα»©u khαΊ£ thi dα»± Γ‘n ΔαΊ§u tΖ°
NhΓ mΓ‘y sαΊ£n xuαΊ₯t phΓ’n bΓ³n diamΓ΄n phα»t phΓ‘t (DAP) tαΊ‘i khu
Kinh tαΊΏ ΔΓ¬nh VΕ©, thΓ nh phα» HαΊ£i PhΓ²ng
THỦ TΖ―α»NG (CHΓNH PHỦ)
CΔn cα»© LuαΊt Tα» chα»©c ChΓnh phα»§ ngΓ y 25 thΓ‘ng 12 nΔm 2001;
CΔn cα»© Nghα» Δα»nh sα» 52/1999/NΔ-CP ngΓ y 8 thΓ‘ng 7 nΔm 1999 cα»§a ChΓnh phα»§
ban hΓ nh (Quy chαΊΏ quαΊ£n lΓ½ ΔαΊ§u tΖ° vΓ xΓ’y dα»±ng vΓ NgΓ nh dα»ch sα» 12/2000/ND-CP
ngΓ y 05 thΓ‘ng 5 nΔm 2000) cα»§a ChΓnh phα»§ quy Δα»nh sα»a Δα»i, bα» sung mα»t sα»
Δiα»u cα»§a Quy chαΊΏ quαΊ£n lΓ½ ΔαΊ§u tΖ° vΓ xΓ’y dα»±ng.
XΓ©t Δα» nghα» cα»§a Tα»ng cΓ΄ng ty HoΓ‘ chαΊ₯t Viα»t Nam (cΓ΄ng vΔn sα» 916/ CV-HΔQT
ngΓ y 01 thΓ‘ng 11 nΔm 2001), Γ½ kiαΊΏn thαΊ©m Δα»nh cα»§a Bα» KαΊΏ hoαΊ‘ch vΓ ΔαΊ§u tΖ° tαΊ‘i
cΓ΄ng vΔn sα» 1944 BKH/VPTD ngΓ y 01 thΓ‘ng 4 nΔm 2002, vα» viα»c phΓͺ duyα»t
BΓ‘o cΓ‘o nghiΓͺn cα»©u khαΊ£ thi dα»± Γ‘n ΔαΊ§u tΖ° NhΓ mΓ‘y sαΊ£n xuαΊ₯t phΓ’n bΓ³n diamΓ΄n
phα»t phΓ‘t tαΊ‘i khu kinh tαΊΏ ΔΓ¬nh VΕ©, thΓ nh phα» HαΊ£i PhΓ²ng vΓ Γ½ kiαΊΏn cα»§a cΓ‘c Bα»,
ngΓ nh tαΊ‘i cuα»c hα»p ngΓ y 19 thΓ‘ng 6 nΔm 2002,
QUYαΊΎT Δα»NH:
Δiα»u 1. PhΓͺ duyα»t BΓ‘o cΓ‘o nghiΓͺn cα»©u khαΊ£ thi dα»± Γ‘n ΔαΊ§u tΖ° NhΓ mΓ‘y sαΊ£n
xuαΊ₯t phΓ’n bΓ³n DAP tαΊ‘i khu kinh tαΊΏ ΔΓ¬nh VΕ©, thΓ nh phα» HαΊ£i PhΓ²ng vα»i cΓ‘c nα»i
dung chΓnh sau :
1. TΓͺn dα»± Γ‘n : NhΓ mΓ‘y sαΊ£n xuαΊ₯t phΓ’n bΓ³n DAP tαΊ‘i khu kinh tαΊΏ ΔΓ¬nh VΕ©,
thΓ nh phα» HαΊ£i PhΓ²ng.
2. Mα»₯c tiΓͺu ΔαΊ§u tΖ°: gΓ³p phαΊ§n ΔαΊ£m bαΊ£o α»n Δα»nh vΓ chα»§ Δα»ng trong viα»c cung
cαΊ₯p phΓ’n bΓ³n DAP cho phΓ‘t triα»n nΓ΄ng nghiα»p, hαΊ‘n chαΊΏ nhαΊp khαΊ©u, sα» dα»₯ng cΓ³
hiα»u quαΊ£ hΖ‘n nguα»n tΓ i nguyΓͺn quαΊ·ng apatit trong nΖ°α»c.
3. Chα»§ ΔαΊ§u tΖ° : Tα»ng cΓ΄ng ty HoΓ‘ chαΊ₯t Viα»t Nam.
Quickstart
Here provides a code snippet to show you how to load the tokenizer and model and how to generate contents.
To run inference using the model, follow the steps outlined in our Colab inference notebook
import numpy as np
import torch
import torchvision.transforms as T
# from decord import VideoReader, cpu
from PIL import Image
from torchvision.transforms.functional import InterpolationMode
from transformers import AutoModel, AutoTokenizer
IMAGENET_MEAN = (0.485, 0.456, 0.406)
IMAGENET_STD = (0.229, 0.224, 0.225)
def build_transform(input_size):
MEAN, STD = IMAGENET_MEAN, IMAGENET_STD
transform = T.Compose([
T.Lambda(lambda img: img.convert('RGB') if img.mode != 'RGB' else img),
T.Resize((input_size, input_size), interpolation=InterpolationMode.BICUBIC),
T.ToTensor(),
T.Normalize(mean=MEAN, std=STD)
])
return transform
def find_closest_aspect_ratio(aspect_ratio, target_ratios, width, height, image_size):
best_ratio_diff = float('inf')
best_ratio = (1, 1)
area = width * height
for ratio in target_ratios:
target_aspect_ratio = ratio[0] / ratio[1]
ratio_diff = abs(aspect_ratio - target_aspect_ratio)
if ratio_diff < best_ratio_diff:
best_ratio_diff = ratio_diff
best_ratio = ratio
elif ratio_diff == best_ratio_diff:
if area > 0.5 * image_size * image_size * ratio[0] * ratio[1]:
best_ratio = ratio
return best_ratio
def dynamic_preprocess(image, min_num=1, max_num=12, image_size=448, use_thumbnail=False):
orig_width, orig_height = image.size
aspect_ratio = orig_width / orig_height
# calculate the existing image aspect ratio
target_ratios = set(
(i, j) for n in range(min_num, max_num + 1) for i in range(1, n + 1) for j in range(1, n + 1) if
i * j <= max_num and i * j >= min_num)
target_ratios = sorted(target_ratios, key=lambda x: x[0] * x[1])
# find the closest aspect ratio to the target
target_aspect_ratio = find_closest_aspect_ratio(
aspect_ratio, target_ratios, orig_width, orig_height, image_size)
# calculate the target width and height
target_width = image_size * target_aspect_ratio[0]
target_height = image_size * target_aspect_ratio[1]
blocks = target_aspect_ratio[0] * target_aspect_ratio[1]
# resize the image
resized_img = image.resize((target_width, target_height))
processed_images = []
for i in range(blocks):
box = (
(i % (target_width // image_size)) * image_size,
(i // (target_width // image_size)) * image_size,
((i % (target_width // image_size)) + 1) * image_size,
((i // (target_width // image_size)) + 1) * image_size
)
# split the image
split_img = resized_img.crop(box)
processed_images.append(split_img)
assert len(processed_images) == blocks
if use_thumbnail and len(processed_images) != 1:
thumbnail_img = image.resize((image_size, image_size))
processed_images.append(thumbnail_img)
return processed_images
def load_image(image_file, input_size=448, max_num=12):
image = Image.open(image_file).convert('RGB')
transform = build_transform(input_size=input_size)
images = dynamic_preprocess(image, image_size=input_size, use_thumbnail=True, max_num=max_num)
pixel_values = [transform(image) for image in images]
pixel_values = torch.stack(pixel_values)
return pixel_values
model = AutoModel.from_pretrained(
"5CD-AI/Vintern-3B-R-beta",
torch_dtype=torch.bfloat16,
low_cpu_mem_usage=True,
trust_remote_code=True,
use_flash_attn=False,
).eval().cuda()
tokenizer = AutoTokenizer.from_pretrained("5CD-AI/Vintern-3B-R-beta", trust_remote_code=True, use_fast=False)
test_image = 'test-image.jpg'
think_prompt_format = """<image>\nBαΊ‘n lΓ ngΖ°α»i rαΊ₯t cαΊ©n thαΊn vΓ Δa nghi, vui lΓ²ng trαΊ£ lα»i cΓ’u hα»i dΖ°α»i ΔΓ’y bαΊ±ng tiαΊΏng Viα»t. Khi suy luαΊn bαΊ‘n thΖ°α»ng liα»t kΓͺ ra cΓ‘c bαΊ±ng chα»©ng Δα» chα» ra cΓ‘c ΔΓ‘p Γ‘n khαΊ£ thi, suy luαΊn vΓ giαΊ£i thΓch tαΊ‘i sao lαΊ‘i lα»±a chα»n vΓ loαΊ‘i bα» trΖ°α»c khi ΔΖ°a ra cΓ’u trαΊ£ lα»i cuα»i cΓΉng.
CΓ’u hα»i:
{question_input}
HΓ£y trαΊ£ lα»i rαΊ₯t dΓ i theo Δα»nh dαΊ‘ng sau:
<SUMMARY>...</SUMMARY>
<CAPTION>...</CAPTION>
<INFORMATION_EXTRACT>...</INFORMATION_EXTRACT>
<EXTERNAL_KNOWLEDGE_EXPANSION>...</EXTERNAL_KNOWLEDGE_EXPANSION>
<FIND_CANDIDATES_REASONING>...</FIND_CANDIDATES_REASONING>
<TOP3_CANDIDATES>...</TOP3_CANDIDATES>
<REASONING_PLAN>...</REASONING_PLAN>
<REASONING>...</REASONING>
<COUNTER_ARGUMENTS>...</COUNTER_ARGUMENTS>
<VALIDATION_REASONING>...</VALIDATION_REASONING>
<CONCLUSION>...</CONCLUSION>
"""
pixel_values = load_image(test_image, max_num=6).to(torch.bfloat16).cuda()
generation_config = dict(max_new_tokens= 1024, do_sample=False, num_beams = 3, repetition_penalty=2.5)
question = '<image>\nTrΓch xuαΊ₯t thΓ΄ng tin chΓnh trong αΊ£nh vΓ trαΊ£ vα» dαΊ‘ng markdown.'
response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=None, return_history=True)
print(f'User: {question}\nAssistant: {response}')
#question = "CΓ’u hα»i khΓ‘c ......"
#response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=history, return_history=True)
#print(f'User: {question}\nAssistant: {response}')
Citation
@misc{doan2024vintern1befficientmultimodallarge,
title={Vintern-1B: An Efficient Multimodal Large Language Model for Vietnamese},
author={Khang T. Doan and Bao G. Huynh and Dung T. Hoang and Thuc D. Pham and Nhat H. Pham and Quan T. M. Nguyen and Bang Q. Vo and Suong N. Hoang},
year={2024},
eprint={2408.12480},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2408.12480},
}
Reference
[1] Z. Chen et al., βExpanding performance boundaries of open-source multimodal models with model, data, and test-time scalingβ, arXiv preprint arXiv:2412. 05271, 2024.
- Downloads last month
- 565


Install from pip and serve model
# Install SGLang from pip: pip install sglang# Start the SGLang server: python3 -m sglang.launch_server \ --model-path "5CD-AI/Vintern-3B-R-beta" \ --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": "5CD-AI/Vintern-3B-R-beta", "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" } } ] } ] }'