Chirayu commited on
Commit
86731e8
1 Parent(s): 6a44b41

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +41 -0
README.md ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # What does this model do?
2
+ This model generates a subject line for the email, given the whole email as input. It is fine-tuned T5-Base
3
+
4
+ Here is how to use this model
5
+
6
+ ```python
7
+
8
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
9
+ import torch
10
+
11
+ model = AutoModelForSeq2SeqLM.from_pretrained("Chirayu/subject-generator-t5-base")
12
+ tokenizer = AutoTokenizer.from_pretrained("Chirayu/subject-generator-t5-base")
13
+ device = torch.device("cuda" if torch.cuda.is_available() else "CPU")
14
+ model = model.to(device)
15
+
16
+ def get_subject(content, num_beams=5,max_length=512, repetition_penalty=2.5, length_penalty=1, early_stopping=True,top_p=.95, top_k=50, num_return_sequences=3):
17
+
18
+ text = "title: " + content + " </s>"
19
+
20
+ input_ids = tokenizer.encode(
21
+ text, return_tensors="pt", add_special_tokens=True
22
+ )
23
+
24
+ input_ids = input_ids.to(device)
25
+ generated_ids = model.generate(
26
+ input_ids=input_ids,
27
+
28
+ num_beams=num_beams,
29
+ max_length=max_length,
30
+ repetition_penalty=repetition_penalty,
31
+ length_penalty=length_penalty,
32
+ early_stopping=early_stopping,
33
+ top_p=top_p,
34
+ top_k=top_k,
35
+ num_return_sequences=num_return_sequences,
36
+ )
37
+ subjects = [tokenizer.decode(generated_id,skip_special_tokens=True,clean_up_tokenization_spaces=True,) for generated_id in generated_ids]
38
+ return subjects
39
+ ```
40
+
41
+