import gradio as gr import os from transformers import pipeline # hgsec = os.getenv("HF_token") # from huggingface_hub import login # login(token = hgsec) summarizer = pipeline("summarization", model="Sidharthkr/InstructTweetSummarizer")#, use_auth_token = hgsec)#, trust_remote_code=True) def summarymaker(instruction = "", tweets = ""): ARTICLE = f"""[INST] {instruction} [/INST] \\n [TWEETS] {tweets} [/TWEETS]""" print(ARTICLE) out = summarizer(ARTICLE, max_length=130, min_length=10, do_sample=False) out = out[0]['summary_text'].split("[SUMMARY]")[-1].split("[/")[0].split("[via")[0].strip() return out theme1 = gr.themes.Base(spacing_size=gr.themes.sizes.spacing_sm, radius_size=gr.themes.sizes.radius_none) # gr.themes.Default(primary_hue=gr.themes.colors.red, secondary_hue=gr.themes.colors.pink, # spacing_size=gr.themes.sizes.spacing_sm, radius_size=gr.themes.sizes.radius_none) #đŸ’Č with gr.Blocks(theme=theme1) as g: gr.Markdown(""" #

Instruct Tweet Summarizer ✔

Generate tweet summaries using instructions.

""" ) with gr.Column(variant = "panel"): with gr.Row(variant = "panel"): with gr.Column(variant = "panel"): instruction_points = gr.Text(lines=1, label="Instruction for tweet summarization.", placeholder="Summarize the tweets for Stellantis in 100 words") tweet_list = gr.Text(lines=5, label="List of tweets as a paragraph", placeholder="""Stellantis - arch critic of Chinese EVs coming to Europe - is in talks with CATL to build a European plant. \n\nIt has concluded that cutting the price of EVs by using Chinese LFP batteries is more important.\n\n@FT story: \nhttps://t.co/l7nGggRFxH. State-of-the-art North America Battery Technology Centre begins to take shape at Stellantis' Automotive Research and Development Centre (ARDC) in Windsor, Ontario.\n\nhttps://t.co/04RO7CL1O5. RT @UAW: đŸ§”After the historic Stand Up Strike, UAW members at Ford, General Motors and Stellantis have voted to ratify their new contracts,
. RT @atorsoli: Stellantis and CATL are set to supply lower-cost EV batteries together for Europe, signaling automaker's efforts to tighten t
. RT @atorsoli: Stellantis and CATL are set to supply lower-cost EV batteries together for Europe, signaling automaker's efforts to tighten""") with gr.Row(variant = "panel"): btn1 = gr.Button("Generate") gr.ClearButton([instruction_points, tweet_list]) summary_text = gr.Text(lines=4, label = "Summary") btn1.click(summarymaker, inputs=[instruction_points, tweet_list], outputs=[summary_text]) gr.Examples([["Summarize the tweets for Stellantis in 100 words", """Stellantis - arch critic of Chinese EVs coming to Europe - is in talks with CATL to build a European plant. \n\nIt has concluded that cutting the price of EVs by using Chinese LFP batteries is more important.\n\n@FT story: \nhttps://t.co/l7nGggRFxH. State-of-the-art North America Battery Technology Centre begins to take shape at Stellantis' Automotive Research and Development Centre (ARDC) in Windsor, Ontario.\n\nhttps://t.co/04RO7CL1O5. RT @UAW: đŸ§”After the historic Stand Up Strike, UAW members at Ford, General Motors and Stellantis have voted to ratify their new contracts,
. RT @atorsoli: Stellantis and CATL are set to supply lower-cost EV batteries together for Europe, signaling automaker's efforts to tighten t
. RT @atorsoli: Stellantis and CATL are set to supply lower-cost EV batteries together for Europe, signaling automaker's efforts to tighten"""], ["Summarize the tweets for Worldcoin in 50 words", """Hundreds signed up to get their eyeballs scanned for Sam Altman’s “Worldcoin” wallet, which ties your biometrics to an online, global wallet. Money talks and folks will sell their privacy. With critical mass, you can say hello to the dystopian future. https://t.co/DApA9q0GVf. see many falsely equating worldcoin w common uses of biometric data that have existed for decades. worldcoin wants to build a globally dominant for-profit, privately administered identity system, not give u fast access to ur iphone. it’s deeply political and deeply f’d up.. HERE WE GO FOLKS: Hundreds of youth voluntarily line-up to have their eyeballs scanned with a Worldcoin orb to get their new digital ID with “free money” Worldcoins in their new digital wallet. This is exactly how #CBDC will be rolled out globally
 https://t.co/whWgxdg7lm. btw, if you trust WorldCoin's data policies, i urge you to look at how OpenAI uses your data it is absolutely atrocious and they only recently added the ability to keep it from being retained after many started to ban it (but doing so requires opting out of features). We must consider the propriety of exchanging private information for cryptocurrency in light of Worldcoin's iris scanning for free tokens. Or it will become a data colonialism from the U.S. #World_Coin_Trap https://t.co/Gdh7niWvi5. I'm excited to interview @alexblania from Worldcoin at Mainnet 2023. (Also, interviewing Brian Armstrong, Paul Grewal, Jeremy Allaire, Caitlin Long, Brad Garlinghouse, and dozens of others across three days.) Just two months out!. It’s been 18 hours since I was Orb’d by Worldcoin. Nothing catastrophic has happened to me yet. I appreciate all the people who called to check and if I’m ok. I am. Just raw-dogging the blockchain ecosystem.. Worldcoin has 3,208 holders (yes, 3 thousand) and a $22.5 Billion fully diluted market cap. Where are those millions of users from the news claiming the airdrop and scanning their iris? https://t.co/zmMR889iFP. sam bankman fried is no longer with us, having passed away, but i can only imagine he is looking down from heaven with a smile on his face seeing how the worldcoin team worked this token launch.. Good read: The business savvy behind Sam Altman's digital ID project Worldcoin - Ledger Insights - blockchain for enterprise https://t.co/9GDBDTwpXX https://t.co/D1b7rLc3AU"""], ["Summarize the tweets for OpenAI Inc", """We saw the same vis-a-vis internet growth: exponential from when Sun adopted it in 1982, to 1996 when we started Juniper and saw internet traffic explode. That was the ChatGPT moment for the internet just like ChatGPT was that moment for AI, which had been predictably growing in
 https://t.co/1QQs7JFweK. ChatGPT has Never Seen a Single Word (Despite Reading All of The Internet). Glance at LLM Tokenizers. New Video! It's fascinating that the actual input to language models is not exactly the text we pass them! Learn more about tokenizers, a key component of LLMs. Link in reply https://t.co/rS5kqJmT2E. La carrera por dominar la inteligencia artificial en los consumidores empezĂł hace NADA y todos los grandes players ingresaron. No obstante mĂĄs allĂĄ de los esfuerzos #ChatGPT sigue a la cabeza del conocimiento general (37%) y igual proporciĂłn de quienes desconocen del tema (37%). https://t.co/6kmNuGV95a. 2023 https://t.co/5gjWmKLjC5 Sep 6-8 SF Bay Area CEO Mailchimp CEO Monday CEO Freshworks CEO Amplitude CEO JFrog CEO Workiva CRO Gong CMO Datadog CMO Databricks CRO OpenAI CMO CRO Miro CCO Asana And 12,000 more!! Grab 20% OFF here -> https://t.co/JCWlW4LzCj https://t.co/HEDRFxKBXp. With over 200k OpenAI credentials up for grabs on the dark web, cybercriminals can easily get their hands on other personal information like phone numbers, physical addresses & credit card numbers, Jumio's Philipp Pointner tells @SiliconANGLE. Read more: https://t.co/FDpZ2zt0me https://t.co/mRoV1x5On0. 🚀JUST LAUNCHED! Discover the power of AI with our new book, "Maximizing Productivity with ChatGPT." Ramp up your efficiency game! 🚀 💰Enjoy an early bird offer with a flat 20% OFF. Use code "20offearlybird" at checkout. Don't miss out! 👉 https://t.co/ml24jyTn3s https://t.co/LZjzOqw782. Chat w a friend working at OpenAI - working there must be fun, but what’s the financial upside? How do you 10x from 30B - by building AGI! - sure, but you don’t need to work at OAI to get exposure to that - true, we’ll all be post scarcity. But I’ll be more post scarcity than you. Oups. OpenAI admet ĂȘtre incapable de dĂ©tecter les textes Ă©crits par l’IA Les dĂ©tecteurs donnaient l’impression d’ĂȘtre trĂšs relativement fiables. OpenAI admet que mĂȘme l’éditeur de ChatGPT ne sait pas distinguer les textes de son IA de textes humains https://t.co/JQXE9L8lk1. Using #chatgpt plugins sounds appealing, of course. But by using them, you need to understand the massive risk - which includes giving these plugins access to company databases and a variety of other systems. These are early days, security researchers encourage exercise
. btw, if you trust WorldCoin's data policies, i urge you to look at how OpenAI uses your data it is absolutely atrocious and they only recently added the ability to keep it from being retained after many started to ban it (but doing so requires opting out of features)"""], ["Summarize the tweets for Netflix Inc in 100 words", """$META Reels revenue run rate up a casual 3.3x since last fall. The short-form video race feels so long ago now, but wasn't long ago when Facebook, IG, and YouTube were scrambling to compete. Even the likes of Netflix and Amazon experimented with similar feeds. https://t.co/6TOL4Jrfva. Finally finished Kohrra (Netflix). Thoroughly engrossing, with a fantastic cast. What made it truly interesting was that the script made us care for and try to understand the motivations of even the incidental characters, like Indira, constable Satnam, Rajji, among others.. The so called “ballerina dance” of the male Western Parotia is a carefully choreographed display performed for any female who chooses to perch on the branch above his well-maintained court [đŸ“č Netflix Our Planet: https://t.co/2RLYcCMBK6] https://t.co/1mgBwpvfEW. WOMAN OF THE DEAD (NETFLIX) An Austrian Netflix production in an amazing setting. A revenge thriller that whilst quirky (a real oddity thrown in) provides enough tension and action to make it an easy binge. 7.5/10 https://t.co/NXdDOIRDF8. I started watching "Top Secret UFO Projects: Declassified" on Netflix 👀 If it's true that Aliens are already on Earth, i wonder why they don't approach many people, maybe some are a bit afraid of humans. https://t.co/dlA84R8KZM. Apple, Amazon and Google are much larger 'FAANG' members, but year-over-year performance for Netflix and $META (nee Facebook) is significantly better - probably because of the deeper selloffs... https://t.co/g4HnPnhOv1. Newsom offers to mediate to help end crippling Hollywood strikes a day after Netflix advertised a $900,000 AI job as Colin Farrell is latest star to join the picket line https://t.co/k5UexyNfvd. Seventh Hulu CEO/GM since debut (Kilar, Forssell, Hopkins, Freer, Campbell, Earley, Tempest) Netflix only just made it's first CEO turnover https://t.co/mdnc8Jz44H. Seventh Hulu CEO/GM since debut (Kilar, Forssell, Hopkins, Freer, Campbell, Eary, Tempest) Netflix only just made it's first CEO turnover https://t.co/mdnc8Jz44H. I want this to be a @netflix series. A boy, his tractor, chicken, goat, goose and dog cross the bridge to..............[finish the story] https://t.co/FcF8hg5GB3"""], ["Summarize the tweets for #COP28 in 50 words", """The World Economic Forum's media advisory for #COP28 is comical. Few times so little has been said employing so many words. multistakeholder initiatives people at the heart holistic approach inter-dependence take stock on progress created momentum. ✅ As a pioneer in supporting companies and investors as they navigate the increasingly complex ESG landscape, @Nasdaq looks forward to participating in critical discussions on the green transition at #COP28 which begins in less than 10 days. 📍 From the crossroads of the
 https://t.co/jjjF0GhSFl https://t.co/EfITHwR3a7. With the colonial-capitalistic drivers of earth’s warming & acceleration of climate change will come more crossings of threshold of 2C-degree warming as we just saw, with greater climate injustices occurring globally. These need to be confronted at #COP28. https://t.co/K22ReCUHsS. There will be a barrage of announcements from #COP28 in Dubai. Comparing two agreements from 2021 offers a hint of what will be meaningful. My newsletter this week: https://t.co/Glk0DWstA0. I don't expect folks to stop posting wishful "shame on us" "what if" CO2 emission curves going back to 1990 ahead of COPS like #cop28. But I do hope those "liking" them look back at the state of the world then. Imagine how global development, largely built on a fossil fuel
 https://t.co/uHja4GQLCh https://t.co/IUM73dG70a. World facing ‘hellish’ 3C of climate heating @UN warns before Cop28 @dpcarrington The report found today’s carbon-cutting policies are so inadequate, 3C of heating will be reached this century Extinction looms, yet nothing is done #COP28 MUST deliver https://t.co/U32XAOOQ93. In a wave of #PowerUp actions across Asia leading up to the United Nations’ #COP28 in December, communities & civil society groups set in motion a story of collaborative empowerment, knowledge sharing, and celebration for a just, renewables-powered world we know is possible. https://t.co/jm1NIbK30s. @WMO Our leaders can still take bold action for climate justice at #COP28 and beyond. Together, we’ll make sure they do✊⁠ ⁠ Find out more about our #PowerUp global month of actions👇 https://t.co/uC1kFIUq0G. Before Ajay Banga became World Bank president, his predecessor suggested he 'wasn't a scientist' when asked about climate change. Even as Banga makes #climate a top priority, activists say it's not enough. @StevenMufson on the man in the middle #COP28 https://t.co/am7kaOjsQg. RT @jar_climate: France, Kenya + others set to launch coalition for global taxes to fund climate action at #COP28. The taskforce will cons
"""], ["Summarize the tweets for #Argentina", """“The changes our country needs are drastic. There is no room for gradualism.” Javier #Milei, newly-elected President of #Argentina, quoted in the @FT. Coming on the back of promises for radical economic and financial changes, Milei’s victory is a reminder of how desperate
 https://t.co/L5whw3cVfz https://t.co/BPnv6VQpUL. Whoa
 If he walks his talk (and isn’t assassinated), I might start investing in #Argentina again. But whatever happens, this is historic, with potential ramifications that could spread far beyond Argentina. https://t.co/yibWo3t8SR. Don’t cry for me #Argentina đŸ‡ŠđŸ‡· đŸ˜± https://t.co/v8oeuocxkY. #Argentina just elected a far right populist offering pie in the sky promises to complex economic problems as the president. I pray that #Srilanka would not elect a leftist populist charlatan offering equally farcical solutions and reverse whatever progress achieved so far.. RT @PrestonPysh: The IMF and World Bank right now... Congrats #Argentina! #Bitcoin https://t.co/Oi1n2z0y3Y"""]], inputs=[instruction_points, tweet_list])#, outputs = [lead_table, downit], fn=evaluate, cache_examples=True) g.queue(concurrency_count=1) g.launch(share=True)