Instructions to use swiss-ai/tiny-processor-apertus1p5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use swiss-ai/tiny-processor-apertus1p5 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="swiss-ai/tiny-processor-apertus1p5") 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("swiss-ai/tiny-processor-apertus1p5") model = AutoModelForMultimodalLM.from_pretrained("swiss-ai/tiny-processor-apertus1p5", 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 swiss-ai/tiny-processor-apertus1p5 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "swiss-ai/tiny-processor-apertus1p5" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "swiss-ai/tiny-processor-apertus1p5", "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/swiss-ai/tiny-processor-apertus1p5
- SGLang
How to use swiss-ai/tiny-processor-apertus1p5 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 "swiss-ai/tiny-processor-apertus1p5" \ --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": "swiss-ai/tiny-processor-apertus1p5", "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 "swiss-ai/tiny-processor-apertus1p5" \ --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": "swiss-ai/tiny-processor-apertus1p5", "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 swiss-ai/tiny-processor-apertus1p5 with Docker Model Runner:
docker model run hf.co/swiss-ai/tiny-processor-apertus1p5
Tiny Apertus 1.5 processor
A small processor-only checkpoint for testing the Apertus 1.5 processor implementation in Transformers
(Apertus1p5Processor). It contains no model weights and cannot be used for inference. For the models, use
swiss-ai/Apertus-v1.5-8B or
swiss-ai/Apertus-v1.5-70B, which share the same processor.
Built from the processor files of swiss-ai/Apertus-v1.5-8B at revision 9e478a7c9833d661d1e13fc49a68648c338f6acb.
Comparison with the full checkpoints
| Apertus-v1.5-8B / 70B | This checkpoint | |
|---|---|---|
| Model weights | 8B / 70B parameters | None |
tokenizer.json size |
44 MB | 53 KB |
| Tokens in total | 266,440 | 656 |
| BPE vocabulary | 131,072 (ids 0 to 131,071) | 520 (ids 0 to 519) |
| Special and added text tokens | 1,190 | 20, those used by the tokenizer config, the chat template and the normalizer |
| Image and audio structure tokens | 8, added tokens only (ids 131,073 to 131,085) | 8, added tokens only (ids 520 to 527) |
Image codes (<|visual token N|>) |
131,072 (ids 131,272 to 262,343) | 64 (ids 528 to 591) |
Audio codes (<|audio token N|>) |
4,096 (ids 262,344 to 266,439) | 64 (ids 592 to 655) |
| Image processor, feature extractor, chat template | Identical |
- Downloads last month
- 99