Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,13 @@
|
|
1 |
-
from transformers import
|
2 |
|
3 |
-
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
model = AutoModelForSequenceClassification.from_pretrained(MODEL_PATH)
|
8 |
-
pipeline = TextClassificationPipeline(model=model, tokenizer=tokenizer)
|
9 |
-
return pipeline
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
return result
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
result = classify_text(text)
|
19 |
-
print(result)
|
|
|
1 |
+
from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
2 |
|
3 |
+
MODEL_NAME = "gpt2" # Ändern Sie dies entsprechend
|
4 |
|
5 |
+
tokenizer = GPT2Tokenizer.from_pretrained(MODEL_NAME)
|
6 |
+
model = GPT2LMHeadModel.from_pretrained(MODEL_NAME)
|
|
|
|
|
|
|
7 |
|
8 |
+
prompt = "Was ist künstliche Intelligenz?" # Ändern Sie dies entsprechend
|
9 |
+
inputs = tokenizer.encode(prompt, return_tensors="pt")
|
10 |
+
outputs = model.generate(inputs, max_length=200, num_return_sequences=5)
|
|
|
11 |
|
12 |
+
for i, output in enumerate(outputs):
|
13 |
+
print(f"Output {i+1}: {tokenizer.decode(output)}")
|
|
|
|