ayjays132 commited on
Commit
5395a29
1 Parent(s): ef4fad5

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +11 -9
README.md CHANGED
@@ -99,30 +99,31 @@ code::after {
99
  </div>
100
 
101
 
102
- <div class="code-container">
103
- <code>
 
104
  from transformers import BartTokenizer, BartForConditionalGeneration
105
  from datasets import load_dataset
106
 
107
- Load pre-trained BART model for summarization
108
  tokenizer = BartTokenizer.from_pretrained('ayjays132/EnhancerModel')
109
  model = BartForConditionalGeneration.from_pretrained('ayjays132/EnhancerModel')
110
 
111
- Load dataset
112
  dataset = load_dataset("cnn_dailymail", "3.0.0")
113
 
114
- Function to generate summary
115
  def summarize(text):
116
  inputs = tokenizer(text, return_tensors="pt", max_length=1024, truncation=True)
117
  summary_ids = model.generate(inputs['input_ids'], max_length=150, min_length=40, length_penalty=2.0, num_beams=4, early_stopping=True)
118
  return tokenizer.decode(summary_ids[0], skip_special_tokens=True)
119
 
120
- ebugging: Print the type and content of the first example
121
  print("Type of dataset['test']:", type(dataset['test']))
122
  print("Type of the first element in dataset['test']:", type(dataset['test'][0]))
123
  print("Content of the first element in dataset['test']:", dataset['test'][0])
124
 
125
- Test the model on a few examples
126
  for example in dataset['test'][:5]:
127
  try:
128
  # If the example is a string, then it's likely that 'dataset['test']' is not loaded as expected
@@ -139,5 +140,6 @@ for example in dataset['test'][:5]:
139
  print("No 'article' field found in this example.")
140
  except Exception as e:
141
  print(f"Error processing example: {e}")
142
- </code>
143
- </div>
 
 
99
  </div>
100
 
101
 
102
+ <body>
103
+ <div class="code-container">
104
+ <pre><code>
105
  from transformers import BartTokenizer, BartForConditionalGeneration
106
  from datasets import load_dataset
107
 
108
+ # Load pre-trained BART model for summarization
109
  tokenizer = BartTokenizer.from_pretrained('ayjays132/EnhancerModel')
110
  model = BartForConditionalGeneration.from_pretrained('ayjays132/EnhancerModel')
111
 
112
+ # Load dataset
113
  dataset = load_dataset("cnn_dailymail", "3.0.0")
114
 
115
+ # Function to generate summary
116
  def summarize(text):
117
  inputs = tokenizer(text, return_tensors="pt", max_length=1024, truncation=True)
118
  summary_ids = model.generate(inputs['input_ids'], max_length=150, min_length=40, length_penalty=2.0, num_beams=4, early_stopping=True)
119
  return tokenizer.decode(summary_ids[0], skip_special_tokens=True)
120
 
121
+ # Debugging: Print the type and content of the first example
122
  print("Type of dataset['test']:", type(dataset['test']))
123
  print("Type of the first element in dataset['test']:", type(dataset['test'][0]))
124
  print("Content of the first element in dataset['test']:", dataset['test'][0])
125
 
126
+ # Test the model on a few examples
127
  for example in dataset['test'][:5]:
128
  try:
129
  # If the example is a string, then it's likely that 'dataset['test']' is not loaded as expected
 
140
  print("No 'article' field found in this example.")
141
  except Exception as e:
142
  print(f"Error processing example: {e}")
143
+ </code></pre>
144
+ </div>
145
+ </body>