Upload 6 files
Browse files- .gitattributes +1 -0
- README.md +30 -3
- config.json +177 -0
- preprocessor_config.json +22 -0
- special_tokens_map.json +51 -0
- tokenizer.json +3 -0
- tokenizer_config.json +54 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## Usage
|
| 2 |
+
Similar usage to jina-clip-v1, the only difference is that it can use matryoshka embeddings, through the truncate_dim argument on the encode_text and encode_image features
|
| 3 |
+
```python
|
| 4 |
+
!pip install transformers einops timm pillow
|
| 5 |
+
from transformers import AutoModel
|
| 6 |
+
|
| 7 |
+
# Initialize the model
|
| 8 |
+
model = AutoModel.from_pretrained('jinaai/jina-clip-v2-test', trust_remote_code=True)
|
| 9 |
+
|
| 10 |
+
# New meaningful sentences
|
| 11 |
+
sentences = ['A blue cat', 'A red cat']
|
| 12 |
+
|
| 13 |
+
# Public image URLs
|
| 14 |
+
image_urls = [
|
| 15 |
+
'https://i.pinimg.com/600x315/21/48/7e/21487e8e0970dd366dafaed6ab25d8d8.jpg',
|
| 16 |
+
'https://i.pinimg.com/736x/c9/f2/3e/c9f23e212529f13f19bad5602d84b78b.jpg'
|
| 17 |
+
]
|
| 18 |
+
|
| 19 |
+
# Encode text and images
|
| 20 |
+
truncate = 512
|
| 21 |
+
text_embeddings = model.encode_text(sentences, truncate_dim = truncate)
|
| 22 |
+
image_embeddings = model.encode_image(image_urls, truncate_dim = truncate) # also accepts PIL.image, local filenames, dataURI
|
| 23 |
+
|
| 24 |
+
# Compute similarities
|
| 25 |
+
print(text_embeddings[0] @ text_embeddings[1].T) # text embedding similarity
|
| 26 |
+
print(text_embeddings[0] @ image_embeddings[0].T) # text-image cross-modal similarity
|
| 27 |
+
print(text_embeddings[0] @ image_embeddings[1].T) # text-image cross-modal similarity
|
| 28 |
+
print(text_embeddings[1] @ image_embeddings[0].T) # text-image cross-modal similarity
|
| 29 |
+
print(text_embeddings[1] @ image_embeddings[1].T)# text-image cross-modal similarity
|
| 30 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_commit_hash": null,
|
| 3 |
+
"_name_or_path": "jinaai/jina-clip-v2-test",
|
| 4 |
+
"add_projections": false,
|
| 5 |
+
"architectures": [
|
| 6 |
+
"JinaCLIPModel"
|
| 7 |
+
],
|
| 8 |
+
"auto_map": {
|
| 9 |
+
"AutoConfig": "jinaai/jina-clip-implementation--configuration_clip.JinaCLIPConfig",
|
| 10 |
+
"AutoModel": "jinaai/jina-clip-implementation--modeling_clip.JinaCLIPModel"
|
| 11 |
+
},
|
| 12 |
+
"initializer_factor": 1.0,
|
| 13 |
+
"logit_scale_init_value": 2.6592,
|
| 14 |
+
"model_type": "jina_clip",
|
| 15 |
+
"projection_dim": 1024,
|
| 16 |
+
"matryoshka_dimensions": [32, 64, 128, 256, 512, 768, 1024],
|
| 17 |
+
"text_config": {
|
| 18 |
+
"_name_or_path": "",
|
| 19 |
+
"add_cross_attention": false,
|
| 20 |
+
"architectures": null,
|
| 21 |
+
"bad_words_ids": null,
|
| 22 |
+
"begin_suppress_tokens": null,
|
| 23 |
+
"bos_token_id": null,
|
| 24 |
+
"chunk_size_feed_forward": 0,
|
| 25 |
+
"cross_attention_hidden_size": null,
|
| 26 |
+
"decoder_start_token_id": null,
|
| 27 |
+
"diversity_penalty": 0.0,
|
| 28 |
+
"do_sample": false,
|
| 29 |
+
"early_stopping": false,
|
| 30 |
+
"embed_dim": 1024,
|
| 31 |
+
"encoder_no_repeat_ngram_size": 0,
|
| 32 |
+
"eos_token_id": null,
|
| 33 |
+
"exponential_decay_length_penalty": null,
|
| 34 |
+
"finetuning_task": null,
|
| 35 |
+
"forced_bos_token_id": null,
|
| 36 |
+
"forced_eos_token_id": null,
|
| 37 |
+
"hf_model_config_kwargs": {
|
| 38 |
+
"use_flash_attn": false
|
| 39 |
+
},
|
| 40 |
+
"hf_model_name_or_path": "jinaai/jina-xlm-roberta-large-rope-8k",
|
| 41 |
+
"id2label": {
|
| 42 |
+
"0": "LABEL_0",
|
| 43 |
+
"1": "LABEL_1"
|
| 44 |
+
},
|
| 45 |
+
"is_decoder": false,
|
| 46 |
+
"is_encoder_decoder": false,
|
| 47 |
+
"label2id": {
|
| 48 |
+
"LABEL_0": 0,
|
| 49 |
+
"LABEL_1": 1
|
| 50 |
+
},
|
| 51 |
+
"length_penalty": 1.0,
|
| 52 |
+
"max_length": 20,
|
| 53 |
+
"min_length": 0,
|
| 54 |
+
"model_type": "jina_clip_text",
|
| 55 |
+
"no_repeat_ngram_size": 0,
|
| 56 |
+
"num_beam_groups": 1,
|
| 57 |
+
"num_beams": 1,
|
| 58 |
+
"num_return_sequences": 1,
|
| 59 |
+
"output_attentions": false,
|
| 60 |
+
"output_hidden_states": false,
|
| 61 |
+
"output_scores": false,
|
| 62 |
+
"pad_token_id": null,
|
| 63 |
+
"pooler_type": "mean_pooler",
|
| 64 |
+
"prefix": null,
|
| 65 |
+
"problem_type": null,
|
| 66 |
+
"proj_bias": false,
|
| 67 |
+
"proj_type": null,
|
| 68 |
+
"pruned_heads": {},
|
| 69 |
+
"remove_invalid_values": false,
|
| 70 |
+
"repetition_penalty": 1.0,
|
| 71 |
+
"return_dict": true,
|
| 72 |
+
"return_dict_in_generate": false,
|
| 73 |
+
"sep_token_id": null,
|
| 74 |
+
"suppress_tokens": null,
|
| 75 |
+
"task_specific_params": null,
|
| 76 |
+
"temperature": 1.0,
|
| 77 |
+
"tf_legacy_loss": false,
|
| 78 |
+
"tie_encoder_decoder": false,
|
| 79 |
+
"tie_word_embeddings": true,
|
| 80 |
+
"tokenizer_class": null,
|
| 81 |
+
"top_k": 50,
|
| 82 |
+
"top_p": 1.0,
|
| 83 |
+
"torch_dtype": null,
|
| 84 |
+
"torchscript": false,
|
| 85 |
+
"transformers_version": "4.42.4",
|
| 86 |
+
"typical_p": 1.0,
|
| 87 |
+
"use_bfloat16": false
|
| 88 |
+
},
|
| 89 |
+
"torch_dtype": "float16",
|
| 90 |
+
"transformers_version": null,
|
| 91 |
+
"use_text_flash_attn": null,
|
| 92 |
+
"use_vision_xformers": null,
|
| 93 |
+
"vision_config": {
|
| 94 |
+
"_name_or_path": "",
|
| 95 |
+
"add_cross_attention": false,
|
| 96 |
+
"architectures": null,
|
| 97 |
+
"bad_words_ids": null,
|
| 98 |
+
"begin_suppress_tokens": null,
|
| 99 |
+
"bos_token_id": null,
|
| 100 |
+
"chunk_size_feed_forward": 0,
|
| 101 |
+
"cross_attention_hidden_size": null,
|
| 102 |
+
"decoder_start_token_id": null,
|
| 103 |
+
"diversity_penalty": 0.0,
|
| 104 |
+
"do_sample": false,
|
| 105 |
+
"drop_path_rate": 0.0,
|
| 106 |
+
"early_stopping": false,
|
| 107 |
+
"embed_dim": 1024,
|
| 108 |
+
"encoder_no_repeat_ngram_size": 0,
|
| 109 |
+
"eos_token_id": null,
|
| 110 |
+
"exponential_decay_length_penalty": null,
|
| 111 |
+
"finetuning_task": null,
|
| 112 |
+
"forced_bos_token_id": null,
|
| 113 |
+
"forced_eos_token_id": null,
|
| 114 |
+
"fused_layer_norm": false,
|
| 115 |
+
"head_width": 64,
|
| 116 |
+
"id2label": {
|
| 117 |
+
"0": "LABEL_0",
|
| 118 |
+
"1": "LABEL_1"
|
| 119 |
+
},
|
| 120 |
+
"image_size": 384,
|
| 121 |
+
"intp_freq": true,
|
| 122 |
+
"is_decoder": false,
|
| 123 |
+
"is_encoder_decoder": false,
|
| 124 |
+
"label2id": {
|
| 125 |
+
"LABEL_0": 0,
|
| 126 |
+
"LABEL_1": 1
|
| 127 |
+
},
|
| 128 |
+
"layers": 24,
|
| 129 |
+
"length_penalty": 1.0,
|
| 130 |
+
"ls_init_value": null,
|
| 131 |
+
"max_length": 20,
|
| 132 |
+
"min_length": 0,
|
| 133 |
+
"mlp_ratio": 2.6667,
|
| 134 |
+
"model_type": "jina_clip_vision",
|
| 135 |
+
"naive_swiglu": true,
|
| 136 |
+
"no_repeat_ngram_size": 0,
|
| 137 |
+
"num_beam_groups": 1,
|
| 138 |
+
"num_beams": 1,
|
| 139 |
+
"num_return_sequences": 1,
|
| 140 |
+
"output_attentions": false,
|
| 141 |
+
"output_hidden_states": false,
|
| 142 |
+
"output_scores": false,
|
| 143 |
+
"pad_token_id": null,
|
| 144 |
+
"patch_dropout": 0.1,
|
| 145 |
+
"patch_size": 14,
|
| 146 |
+
"post_norm": false,
|
| 147 |
+
"prefix": null,
|
| 148 |
+
"problem_type": null,
|
| 149 |
+
"proj_type": null,
|
| 150 |
+
"pruned_heads": {},
|
| 151 |
+
"pt_hw_seq_len": 16,
|
| 152 |
+
"qkv_bias": true,
|
| 153 |
+
"remove_invalid_values": false,
|
| 154 |
+
"repetition_penalty": 1.0,
|
| 155 |
+
"return_dict": true,
|
| 156 |
+
"return_dict_in_generate": false,
|
| 157 |
+
"rope_embeddings": true,
|
| 158 |
+
"sep_token_id": null,
|
| 159 |
+
"subln": true,
|
| 160 |
+
"suppress_tokens": null,
|
| 161 |
+
"task_specific_params": null,
|
| 162 |
+
"temperature": 1.0,
|
| 163 |
+
"tf_legacy_loss": false,
|
| 164 |
+
"tie_encoder_decoder": false,
|
| 165 |
+
"tie_word_embeddings": true,
|
| 166 |
+
"tokenizer_class": null,
|
| 167 |
+
"top_k": 50,
|
| 168 |
+
"top_p": 1.0,
|
| 169 |
+
"torch_dtype": null,
|
| 170 |
+
"torchscript": false,
|
| 171 |
+
"transformers_version": "4.42.4",
|
| 172 |
+
"typical_p": 1.0,
|
| 173 |
+
"use_bfloat16": false,
|
| 174 |
+
"width": 1024,
|
| 175 |
+
"x_attention": false
|
| 176 |
+
}
|
| 177 |
+
}
|
preprocessor_config.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"auto_map": {
|
| 3 |
+
"AutoImageProcessor": "jinaai/jina-clip-implementation--processing_clip.JinaCLIPImageProcessor",
|
| 4 |
+
"AutoProcessor": "jinaai/jina-clip-implementation--processing_clip.JinaCLIPProcessor"
|
| 5 |
+
},
|
| 6 |
+
"fill_color": 0,
|
| 7 |
+
"image_processor_type": "JinaCLIPImageProcessor",
|
| 8 |
+
"interpolation": "bicubic",
|
| 9 |
+
"mean": [
|
| 10 |
+
0.48145466,
|
| 11 |
+
0.4578275,
|
| 12 |
+
0.40821073
|
| 13 |
+
],
|
| 14 |
+
"processor_class": "JinaCLIPProcessor",
|
| 15 |
+
"resize_mode": "shortest",
|
| 16 |
+
"size": 384,
|
| 17 |
+
"std": [
|
| 18 |
+
0.26862954,
|
| 19 |
+
0.26130258,
|
| 20 |
+
0.27577711
|
| 21 |
+
]
|
| 22 |
+
}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<s>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"cls_token": {
|
| 10 |
+
"content": "<s>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"eos_token": {
|
| 17 |
+
"content": "</s>",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": false,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
},
|
| 23 |
+
"mask_token": {
|
| 24 |
+
"content": "<mask>",
|
| 25 |
+
"lstrip": true,
|
| 26 |
+
"normalized": false,
|
| 27 |
+
"rstrip": false,
|
| 28 |
+
"single_word": false
|
| 29 |
+
},
|
| 30 |
+
"pad_token": {
|
| 31 |
+
"content": "<pad>",
|
| 32 |
+
"lstrip": false,
|
| 33 |
+
"normalized": false,
|
| 34 |
+
"rstrip": false,
|
| 35 |
+
"single_word": false
|
| 36 |
+
},
|
| 37 |
+
"sep_token": {
|
| 38 |
+
"content": "</s>",
|
| 39 |
+
"lstrip": false,
|
| 40 |
+
"normalized": false,
|
| 41 |
+
"rstrip": false,
|
| 42 |
+
"single_word": false
|
| 43 |
+
},
|
| 44 |
+
"unk_token": {
|
| 45 |
+
"content": "<unk>",
|
| 46 |
+
"lstrip": false,
|
| 47 |
+
"normalized": false,
|
| 48 |
+
"rstrip": false,
|
| 49 |
+
"single_word": false
|
| 50 |
+
}
|
| 51 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3a56def25aa40facc030ea8b0b87f3688e4b3c39eb8b45d5702b3a1300fe2a20
|
| 3 |
+
size 17082734
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "<s>",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"1": {
|
| 12 |
+
"content": "<pad>",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"2": {
|
| 20 |
+
"content": "</s>",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"3": {
|
| 28 |
+
"content": "<unk>",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"250001": {
|
| 36 |
+
"content": "<mask>",
|
| 37 |
+
"lstrip": true,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"bos_token": "<s>",
|
| 45 |
+
"clean_up_tokenization_spaces": true,
|
| 46 |
+
"cls_token": "<s>",
|
| 47 |
+
"eos_token": "</s>",
|
| 48 |
+
"mask_token": "<mask>",
|
| 49 |
+
"model_max_length": 8194,
|
| 50 |
+
"pad_token": "<pad>",
|
| 51 |
+
"sep_token": "</s>",
|
| 52 |
+
"tokenizer_class": "XLMRobertaTokenizer",
|
| 53 |
+
"unk_token": "<unk>"
|
| 54 |
+
}
|