Visual Document Retrieval
PEFT
Safetensors
ColPali
vidore
multimodal_embedding
multilingual_embedding
Text-to-Visual Document (T→VD) retrieval
Run this model with HF Jobs
Run nomic-ai/nomic-embed-multimodal-7b on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/nomic-ai/nomic-embed-multimodal-7b. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/nomic-ai/nomic-embed-multimodal-7b on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use nomic-ai/nomic-embed-multimodal-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use nomic-ai/nomic-embed-multimodal-7b with PEFT:
from peft import PeftModel from transformers import AutoModel base_model = AutoModel.from_pretrained("Qwen/Qwen2.5-VL-7B-Instruct") model = PeftModel.from_pretrained(base_model, "nomic-ai/nomic-embed-multimodal-7b") - ColPali
How to use nomic-ai/nomic-embed-multimodal-7b with ColPali:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Tom Aarsen commited on
Commit ·
234bc27
1
Parent(s): 1291f1b
Integrate with Sentence Transformers v5.4
Browse filesFiles changed (8)
- 1_Pooling/config.jsonAdded+5
- README.md+45-2
- chat_template.jinjaAdded+31
- chat_template.jsonDeleted-3
- config_sentence_transformers.jsonAdded+8
- modules.jsonAdded+20
- processor_config.json+1-1
- sentence_bert_config.jsonAdded+20
12345{ "embedding_dimension": 3584, "pooling_mode": "lasttoken", "include_prompt": true}16 unmodified lines17181920212223 unmodified lines46474849505152535455565733 unmodified lines91929394959616 unmodified lines- multimodal_embedding- multilingual_embedding- Text-to-Visual Document (T→VD) retrievallicense: apache-2.0---23 unmodified lines## Getting StartedTo use `nomic-embed-multimodal-7b`, please install `colpali` from source```bashpip install git+https://github.com/illuin-tech/colpali.git``````pythonimport torch33 unmodified linesquery_embeddings = model(**batch_queries)scores = processor.score(list(torch.unbind(query_embeddings)), list(torch.unbind(image_embeddings)))```16 unmodified lines1718192021222323 unmodified lines47484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969733 unmodified lines13113213313413513613713813916 unmodified lines- multimodal_embedding- multilingual_embedding- Text-to-Visual Document (T→VD) retrieval- sentence-transformerslicense: apache-2.0---23 unmodified lines## Getting Started### Using Sentence TransformersInstall Sentence Transformers:```bashpip install "sentence_transformers[image]"``````pythonimport torchfrom PIL import Imagefrom sentence_transformers import SentenceTransformermodel = SentenceTransformer("nomic-ai/nomic-embed-multimodal-7b",model_kwargs={"dtype": torch.bfloat16},)# Images can be paths, URLs, or PIL Imagesimages = [Image.new("RGB", (128, 128), color="white"),Image.new("RGB", (64, 32), color="black"),]queries = ["What is the organizational structure for our R&D department?","Can you provide a breakdown of last year’s financial performance?",]image_embeddings = model.encode(images)query_embeddings = model.encode(queries)print(image_embeddings.shape, query_embeddings.shape)# (2, 3584) (2, 3584)scores = model.similarity(query_embeddings, image_embeddings)print(scores)# tensor([[ 0.0076, -0.0014],# [ 0.0156, -0.0040]])```### Using ColPaliInstall `colpali-engine`. Pin to `<0.3.11` as later versions refactored `BiQwen2_5_Processor.process_queries` in a way that no longer matches the format this model was trained with (they dropped the `"Query: "` prefix and switched to a 10-token `<|endoftext|>` augmentation buffer), and loading newer code against these weights produces different scores:```bashpip install "colpali-engine<0.3.11"``````pythonimport torch33 unmodified linesquery_embeddings = model(**batch_queries)scores = processor.score(list(torch.unbind(query_embeddings)), list(torch.unbind(image_embeddings)))print(scores)# tensor([[ 0.0089, -0.0003],# [ 0.0070, 0.0098]])```
12345678910111213141516171819202122232425262728293031{%- for message in messages -%}{%- set has_image = namespace(value=false) -%}{%- if message['content'] is not string -%}{%- for content in message['content'] -%}{%- if content.get('type', '') == 'image' or 'image' in content -%}{%- set has_image.value = true -%}{%- endif -%}{%- endfor -%}{%- endif -%}{%- if has_image.value -%}<|im_start|>user{% for content in message['content'] -%}{%- if content.get('type', '') == 'image' or 'image' in content -%}<|vision_start|><|image_pad|><|vision_end|>{%- endif -%}{%- endfor -%}Describe the image.<|im_end|><|endoftext|>{%- else -%}{{- 'Query: ' -}}{%- if message['content'] is string -%}{{ message['content'] }}{%- else -%}{%- for content in message['content'] -%}{%- if content.get('type', '') == 'text' -%}{{ content['text'] }}{%- endif -%}{%- endfor -%}{%- endif -%}<|endoftext|>{%- endif -%}{%- endfor -%}123{ "chat_template": "{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n{% endif %}<|im_start|>{{ message['role'] }}\n{% if message['content'] is string %}{{ message['content'] }}<|im_end|>\n{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>\n{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant\n{% endif %}"}12345678{ "__version__": { "sentence_transformers": "5.4.0", "transformers": "5.5.0.dev0" }, "model_type": "SentenceTransformer", "similarity_fn_name": "cosine"}1234567891011121314151617181920[ { "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" }]1234{"max_num_visual_tokens": 768,"processor_class": "BiQwen2_5_Processor"}1234{"max_num_visual_tokens": 768,"processor_class": "Qwen2_5_VLProcessor"}
1234567891011121314151617181920{ "transformer_task": "feature-extraction", "modality_config": { "text": { "method": "forward", "method_output_name": "last_hidden_state" }, "image": { "method": "forward", "method_output_name": "last_hidden_state" }, "message": { "method": "forward", "method_output_name": "last_hidden_state", "format": "structured" } }, "module_output_name": "token_embeddings", "unpad_inputs": false}1_Pooling/config.jsonAdded+5
README.md+45-2
chat_template.jinjaAdded+31
chat_template.jsonDeleted-3
config_sentence_transformers.jsonAdded+8
modules.jsonAdded+20
processor_config.json+1-1
sentence_bert_config.jsonAdded+20