Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -37,15 +37,14 @@ def load_or_finetune_pegasus():
|
|
37 |
tokenizer = PegasusTokenizer.from_pretrained("google/pegasus-xsum")
|
38 |
model = PegasusForConditionalGeneration.from_pretrained("google/pegasus-xsum")
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
xsum = load_dataset("xsum", split="train[:5000]", trust_remote_code=True).rename_column("document", "text")
|
43 |
combined_dataset = concatenate_datasets([cnn_dm, xsum])
|
44 |
|
45 |
def preprocess_function(examples):
|
46 |
-
# Ensure texts and summaries are
|
47 |
-
texts =
|
48 |
-
summaries = [
|
49 |
|
50 |
# Tokenize inputs and targets
|
51 |
inputs = tokenizer(texts, max_length=512, truncation=True, padding="max_length", return_tensors="pt")
|
|
|
37 |
tokenizer = PegasusTokenizer.from_pretrained("google/pegasus-xsum")
|
38 |
model = PegasusForConditionalGeneration.from_pretrained("google/pegasus-xsum")
|
39 |
|
40 |
+
cnn_dm = load_dataset("cnn_dailymail", "3.0.0", split="train[:5000]")
|
41 |
+
xsum = load_dataset("xsum", split="train[:5000]", trust_remote_code=True)
|
|
|
42 |
combined_dataset = concatenate_datasets([cnn_dm, xsum])
|
43 |
|
44 |
def preprocess_function(examples):
|
45 |
+
# Ensure texts and summaries are lists of strings
|
46 |
+
texts = examples["article"] if "article" in examples else examples["document"]
|
47 |
+
summaries = examples["highlights"] if "highlights" in examples else examples["summary"]
|
48 |
|
49 |
# Tokenize inputs and targets
|
50 |
inputs = tokenizer(texts, max_length=512, truncation=True, padding="max_length", return_tensors="pt")
|