balhafni commited on
Commit
0dd12ec
1 Parent(s): a051749

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +65 -1
README.md CHANGED
@@ -2,4 +2,68 @@
2
  license: mit
3
  language:
4
  - en
5
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: mit
3
  language:
4
  - en
5
+ ---
6
+
7
+ # Personalized Text Generation with Fine-Grained Linguistic Control
8
+
9
+ ## Model Description
10
+
11
+
12
+ ## Usage
13
+
14
+ ```python
15
+ from transformers import AutoModelForCausalLM, AutoTokenizer
16
+
17
+ model = AutoModelForCausalLM.from_pretrained('balhafni/personalized-gen')
18
+ tokenizer = AutoTokenizer.from_pretrained('balhafni/personalized-gen')
19
+
20
+
21
+ ling_atts = {"ADJ": "5-8", "ADP": "10-11", "ADV": "6-8", "AUX": "9-11",
22
+ "CONJ": "2-4", "DET": "7-10", "FKGL": "5-6", "NOUN": "11-18",
23
+ "NUM": "2-3", "PART": "4-5", "PRON": "14-17", "PROPN": "8-11",
24
+ "PUNCT": "22-25", "ROOT": "9-10", "SCONJ": "3-4", "VERB": "16-20",
25
+ "acl": "0-1", "acomp": "1-2", "advcl": "2-3", "advmod": "7-9",
26
+ "amod": "3-6", "appos": "0-1", "attr": "1-2", "attribution": "2-3",
27
+ "aux": "6-7", "auxpass": "0-1", "case": "0-1", "cc": "2-4",
28
+ "ccomp": "3-4", "compound": "5-6", "conj": "2-4", "contrast": "0-1",
29
+ "det": "7-10", "dobj": "6-7", "domain": "blog", "elaboration": "10-12",
30
+ "mark": "2-3", "neg": "2-3", "nmod": "0-1", "npadvmod": "1-2",
31
+ "nsubj": "13-16", "nsubjpass": "0-1", "num_sents": "9-10",
32
+ "num_tokens": "118-139", "nummod": "1-2", "pcomp": "0-1", "pobj": "8-10",
33
+ "poss": "2-3", "prep": "9-10"
34
+ }
35
+
36
+ prompt = ("Today's lunch was a layered entree, consisting of, "
37
+ "shredded lettuce and popcorn chicken.")
38
+
39
+ inputs = [''.join([f'{k}:{v}' for k, v in ling_atts.items()]) + prompt]
40
+ inputs = tokenizer(inputs, return_tensors='pt')
41
+
42
+ preds = model.generate(**inputs,
43
+ max_length=1024,
44
+ pad_token_id=tokenizer.pad_token_id,
45
+ no_repeat_ngram_size=2
46
+ )
47
+
48
+ decoded_preds = tokenizer.batch_decode(preds[:, inputs['input_ids'].shape[1]:], skip_special_tokens=True)[0]
49
+ output = prompt + ' ' + decoded_preds.strip()
50
+ print(output)
51
+ ```
52
+
53
+
54
+ ## Citation
55
+
56
+ ```BibTeX
57
+ @inproceedings{alhafni-etal-2024-personalized,
58
+ title = "Personalized Text Generation with Fine-Grained Linguistic Control",
59
+ author = "Alhafni, Bashar and
60
+ Kulkarni, Vivek and
61
+ Kumar, Dhurv and
62
+ Raheja, Vipul",
63
+ month = march,
64
+ year = "2024",
65
+ address = "Malta",
66
+ publisher = "Association for Computational Linguistics",
67
+ abstract = "As the text generation capabilities of large language models become increasingly prominent, recent studies have focused on controlling particular aspects of the generated text to make it more personalized. However, most research on controllable text generation focuses on controlling the content or modeling specific high-level/coarse-grained attributes that reflect authors’ writing styles, such as formality, domain, or sentiment. In this paper, we focus on controlling fine-grained attributes spanning multiple linguistic dimensions, such as lexical and syntactic attributes. We introduce a novel benchmark to train generative models and evaluate their ability to generate personalized text based on multiple fine-grained linguistic attributes. We systematically investigate the performance of various large language models on our benchmark and draw insights from the factors that impact their performance. We make our code, data, and pretrained models publicly available.",
68
+ }
69
+ ```