Update README.md
Browse files
README.md
CHANGED
|
@@ -712,9 +712,6 @@ code {
|
|
| 712 |
}
|
| 713 |
</style>
|
| 714 |
<body>
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
|
| 718 |
<div class="section">
|
| 719 |
<div class="section-header">
|
| 720 |
<div class="model-description">
|
|
@@ -725,52 +722,4 @@ code {
|
|
| 725 |
<p><strong>User Experience:</strong> Designed with a focus on seamless interaction, offering an intuitive and refined user experience.</p>
|
| 726 |
</div>
|
| 727 |
</div>
|
| 728 |
-
|
| 729 |
-
|
| 730 |
-
<body>
|
| 731 |
-
<div class="section">
|
| 732 |
-
<div class="section-header">
|
| 733 |
-
<div class="model-description">
|
| 734 |
-
<div class="code-container">
|
| 735 |
-
<pre><code>
|
| 736 |
-
from transformers import BartTokenizer, BartForConditionalGeneration
|
| 737 |
-
from datasets import load_dataset
|
| 738 |
-
|
| 739 |
-
# Load pre-trained BART model for summarization
|
| 740 |
-
tokenizer = BartTokenizer.from_pretrained('ayjays132/EnhancerModel')
|
| 741 |
-
model = BartForConditionalGeneration.from_pretrained('ayjays132/EnhancerModel')
|
| 742 |
-
|
| 743 |
-
# Load dataset
|
| 744 |
-
dataset = load_dataset("cnn_dailymail", "3.0.0")
|
| 745 |
-
|
| 746 |
-
# Function to generate summary
|
| 747 |
-
def summarize(text):
|
| 748 |
-
inputs = tokenizer(text, return_tensors="pt", max_length=1024, truncation=True)
|
| 749 |
-
summary_ids = model.generate(inputs['input_ids'], max_length=150, min_length=40, length_penalty=2.0, num_beams=4, early_stopping=True)
|
| 750 |
-
return tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
| 751 |
-
|
| 752 |
-
# Debugging: Print the type and content of the first example
|
| 753 |
-
print("Type of dataset['test']:", type(dataset['test']))
|
| 754 |
-
print("Type of the first element in dataset['test']:", type(dataset['test'][0]))
|
| 755 |
-
print("Content of the first element in dataset['test']:", dataset['test'][0])
|
| 756 |
-
|
| 757 |
-
# Test the model on a few examples
|
| 758 |
-
for example in dataset['test'][:5]:
|
| 759 |
-
try:
|
| 760 |
-
# If the example is a string, then it's likely that 'dataset['test']' is not loaded as expected
|
| 761 |
-
if isinstance(example, str):
|
| 762 |
-
print(f"Article: {example}\n")
|
| 763 |
-
print(f"Summary: {summarize(example)}\n")
|
| 764 |
-
else:
|
| 765 |
-
# Access the 'article' field if the example is a dictionary
|
| 766 |
-
article = example.get('article', None)
|
| 767 |
-
if article:
|
| 768 |
-
print(f"Article: {article}\n")
|
| 769 |
-
print(f"Summary: {summarize(article)}\n")
|
| 770 |
-
else:
|
| 771 |
-
print("No 'article' field found in this example.")
|
| 772 |
-
except Exception as e:
|
| 773 |
-
print(f"Error processing example: {e}")
|
| 774 |
-
</code></pre>
|
| 775 |
-
</div>
|
| 776 |
</body>
|
|
|
|
| 712 |
}
|
| 713 |
</style>
|
| 714 |
<body>
|
|
|
|
|
|
|
|
|
|
| 715 |
<div class="section">
|
| 716 |
<div class="section-header">
|
| 717 |
<div class="model-description">
|
|
|
|
| 722 |
<p><strong>User Experience:</strong> Designed with a focus on seamless interaction, offering an intuitive and refined user experience.</p>
|
| 723 |
</div>
|
| 724 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 725 |
</body>
|