🚀 SPhilBerta
SPhilBerta是一個用於識別拉丁語和古希臘語文本之間跨語言引用的句子轉換器模型。該模型以PhilBERTa為基礎,採用了知識蒸餾方法。相關論文首次嘗試為古典文獻學系統地提供最先進的語言模型,可在此處查看。
🚀 快速開始
本模型可用於識別拉丁語和古希臘語文本之間的跨語言引用。下面將介紹不同方式下的使用方法。
💻 使用示例
基礎用法
當你安裝了 sentence-transformers 時,可以按如下方式使用模型:
from sentence_transformers import SentenceTransformer
sentences = ["This is an example sentence", "Each sentence is converted"]
model = SentenceTransformer('{MODEL_NAME}')
embeddings = model.encode(sentences)
print(embeddings)
高級用法
若未安裝 sentence-transformers,可以按以下方式使用模型:首先將輸入傳遞給transformer模型,然後對上下文詞嵌入應用正確的池化操作。
from transformers import AutoTokenizer, AutoModel
import torch
def mean_pooling(model_output, attention_mask):
token_embeddings = model_output[0]
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 = ['This is an example sentence', 'Each sentence is converted']
tokenizer = AutoTokenizer.from_pretrained('{MODEL_NAME}')
model = AutoModel.from_pretrained('{MODEL_NAME}')
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
with torch.no_grad():
model_output = model(**encoded_input)
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
print("Sentence embeddings:")
print(sentence_embeddings)
📚 詳細文檔
論文 Exploring Language Models for Classical Philology 是首次為古典文獻學系統提供最先進語言模型的嘗試。我們以PhilBERTa為基礎,引入了SPhilBERTa,一個用於識別拉丁語和古希臘語文本之間跨語言引用的句子轉換器模型。我們採用了 Reimers and Gurevych (2020) 提出的知識蒸餾方法。我們的論文可在 此處 找到。
📄 許可證
本項目採用 apache-2.0
許可證。
👥 聯繫我們
如果您有任何問題或疑問,請隨時 聯繫我們。
📖 引用
如果您使用了該模型,請引用以下論文:
@incollection{riemenschneiderfrank:2023b,
author = "Riemenschneider, Frederick and Frank, Anette",
title = "{Graecia capta ferum victorem cepit. Detecting Latin Allusions to Ancient Greek Literature}",
year = "2023",
url = "https://arxiv.org/abs/2308.12008",
note = "to appear",
publisher = "Association for Computational Linguistics",
booktitle = "Proceedings of the First Workshop on Ancient Language Processing",
address = "Varna, Bulgaria"
}
模型信息
屬性 |
詳情 |
模型類型 |
句子轉換器模型 |
支持語言 |
多語言、古希臘語、英語、拉丁語 |
標籤 |
sentence-transformers、sentence-similarity |
許可證 |
apache-2.0 |