Feature Extraction
Transformers
Safetensors
sentence-transformers
English
qwen3_5
image-text-to-text
multimodal-embedding
image-text-retrieval
visual-document-retrieval
custom_code
Instructions to use UCSC-VLAA/OpenEmbed-0.8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use UCSC-VLAA/OpenEmbed-0.8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="UCSC-VLAA/OpenEmbed-0.8B", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("UCSC-VLAA/OpenEmbed-0.8B", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("UCSC-VLAA/OpenEmbed-0.8B", trust_remote_code=True, device_map="auto") - sentence-transformers
How to use UCSC-VLAA/OpenEmbed-0.8B with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("UCSC-VLAA/OpenEmbed-0.8B", trust_remote_code=True) sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
Load without remote code; vLLM usage; the evaluated image bounds
Browse filesThe chat template now writes the input format out exactly, the processor defaults to at most 8,388,608 pixels, and Sentence Transformers uses its stock modules. The model card shows plain Transformers, Sentence Transformers and vLLM usage, with how close each is to the evaluated embeddings.
Files changed (10)
- 1_Pooling/config.jsonAdded+5
- NOTICE+8-6
- README.md+78-29
- additional_chat_templates/sentence_transformers.jinjaDeleted-32
- chat_template.jinja+21-149
- config_sentence_transformers.json+2-2
- modeling_st_wemm.pyDeleted-93
- modules.json+13-1
- processor_config.json+1-1
- sentence_bert_config.json+25-33
12345{ "embedding_dimension": 1024, "pooling_mode": "lasttoken", "include_prompt": true}15 unmodified lines16171819202122232425262728293015 unmodified lines2. WeMM-Embedding (Tencent), https://huggingface.co/tencent/WeMM-Embedding-2BCopyright (C) 2026 Tencent. Files taken from it:modeling_wemm_embedding.py, tokenizer.json, tokenizer_config.json,chat_template.jinja, embedding_chat_template.jinja, processor_config.json,modules.json, sentence_bert_config.json,additional_chat_templates/sentence_transformers.jinjaModified by the OpenEmbed authors:modeling_st_wemm.py (an image item without its own pixel bounds is resizedwithin 65,536 to 8,388,608 pixels, the bounds OpenEmbed was evaluated with),config_sentence_transformers.json (the library versions it was tested with).License: third_party/LICENSE-WeMM-EmbeddingThe two distillation teachers, Qwen3-VL-Embedding-8B (Qwen team) andWeMM-Embedding-9B (Tencent), are licensed under Apache-2.0. Their weights are notincluded in this repository.15 unmodified lines161718192021222324252627282930313215 unmodified lines2. WeMM-Embedding (Tencent), https://huggingface.co/tencent/WeMM-Embedding-2BCopyright (C) 2026 Tencent. Files taken from it:modeling_wemm_embedding.py, tokenizer.json, tokenizer_config.json,embedding_chat_template.jinjaModified by the OpenEmbed authors:processor_config.json (the largest image lowered from 16,777,216 to8,388,608 pixels, the bound OpenEmbed was trained and evaluated with).License: third_party/LICENSE-WeMM-EmbeddingWritten by the OpenEmbed authors: chat_template.jinja (renders the input formatof training exactly, so the tokens do not depend on the tokenizer's normalizer),and the Sentence Transformers files modules.json, sentence_bert_config.json,1_Pooling/config.json and config_sentence_transformers.json (stock modules).The two distillation teachers, Qwen3-VL-Embedding-8B (Qwen team) andWeMM-Embedding-9B (Tencent), are licensed under Apache-2.0. Their weights are notincluded in this repository.
36 unmodified lines373839404142434445464748495051525354555610 unmodified lines6768697071727374757677787980818283848586878889909192939495969798991001 unmodified line10210310410510610710810911011111211311411511611711811912012112212312412512612712812913036 unmodified lines## UsageTested with torch 2.8.0, torchvision 0.23.0, transformers 5.2.0, qwen-vl-utils 0.0.14, and sentence-transformers 5.7.0. qwen-vl-utils needs torchvision, which it does not install by itself.```bashpip install torch torchvision transformers==5.2.0 qwen-vl-utils==0.0.14 "sentence-transformers>=5.7.0"```### Input formatOpenEmbed was trained and evaluated with WeMM-Embedding's input format:- Each input is one user turn with no system turn. Images come first, followed by one text item that holds the instruction and the text, joined by a space.- The chat template is applied with `add_generation_prompt=False`. The tokenizer appends the `<embedding>` token.- Images are resized to between 65,536 and 8,388,608 pixels (`min_pixels`, `max_pixels`), the bounds used in evaluation.- Keep the tokenizer's default right padding: the embedding is read at the last non-padding position.Instructions used in training and in MMEB-V2:10 unmodified lines```pythonimport torchfrom qwen_vl_utils import process_vision_infofrom transformers import AutoModel, AutoProcessormodel_id = "UCSC-VLAA/OpenEmbed-0.8B"processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)model = AutoModel.from_pretrained(model_id, trust_remote_code=True, dtype=torch.bfloat16).cuda().eval()MIN_PIXELS, MAX_PIXELS = 65536, 8388608def embed(inputs):"""inputs: dicts with an optional "image" (path, URL, or PIL.Image) and an optional "text"."""conversations = []for x in inputs:content = []if x.get("image") is not None:content.append({"type": "image", "image": x["image"],"min_pixels": MIN_PIXELS, "max_pixels": MAX_PIXELS})if x.get("text") or not content:content.append({"type": "text", "text": x.get("text", "")})conversations.append([{"role": "user", "content": content}])texts = [processor.apply_chat_template(c, tokenize=False, add_generation_prompt=False)for c in conversations]images, _ = process_vision_info(conversations, image_patch_size=16)batch = processor(text=texts, images=images, padding=True, do_resize=False,return_tensors="pt").to(model.device)with torch.inference_mode():return model.embedding(**batch) # shape (len(inputs), 1024), L2-normalizedqueries = embed([1 unmodified line{"text": "Find a document image that matches the given query. What was the revenue in 2023?"},])candidates = embed([{"image": "dog.jpg", "text": "Represent the given image."},{"image": "annual_report_page.png"},])print(queries @ candidates.T)```### Sentence Transformers```pythonfrom sentence_transformers import SentenceTransformermodel = SentenceTransformer("UCSC-VLAA/OpenEmbed-0.8B", trust_remote_code=True)queries = model.encode(["Find me an everyday image that matches the given caption: A brown dog running on a beach.","Find a document image that matches the given query. What was the revenue in 2023?",])candidates = model.encode([{"image": "dog.jpg", "text": "Represent the given image."},{"image": "annual_report_page.png"},])print(model.similarity(queries, candidates))```## Training| | |36 unmodified lines3738394041424344454647484950515253545510 unmodified lines66676869707172737475767778798081828384858687888990919293949596971 unmodified line9910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817936 unmodified lines## UsageNo remote code is needed. Tested with transformers 5.2.0 and 5.23.0, sentence-transformers 5.7.0 and 6.3.0 (torch 2.8.0), and vLLM 0.34.0.```bashpip install torch torchvision "transformers>=5.2.0" "sentence-transformers>=5.7.0"```### Input formatOpenEmbed was trained and evaluated with WeMM-Embedding's input format, which the repository's chat template renders:- Each input is one user turn with no system turn. Images come first, followed by one text item that holds the instruction and the text, joined by a space.- The tokenizer appends the `<embedding>` token. The embedding is the L2-normalized last hidden state at that token, the last non-padding position (keep the default right padding).- Images are resized to between 65,536 and 8,388,608 pixels, the bounds of training and evaluation and the processor's defaults. Scores move with the image budget, so keep them.Instructions used in training and in MMEB-V2:10 unmodified lines```pythonimport torchimport torch.nn.functional as Ffrom PIL import Imagefrom transformers import AutoModel, AutoProcessormodel_id = "UCSC-VLAA/OpenEmbed-0.8B"processor = AutoProcessor.from_pretrained(model_id, use_fast=False)model = AutoModel.from_pretrained(model_id, dtype=torch.bfloat16).cuda().eval()def embed(inputs):"""inputs: dicts with an optional "image" (a PIL.Image) and an optional "text"."""texts, images = [], []for x in inputs:content = [{"type": "image"}] if x.get("image") is not None else []if x.get("text") or not content:content.append({"type": "text", "text": x.get("text", "")})texts.append(processor.apply_chat_template([{"role": "user", "content": content}], tokenize=False))if x.get("image") is not None:images.append(x["image"])batch = processor(text=texts, images=images or None, padding=True, return_tensors="pt").to(model.device)model.rope_deltas = None # transformers < 5.15 would reuse the last image batch's valuewith torch.inference_mode():hidden = model(**batch).last_hidden_statelast = batch["attention_mask"].sum(dim=1) - 1 # the <embedding> tokenrows = torch.arange(hidden.size(0), device=hidden.device)return F.normalize(hidden[rows, last].float(), dim=-1) # shape (len(inputs), 1024)queries = embed([1 unmodified line{"text": "Find a document image that matches the given query. What was the revenue in 2023?"},])candidates = embed([{"image": Image.open("dog.jpg"), "text": "Represent the given image."},{"image": Image.open("annual_report_page.png")},])print(queries @ candidates.T)````use_fast=False` resizes images with PIL, as our evaluation did. The default (torchvision) processor works too and gives embeddings within a cosine of 0.999 of these.### Sentence Transformers```pythonimport torchfrom PIL import Imagefrom sentence_transformers import SentenceTransformermodel = SentenceTransformer("UCSC-VLAA/OpenEmbed-0.8B", model_kwargs={"dtype": torch.bfloat16})queries = model.encode(["Find me an everyday image that matches the given caption: A brown dog running on a beach.","Find a document image that matches the given query. What was the revenue in 2023?",])candidates = model.encode([{"image": Image.open("dog.jpg"), "text": "Represent the given image."},{"image": Image.open("annual_report_page.png")},])print(model.similarity(queries, candidates))```Add `processor_kwargs={"use_fast": False}` to resize images exactly as our evaluation did.### vLLM```bashhf download UCSC-VLAA/OpenEmbed-0.8B --local-dir OpenEmbed-0.8Bvllm serve OpenEmbed-0.8B --runner pooling --chat-template OpenEmbed-0.8B/embedding_chat_template.jinja \--limit-mm-per-prompt.video=0``````pythonimport base64import requestsdef image_url(path):return "data:image/jpeg;base64," + base64.b64encode(open(path, "rb").read()).decode()response = requests.post("http://localhost:8000/v1/embeddings", json={"model": "OpenEmbed-0.8B","messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": image_url("dog.jpg")}},{"type": "text", "text": "Represent the given image."},]}],"encoding_format": "float",})embedding = response.json()["data"][0]["embedding"]```We ran it on a 24 GB card with `--max-model-len 16384` added. `--limit-mm-per-prompt.video=0` leaves out video inputs, which OpenEmbed was not trained on, and the memory vLLM would set aside for them.### How close each path is to our evaluationWe compared each path with the embeddings of our evaluation (the official evaluation code, transformers 5.2.0) on nine inputs: three texts, three images with text, a document page, and an image above and one below the pixel bounds. The Transformers code above produced the evaluation's token ids and image grids for every input. Lowest cosine similarity per path:| Path | Lowest cosine ||---|---:|| Transformers code above, transformers 5.2.0 | 0.999998 || Transformers code above, transformers 5.23.0 | 0.9992 || Sentence Transformers 5.7.0 (transformers 5.2.0) | 0.9997 || Sentence Transformers 6.3.0 (transformers 5.23.0) | 0.9990 || vLLM 0.34.0 | 0.9996 |The rest comes from the numerics of later library versions and from the default image processor's resizing.`trust_remote_code=True` still loads WeMM-Embedding's class (`modeling_wemm_embedding.py`, which the evaluation code reads); its `embedding` method computes the same embedding.## Training| | |
1234567891011121314151617181920212223242526272829303132{#- Embedding template used by Sentence Transformers.
Renders the same surface form as chat_template.jinja for text and images. Video is the exception: it renders as a bare <|video_pad|>, because the processor expands that token into one <seconds><|vision_start|>...<|vision_end|> block per frame and, from transformers 5.3, no longer consumes a surrounding pair. The wrapped form therefore gains a second, unwanted pair of vision boundaries there. This matches embedding_chat_template.jinja, which is bare for the same reason.
The tokenizer normalizer drops the role newline before a leading image and the newline after the final <|im_end|>, then the post-processor appends <embedding>. #}{%- for message in messages %}{{- '<|im_start|>' + message.role + '\n' }}{%- if message.content is string %}{{- message.content }}{%- elif message.content is iterable and message.content is not mapping %}{%- for item in message.content %}{%- if 'image' in item or 'image_url' in item or item.type == 'image' %}{{- '<|vision_start|><|image_pad|><|vision_end|>' }}{%- elif 'video' in item or item.type == 'video' %}{{- '<|video_pad|>' }}{%- elif 'text' in item %}{{- item.text }}{%- else %}{{- raise_exception('Unexpected item type in content.') }}{%- endif %}{%- endfor %}{%- elif message.content is not none %}{{- raise_exception('Unexpected content type.') }}{%- endif %}{{- '<|im_end|>\n' }}{%- endfor %}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154{%- set image_count = namespace(value=0) %}{%- set video_count = namespace(value=0) %}{%- macro render_content(content, do_vision_count, is_system_content=false) %}{%- if content is string %}{{- content }}{%- elif content is iterable and content is not mapping %}{%- for item in content %}{%- if 'image' in item or 'image_url' in item or item.type == 'image' %}{%- if is_system_content %}{{- raise_exception('System message cannot contain images.') }}{%- endif %}{%- if do_vision_count %}{%- set image_count.value = image_count.value + 1 %}{%- endif %}{%- if add_vision_id %}{{- 'Picture ' ~ image_count.value ~ ': ' }}{%- endif %}{{- '<|vision_start|><|image_pad|><|vision_end|>' }}{%- elif 'video' in item or item.type == 'video' %}{%- if is_system_content %}{{- raise_exception('System message cannot contain videos.') }}{%- endif %}{%- if do_vision_count %}{%- set video_count.value = video_count.value + 1 %}{%- endif %}{%- if add_vision_id %}{{- 'Video ' ~ video_count.value ~ ': ' }}{%- endif %}{{- '<|vision_start|><|video_pad|><|vision_end|>' }}{%- elif 'text' in item %}{{- item.text }}{%- else %}{{- raise_exception('Unexpected item type in content.') }}{%- endif %}{%- endfor %}{%- elif content is none or content is undefined %}{{- '' }}{%- else %}{{- raise_exception('Unexpected content type.') }}{%- endif %}{%- endmacro %}{%- if not messages %}{{- raise_exception('No messages provided.') }}{%- endif %}{%- if tools and tools is iterable and tools is not mapping %}{{- '<|im_start|>system\n' }}{{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}{%- for tool in tools %}{{- "\n" }}{{- tool | tojson }}{%- endfor %}{{- "\n</tools>" }}{{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}{%- if messages[0].role == 'system' %}{%- set content = render_content(messages[0].content, false, true)|trim %}{%- if content %}{{- '\n\n' + content }}{%- endif %}{%- endif %}{{- '<|im_end|>\n' }}{%- else %}{%- if messages[0].role == 'system' %}{%- set content = render_content(messages[0].content, false, true)|trim %}{{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}{%- endif %}{%- endif %}{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}{%- for message in messages[::-1] %}{%- set index = (messages|length - 1) - loop.index0 %}{%- if ns.multi_step_tool and message.role == "user" %}{%- set content = render_content(message.content, false)|trim %}{%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}{%- set ns.multi_step_tool = false %}{%- set ns.last_query_index = index %}{%- endif %}{%- endif %}{%- endfor %}{%- if ns.multi_step_tool %}{{- raise_exception('No user query found in messages.') }}{%- endif %}{%- for message in messages %}{%- set content = render_content(message.content, true)|trim %}{%- if message.role == "system" %}{%- if not loop.first %}{{- raise_exception('System message must be at the beginning.') }}{%- endif %}{%- elif message.role == "user" %}{{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}{%- elif message.role == "assistant" %}{%- set reasoning_content = '' %}{%- if message.reasoning_content is string %}{%- set reasoning_content = message.reasoning_content %}{%- else %}{%- if '</think>' in content %}{%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}{%- set content = content.split('</think>')[-1].lstrip('\n') %}{%- endif %}{%- endif %}{%- set reasoning_content = reasoning_content|trim %}{%- if loop.index0 > ns.last_query_index %}{{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}{%- else %}{{- '<|im_start|>' + message.role + '\n' + content }}{%- endif %}{%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}{%- for tool_call in message.tool_calls %}{%- if tool_call.function is defined %}{%- set tool_call = tool_call.function %}{%- endif %}{%- if loop.first %}{%- if content|trim %}{{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}{%- else %}{{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}{%- endif %}{%- else %}{{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}{%- endif %}{%- if tool_call.arguments is defined %}{%- for args_name, args_value in tool_call.arguments|items %}{{- '<parameter=' + args_name + '>\n' }}{%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}{{- args_value }}{{- '\n</parameter>\n' }}{%- endfor %}{%- endif %}{{- '</function>\n</tool_call>' }}{%- endfor %}{%- endif %}{{- '<|im_end|>\n' }}{%- elif message.role == "tool" %}{%- if loop.previtem and loop.previtem.role != "tool" %}{{- '<|im_start|>user' }}{%- endif %}{{- '\n<tool_response>\n' }}{{- content }}{{- '\n</tool_response>' }}{%- if not loop.last and loop.nextitem.role != "tool" %}{{- '<|im_end|>\n' }}{%- elif loop.last %}{{- '<|im_end|>\n' }}{%- endif %}{%- else %}{{- raise_exception('Unexpected message role.') }}{%- endif %}{%- endfor %}{%- if add_generation_prompt %}{{- '<|im_start|>assistant\n' }}{%- if enable_thinking is defined and enable_thinking is true %}{{- '<think>\n' }}{%- else %}{{- '<think>\n\n</think>\n\n' }}{%- endif %}{%- endif %}1234567891011121314151617181920212223242526{#- OpenEmbed input format: one user turn with no system turn; images first, then one text item.The surface form is written out exactly as in training (no newline between the role and a leading image,none after the final <|im_end|>), so the tokens do not depend on the tokenizer's normalizer, whichtransformers stopped applying in later 5.x releases. The tokenizer's post-processor appends <embedding>. -#}{%- for message in messages %}{{- '<|im_start|>' + message.role }}{%- if message.content is string %}{{- '\n' + message.content }}{%- else %}{%- for item in message.content %}{%- if item.type in ['image', 'image_url'] or 'image' in item or 'image_url' in item %}{{- '<|vision_start|><|image_pad|><|vision_end|>' }}{%- elif item.type in ['video', 'video_url'] or 'video' in item or 'video_url' in item %}{{- '\n<|video_pad|>' }}{%- elif item.type == 'text' or 'text' in item %}{{- ('\n' if loop.first else '') + item.text }}{%- else %}{{- raise_exception('Unsupported content type') }}{%- endif %}{%- endfor %}{%- endif %}{{- '<|im_end|>' }}{%- if not loop.last %}{{- '\n' }}{%- endif %}{%- endfor %}
12345678{"__version__": {"pytorch": "2.8.0","sentence_transformers": "5.7.0","transformers": "5.2.0"},"default_prompt_name": null,"model_type": "SentenceTransformer",12345678{"__version__": {"pytorch": "2.8.0","sentence_transformers": "6.3.0","transformers": "5.23.0"},"default_prompt_name": null,"model_type": "SentenceTransformer",
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293"""Sentence Transformers module for WeMM-Embedding.
Reproduces the `transformers` usage from the model card inside a Sentence Transformerspipeline: vision inputs are prepared with `qwen_vl_utils.process_vision_info` and theembedding is read from `WeMMEmbedding.embedding`, which pools the `<embedding>` position andL2-normalizes. Everything else (batching, prompts, truncation, `encode_query` /`encode_document`, similarity) comes from the stock `Transformer` module.
Modified by the OpenEmbed authors (2026-11-18) from tencent/WeMM-Embedding-2B (Apache-2.0):an image item without its own `min_pixels` / `max_pixels` is resized within 65,536 to8,388,608 pixels, the image budget OpenEmbed was evaluated with. Nothing else changes."""
from __future__ import annotations
import inspectfrom typing import Any
from sentence_transformers.models import Transformer
OPENEMBED_MIN_PIXELS = 65536OPENEMBED_MAX_PIXELS = 8388608
def _with_pixel_budget(conversation): """A copy of one conversation whose image items carry the OpenEmbed pixel bounds.""" out = [] for message in conversation: content = message.get("content") if isinstance(message, dict) else None if isinstance(content, (list, tuple)): items = [] for item in content: if isinstance(item, dict) and ("image" in item or "image_url" in item or item.get("type") == "image"): item = {"min_pixels": OPENEMBED_MIN_PIXELS, "max_pixels": OPENEMBED_MAX_PIXELS, **item} items.append(item) message = {**message, "content": items} out.append(message) return out
class WeMMTransformer(Transformer): """`Transformer` that prepares images and videos the way the model card's snippet does."""
def __init__(self, model_name_or_path: str, **kwargs: Any) -> None: super().__init__(model_name_or_path, **kwargs) vision_config = getattr(self.config, "vision_config", None) self.image_patch_size = int(getattr(vision_config, "patch_size", 16))
# `embedding` hands its **kwargs to the inner model, so filtering on its own signature # would drop `pixel_values`. Filter on the inner model's parameters instead, plus the # processor's input names for anything the model only accepts as **kwargs. inner_model = getattr(self.model, "model", self.model) signature = set(inspect.signature(inner_model.forward).parameters) signature |= set(getattr(self.processor, "model_input_names", ())) for modality_params in self.modality_config.values(): method_name = modality_params["method"] if method_name != "forward": self._method_signature_cache.setdefault(method_name, signature)
def _apply_chat_template( self, messages: list[list[dict[str, Any]]], modality_kwargs: dict[str, dict[str, Any]], common_kwargs: dict[str, Any], chat_template_kwargs: dict[str, Any], ) -> dict[str, Any]: """Render the chat template and prepare images / videos exactly as the model card does.""" from qwen_vl_utils import process_vision_info
chat_template_kwargs = {"add_generation_prompt": False, **chat_template_kwargs} texts = [ self.processor.apply_chat_template(conversation, tokenize=False, **chat_template_kwargs) for conversation in messages ] images, videos, video_kwargs = process_vision_info( [_with_pixel_budget(list(conversation)) for conversation in messages], image_patch_size=self.image_patch_size, return_video_kwargs=True, return_video_metadata=True, ) if videos is not None: videos, video_metadata = (list(part) for part in zip(*videos)) video_kwargs = {**video_kwargs, "video_metadata": video_metadata}
return self.processor( text=texts, images=images, videos=videos, text_kwargs=modality_kwargs["text"], images_kwargs=modality_kwargs["image"], videos_kwargs={**modality_kwargs["video"], **video_kwargs}, common_kwargs=common_kwargs, )2 unmodified lines3456782 unmodified lines"idx": 0,"name": "0","path": "","type": "modeling_st_wemm.WeMMTransformer"}]2 unmodified lines345678910111213141516171819202 unmodified lines"idx": 0,"name": "0","path": "","type": "sentence_transformers.base.modules.transformer.Transformer"},{"idx": 1,"name": "1","path": "1_Pooling","type": "sentence_transformers.sentence_transformer.modules.pooling.Pooling"},{"idx": 2,"name": "2","path": "2_Normalize","type": "sentence_transformers.sentence_transformer.modules.normalize.Normalize"}]
19 unmodified lines2021222324252619 unmodified lines"resample": 3,"rescale_factor": 0.00392156862745098,"size": {"longest_edge": 16777216,"shortest_edge": 65536},"temporal_patch_size": 219 unmodified lines2021222324252619 unmodified lines"resample": 3,"rescale_factor": 0.00392156862745098,"size": {"longest_edge": 8388608,"shortest_edge": 65536},"temporal_patch_size": 2
12345678910111213141516171819202122232425262728293031323334353637{"transformer_task": "feature-extraction","modality_config": {"text": {"method": "embedding","method_output_name": null},"image": {"method": "embedding","method_output_name": null},"video": {"method": "embedding","method_output_name": null},"image+text": {"method": "embedding","method_output_name": null},"text+video": {"method": "embedding","method_output_name": null},"message": {"method": "embedding","method_output_name": null,"format": "structured"}},"module_output_name": "sentence_embedding","processing_kwargs": {"chat_template": {"chat_template": "sentence_transformers"}},"unpad_inputs": false}1234567891011121314151617181920212223242526272829{"transformer_task": "feature-extraction","modality_config": {"text": {"method": "forward","method_output_name": "last_hidden_state"},"image": {"method": "forward","method_output_name": "last_hidden_state"},"image+text": {"method": "forward","method_output_name": "last_hidden_state"},"message": {"method": "forward","method_output_name": "last_hidden_state","format": "structured"}},"module_output_name": "token_embeddings","processing_kwargs": {"chat_template": {"add_generation_prompt": false}},"unpad_inputs": false}
1_Pooling/config.jsonAdded+5
NOTICE+8-6
README.md+78-29
additional_chat_templates/sentence_transformers.jinjaDeleted-32
chat_template.jinja+21-149
config_sentence_transformers.json+2-2
modeling_st_wemm.pyDeleted-93
modules.json+13-1
processor_config.json+1-1
sentence_bert_config.json+25-33