Image-Text-to-Text
Transformers
Safetensors
English
R
feature-extraction
conversational
custom_code
Eval Results
Instructions to use YannQi/R-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use YannQi/R-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="YannQi/R-4B", 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("YannQi/R-4B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use YannQi/R-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "YannQi/R-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "YannQi/R-4B", "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/YannQi/R-4B
- SGLang
How to use YannQi/R-4B 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 "YannQi/R-4B" \ --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": "YannQi/R-4B", "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 "YannQi/R-4B" \ --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": "YannQi/R-4B", "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 YannQi/R-4B with Docker Model Runner:
docker model run hf.co/YannQi/R-4B
Update README.md
Browse files18 unmodified lines1920212223242526272829303110 unmodified lines424344454647484950515256 unmodified lines109110111112113114115116117118189 unmodified lines30830931031131231318 unmodified lines<img src="asset/R-4B.png" width="100%" alt="R-4B Performance"></div>## ⭐️ IntroductionIn this report, we present **R-4B**, a multimodal large language model designed to achieve adaptive multimodal reasoning—dynamically choosing between step-by-step thinking and direct response generation based on task complexity. This capability enables R-4B to deliver high-quality responses while significantly improving inference efficiency and reducing computational costs.The development of R-4B follows a two-stage training paradigm:(1) Dual-Capability Pretraining, which establishes both thinking and non-thinking capabilities for VQA; and(2) Adaptive Thinking Post-Training, which enables the model to adaptively switch between modes based on input demands.R-4B achieves state-of-the-art performance among models of its scale. In evaluations across multiple public benchmarks, R-4B outperforms Qwen2.5-VL-7B on nearly all tasks. Notably, it matches or exceeds the performance of the much larger Kimi-VL-Thinking-2506 (3B activated, 16B total parameters).10 unmodified linesimport requestsimport torchfrom transformers import AutoModel, AutoProcessormodel_path = "YannQi/R-4B"from PIL import Imagemodel = AutoModel.from_pretrained(model_path,torch_dtype=torch.float16,56 unmodified lines#### InstallThe code of R-4B requires custom vllm. Please install from local source:```bashgit clone https://github.com/yannqi/vllm.gitcd vllmVLLM_USE_PRECOMPILED=1 uv pip install --editable .```189 unmodified lines}``` -->## AcknowledgementR-4B is developed based on the codebases of the following projects: [LLaVA-Next](https://github.com/LLaVA-VL/LLaVA-NeXT), [SigLIP2](https://huggingface.co/google/siglip2-so400m-patch14-384), [Qwen3](https://github.com/QwenLM/Qwen3), [Qwen2.5-VL](https://github.com/QwenLM/Qwen2.5-VL), [VLMEvalKit](https://github.com/open-compass/VLMEvalKit). We sincerely thank these projects for their outstanding work.18 unmodified lines192021222324252627282930313210 unmodified lines4344454647484950515256 unmodified lines109110111112113114115116117118189 unmodified lines30830931031131231318 unmodified lines<img src="asset/R-4B.png" width="100%" alt="R-4B Performance"></div>## ⭐️ IntroductionIn this repo, we present **R-4B**, a multimodal large language model designed for general-purpose auto-thinking, autonomously switching between step-by-step thinking and direct response generation based on task complexity. This capability enables R-4B to deliver high-quality responses while significantly improving inference efficiency and reducing computational costs.The development of R-4B follows a two-stage training paradigm:(1) Bi-mode Annealing, which establishes both thinking and non-thinking capabilities for VQA; and(2) Bi-mode Policy Optimization (BPO), which enables the model to adaptively switch between thinking and non-thinking modes based on input demands.R-4B achieves state-of-the-art performance among models of its scale. In evaluations across multiple public benchmarks, R-4B outperforms Qwen2.5-VL-7B on nearly all tasks. Notably, it matches or exceeds the performance of the much larger Kimi-VL-Thinking-2506 (3B activated, 16B total parameters).10 unmodified linesimport requestsimport torchfrom transformers import AutoModel, AutoProcessorfrom PIL import Imagemodel_path = "YannQi/R-4B"model = AutoModel.from_pretrained(model_path,torch_dtype=torch.float16,56 unmodified lines#### InstallThe code of R-4B requires the newest vllm now. Please install from local source:```bashgit clone https://github.com/vllm-project/vllm.gitcd vllmVLLM_USE_PRECOMPILED=1 uv pip install --editable .```189 unmodified lines}``` -->## AcknowledgementsR-4B is developed based on the codebases of the following projects: [LLaVA-Next](https://github.com/LLaVA-VL/LLaVA-NeXT), [SigLIP2](https://huggingface.co/google/siglip2-so400m-patch14-384), [Qwen3](https://github.com/QwenLM/Qwen3), [Qwen2.5-VL](https://github.com/QwenLM/Qwen2.5-VL), [VLMEvalKit](https://github.com/open-compass/VLMEvalKit). We sincerely thank these projects for their outstanding work.
README.md+8-8