EmreYY20 commited on
Commit
5cd73f5
·
1 Parent(s): a5dca46
Files changed (1) hide show
  1. abstractive_model.py +4 -3
abstractive_model.py CHANGED
@@ -1,10 +1,11 @@
1
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
 
3
- tokenizer = AutoTokenizer.from_pretrained("EE21/Fine-tuned-BART-ToS-Summarization")
4
- model = AutoModelForSeq2SeqLM.from_pretrained("EE21/Fine-tuned-BART-ToS-Summarization")
 
5
 
6
  def summarize_with_bart(input_text):
7
  inputs = tokenizer.encode("summarize: " + input_text, return_tensors="pt", max_length=1024, truncation=True)
8
  summary_ids = model.generate(inputs, max_length=150, min_length=40, length_penalty=2.0, num_beams=4, early_stopping=True)
9
  summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
10
- return summary
 
1
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
 
3
+ model_name = "EE21/BART-ToS-Summarization" # Replace with the actual path to your model
4
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
5
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
6
 
7
  def summarize_with_bart(input_text):
8
  inputs = tokenizer.encode("summarize: " + input_text, return_tensors="pt", max_length=1024, truncation=True)
9
  summary_ids = model.generate(inputs, max_length=150, min_length=40, length_penalty=2.0, num_beams=4, early_stopping=True)
10
  summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
11
+ return summary