Using the model with Transformer pipeline
#7
by
yungsinatra0
- opened
Hi everyone, has anyone been successful in using the model using the transformer
library's pipeline
?
Here's my code:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline(task="text2text-generation", model="allenai/PRIMERA-multinews")
# Combine selected texts in a long string
concatenated_report = ' '.join(chosen_texts)
# Remove newline or extra spaces
concatenated_report = ' '.join(concatenated_report.split())
print(concatenated_report)
# Use model
result = pipe(concatenated_report)
print(result)
I'm not sure what I'm doing wrong as I'm getting a very small summary that doesn't even properly summarizes one document. Here's an example of an output:
A senior Russian draft officer and former submarine commander accused by Ukraine of deadly strikes on its territory has been shot dead while jogging in the southern Russian city of Krasnodar. Stanislav Rzhitsky, 42, was killed on Monday by an unidentified gunman during a morning run in a park near the Olimp sports centre, local police said. Russian FSB security services said on Tuesday that a 64- year-old man was arrested on suspicion of carrying out the attack. At the time of his death, Rzhitsky was serving as the deputy head of the Krasnodar c ity administration’s mobilisation. According to the Russian daily newspaper Kommersant, Rzhitsky was previously the commander of the Krasnodar submarine, named after the city, in the Russian navy. The Ukrainian army said in a Telegram post on Tuesday that Rzhitsky was in command of a submarine that carried out a deadly missile attack on the Ukrainian city of Vinnytsi a in July 2022 , killing 23 civilians. Rzhitsky’s father told the Baza, a Russian Telegram channel with links to the security services, that his son left the military in December 2021, before Russia invaded Ukraine. Several close friends of Rzhitsky similar ly told the independent Russian station Dozdh that Rzhitsky left the army before the war started. Baza further reported that the killer could have tracked Rzhitsky’s runs on the Strava app, as he regularly followed the same 4- mile route while running. The Ukrainian defence ministry’s main directorate of intelligence, GUR, did not claim responsibility for Rzhitsky’s death. But in a cryptic message, GUR shared a series of details about the killing, including the time of the attack (6am) and the lack of witnes ses because of rain. “Due to heavy rain, the park was deserted, so there were no witnesses who could provide details or identify the attacker,” the GUR said. In a later statement, the agency’s chief, Kyrylo Budanov, rejected the claim that Ukrainian intelligence was behind the killing. “Statements by some media and politicians that the GUR has something to do with the death of Stanislav Rzhitsky have no basis,” Budanov said. Ukraine typically declines to claim responsibility for attacks on Russia or Russian- annexed Crimea, though Kyiv officials have frequently celebrated such attacks with cryptic or mocking remarks. US intelligence has previously said the Ukrainian government authorised last year’s car bomb attack that killed Darya Dugina , the daughter of the prominent Russian nationalist Alexander Dugin. The Britis h defence secretary, Ben Wallace, has suggested Ukraine needs to put more emphasis on thanking the west for its assistance after Volodymyr Zelenskiy’s complaints on Tuesday that his country had not been issued a firm timetable or set of conditions for joining Nato. “Whether we like it or not, people want to see a bit of gratitude,” Wallace said at a briefing in the margins of the Nato summit in the Lithuanian capital, Vilnius, when asked about the Ukrainian president’s comments that it was “absurd” for Kyiv to be told it would be welcome in the alliance but not given a date or exact conditions. “Sometimes you are asking countries to give up their own stocks [of weapons],” Wallace said. “Sometimes you have to persuade lawmakers on the [Capitol] Hill in America.” The US national security adviser, Jake Sullivan, told a public forum at the summit he believed “the American people do deserve a degree of gratitude from the United States government for their willingness to step up and from the rest of the world as well” . He said: “The United States of America has stepped up to provide an enormous amount of capacity to help ensure that Ukraine’s brave soldiers have the ammunition, air defence, the infantry, fighting vehicles, the mine clearing equipment and so much else to be able to effectively defend against Russia’s onslaught and to take territory back as well.” Zelenskiy, speaking in Vilnius on Wednesday, said it was “understandable that Ukraine cannot join Nato when at war” but it would have been ideal if there had been an invitation for Kyiv to join the alliance. He welcomed the results of the Nato summit, in particular the recognition that Ukraine did not need to follow a membership action plan, as well as the positive news on defence packages announced during the summit. Wallace revealed at the briefing that he had travelled to Ukraine last year to be presented with a shopping list of weapons. “You know, we’re not Amazon,” he said. “I told them that last year, when I drove 11 hours to be given a list.” But he said he understood Zelenskiy was speaking to his own public and that, despite his complaint on Tuesday, the final summit deal was a good one for Ukraine. There was an acceptance that “Ukraine belongs at Nato” and that amounted to an effective invitation for membership once t he conflict had died down. Britain, the US and global allies were due to unveil new security assurances for Ukraine on Wednesday. A declaration by the G7 industrialised countries “will set out how allies will support Ukraine over the coming years to end the war and deter and respond to any future attack”, a British government statement said. In practice, this would come as bilateral agreements with Kyiv on long- term military and financial aid to keep Ukraine’s army and economy running. A White House official said the US would start such talks with Kyiv soon. Russia, which says Nato’s eastward expansion is an existential threat to its own security, swiftly lashed out. Dmitry Medvedev, the deputy secretary of Russia’s powerful security council and an anti -western hawk, said increased military assistance to Ukraine from Nato was bringing a third world war a step closer. Musician Alex Yatsun’s house was shelled by Russian forces, but he has focused the trauma and apocalyptic feeling into atmospheric tracks that help him get ‘out of reality’ When the Russian invasion of Ukraine began in 2022, Alex Yatsun was living just 30km from the Russian border in the northernmost part of Kharkiv. “When I woke up that day I started living in a completely different reality,” he recalls. “There were bombs falling every hour.” - Yatsun’s family evacuated but he soon returned north to more dangerous territory to volunteer at a medical centre. “But my house was hit by shelling,” he recalls. A photograph on his Instagram shows the aftermath: huge chunks of wall blown out, smashed windows, a mangled front door. “That was the moment I decided to move closer to central Ukraine.” Despite the difficult and often harrowing backdrop of the last year, the 24- year-old has managed to produce a new 21- track compilation album as DJ Sacred, entitled Dungeon Rap: the Evolution . It’s a follow -up to 2019’s, Dungeon Rap: the Intr oduction . Dungeon rap is a new hybrid style of hip- hop created by Yatsun. It merges Memphis rap – a style of lo -fi atmospheric southern hip- hop made popular by the likes of Three Six Mafia in the late 80s and early 90s – and dungeon synth, a sub- genre that blossomed in 1990s Scandinavia blending dark ambient and black metal. Yatsun’s compilations feature a variety of his musical aliases, such as DJ Bishop, DJ Armok and Pillbox. While other artists also feature as guests, this approach allowed him a variety of musical personalities to explore while presenting the image of a more engaged and thriving scene around the infant genre. “I came to the conclusion it would be very difficult to develop a whole new genre of music only by using one name,” he says. “I thought I could reinvent the process by having these different approaches. DJ Armok is more reliant on bass and more heavily connected to Memphis rap, whereas Pillbox is more about the ethereal and transcendental – like a sublime melancholic feeling.” The res ult is moody and atmospheric stuff. Synths hum doomily, lo- fi beats crackle and snap, while sampled vocals are often slowed to a woozy drawl, blending in as texture rather than leading the charge. Yatsun became so obsessed with Memphis rap, and its “evil” sound, that he spent months breaking down hundreds of tracks, collecting their beats, vocals, melodies and synth lines. He’s assembled them in mega packs, containing thousands of samples, that can be used as the basis for other people to make their own mut ated twist on the genre. There is also a feeling of inescapable darkness to the music. Elements of dread hover like ominous clouds about to unleas h a storm – but the storm itself never comes. “The whole idea of this music is the end of times,” Yatsun says. “It corresponds to my life and my beliefs that the future is bleak.” Yatsun also cites the late theorist and music critic Mark Fisher, and his writings on hauntology, as being linked to the work. “It relates to the idea of a lost future,” he says. “Since the 2013 uprising, most of my life I’ve been living in a condition without stability or any clear vision of a future. I can’t predict my future be cause I don’t even believe in the idea of one, because right now it’s being cancelled. Through this music I have nostalgia for times I have never experienced. It’s completely out of reality – more like a fantasy.” Yatsun’s approach to creating a new genre out of thin air seemingly worked. There are now dungeon rap artists and labels popping up in other countries like Finland, Germany and the UK. Some of these new artists embracing the genre – like DJ Gravelord, Dominus Soul and Lord Crucifix – feature as gu ests on the latest compilation. Yatsun suggests that the themes of alienation and a sense of being trapped in a futureless existence are resonating. “It’s not something that is just localised in Ukraine,” he says. “It’s something we are all experiencing, especially the younger generation. It’s now much clearer that what we were promised, in terms of neoliberalism and a better life and future, has all started to decay. We are all feeling this.” There’s perhaps also an element of relating to a deeper darkness at the core of the music that is as universally personal as it is political. “If you look at my most popular tracks, most of them were written during very difficult times for me,” Yatsun says. “I often have strong, negative emotions in myself and I’m tryi ng to battle through them by making art. Hence why my music is pretty depressing sometimes.” However, what was pretty much an isolated incident of a teenager experimenting with different sounds to create a new hybrid genre has steadily bloomed into a conne cted network that now spans continents. “Dungeon rap is my brainchild,” he says. “The Introduction release was like looking at my child taking its first steps. For this one, it’s like looking at my child growing up and learning to speak.”
[{'generated_text': '– A senior Russian draft officer and former submarine commander accused by Ukraine of deadly strikes on its territory'}]
If I change the task
parameter in the pipeline()
call to "summarization"
, it gives me a slightly better result, but overall it's still quite bad and short. Can anyone help me as I've never really done anything like this before and I'm not sure how to do it properly? Thanks!