Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -27,12 +27,15 @@ chat = [
|
|
27 |
# Vorbereitung des Eingabeformats
|
28 |
conversation_str = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=False)
|
29 |
|
30 |
-
# Tokenisierung der Eingabe
|
31 |
-
|
32 |
|
33 |
# Inferenz durchführen
|
34 |
with torch.no_grad():
|
35 |
-
outputs = model.generate(input_ids=input_ids,
|
|
|
|
|
|
|
36 |
|
37 |
# Ausgabe anzeigen
|
38 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
|
|
27 |
# Vorbereitung des Eingabeformats
|
28 |
conversation_str = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=False)
|
29 |
|
30 |
+
# Tokenisierung der Eingabe und Erzeugen der attention_mask
|
31 |
+
inputs = tokenizer(conversation_str, return_tensors="pt", padding=True, truncation=True)
|
32 |
|
33 |
# Inferenz durchführen
|
34 |
with torch.no_grad():
|
35 |
+
outputs = model.generate(input_ids=inputs["input_ids"].to(device),
|
36 |
+
attention_mask=inputs["attention_mask"].to(device),
|
37 |
+
max_length=256,
|
38 |
+
num_return_sequences=1)
|
39 |
|
40 |
# Ausgabe anzeigen
|
41 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|