Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -14,8 +14,8 @@ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
14 |
|
15 |
@st.cache(allow_output_mutation=True)
|
16 |
def get_model():
|
17 |
-
tokenizer = AutoTokenizer.from_pretrained("BigSalmon/
|
18 |
-
model = AutoModelWithLMHead.from_pretrained("BigSalmon/
|
19 |
model.to(device)
|
20 |
return model, tokenizer
|
21 |
|
@@ -51,7 +51,7 @@ with st.form(key='my_form'):
|
|
51 |
logits, past_key_values = model(myinput, past_key_values = past_key_values, return_dict=False)
|
52 |
logits = logits[0,-1]
|
53 |
probabilities = torch.nn.functional.softmax(logits)
|
54 |
-
best_logits, best_indices = logits.topk(
|
55 |
best_words = [tokenizer.decode([idx.item()]) for idx in best_indices]
|
56 |
text.append(best_indices[0].item())
|
57 |
best_probabilities = probabilities[best_indices].tolist()
|
|
|
14 |
|
15 |
@st.cache(allow_output_mutation=True)
|
16 |
def get_model():
|
17 |
+
tokenizer = AutoTokenizer.from_pretrained("BigSalmon/InformalToFormalLincoln20")
|
18 |
+
model = AutoModelWithLMHead.from_pretrained("BigSalmon/InformalToFormalLincoln20")
|
19 |
model.to(device)
|
20 |
return model, tokenizer
|
21 |
|
|
|
51 |
logits, past_key_values = model(myinput, past_key_values = past_key_values, return_dict=False)
|
52 |
logits = logits[0,-1]
|
53 |
probabilities = torch.nn.functional.softmax(logits)
|
54 |
+
best_logits, best_indices = logits.topk(150)
|
55 |
best_words = [tokenizer.decode([idx.item()]) for idx in best_indices]
|
56 |
text.append(best_indices[0].item())
|
57 |
best_probabilities = probabilities[best_indices].tolist()
|