Views
No views yet
git clone https://github.com/hieum98/Counterfactual-Augmentation-for-Robust-Authorship-Representation-Learning.git
cd Counterfactual-Augmentation-for-Robust-Authorship-Representation-Learning
pip install -r requirements.txt
pip install -e .1from ERLAS.model.erlas import ERLAS
2from transformers import AutoTokenizer
3
4model = ERLAS.from_pretrained('Hieuman/erlas')
5tokenizer = AutoTokenizer.from_pretrained('Hieuman/erlas')
6
7batch_size = 3
8episode_length = 16
9text = [
10 ["Foo"] * episode_length,
11 ["Bar"] * episode_length,
12 ["Zoo"] * episode_length,
13]
14text = [j for i in text for j in i]
15tokenized_text = tokenizer(
16 text,
17 max_length=32,
18 padding="max_length",
19 truncation=True,
20 return_tensors="pt"
21)
22# inputs size: (batch_size, episode_length, max_token_length)
23tokenized_text["input_ids"] = tokenized_text["input_ids"].reshape(batch_size, 1, episode_length, -1)
24tokenized_text["attention_mask"] = tokenized_text["attention_mask"].reshape(batch_size, 1, episode_length, -1)
25
26author_reps, _ = model(tokenized_text['input_ids'], tokenized_text['attention_mask'])
27
28author_reps = author_reps.squeeze(1) # [bs, hidden_size]1@inproceedings{10.1145/3626772.3657956,
2author = {Man, Hieu and Huu Nguyen, Thien},
3title = {Counterfactual Augmentation for Robust Authorship Representation Learning},
4year = {2024},
5isbn = {9798400704314},
6publisher = {Association for Computing Machinery},
7address = {New York, NY, USA},
8url = {https://doi.org/10.1145/3626772.3657956},
9doi = {10.1145/3626772.3657956},
10pages = {2347–2351},
11numpages = {5},
12keywords = {authorship attribution, counterfactual learning, domain generalization},
13location = {Washington DC, USA},
14series = {SIGIR '24}
15}