File size: 4,644 Bytes
1944439 0417d9a ab20b0f ef4fad5 e676861 ef4fad5 e676861 ab20b0f 0417d9a ab20b0f 0417d9a ab20b0f 5395a29 0417d9a 5395a29 0417d9a 5395a29 0417d9a 5395a29 0417d9a 5395a29 0417d9a 5395a29 0417d9a 5395a29 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
---
license: apache-2.0
library_name: transformers
---
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 0;
padding: 20px;
background-color: #f4f4f4;
}
.model-description {
background: #fff;
border-radius: 8px;
padding: 20px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
max-width: 800px;
margin: auto;
}
.model-description h2 {
margin-top: 0;
color: #333;
}
.model-description p {
margin: 0 0 10px;
color: #666;
}
body {
font-family: 'Arial', sans-serif;
line-height: 1.6;
margin: 0;
padding: 20px;
background-color: #f4f4f4;
}
.model-description {
background: #ffffff;
border-radius: 8px;
padding: 20px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
max-width: 800px;
margin: 20px auto;
}
.code-container {
background: #1e1e1e;
color: #dcdcdc;
border-radius: 8px;
padding: 20px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
max-width: 800px;
margin: 20px auto;
overflow-x: auto;
font-family: 'Courier New', Courier, monospace;
font-size: 16px;
line-height: 1.4;
}
code {
display: block;
white-space: pre-wrap;
word-break: break-word;
}
code::before {
content: " ";
display: block;
margin: 0 -20px;
padding: 10px;
background: #282c34;
border-radius: 8px 8px 0 0;
}
code::after {
content: " ";
display: block;
margin: 10px -20px;
padding: 10px;
background: #282c34;
border-radius: 0 0 8px 8px;
}
body {
font-family: 'Arial', sans-serif;
line-height: 1.6;
margin: 0;
padding: 20px;
background-color: #f4f4f4;
}
.code-container {
background: #1e1e1e;
color: #dcdcdc;
border-radius: 8px;
padding: 20px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
max-width: 800px;
margin: 20px auto;
overflow-x: auto;
font-family: 'Courier New', Courier, monospace;
font-size: 16px;
line-height: 1.4;
}
pre {
margin: 0;
}
code {
display: block;
white-space: pre-wrap;
word-break: break-word;
}
</style>
<body>
<div class="model-description">
<h2>Enhanced Model Features</h2>
<p><strong>Adaptability:</strong> Adjusts to diverse contexts and user needs, ensuring relevant and precise interactions.</p>
<p><strong>Contextual Intelligence:</strong> Provides contextually aware responses, improving engagement and interaction quality.</p>
<p><strong>Advanced Algorithms:</strong> Employs cutting-edge algorithms for sophisticated and intelligent responses.</p>
<p><strong>User Experience:</strong> Designed with a focus on seamless interaction, offering an intuitive and refined user experience.</p>
</div>
<body>
<div class="code-container">
<pre><code>
from transformers import BartTokenizer, BartForConditionalGeneration
from datasets import load_dataset
# Load pre-trained BART model for summarization
tokenizer = BartTokenizer.from_pretrained('ayjays132/EnhancerModel')
model = BartForConditionalGeneration.from_pretrained('ayjays132/EnhancerModel')
# Load dataset
dataset = load_dataset("cnn_dailymail", "3.0.0")
# Function to generate summary
def summarize(text):
inputs = tokenizer(text, return_tensors="pt", max_length=1024, truncation=True)
summary_ids = model.generate(inputs['input_ids'], max_length=150, min_length=40, length_penalty=2.0, num_beams=4, early_stopping=True)
return tokenizer.decode(summary_ids[0], skip_special_tokens=True)
# Debugging: Print the type and content of the first example
print("Type of dataset['test']:", type(dataset['test']))
print("Type of the first element in dataset['test']:", type(dataset['test'][0]))
print("Content of the first element in dataset['test']:", dataset['test'][0])
# Test the model on a few examples
for example in dataset['test'][:5]:
try:
# If the example is a string, then it's likely that 'dataset['test']' is not loaded as expected
if isinstance(example, str):
print(f"Article: {example}\n")
print(f"Summary: {summarize(example)}\n")
else:
# Access the 'article' field if the example is a dictionary
article = example.get('article', None)
if article:
print(f"Article: {article}\n")
print(f"Summary: {summarize(article)}\n")
else:
print("No 'article' field found in this example.")
except Exception as e:
print(f"Error processing example: {e}")
</code></pre>
</div>
</body> |