File size: 570 Bytes
2d8e2b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
model_path = '/content/drive/My Drive/Bart_samsum'

from transformers import pipeline

# Load the tokenizer and model from the specified path
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForSeq2SeqLM.from_pretrained(model_path)

# Create a pipeline for text summarization
summarizer = pipeline("summarization", model=model, tokenizer=tokenizer)

# Example input for inference

# Perform inference
summary = summarizer(dialogue, max_length=500, min_length=300, do_sample=False)

# Print the summary
print("Summary:", summary[0]['summary_text'])