trichter commited on
Commit
4f4193a
·
verified ·
1 Parent(s): 9c38139

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +20 -1
README.md CHANGED
@@ -3,6 +3,7 @@ language:
3
  - en
4
  base_model:
5
  - google-t5/t5-large
 
6
  ---
7
  Model: t5-DistillingSbS-ABSA
8
 
@@ -39,4 +40,22 @@ Learning Rate: 1e-4
39
 
40
  Epochs: 5
41
 
42
- Max Sequence Length: 512
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  - en
4
  base_model:
5
  - google-t5/t5-large
6
+ library_name: transformers
7
  ---
8
  Model: t5-DistillingSbS-ABSA
9
 
 
40
 
41
  Epochs: 5
42
 
43
+ Max Sequence Length: 512
44
+
45
+ Example usage:
46
+
47
+ base_model_name = 't5-large'
48
+ tokenizer = T5Tokenizer.from_pretrained(base_model_name, model_max_length=512)
49
+ model = T5ForConditionalGeneration.from_pretrained('trichter/t5-DistillingSbS-ABSA')
50
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
51
+ model.to(device)
52
+ examples = {'appName': ['Google Chrome', 'Google Chrome'], 'review': ['This app is great, the speed is unmatched', 'Bad app, crashes constantly']}
53
+ model_inputs = tokenize_function(examples) # assuming example has the fields 'appName' and 'review'. tokenize_function is in the GitHub repo in data_utils.py.
54
+
55
+ outputs = generate(model, model_inputs, return_type = 'labels') # generate() is in the github repo and generates either labels or rationales depening on return_type. Default is 'labels' but can be changed to 'rationales'
56
+ tokenizer.decode(outputs[0], skip_special_tokens=True) # prints '"speed": "positive"'
57
+ tokenizer.decode(outputs[1], skip_special_tokens=True) # prints '"crashes": "negative"'
58
+
59
+ outputs = generate(model, model_inputs, return_type = 'rationales')
60
+ tokenizer.decode(outputs[0], skip_special_tokens=True) # prints '"speed": "the review explicitly mentions that the speed of the app is unmatched, indicating satisfaction with its performance in terms of speed."'
61
+ tokenizer.decode(outputs[1], skip_special_tokens=True) # prints '"crashes": "the app crashing constantly is explicitly mentioned as a major issue, indicating dissatisfaction with its stability."'