Integrate with Sentence Transformers v5.4

#11
by tomaarsen HF Staff - opened
1_Pooling/config.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "embedding_dimension": 4096,
3
+ "pooling_mode": "lasttoken",
4
+ "include_prompt": true
5
+ }
README.md CHANGED
@@ -1,11 +1,12 @@
1
  ---
2
  license: apache-2.0
3
- library_name: transformers
4
- pipeline_tag: feature-extraction
5
 
6
  base_model:
7
  - Qwen/Qwen3-VL-8B-Instruct
8
  tags:
 
9
  - transformers
10
  - multimodal embedding
11
  - qwen
@@ -104,6 +105,55 @@ Results on the MMTEB benchmark.
104
 
105
  ## Usage
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  - **requirements**
108
  ```text
109
  transformers>=4.57.0
 
1
  ---
2
  license: apache-2.0
3
+ library_name: sentence-transformers
4
+ pipeline_tag: sentence-similarity
5
 
6
  base_model:
7
  - Qwen/Qwen3-VL-8B-Instruct
8
  tags:
9
+ - sentence-transformers
10
  - transformers
11
  - multimodal embedding
12
  - qwen
 
105
 
106
  ## Usage
107
 
108
+ ### Sentence Transformers
109
+
110
+ Install Sentence Transformers with `pip install sentence-transformers`, then use the model like this:
111
+
112
+ ```python
113
+ from sentence_transformers import SentenceTransformer
114
+
115
+ # Load the model
116
+ model = SentenceTransformer("Qwen/Qwen3-VL-Embedding-8B")
117
+
118
+ # Text queries
119
+ queries = [
120
+ "A woman playing with her dog on a beach at sunset.",
121
+ "Pet owner training dog outdoors near water.",
122
+ "Woman surfing on waves during a sunny day.",
123
+ "City skyline view from a high-rise building at night.",
124
+ ]
125
+
126
+ # Documents: text, image, and text+image
127
+ documents = [
128
+ "A woman shares a joyful moment with her golden retriever on a sun-drenched beach at sunset, as the dog offers its paw in a heartwarming display of companionship and trust.",
129
+ "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
130
+ {"text": "A woman shares a joyful moment with her golden retriever on a sun-drenched beach at sunset, as the dog offers its paw in a heartwarming display of companionship and trust.", "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"},
131
+ ]
132
+
133
+ # Encode queries and documents
134
+ query_embeddings = model.encode(queries)
135
+ doc_embeddings = model.encode(documents)
136
+ print(query_embeddings.shape, doc_embeddings.shape)
137
+ # (4, 4096) (3, 4096)
138
+
139
+ # Compute similarities
140
+ similarities = model.similarity(query_embeddings, doc_embeddings)
141
+ print(similarities)
142
+ # tensor([[0.7438, 0.6556, 0.6244],
143
+ # [0.4430, 0.3323, 0.3929],
144
+ # [0.3685, 0.2310, 0.2874],
145
+ # [0.0602, -0.0162, 0.0167]])
146
+ ```
147
+
148
+ By default, all inputs are wrapped with the `"Represent the user's input."` instruction via a system prompt. You can customize this by passing a different prompt:
149
+
150
+ ```python
151
+ # With a custom prompt
152
+ model.encode(queries, prompt="Retrieve relevant documents for the query.")
153
+ ```
154
+
155
+ ### Using transformers
156
+
157
  - **requirements**
158
  ```text
159
  transformers>=4.57.0
config_sentence_transformers.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "5.4.0"
4
+ },
5
+ "default_prompt_name": "default",
6
+ "model_type": "SentenceTransformer",
7
+ "prompts": {
8
+ "default": "Represent the user's input."
9
+ },
10
+ "similarity_fn_name": "cosine"
11
+ }
modules.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.base.modules.transformer.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.sentence_transformer.modules.pooling.Pooling"
13
+ },
14
+ {
15
+ "idx": 2,
16
+ "name": "2",
17
+ "path": "2_Normalize",
18
+ "type": "sentence_transformers.sentence_transformer.modules.normalize.Normalize"
19
+ }
20
+ ]
sentence_bert_config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "transformer_task": "feature-extraction",
3
+ "modality_config": {
4
+ "text": {
5
+ "method": "forward",
6
+ "method_output_name": "last_hidden_state"
7
+ },
8
+ "image": {
9
+ "method": "forward",
10
+ "method_output_name": "last_hidden_state"
11
+ },
12
+ "video": {
13
+ "method": "forward",
14
+ "method_output_name": "last_hidden_state"
15
+ },
16
+ "message": {
17
+ "method": "forward",
18
+ "method_output_name": "last_hidden_state",
19
+ "format": "structured"
20
+ }
21
+ },
22
+ "module_output_name": "token_embeddings",
23
+ "processing_kwargs": {
24
+ "chat_template": {
25
+ "add_generation_prompt": true
26
+ }
27
+ },
28
+ "unpad_inputs": false
29
+ }