Image-Text-to-Text
Transformers
Safetensors
qwen3_5
vllm
video
multimodal
reinforcement-learning
temporal-grounding
object-tracking
video-segmentation
visual-question-answering
spatial-reasoning
qwen3.5
conversational
Instructions to use OraRL/Video-ORA-9B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OraRL/Video-ORA-9B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="OraRL/Video-ORA-9B") 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("OraRL/Video-ORA-9B") model = AutoModelForMultimodalLM.from_pretrained("OraRL/Video-ORA-9B", device_map="auto") 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use OraRL/Video-ORA-9B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OraRL/Video-ORA-9B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OraRL/Video-ORA-9B", "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/OraRL/Video-ORA-9B
- SGLang
How to use OraRL/Video-ORA-9B 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 "OraRL/Video-ORA-9B" \ --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": "OraRL/Video-ORA-9B", "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 "OraRL/Video-ORA-9B" \ --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": "OraRL/Video-ORA-9B", "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 OraRL/Video-ORA-9B with Docker Model Runner:
docker model run hf.co/OraRL/Video-ORA-9B
| # Copyright 2024 Bytedance Ltd. and/or its affiliates | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| import gc | |
| from collections import defaultdict | |
| from functools import partial | |
| from typing import Callable, Union | |
| import torch | |
| from torch import nn | |
| from torch.distributed.fsdp import FullyShardedDataParallel as FSDP | |
| from torch.distributed.fsdp._runtime_utils import _lazy_init | |
| from torch.distributed.fsdp.wrap import transformer_auto_wrap_policy | |
| from torch.optim import Optimizer | |
| from transformers import PreTrainedModel | |
| from transformers.trainer_pt_utils import get_module_class_from_name | |
| def get_init_fn(model: nn.Module, device: Union[str, torch.device]) -> Callable[[nn.Module], None]: | |
| param_occurrence = defaultdict(int) | |
| for _, param in model.named_parameters(remove_duplicate=False): | |
| param_occurrence[param] += 1 | |
| duplicated_params = {param for param in param_occurrence.keys() if param_occurrence[param] > 1} | |
| materialized_params = {} | |
| def init_fn(module: nn.Module): | |
| for name, param in module.named_parameters(recurse=False): | |
| if param in duplicated_params: | |
| module._parameters[name] = materialized_params.setdefault( | |
| param, nn.Parameter(torch.empty_like(param.data, device=device), requires_grad=param.requires_grad) | |
| ) | |
| else: | |
| module._parameters[name] = nn.Parameter( | |
| torch.empty_like(param.data, device=device), requires_grad=param.requires_grad | |
| ) | |
| return init_fn | |
| def get_fsdp_wrap_policy(model: PreTrainedModel): | |
| """Get FSDP wrap policy for the model. | |
| Args: | |
| module: The module to get wrap policy for | |
| """ | |
| transformer_cls_to_wrap = set() | |
| for module in model._no_split_modules: | |
| transformer_cls = get_module_class_from_name(model, module) | |
| if transformer_cls is None: | |
| raise Exception(f"Cannot find {module} in pretrained model.") | |
| else: | |
| transformer_cls_to_wrap.add(transformer_cls) | |
| return partial(transformer_auto_wrap_policy, transformer_layer_cls=transformer_cls_to_wrap) | |
| def offload_fsdp_model(model: FSDP, empty_cache: bool = True): | |
| # lazy init FSDP model | |
| _lazy_init(model, model) | |
| assert model._is_root, "Only support root model offloading to CPU" | |
| for handle in model._all_handles: | |
| if handle._offload_params: | |
| continue | |
| flat_param = handle.flat_param | |
| assert ( | |
| flat_param.data.data_ptr() == flat_param._local_shard.data_ptr() | |
| and id(flat_param.data) != id(flat_param._local_shard) | |
| and flat_param.data.size() == flat_param._local_shard.size() | |
| ) | |
| handle.flat_param_to("cpu", non_blocking=True) | |
| # the following still keeps id(._local_shard) != id(.data) | |
| flat_param._local_shard = flat_param.data | |
| assert id(flat_param._local_shard) != id(flat_param.data) | |
| if empty_cache: | |
| torch.cuda.empty_cache() | |
| def load_fsdp_model(model: FSDP, empty_cache: bool = True): | |
| # lazy init FSDP model | |
| _lazy_init(model, model) | |
| assert model._is_root, "Only support root model loading to GPU" | |
| for handle in model._all_handles: | |
| if handle._offload_params: | |
| continue | |
| flat_param = handle.flat_param | |
| handle.flat_param_to("cuda", non_blocking=True) | |
| # the following still keeps id(._local_shard) != id(.data) | |
| flat_param._local_shard = flat_param.data | |
| if empty_cache: | |
| gc.collect() | |
| def offload_fsdp_optimizer(optimizer: Optimizer, empty_cache: bool = True): | |
| if not optimizer.state: | |
| return | |
| for param_group in optimizer.param_groups: | |
| for param in param_group["params"]: | |
| state = optimizer.state[param] | |
| for key, value in state.items(): | |
| if isinstance(value, torch.Tensor): | |
| state[key] = value.to("cpu", non_blocking=True) | |
| if empty_cache: | |
| torch.cuda.empty_cache() | |
| def load_fsdp_optimizer(optimizer: Optimizer, empty_cache: bool = True): | |
| if not optimizer.state: | |
| return | |
| for param_group in optimizer.param_groups: | |
| for param in param_group["params"]: | |
| state = optimizer.state[param] | |
| for key, value in state.items(): | |
| if isinstance(value, torch.Tensor): | |
| state[key] = value.to("cuda", non_blocking=True) | |
| if empty_cache: | |
| gc.collect() | |