AhmedSSabir
commited on
Commit
•
8f47b61
1
Parent(s):
86d638a
Update app.py
Browse files
app.py
CHANGED
@@ -44,16 +44,16 @@ def softmax(x):
|
|
44 |
|
45 |
# Load pre-trained model
|
46 |
|
47 |
-
model = GPT2LMHeadModel.from_pretrained('distilgpt2', output_hidden_states = True, output_attentions = True)
|
48 |
|
49 |
-
#model = gr.Interface.load('huggingface/distilgpt2', output_hidden_states = True, output_attentions = True)
|
50 |
|
51 |
-
#model.eval()
|
52 |
-
#tokenizer = gr.Interface.load('huggingface/distilgpt2')
|
53 |
|
54 |
-
#tokenizer = GPT2Tokenizer.from_pretrained('distilgpt2')
|
55 |
-
tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
|
56 |
-
#tokenizer = GPT2Tokenizer.from_pretrained('distilgpt2')
|
57 |
|
58 |
tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
|
59 |
model = GPT2LMHeadModel.from_pretrained('gpt2')
|
@@ -120,6 +120,7 @@ def sentence_prob_mean(text):
|
|
120 |
# Compute the mean probability across the tokens
|
121 |
mean_prob = torch.mean(gathered_probs).item()
|
122 |
|
|
|
123 |
|
124 |
|
125 |
|
|
|
44 |
|
45 |
# Load pre-trained model
|
46 |
|
47 |
+
# model = GPT2LMHeadModel.from_pretrained('distilgpt2', output_hidden_states = True, output_attentions = True)
|
48 |
|
49 |
+
# #model = gr.Interface.load('huggingface/distilgpt2', output_hidden_states = True, output_attentions = True)
|
50 |
|
51 |
+
# #model.eval()
|
52 |
+
# #tokenizer = gr.Interface.load('huggingface/distilgpt2')
|
53 |
|
54 |
+
# #tokenizer = GPT2Tokenizer.from_pretrained('distilgpt2')
|
55 |
+
# tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
|
56 |
+
# #tokenizer = GPT2Tokenizer.from_pretrained('distilgpt2')
|
57 |
|
58 |
tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
|
59 |
model = GPT2LMHeadModel.from_pretrained('gpt2')
|
|
|
120 |
# Compute the mean probability across the tokens
|
121 |
mean_prob = torch.mean(gathered_probs).item()
|
122 |
|
123 |
+
return mean_prob
|
124 |
|
125 |
|
126 |
|