--- license: mit pipeline_tag: summarization datasets: - scientific_papers language: - en model-index: - name: MariamMounnir/Bart_SP results: - task: type: summarization name: Summarization metrics: - name: ROUGE-1 type: rouge value: 38.668300 verified: true - name: ROUGE-2 type: rouge value: 15.265900 verified: true - name: ROUGE-L type: rouge value: 24.395100 verified: true - name: ROUGE-LSUM type: rouge value: 33.791300 verified: true - name: loss type: loss value: 2.6066595224233775 verified: true - name: gen_len type: gen_len value: 121.772000 verified: true --- # BART (large-sized model), fine-tuned on scientific_papers BART Lecture Summarization is a model fine-tuned to summarize lectures, utilizing a dataset of scientific papers due to its similarity in content structure to lectures. The model employs a custom summarization function tailored specifically for lecture content. ## Intended uses & limitations The primary use case for the BART Lecture Summarization model is to condense lecture content into concise summaries. It is designed to assist students, educators, and researchers in extracting key information from lectures for study, reference, or review purposes. ### How to use Here is how to use this model: I added this function to avoid making the summarization too brief. ```python import numpy as np from transformers import BartForConditionalGeneration, BartTokenizer model = BartForConditionalGeneration.from_pretrained("MariamMounnir/Bart_SP") tokenizer = BartTokenizer.from_pretrained("MariamMounnir/Bart_SP") def summarize(text, maxSummarylength=500): # Encode the text and summarize inputs = tokenizer.encode("summarize: " + text, return_tensors="pt", max_length=1024, truncation=True) summary_ids = model.generate(inputs, max_length=maxSummarylength, min_length=int(maxSummarylength/5), length_penalty=10.0, num_beams=4, early_stopping=True) summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True) return summary def split_text_into_pieces(text, max_tokens=900, overlapPercent=10): # Tokenize the text tokens = tokenizer.tokenize(text) # Calculate the overlap in tokens overlap_tokens = int(max_tokens * overlapPercent / 100) # Split the tokens into chunks of size # max_tokens with overlap pieces = [tokens[i:i + max_tokens] for i in range(0, len(tokens), max_tokens - overlap_tokens)] # Convert the token pieces back into text text_pieces = [tokenizer.decode( tokenizer.convert_tokens_to_ids(piece), skip_special_tokens=True) for piece in pieces] return text_pieces def recursive_summarize(text, max_length=200): tokens = tokenizer.tokenize(text) expectedCountOfChunks = len(tokens)/max_length max_length=int(len(tokens)/expectedCountOfChunks)+2 # Break the text into pieces of max_length pieces = split_text_into_pieces(text, max_tokens=max_length) print("Number of pieces: ", len(pieces)) # Summarize each piece summaries=[] k=0 for k in range(0, len(pieces)): piece=pieces[k] print("****************************************************") print("Piece:",(k+1)," out of ", len(pieces), "pieces") print(piece, "\n") summary =summarize(piece, maxSummarylength=max_length/3*2) summaries.append(summary) print("SUMNMARY: ", summary) print("****************************************************") concatenated_summary = ' '.join(summaries) return concatenated_summary ARTICLE = """In this class, you learn about the state of the art and also practice implementing machine learning algorithms yourself. You learn about the most important machine learning algorithms, some of which are exactly what's being used in large AI or large tech companies today, and you get a sense of what is the state of the art in AI. Beyond learning the algorithms though, in this class, you also learn all the important practical tips and tricks for making them perform well, and you get to implement them and see how they work for yourself. So why is machine learning so widely used today? Machine learning had grown up as a subfield of AI or artificial intelligence. We wanted to build intelligent machines, and it turns out that there are a few big of things that we could program a machine to do, such as how to find the shortest path from A to B, like in your GPS. But for the most part, we just did not know how to write an explicit program to do many of the more interesting things, such as perform web search, recognize human speech, diagnose diseases from X-rays, or build a self-driving car. The only way we knew how to do these things was to have a machine learn to do it by itself. For me, when I found it and was leading the Google Brain team, I worked on problems like speech recognition, computer vision for Google Maps review images, and advertising. Or leading AI by two, I worked on everything from AI for augmented reality to combating payment forward to leading a self-driving car team. Most recently, at Lending AI, AI find an established university up and gain to work on AI applications and manufacturing, large-scale agriculture, healthcare e-commerce, and other problems. Today, there are hundreds of thousands, perhaps millions of people working on machine learning applications who could tell you still more stories about their work with machine learning. When you've learned these skills, I hope that you too will find it great fun to dabble in exciting different applications and maybe even different industries. In fact , I find it hard to think of any industry that machine learning is unlikely to touch in a significant way now and in the near future. I mean, even further into the future, many people, including me, are excited about the AI dream of someday building machines as intelligence as you or me. This is sometimes called artificial general intelligence or AI. I think AI has been over height and was still a long way away from that goal. I don't know if it'll take 50 years or 500 years or longer to get there, but most AI researchers believe that the best way to get closer to what that goal is by using learning algorithms, maybe once that takes some inspiration from how the human brain works. You also hear a little more about this quest for AGI later in this course. According to a study by McKinsey, AI and machine learning is estimated to create an additional 13 trillion US dollars of value annually by the year 2013. Even though machine learning is already creating tremendous amounts of value in the software industry, I think there could be even vastly greater value that is yet to be created outside the software industry, in sectors such as retail, travel, transportation, automotive, materials, manufacturing and so on. Because of the massive untouched opportunities across so many different sectors, today there is a vast, unfulfilled demand for this skill set. That's why this is such a great time to be learning about machine learning. If you find machine learning applications exciting, I hope you stick with me through this course. I can almost guarantee that you find mastering these skills worthwhile. In the next video, we'll look at a more formal definition of what is machine learning. And we'll begin to talk about the main types of machine learning problems and algorithms. You pick up some of the main machine learning terminology and start to get a sense of what are the different algorithms and when each one might be appropriate. So let's go on to the next video""" final_summary = recursive_summarize(ARTICLE) print("\n%%%%%%%%%%%%%%%%%%%%%\n") print("Final summary:", final_summary) >>>Final summary: machine learning is the state of the art in artificial intelligence. In this class, you learn about the most important machine learning algorithms and practical tips and tricks for implementing them. we just did not know how to write an explicit program to do many of the more interesting things, such as perform web search, recognize human speech, diagnose diseases from X-rays, or build a self-driving car. The only way we knew how to do these things was to have a machine learn to do it by itself. machine learning can be applied to a wide range of industries and applications. I find it hard to think of any industry that machine learning is unlikely to touch in a significant way now and in the near future. Many people, including me, are excited about the AI dream of someday building machines as intelligence as you or me. AI and machine learning is estimated to create an additional 13 trillion US dollars of value annually by the year 2013. Because of the massive untouched opportunities across so many different sectors, today there is a vast, unfulfilled demand for this skill set. machine learning is an important skill that can be taught in a number of ways. In the next video, we'll look at a more formal definition of what is machine learning. And we'll begin to talk about the main types of machine learning problems and algorithms