Views
No views yet
1tokenizer = AutoTokenizer.from_pretrained('roberta-large')
2model = AutoModel.from_pretrained('AIDA-UPM/star')
3
4examples = ['My text 1', 'This is another text']
5
6def extract_embeddings(texts):
7 encoded_texts = tokenizer(texts)
8 with torch.no_grad():
9 style_embeddings = model(encoded_texts.input_ids,
10 attention_mask=encoded_texts.attention_mask).pooler_output
11 return style_embeddings
12
13print(extract_embeddings(examples))@article{Huertas-Tato2023Oct,
author = {Huertas-Tato, Javier and Martin, Alejandro and Camacho, David},
title = {{Understanding writing style in social media with a supervised contrastively pre-trained transformer}},
journal = {arXiv},
year = {2023},
month = oct,
eprint = {2310.11081},
doi = {10.48550/arXiv.2310.11081}
}