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 #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 = [summary_text], fn=summarymaker, cache_examples=True) g.queue() g.launch(share=True)