Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -76,6 +76,7 @@ def predict(text,
|
|
76 |
#hier soll das NN ja auch nicht geändert werden 8backprop ist nicht nötig), da es um interference-prompts geht!
|
77 |
print("toch.no_grad")
|
78 |
with torch.no_grad():
|
|
|
79 |
#die vergangenen prompts werden alle als Tupel in history abgelegt sortiert nach 'Human' und 'AI'- dass sind daher auch die stop-words, die den jeweils nächsten Eintrag kennzeichnen
|
80 |
for x in greedy_search(input_ids,model,tokenizer,stop_words=["[|Human|]", "[|AI|]"],max_length=max_length_tokens,temperature=temperature,top_p=top_p):
|
81 |
if is_stop_word_or_prefix(x,["[|Human|]", "[|AI|]"]) is False:
|
@@ -83,15 +84,16 @@ def predict(text,
|
|
83 |
x = x[:x.index("[|Human|]")].strip()
|
84 |
if "[|AI|]" in x:
|
85 |
x = x[:x.index("[|AI|]")].strip()
|
86 |
-
x = x.strip()
|
87 |
-
|
|
|
88 |
print("Erzeuge")
|
89 |
-
return
|
90 |
if shared_state.interrupted:
|
91 |
shared_state.recover()
|
92 |
try:
|
93 |
print("Erfolg")
|
94 |
-
return
|
95 |
except:
|
96 |
pass
|
97 |
del input_ids
|
|
|
76 |
#hier soll das NN ja auch nicht geändert werden 8backprop ist nicht nötig), da es um interference-prompts geht!
|
77 |
print("toch.no_grad")
|
78 |
with torch.no_grad():
|
79 |
+
ausgabe = ""
|
80 |
#die vergangenen prompts werden alle als Tupel in history abgelegt sortiert nach 'Human' und 'AI'- dass sind daher auch die stop-words, die den jeweils nächsten Eintrag kennzeichnen
|
81 |
for x in greedy_search(input_ids,model,tokenizer,stop_words=["[|Human|]", "[|AI|]"],max_length=max_length_tokens,temperature=temperature,top_p=top_p):
|
82 |
if is_stop_word_or_prefix(x,["[|Human|]", "[|AI|]"]) is False:
|
|
|
84 |
x = x[:x.index("[|Human|]")].strip()
|
85 |
if "[|AI|]" in x:
|
86 |
x = x[:x.index("[|AI|]")].strip()
|
87 |
+
x = x.strip()
|
88 |
+
ausgabe = ausgabe + x
|
89 |
+
# a, b= [[y[0],convert_to_markdown(y[1])] for y in history]+[[text, convert_to_markdown(x)]],history + [[text,x]]
|
90 |
print("Erzeuge")
|
91 |
+
return ausgabe
|
92 |
if shared_state.interrupted:
|
93 |
shared_state.recover()
|
94 |
try:
|
95 |
print("Erfolg")
|
96 |
+
return ausgabe
|
97 |
except:
|
98 |
pass
|
99 |
del input_ids
|