模型:
sentence-transformers/msmarco-roberta-base-ance-firstp
这是一个将句子和段落映射到768维密集向量空间的模型,可用于聚类或语义搜索等任务。
安装了 sentence-transformers 后,使用此模型变得很容易:
pip install -U sentence-transformers
然后您可以像这样使用模型:
from sentence_transformers import SentenceTransformer sentences = ["This is an example sentence", "Each sentence is converted"] model = SentenceTransformer('sentence-transformers/msmarco-roberta-base-ance-firstp') embeddings = model.encode(sentences) print(embeddings)
要进行对该模型的自动评估,请参阅 句子嵌入基准(Sentence Embeddings Benchmark): https://seb.sbert.net
SentenceTransformer( (0): Transformer({'max_seq_length': 512, 'do_lower_case': True}) with Transformer model: RobertaModel (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False}) (2): Dense({'in_features': 768, 'out_features': 768, 'bias': True, 'activation_function': 'torch.nn.modules.linear.Identity'}) (3): LayerNorm( (norm): LayerNorm((768,), eps=1e-05, elementwise_affine=True) ) )
参考文献: ANCE Model