Image-Text-to-Text
Transformers
qwen3_5
embedding
multimodal
quantized
fp8
video-text-to-text
conversational
custom_code
Instructions to use Weidows/WeMM-Embedding-2B-FP8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Weidows/WeMM-Embedding-2B-FP8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Weidows/WeMM-Embedding-2B-FP8", 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 AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Weidows/WeMM-Embedding-2B-FP8", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("Weidows/WeMM-Embedding-2B-FP8", trust_remote_code=True, 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 Weidows/WeMM-Embedding-2B-FP8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Weidows/WeMM-Embedding-2B-FP8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Weidows/WeMM-Embedding-2B-FP8", "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/Weidows/WeMM-Embedding-2B-FP8
- SGLang
How to use Weidows/WeMM-Embedding-2B-FP8 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 "Weidows/WeMM-Embedding-2B-FP8" \ --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": "Weidows/WeMM-Embedding-2B-FP8", "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 "Weidows/WeMM-Embedding-2B-FP8" \ --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": "Weidows/WeMM-Embedding-2B-FP8", "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 Weidows/WeMM-Embedding-2B-FP8 with Docker Model Runner:
docker model run hf.co/Weidows/WeMM-Embedding-2B-FP8
Download modeling_wemm_embedding.py from Weidows/WeMM-Embedding-2B-FP8: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/Weidows/WeMM-Embedding-2B-FP8/resolve/main/modeling_wemm_embedding.py
- Command line
-
hf download hf://Weidows/WeMM-Embedding-2B-FP8/modeling_wemm_embedding.py
-
curl -L -o modeling_wemm_embedding.py https://huggingface.co/Weidows/WeMM-Embedding-2B-FP8/resolve/main/modeling_wemm_embedding.py
1.21 kB
| import torch | |
| import torch.nn.functional as F | |
| from transformers import Qwen3_5ForConditionalGeneration | |
| class WeMMEmbedding(Qwen3_5ForConditionalGeneration): | |
| def embedding(self, input_ids=None, attention_mask=None, **kwargs): | |
| # transformers < 5.15 reuses the rope_deltas cached by the previous multimodal | |
| # forward for a text-only one, which shifts its position ids. | |
| self.model.rope_deltas = None | |
| outputs = self.model( | |
| input_ids=input_ids, | |
| attention_mask=attention_mask, | |
| **kwargs | |
| ) | |
| last_hidden_state = outputs.last_hidden_state | |
| if attention_mask is not None: | |
| eos_positions = attention_mask.sum(dim=1) - 1 | |
| else: | |
| eos_positions = torch.full((last_hidden_state.shape[0],), last_hidden_state.shape[1] - 1, device=last_hidden_state.device) | |
| eos_positions = eos_positions.clamp(min=0) | |
| batch_indices = torch.arange(last_hidden_state.size(0), device=last_hidden_state.device) | |
| embeddings = last_hidden_state[batch_indices, eos_positions] | |
| embeddings = F.normalize(embeddings, dim=-1) | |
| return embeddings |