Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,7 +37,8 @@ informal english:''')
|
|
| 37 |
@st.cache(allow_output_mutation=True)
|
| 38 |
def get_model():
|
| 39 |
tokenizer = AutoTokenizer.from_pretrained("gpt2")
|
| 40 |
-
model = AutoModelWithLMHead.from_pretrained("BigSalmon/MrLincoln12")
|
|
|
|
| 41 |
return model, tokenizer
|
| 42 |
|
| 43 |
model, tokenizer = get_model()
|
|
@@ -55,7 +56,7 @@ with st.form(key='my_form'):
|
|
| 55 |
logits, past_key_values = model(myinput, past_key_values = past_key_values, return_dict=False)
|
| 56 |
logits = logits[0,-1]
|
| 57 |
probabilities = torch.nn.functional.softmax(logits)
|
| 58 |
-
best_logits, best_indices = logits.topk(
|
| 59 |
best_words = [tokenizer.decode([idx.item()]) for idx in best_indices]
|
| 60 |
text.append(best_indices[0].item())
|
| 61 |
best_probabilities = probabilities[best_indices].tolist()
|
|
|
|
| 37 |
@st.cache(allow_output_mutation=True)
|
| 38 |
def get_model():
|
| 39 |
tokenizer = AutoTokenizer.from_pretrained("gpt2")
|
| 40 |
+
#model = AutoModelWithLMHead.from_pretrained("BigSalmon/MrLincoln12")
|
| 41 |
+
model = AutoModelWithLMHead.from_pretrained("BigSalmon/MrLincoln125MNeo")
|
| 42 |
return model, tokenizer
|
| 43 |
|
| 44 |
model, tokenizer = get_model()
|
|
|
|
| 56 |
logits, past_key_values = model(myinput, past_key_values = past_key_values, return_dict=False)
|
| 57 |
logits = logits[0,-1]
|
| 58 |
probabilities = torch.nn.functional.softmax(logits)
|
| 59 |
+
best_logits, best_indices = logits.topk(100)
|
| 60 |
best_words = [tokenizer.decode([idx.item()]) for idx in best_indices]
|
| 61 |
text.append(best_indices[0].item())
|
| 62 |
best_probabilities = probabilities[best_indices].tolist()
|