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.
The processor tests in tests/models/apertus1p5/test_processing_apertus1p5.py load it through tiny_model_id, so they
run the real image processor, feature extractor and chat template with a tokenizer small enough for fast CI.
Contents
processor_config.json(image processor and WavTokenizer feature extractor, including the -3 dBFS peak normalization) andchat_template.jinjaare identical to the full checkpoints.config.jsonandgeneration_config.jsonare copied unchanged from the 8B checkpoint for reference. Their token offsets refer to the full vocabulary, not to this tokenizer.tokenizer.jsonkeeps the normalizer, pre-tokenizer, decoder and post-processor of the full tokenizer, with a trimmed vocabulary. The token layout mirrors the full tokenizer: special tokens, then the BPE vocabulary, then the image and audio structure tokens, image codes and audio codes as added tokens. Token ids differ from the full checkpoints, and text splits into more, shorter tokens ("Hello world!"is 9 tokens instead of 3).tokenizer_config.jsonkeeps the standard keys only. The swiss-ai pipeline keys of the full checkpoints (omnimodal_config,sft_*, ...) hold ids of the full vocabulary and are left out.
Built from the processor files of swiss-ai/Apertus-v1.5-8B at revision 3b9f74b85572c52584f53c8bc56639d4516fcc12.
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
- 145