模型概述
模型特點
模型能力
使用案例
🚀 nblokker/debatenet-2-cat
這是一個 sentence-transformers 模型,它可以將句子和段落映射到 768 維的密集向量空間,可用於聚類或語義搜索等任務。該模型可用於估算包含移民相關需求和提議的句子之間的相似度。更多信息和潛在用例請查看這篇 博客文章。
🚀 快速開始
本模型可用於將句子和段落映射到 768 維的密集向量空間,可用於聚類或語義搜索等任務,還能估算包含移民相關需求和提議的句子之間的相似度。
✨ 主要特性
- 可將句子和段落映射到 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('nblokker/debatenet-2-cat')
embeddings = model.encode(sentences)
print(embeddings)
高級用法
在不使用 sentence-transformers 的情況下,你可以按以下方式使用該模型:首先,將輸入數據傳入 Transformer 模型,然後對上下文相關的詞嵌入應用正確的池化操作。
from transformers import AutoTokenizer, AutoModel
import torch
#Mean Pooling - Take attention mask into account for correct averaging
def mean_pooling(model_output, attention_mask):
token_embeddings = model_output[0] #First element of model_output contains all token embeddings
input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
# Sentences we want sentence embeddings for
sentences = ['This is an example sentence', 'Each sentence is converted']
# Load model from HuggingFace Hub
tokenizer = AutoTokenizer.from_pretrained('nblokker/debatenet-2-cat')
model = AutoModel.from_pretrained('nblokker/debatenet-2-cat')
# Tokenize sentences
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
# Compute token embeddings
with torch.no_grad():
model_output = model(**encoded_input)
# Perform pooling. In this case, mean pooling.
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
print("Sentence embeddings:")
print(sentence_embeddings)
📚 詳細文檔
評估結果
若要對該模型進行自動評估,請查看 Sentence Embeddings Benchmark:https://seb.sbert.net
訓練
該模型的訓練參數如下:
數據加載器:
torch.utils.data.dataloader.DataLoader
,長度為 38,參數如下:
{'batch_size': 32, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
損失函數:
sentence_transformers.losses.BatchHardSoftMarginTripletLoss.BatchHardSoftMarginTripletLoss
fit()
方法的參數:
{
"epochs": 15,
"evaluation_steps": 120.5,
"evaluator": "sentence_transformers.evaluation.BinaryClassificationEvaluator.BinaryClassificationEvaluator",
"max_grad_norm": 1,
"optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
"optimizer_params": {
"lr": 2e-05
},
"scheduler": "WarmupLinear",
"steps_per_epoch": null,
"warmup_steps": 120.5,
"weight_decay": 0.01
}
完整模型架構
SentenceTransformer(
(0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: XLMRobertaModel
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
)
引用與作者
@preprint{blokker2023,
author = {Blokker, Nico and Blessing, Andre and Dayanik, Erenay and Kuhn, Jonas and Padó, Sebastian and Lapesa, Gabriella},
note = {To appear in \textit{Language Resources and Evaluation}},
title = {Between welcome culture and border fence: The {E}uropean refugee crisis in {G}erman newspaper reports},
url = {https://arxiv.org/abs/2111.10142},
year = 2023
}
@inproceedings{lapesa2020,
abstract = {DEbateNet-migr15 is a manually annotated dataset for German which covers the public debate on immigration in 2015. The building block of our annotation is the political science notion of a claim, i.e., a statement made by a political actor (a politician, a party, or a group of citizens) that a specific action should be taken (e.g., vacant flats should be assigned to refugees). We identify claims in newspaper articles, assign them to actors and fine-grained categories and annotate their polarity and date. The aim of this paper is two-fold: first, we release the full DEbateNet-mig15 corpus and document it by means of a quantitative and qualitative analysis; second, we demonstrate its application in a discourse network analysis framework, which enables us to capture the temporal dynamics of the political debate.},
address = {Online},
author = {Lapesa, Gabriella and Blessing, Andre and Blokker, Nico and Dayanik, Erenay and Haunss, Sebastian and Kuhn, Jonas and Padó, Sebastian},
booktitle = {Proceedings of LREC},
pages = {919--927},
title = {{DEbateNet-mig15}: {T}racing the 2015 Immigration Debate in {G}ermany Over Time},
url = {https://www.aclweb.org/anthology/2020.lrec-1.115},
year = 2020
}
致謝
本模型基於 sentence-transformers/paraphrase-multilingual-mpnet-base-v2
模型:
@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 = "http://arxiv.org/abs/1908.10084",
}
- 原始模型 URL:https://huggingface.co/sentence-transformers/paraphrase-multilingual-mpnet-base-v2
- 許可證:Apache 2.0
📄 許可證
本模型的微調部分採用 MIT 許可證發佈。更多詳細信息請查看 LICENSE
文件。原始的 sentence-transformers/paraphrase-multilingual-mpnet-base-v2
模型仍遵循其原始的 Apache 2.0 許可證。







