bistdude commited on
Commit
fbd5a07
1 Parent(s): 0765dda

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+ import torch
4
+
5
+ torch_device = "cuda" if torch.cuda.is_available() else "cpu"
6
+
7
+ #model_name = "gpt2"
8
+ model_name = "mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis"
9
+
10
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
11
+
12
+ model = AutoModelForCausalLM.from_pretrained(model_name, pad_token_id=tokenizer.eos_token_id).to(torch_device)
13
+
14
+ model_inputs = tokenizer('bad boy you ', return_tensors='pt').to(torch_device)
15
+
16
+ #output = model.generate(**model_inputs, max_new_tokens=50, do_sample=True, top_p=0.92, top_k=0, temperature=0.6)
17
+ output = model(**model_inputs).logits.argmax(axis=1)
18
+
19
+ print(tokenizer.decode(output[0],skip_special_tokens=True))