Update README.md
Browse files
README.md
CHANGED
@@ -42,3 +42,24 @@ summary_ids = model.generate(inputs, max_length=150, min_length=50, length_penal
|
|
42 |
# Decode and print the summary
|
43 |
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
44 |
print(summary)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
# Decode and print the summary
|
43 |
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
44 |
print(summary)
|
45 |
+
|
46 |
+
|
47 |
+
# Example of a random article (can replace this with any article)
|
48 |
+
random_article = """
|
49 |
+
Artificial intelligence (AI) is intelligence demonstrated by machines, as opposed to the natural intelligence displayed by animals including humans.
|
50 |
+
Leading AI textbooks define the field as the study of "intelligent agents": any system that perceives its environment and takes actions that maximize its chance of achieving its goals.
|
51 |
+
Some popular accounts use the term "artificial intelligence" to describe machines that mimic "cognitive" functions that humans associate with the human mind, such as "learning" and "problem-solving".
|
52 |
+
As machines become increasingly capable, tasks considered to require "intelligence" are often removed from the definition of AI, a phenomenon known as the AI effect.
|
53 |
+
A quip in Tesler's Theorem says "AI is whatever hasn't been done yet.
|
54 |
+
"""
|
55 |
+
|
56 |
+
# Tokenize the input article
|
57 |
+
inputs = tokenizer.encode("summarize: " + random_article, return_tensors="pt", max_length=512, truncation=True)
|
58 |
+
|
59 |
+
# Generate summary
|
60 |
+
summary_ids = model.generate(inputs, max_length=150, min_length=100, length_penalty=3.0, num_beams=7, early_stopping=False)
|
61 |
+
|
62 |
+
# Decode and print the summary
|
63 |
+
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
64 |
+
print("Summary:")
|
65 |
+
print(summary)
|