Improving Efficient Neural Ranking Models with Cross-Architecture Knowledge Distillation
Paper • 2010.02666 • Published
How to use liudev/novel-embedding-gpl-base-v1 with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("liudev/novel-embedding-gpl-base-v1")
sentences = [
"同伴因祸得福武功大进",
"跟随队伍一同进城采购",
"击退邪神后,邪神夺舍村民",
"说服父母改变只求多生的老旧生育观念"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from BAAI/bge-base-zh-v1.5. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, classification, clustering, and more.
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': 768, 'pooling_mode': 'cls', 'include_prompt': True})
(2): Normalize({})
)
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("liudev/novel-embedding-gpl-base-v1")
# Run inference
sentences = [
'在异能觉醒爆发时安抚对方并带走宝物',
'宴席上有人当众示爱引发全场震惊',
'凶暴巨兽冲破防线引发骚乱',
'山贼讲述当年的恐惧往事,结果再次遭遇强敌被瞬杀',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [4, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]
anchor, sentence1, sentence2, and label| anchor | sentence1 | sentence2 | label | |
|---|---|---|---|---|
| type | string | string | string | float |
| modality | text | text | text | |
| details |
|
|
|
|
| anchor | sentence1 | sentence2 | label |
|---|---|---|---|
看破敌人的隐身手段 |
周昂在围攻强敌时敏锐察觉到异样,通过观察灵气流动识破并破除隐身法术,最终果断出手将藏匿在墙头的施法者格杀。 |
李破在马场以赏罚分明的手段收拢人心并大摆酒宴后,在李碧的私下召见中,意外得知其欲随军出征辽东的计划并被征询意见。 |
0.759356061900818 |
在仓库意外得到防身宝物 |
柳渊在医馆仓库意外获得防御法器佛珠及攻击真言,随后通过定星罗盘锁定义务星邪,并凭借缜密的推理引导葛老与辛捕头共同前往后院枯井探查。 |
沈河在烂尾楼工地通过系统指引接连开启宝箱,获得了具备强控效果的“大力飞砖”与防御性的“安全员安全帽”,在确认工地无剩余宝箱后,随即根据新坐标向十公里外进发。 |
0.09672797019024215 |
进宫面圣前,太监好心提醒忌讳规矩 |
宦官郭穰在权衡利弊后决定拉拢入觐的天子待诏秀才张毅,不仅对其礼遇有加,更在入宫途中悉心传授面圣禁忌与生存经验,双方达成了初步的盟友共识。 |
在正月初一太子加冠的重大典礼上,南风费尽心思哄劝赖床的太子完成繁琐仪式并接手庞大的东宫官僚体系,同时担忧自己微服出游时的糗事在稍后的公开亮相中被路人认出。 |
0.5887360227245302 |
MarginMSELoss with these parameters:{
"similarity_fct": "pairwise_dot_score"
}
per_device_train_batch_size: 32num_train_epochs: 150learning_rate: 2e-05warmup_steps: 0.02fp16: Truepush_to_hub: Truehub_model_id: liudev/novel-embedding-gpl-base-v1hub_strategy: checkpointdataloader_num_workers: 4per_device_train_batch_size: 32num_train_epochs: 150max_steps: -1learning_rate: 2e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0.02optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_tokens_across_devices: Truemax_grad_norm: 1.0label_smoothing_factor: 0.0bf16: Falsefp16: Truebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Nonetorch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneuse_liger_kernel: Falseliger_kernel_config: Noneuse_cache: Falseneftune_noise_alpha: Nonetorch_empty_cache_steps: Noneauto_find_batch_size: Falselog_on_each_node: Truelogging_nan_inf_filter: Trueinclude_num_input_tokens_seen: nolog_level: passivelog_level_replica: warningdisable_tqdm: Falseproject: huggingfacetrackio_space_id: Nonetrackio_bucket_id: Nonetrackio_static_space_id: Noneper_device_eval_batch_size: 8prediction_loss_only: Trueeval_on_start: Falseeval_do_concat_batches: Trueeval_use_gather_object: Falseeval_accumulation_steps: Noneinclude_for_metrics: []batch_eval_metrics: Falsesave_only_model: Falsesave_on_each_node: Falseenable_jit_checkpoint: Falsepush_to_hub: Truehub_private_repo: Nonehub_model_id: liudev/novel-embedding-gpl-base-v1hub_strategy: checkpointhub_always_push: Falsehub_revision: Noneload_best_model_at_end: Falseignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_seed: Noneuse_cpu: Falseaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedataloader_drop_last: Truedataloader_num_workers: 4dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Nonedataloader_multiprocessing_context: Nonedataloader_in_order: Trueremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_static_graph: Noneddp_backend: Noneddp_timeout: 1800fsdp: Nonefsdp_config: Nonedeepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonelocal_rank: -1prompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}warmup_ratio: None| Epoch | Step | Training Loss |
|---|---|---|
| 148.5368 | 1010050 | 0.0080 |
| 148.5441 | 1010100 | 0.0075 |
| 148.5515 | 1010150 | 0.0079 |
| 148.5588 | 1010200 | 0.0074 |
| 148.5662 | 1010250 | 0.0076 |
| 148.5735 | 1010300 | 0.0079 |
| 148.5809 | 1010350 | 0.0075 |
| 148.5882 | 1010400 | 0.0075 |
| 148.5956 | 1010450 | 0.0076 |
| 148.6029 | 1010500 | 0.0074 |
| 148.6103 | 1010550 | 0.0076 |
| 148.6176 | 1010600 | 0.0077 |
| 148.625 | 1010650 | 0.0074 |
| 148.6324 | 1010700 | 0.0073 |
| 148.6397 | 1010750 | 0.0069 |
| 148.6471 | 1010800 | 0.0074 |
| 148.6544 | 1010850 | 0.0079 |
| 148.6618 | 1010900 | 0.0073 |
| 148.6691 | 1010950 | 0.0075 |
| 148.6765 | 1011000 | 0.0076 |
| 148.6838 | 1011050 | 0.0076 |
| 148.6912 | 1011100 | 0.0072 |
| 148.6985 | 1011150 | 0.0077 |
| 148.7059 | 1011200 | 0.0073 |
| 148.7132 | 1011250 | 0.0075 |
| 148.7206 | 1011300 | 0.0072 |
| 148.7279 | 1011350 | 0.0077 |
| 148.7353 | 1011400 | 0.0074 |
| 148.7426 | 1011450 | 0.0074 |
| 148.75 | 1011500 | 0.0077 |
| 148.7574 | 1011550 | 0.0075 |
| 148.7647 | 1011600 | 0.0073 |
| 148.7721 | 1011650 | 0.0075 |
| 148.7794 | 1011700 | 0.0075 |
| 148.7868 | 1011750 | 0.0077 |
| 148.7941 | 1011800 | 0.0076 |
| 148.8015 | 1011850 | 0.0074 |
| 148.8088 | 1011900 | 0.0073 |
| 148.8162 | 1011950 | 0.0075 |
| 148.8235 | 1012000 | 0.0076 |
| 148.8309 | 1012050 | 0.0073 |
| 148.8382 | 1012100 | 0.0077 |
| 148.8456 | 1012150 | 0.0074 |
| 148.8529 | 1012200 | 0.0077 |
| 148.8603 | 1012250 | 0.0078 |
| 148.8676 | 1012300 | 0.0075 |
| 148.875 | 1012350 | 0.0077 |
| 148.8824 | 1012400 | 0.0076 |
| 148.8897 | 1012450 | 0.0076 |
| 148.8971 | 1012500 | 0.0074 |
| 148.9044 | 1012550 | 0.0077 |
| 148.9118 | 1012600 | 0.0080 |
| 148.9191 | 1012650 | 0.0075 |
| 148.9265 | 1012700 | 0.0073 |
| 148.9338 | 1012750 | 0.0075 |
| 148.9412 | 1012800 | 0.0073 |
| 148.9485 | 1012850 | 0.0076 |
| 148.9559 | 1012900 | 0.0075 |
| 148.9632 | 1012950 | 0.0076 |
| 148.9706 | 1013000 | 0.0076 |
| 148.9779 | 1013050 | 0.0077 |
| 148.9853 | 1013100 | 0.0074 |
| 148.9926 | 1013150 | 0.0078 |
| 149.0 | 1013200 | 0.0077 |
| 149.0074 | 1013250 | 0.0074 |
| 149.0147 | 1013300 | 0.0072 |
| 149.0221 | 1013350 | 0.0076 |
| 149.0294 | 1013400 | 0.0077 |
| 149.0368 | 1013450 | 0.0075 |
| 149.0441 | 1013500 | 0.0073 |
| 149.0515 | 1013550 | 0.0080 |
| 149.0588 | 1013600 | 0.0076 |
| 149.0662 | 1013650 | 0.0074 |
| 149.0735 | 1013700 | 0.0072 |
| 149.0809 | 1013750 | 0.0078 |
| 149.0882 | 1013800 | 0.0076 |
| 149.0956 | 1013850 | 0.0078 |
| 149.1029 | 1013900 | 0.0072 |
| 149.1103 | 1013950 | 0.0078 |
| 149.1176 | 1014000 | 0.0080 |
| 149.125 | 1014050 | 0.0079 |
| 149.1324 | 1014100 | 0.0074 |
| 149.1397 | 1014150 | 0.0072 |
| 149.1471 | 1014200 | 0.0078 |
| 149.1544 | 1014250 | 0.0079 |
| 149.1618 | 1014300 | 0.0075 |
| 149.1691 | 1014350 | 0.0079 |
| 149.1765 | 1014400 | 0.0079 |
| 149.1838 | 1014450 | 0.0073 |
| 149.1912 | 1014500 | 0.0077 |
| 149.1985 | 1014550 | 0.0075 |
| 149.2059 | 1014600 | 0.0075 |
| 149.2132 | 1014650 | 0.0076 |
| 149.2206 | 1014700 | 0.0076 |
| 149.2279 | 1014750 | 0.0074 |
| 149.2353 | 1014800 | 0.0074 |
| 149.2426 | 1014850 | 0.0078 |
| 149.25 | 1014900 | 0.0079 |
| 149.2574 | 1014950 | 0.0075 |
| 149.2647 | 1015000 | 0.0074 |
| 149.2721 | 1015050 | 0.0074 |
| 149.2794 | 1015100 | 0.0077 |
| 149.2868 | 1015150 | 0.0079 |
| 149.2941 | 1015200 | 0.0076 |
| 149.3015 | 1015250 | 0.0070 |
| 149.3088 | 1015300 | 0.0074 |
| 149.3162 | 1015350 | 0.0076 |
| 149.3235 | 1015400 | 0.0074 |
| 149.3309 | 1015450 | 0.0075 |
| 149.3382 | 1015500 | 0.0078 |
| 149.3456 | 1015550 | 0.0077 |
| 149.3529 | 1015600 | 0.0080 |
| 149.3603 | 1015650 | 0.0077 |
| 149.3676 | 1015700 | 0.0073 |
| 149.375 | 1015750 | 0.0074 |
| 149.3824 | 1015800 | 0.0077 |
| 149.3897 | 1015850 | 0.0079 |
| 149.3971 | 1015900 | 0.0074 |
| 149.4044 | 1015950 | 0.0075 |
| 149.4118 | 1016000 | 0.0074 |
| 149.4191 | 1016050 | 0.0077 |
| 149.4265 | 1016100 | 0.0078 |
| 149.4338 | 1016150 | 0.0073 |
| 149.4412 | 1016200 | 0.0072 |
| 149.4485 | 1016250 | 0.0075 |
| 149.4559 | 1016300 | 0.0078 |
| 149.4632 | 1016350 | 0.0077 |
| 149.4706 | 1016400 | 0.0077 |
| 149.4779 | 1016450 | 0.0074 |
| 149.4853 | 1016500 | 0.0077 |
| 149.4926 | 1016550 | 0.0076 |
| 149.5 | 1016600 | 0.0076 |
| 149.5074 | 1016650 | 0.0081 |
| 149.5147 | 1016700 | 0.0075 |
| 149.5221 | 1016750 | 0.0076 |
| 149.5294 | 1016800 | 0.0074 |
| 149.5368 | 1016850 | 0.0079 |
| 149.5441 | 1016900 | 0.0073 |
| 149.5515 | 1016950 | 0.0076 |
| 149.5588 | 1017000 | 0.0076 |
| 149.5662 | 1017050 | 0.0077 |
| 149.5735 | 1017100 | 0.0080 |
| 149.5809 | 1017150 | 0.0076 |
| 149.5882 | 1017200 | 0.0077 |
| 149.5956 | 1017250 | 0.0076 |
| 149.6029 | 1017300 | 0.0075 |
| 149.6103 | 1017350 | 0.0077 |
| 149.6176 | 1017400 | 0.0077 |
| 149.625 | 1017450 | 0.0071 |
| 149.6324 | 1017500 | 0.0078 |
| 149.6397 | 1017550 | 0.0077 |
| 149.6471 | 1017600 | 0.0075 |
| 149.6544 | 1017650 | 0.0071 |
| 149.6618 | 1017700 | 0.0074 |
| 149.6691 | 1017750 | 0.0076 |
| 149.6765 | 1017800 | 0.0078 |
| 149.6838 | 1017850 | 0.0076 |
| 149.6912 | 1017900 | 0.0076 |
| 149.6985 | 1017950 | 0.0075 |
| 149.7059 | 1018000 | 0.0074 |
| 149.7132 | 1018050 | 0.0079 |
| 149.7206 | 1018100 | 0.0075 |
| 149.7279 | 1018150 | 0.0078 |
| 149.7353 | 1018200 | 0.0075 |
| 149.7426 | 1018250 | 0.0073 |
| 149.75 | 1018300 | 0.0076 |
| 149.7574 | 1018350 | 0.0073 |
| 149.7647 | 1018400 | 0.0077 |
| 149.7721 | 1018450 | 0.0074 |
| 149.7794 | 1018500 | 0.0073 |
| 149.7868 | 1018550 | 0.0076 |
| 149.7941 | 1018600 | 0.0074 |
| 149.8015 | 1018650 | 0.0078 |
| 149.8088 | 1018700 | 0.0073 |
| 149.8162 | 1018750 | 0.0077 |
| 149.8235 | 1018800 | 0.0072 |
| 149.8309 | 1018850 | 0.0079 |
| 149.8382 | 1018900 | 0.0076 |
| 149.8456 | 1018950 | 0.0072 |
| 149.8529 | 1019000 | 0.0074 |
| 149.8603 | 1019050 | 0.0077 |
| 149.8676 | 1019100 | 0.0074 |
| 149.875 | 1019150 | 0.0076 |
| 149.8824 | 1019200 | 0.0078 |
| 149.8897 | 1019250 | 0.0075 |
| 149.8971 | 1019300 | 0.0070 |
| 149.9044 | 1019350 | 0.0075 |
| 149.9118 | 1019400 | 0.0076 |
| 149.9191 | 1019450 | 0.0075 |
| 149.9265 | 1019500 | 0.0074 |
| 149.9338 | 1019550 | 0.0072 |
| 149.9412 | 1019600 | 0.0080 |
| 149.9485 | 1019650 | 0.0073 |
| 149.9559 | 1019700 | 0.0077 |
| 149.9632 | 1019750 | 0.0075 |
| 149.9706 | 1019800 | 0.0078 |
| 149.9779 | 1019850 | 0.0075 |
| 149.9853 | 1019900 | 0.0077 |
| 149.9926 | 1019950 | 0.0074 |
| 150.0 | 1020000 | 0.0076 |
@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/1908.10084",
}
@misc{hofstätter2021improving,
title={Improving Efficient Neural Ranking Models with Cross-Architecture Knowledge Distillation},
author={Sebastian Hofstätter and Sophia Althammer and Michael Schröder and Mete Sertkan and Allan Hanbury},
year={2021},
eprint={2010.02666},
archivePrefix={arXiv},
primaryClass={cs.IR}
}