Views
No views yet
all-distillroberta-v1 as the base sentence encoder and was trained on the Scene split of DramaCV, a dataset consisting of drama plays collected from Project Gutenberg.1from transformers import AutoModel, AutoTokenizer
2tokenizer = AutoTokenizer.from_pretrained("gasmichel/UAR_scene")
3model = AutoModel.from_pretrained("gasmichel/UAR_scene")
4#`episodes` are embedded as colletions of documents presumed to come from an author
5# NOTE: make sure that `episode_length` consistent across `episode`
6batch_size = 3
7episode_length = 16
8text = [
9 ["Foo"] * episode_length,
10 ["Bar"] * episode_length,
11 ["Zoo"] * episode_length,
12]
13text = [j for i in text for j in i]
14tokenized_text = tokenizer(
15 text,
16 max_length=32,
17 padding="max_length",
18 truncation=True,
19 return_tensors="pt"
20)
21# inputs size: (batch_size, episode_length, max_token_length)
22tokenized_text["input_ids"] = tokenized_text["input_ids"].reshape(batch_size, episode_length, -1)
23tokenized_text["attention_mask"] = tokenized_text["attention_mask"].reshape(batch_size, episode_length, -1)
24print(tokenized_text["input_ids"].size()) # torch.Size([3, 16, 32])
25print(tokenized_text["attention_mask"].size()) # torch.Size([3, 16, 32])
26out = model(**tokenized_text)
27print(out.size()) # torch.Size([3, 512])
28# to get the Transformer attentions:
29out, attentions = model(**tokenized_text, output_attentions=True)
30print(attentions[0].size()) # torch.Size([48, 12, 32, 32])@inproceedings{michel-etal-2024-improving,
title = "Improving Quotation Attribution with Fictional Character Embeddings",
author = "Michel, Gaspard and
Epure, Elena V. and
Hennequin, Romain and
Cerisara, Christophe",
editor = "Al-Onaizan, Yaser and
Bansal, Mohit and
Chen, Yun-Nung",
booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2024",
month = nov,
year = "2024",
address = "Miami, Florida, USA",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2024.findings-emnlp.744",
doi = "10.18653/v1/2024.findings-emnlp.744",
pages = "12723--12735",,
}