Views
No views yet
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'BertModel'})
(1): Pooling({'embedding_dimension': 1024, 'pooling_mode': 'mean', 'include_prompt': True})
(2): Dense({'in_features': 1024, 'out_features': 1792, 'bias': True, 'activation_function': 'torch.nn.modules.linear.Identity', 'module_input_name': 'sentence_embedding', 'module_output_name': 'sentence_embedding'})
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("sentence_transformers_model_id")
5# Run inference
6queries = [
7 '上学文具分享',
8]
9documents = [
10 '准初三生的书包里有啥😉👉🏻💗\n都是一些很真实的东西哈哈哈 \n我就问有谁懂…?\n#笔袋[话题]# #笔袋介绍[话题]# #我的文具分享[话题]# \n#晒晒我的书桌[话题]# #我的日常[话题]# \n#whatsinmybag[话题]# #书包里面装什么[话题]# \n#书包[话题]# ',
11 '下辈子我也要当仓鼠\n傻傻的胖胖的不知道悲伤……#珍藏的宠物照[话题]# #侏儒仓鼠[话题]# #鼠鼠教[话题]# #宠物[话题]# #宠物日常[话题]# ',
12 '云南丽江~ 束河古镇风景(上)\n拍于2023年11.19哦~\n从白沙坐公交去的束河古镇\n进门的时候忘记拍牌楼了[笑哭R]\n刚进门不久走到了茶马古道博物馆但是是关闭状态的\n不走人多的地方风景很不错\n图上那只松鼠的表情真的笑死\n看起来比香格里拉和雨崩的可爱\n建议沿着水流走 风景不会太差\n#云南[话题]# #云南游[话题]# #云南丽江[话题]# #束河古镇[话题]# ',
13]
14query_embeddings = model.encode_query(queries)
15document_embeddings = model.encode_document(documents)
16print(query_embeddings.shape, document_embeddings.shape)
17# [1, 1792] [3, 1792]
18
19# Get the similarity scores for the embeddings
20similarities = model.similarity(query_embeddings, document_embeddings)
21print(similarities)
22# tensor([[ 0.6374, 0.0472, -0.0356]])query_note_test and query_note_valInformationRetrievalEvaluator| Metric | query_note_test | query_note_val |
|---|---|---|
| cosine_accuracy@1 | 0.2839 | 0.3002 |
| cosine_accuracy@3 | 0.5495 | 0.5971 |
| cosine_accuracy@5 | 0.6792 | 0.7274 |
| cosine_accuracy@10 | 0.8055 | 0.8523 |
| cosine_precision@1 | 0.2839 | 0.3002 |
| cosine_precision@3 | 0.2471 | 0.2702 |
| cosine_precision@5 | 0.2212 | 0.2335 |
| cosine_precision@10 | 0.1722 | 0.1784 |
| cosine_recall@1 | 0.111 | 0.1289 |
| cosine_recall@3 | 0.2748 | 0.3301 |
| cosine_recall@5 | 0.3833 | 0.4495 |
| cosine_recall@10 | 0.5335 | 0.6154 |
| cosine_ndcg@10 | 0.4031 | 0.4517 |
| cosine_ndcg@100 | 0.5231 | 0.5634 |
| cosine_mrr@10 | 0.4463 | 0.475 |
| cosine_mrr@100 | 0.4544 | 0.4818 |
| cosine_map@10 | 0.2898 | 0.334 |
| cosine_map@100 | 0.3372 | 0.3809 |
query_note_test_256 and query_note_val_256InformationRetrievalEvaluator with these parameters:
1{
2 "truncate_dim": 256
3}| Metric | query_note_test_256 | query_note_val_256 |
|---|---|---|
| cosine_accuracy@1 | 0.2763 | 0.2939 |
| cosine_accuracy@3 | 0.5444 | 0.5918 |
| cosine_accuracy@5 | 0.6674 | 0.7245 |
| cosine_accuracy@10 | 0.8007 | 0.8479 |
| cosine_precision@1 | 0.2763 | 0.2939 |
| cosine_precision@3 | 0.2432 | 0.2667 |
| cosine_precision@5 | 0.2151 | 0.2339 |
| cosine_precision@10 | 0.1695 | 0.1766 |
| cosine_recall@1 | 0.1077 | 0.1255 |
| cosine_recall@3 | 0.2702 | 0.3267 |
| cosine_recall@5 | 0.3715 | 0.4489 |
| cosine_recall@10 | 0.5229 | 0.607 |
| cosine_ndcg@10 | 0.3951 | 0.4467 |
| cosine_ndcg@100 | 0.5137 | 0.5581 |
| cosine_mrr@10 | 0.4397 | 0.4712 |
| cosine_mrr@100 | 0.4477 | 0.4781 |
| cosine_map@10 | 0.2826 | 0.3295 |
| cosine_map@100 | 0.3287 | 0.376 |
anchor and positive| anchor | positive | |
|---|---|---|
| type | string | string |
| modality | text | text |
| details |
|
|
| anchor | positive |
|---|---|
jeep冲锋衣属于档次 | 🧥吉普冲锋衣,秋季必备🍂[object Object]Jeep吉普官方正品,品质有保障👍。 [object Object] [object Object]卡其色/M码,适合90-110斤,款式时尚百搭。 [object Object] [object Object]防风防水设计,适合户外活动,保暖又舒适😊。 [object Object] [object Object]秋季穿搭必备,你值得拥有! #小红书秋日焕新[话题]# #jeep[话题]# #冲锋衣[话题]# #秋季外套[话题]# #正品保证[话题]# #防风防水[话题]# #户外穿搭[话题]# #时尚百搭[话题]# #品质选择[话题]# |
喝酒文案微醺 | 秋冬时刻需要威士忌 | 见面吗?![object Object]🍽️[object Object]属于我和先生的浪漫约会日常[object Object]便是放下孩子后的小酌怡情~[object Object] 刚好最近气温骤降,多了些凉意[object Object]想来一杯Whisky的心情达到上限[object Object] 🍽️[object Object]听闻格兰菲迪最近和MU·慕有出合作套餐[object Object]与先生的couple vacation时刻瞬间启动~[object Object]在轻奢环境下更适合开一瓶格兰菲迪22年单一麦芽苏格兰威士忌[object Object]@格兰菲迪 Glenfiddich [object Object]作为在全球屡获殊荣的单一麦芽苏格兰威士忌品牌[object Object]自诞生起就从未停止探索的脚步[object Object]不断探究威士忌与餐食搭配的新风味[object Object] 🍽️[object Object]当杯中深红琥珀色的酒体[object Object]在灯光下衬得更加迷人时[object Object]黑巧克力以及葡萄果干的浓郁香气也同时散发[object Object]象拔蚌和波士顿龙虾的上场[object Object]将视觉的色与口感的香瞬间突出[object Object]薄如刀片的爽脆蚌肉和Q弹龙虾肉[object Object]在酒精的碰撞下太立体太美好[object Object] [object Object]余韵的温润柑橘果香和馥郁水果蛋糕香[object Object]像是激情生活之后的源远流长[object Object]搭配新西兰羊排嫩多汁的奶香气息[object Object]像是被酒精注入新的灵感和层次[object Object] 🤎[object Object]婚后的微醺节奏[object Object]同样能拉近彼此的距离[object Object]大家也可以打卡格兰菲迪合作餐厅哦[object Object]用一杯格兰菲迪杯找寻浪漫~找寻生活吧[object Object]#广州探店[话题]# #福鹿结伴山海寻鲜[话题]# #威士忌推荐[话题]# #格兰菲迪[话题]# #格兰菲迪单一麦芽威士忌[话题]# |
长沙酒吧 | 长沙一定要去的6️⃣大夜店!!![object Object]长沙夜生活 蹦迪💃酒吧 再多的攻略都不及去亲身体验一次!![object Object] [object Object]✅长沙一定要去的夜店❗️❗️[object Object]1️⃣X-sta:长沙最火爆的高空edm场 声光电体验感强 非常具有科技感 总投资1.8亿[赞R] 四五六楼是包厢 娱乐综合体[object Object]2️⃣one9:小厅bounce场 韩国江南风夜店 前身是火爆长沙的NBEK 喜欢小厅的朋友不要错过啦[派对R][object Object]3️⃣FTF:新开业中型edm/bounce酒吧 位置在海信广场 以前的超级猴子[派对R][object Object]4️⃣kok:网红爆品小厅 每晚都有男团演出与玩家们互动 人气也一直居高不下[自拍R][object Object]5️⃣猩猩地堡:连锁品牌 打卡的人很多 长沙年轻人的聚集地[object Object]6️⃣试音:长沙hiphop吧天花板 嘉宾众多气氛火爆 值得打卡[object Object] [object Object]🌿住宿推荐[object Object]建议住五一广场/开福区万达广场(去哪都方便)[object Object] [object Object]⚠️温馨提示:想去长沙夜店玩的朋友记得提前做好攻略,提前找销售预约好门店避免排队![object Object] [object Object]希望这些对您有所帮助![object Object]图片来源于网络 侵删![object Object]#长沙酒吧[话题]# #长沙酒吧推荐[话题]# #长沙酒吧订台[话题]# #长沙旅游[话题]# #长沙蹦迪[话题]# |
MatryoshkaLoss with these parameters:
1{
2 "loss": "MultipleNegativesRankingLoss",
3 "matryoshka_dims": [
4 1024,
5 256
6 ],
7 "matryoshka_weights": [
8 1,
9 1
10 ],
11 "n_dims_per_step": -1
12}per_device_train_batch_size: 256learning_rate: 0.0001weight_decay: 0.01num_train_epochs: 1lr_scheduler_type: cosinewarmup_ratio: 0.05seed: 3407bf16: Truebatch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseprediction_loss_only: Trueper_device_train_batch_size: 256per_device_eval_batch_size: 8per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 0.0001weight_decay: 0.01adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 1max_steps: -1lr_scheduler_type: cosinelr_scheduler_kwargs: {}warmup_ratio: 0.05warmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Truesave_safetensors: Truesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseno_cuda: Falseuse_cpu: Falseuse_mps_device: Falseseed: 3407data_seed: Nonejit_mode_eval: Falseuse_ipex: Falsebf16: Truefp16: Falsefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonepast_index: -1disable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Falseignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap: Noneaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsehub_revision: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseinclude_for_metrics: []eval_do_concat_batches: Truefp16_backend: autopush_to_hub_model_id: Nonepush_to_hub_organization: Nonemp_parameters:auto_find_batch_size: Falsefull_determinism: Falsetorchdynamo: Noneray_scope: lastddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | query_note_test_cosine_ndcg@100 | query_note_test_256_cosine_ndcg@100 | query_note_val_cosine_ndcg@100 | query_note_val_256_cosine_ndcg@100 |
|---|---|---|---|---|---|---|
| -1 | -1 | - | 0.4211 | 0.4014 | - | - |
| 0.0776 | 50 | 1.8314 | - | - | - | - |
| 0.1553 | 100 | 0.7712 | - | - | - | - |
| 0.2329 | 150 | 0.7237 | - | - | - | - |
| 0.3106 | 200 | 0.7116 | - | - | - | - |
| 0.3882 | 250 | 0.6376 | - | - | - | - |
| 0.4658 | 300 | 0.6284 | - | - | - | - |
| 0.5435 | 350 | 0.6425 | - | - | - | - |
| 0.6211 | 400 | 0.6198 | - | - | - | - |
| 0.6988 | 450 | 0.6409 | - | - | - | - |
| 0.7764 | 500 | 0.5954 | - | - | - | - |
| 0.8540 | 550 | 0.5891 | - | - | - | - |
| 0.9317 | 600 | 0.5833 | - | - | - | - |
| 1.0 | 644 | - | - | - | 0.5634 | 0.5581 |
| -1 | -1 | - | 0.5231 | 0.5137 | - | - |
1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}1@misc{kusupati2024matryoshka,
2 title={Matryoshka Representation Learning},
3 author={Aditya Kusupati and Gantavya Bhatt and Aniket Rege and Matthew Wallingford and Aditya Sinha and Vivek Ramanujan and William Howard-Snyder and Kaifeng Chen and Sham Kakade and Prateek Jain and Ali Farhadi},
4 year={2024},
5 eprint={2205.13147},
6 archivePrefix={arXiv},
7 primaryClass={cs.LG}
8}1@misc{oord2019representationlearningcontrastivepredictive,
2 title={Representation Learning with Contrastive Predictive Coding},
3 author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
4 year={2019},
5 eprint={1807.03748},
6 archivePrefix={arXiv},
7 primaryClass={cs.LG},
8 url={https://arxiv.org/abs/1807.03748},
9}