Image-Text-to-Text
Transformers
Safetensors
Moroccan Arabic
Arabic
English
qwen3_5
compiwer-ai
mtrini
svl
reasoning
moroccan-darija
conversational
Instructions to use CompiwerAI/Mtrini-SVL-2.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CompiwerAI/Mtrini-SVL-2.0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="CompiwerAI/Mtrini-SVL-2.0") 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 AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("CompiwerAI/Mtrini-SVL-2.0") model = AutoModelForMultimodalLM.from_pretrained("CompiwerAI/Mtrini-SVL-2.0", 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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use CompiwerAI/Mtrini-SVL-2.0 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "CompiwerAI/Mtrini-SVL-2.0" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CompiwerAI/Mtrini-SVL-2.0", "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/CompiwerAI/Mtrini-SVL-2.0
- SGLang
How to use CompiwerAI/Mtrini-SVL-2.0 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 "CompiwerAI/Mtrini-SVL-2.0" \ --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": "CompiwerAI/Mtrini-SVL-2.0", "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 "CompiwerAI/Mtrini-SVL-2.0" \ --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": "CompiwerAI/Mtrini-SVL-2.0", "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 CompiwerAI/Mtrini-SVL-2.0 with Docker Model Runner:
docker model run hf.co/CompiwerAI/Mtrini-SVL-2.0
File size: 1,656 Bytes
fe356f5 | 1 | {"steps": 5, "max_steps": 5, "log": [{"loss": 0.6931473016738892, "grad_norm": 17.957149505615234, "learning_rate": 1.6666666666666667e-06, "entropy": 0.6042060684412718, "num_tokens": 129113.0, "logits/chosen": -2.031570067427444, "logits/rejected": -2.066084378741378, "mean_token_accuracy": 0.8573183789849281, "rewards/chosen": 0.0, "rewards/rejected": 0.0, "rewards/accuracies": 0.0, "rewards/margins": 0.0, "logps/chosen": -1720.7409473061562, "logps/rejected": -1911.8703248500824, "epoch": 0.43243243243243246, "step": 2}, {"loss": 0.7156742215156555, "grad_norm": 14.256765365600586, "learning_rate": 5e-06, "entropy": 0.7723287399858236, "num_tokens": 235146.0, "logits/chosen": -1.9302834164158855, "logits/rejected": -1.978542090787214, "mean_token_accuracy": 0.832091361284256, "rewards/chosen": -0.020962871101801284, "rewards/rejected": 0.020634264779801015, "rewards/accuracies": 0.4375, "rewards/margins": -0.04159713693661615, "logps/chosen": -1395.894810795784, "logps/rejected": -1786.6366989016533, "epoch": 0.8648648648648649, "step": 4}, {"train_runtime": 249.6526, "train_samples_per_second": 0.16, "train_steps_per_second": 0.02, "total_flos": 1.5657738870199104e+16, "train_loss": 0.7078817367553711, "entropy": 0.6014999866485595, "num_tokens": 277106.0, "logits/chosen": -2.0039181554060184, "logits/rejected": -1.9878743479109093, "mean_token_accuracy": 0.8745649218559265, "rewards/chosen": -0.044874840695410964, "rewards/rejected": -0.00777633311226964, "rewards/accuracies": 0.6, "rewards/margins": -0.03709850497543812, "logps/chosen": -1500.4318752288818, "logps/rejected": -1871.2910789489747, "epoch": 1.0, "step": 5}]} |