Updates in IR+QA example
Signed-off-by: Vlad Getselevich <vgetselevich@nvidia.com>
This commit is contained in:
parent
c1afd235c8
commit
dab33d8a17
|
@ -15,14 +15,8 @@
|
|||
from lfqa_utils import *
|
||||
|
||||
|
||||
def full_test():
|
||||
# eli5 = nlp.load_dataset('eli5')
|
||||
# wiki40b_snippets = nlp.load_dataset('wiki_snippets', name='wiki40b_en_100_0')['train']
|
||||
|
||||
marvel_snippets = load_data("/home/vgetselevich/data/marvel/wiki/", 100)
|
||||
|
||||
# print(eli5['test_eli5'][12345])
|
||||
# print(wiki40b_snippets[8991855])
|
||||
def full_test(directory, proj_name, questions, ir_results=5, use_eqa=True):
|
||||
content_snippets = load_data(directory, 100)
|
||||
|
||||
# load models
|
||||
# dense IR model
|
||||
|
@ -31,30 +25,30 @@ def full_test():
|
|||
_ = qar_model.eval()
|
||||
|
||||
# prepare IR index
|
||||
if not os.path.isfile('marvel_passages_reps_32_l-8_h-768_b-512-512.dat'):
|
||||
if not os.path.isfile(f'{proj_name}_passages_reps_32_l-8_h-768_b-512-512.dat'):
|
||||
print("*** Generating dense index ***")
|
||||
make_qa_dense_index_text_chunks(
|
||||
qar_model,
|
||||
qar_tokenizer,
|
||||
# wiki40b_snippets,
|
||||
marvel_snippets,
|
||||
content_snippets,
|
||||
device='cuda:0',
|
||||
index_name='marvel_passages_reps_32_l-8_h-768_b-512-512.dat',
|
||||
index_name=f'{proj_name}_passages_reps_32_l-8_h-768_b-512-512.dat',
|
||||
)
|
||||
|
||||
# load index to memory
|
||||
faiss_res = faiss.StandardGpuResources()
|
||||
marvel_passage_reps = np.memmap(
|
||||
'marvel_passages_reps_32_l-8_h-768_b-512-512.dat',
|
||||
content_passage_reps = np.memmap(
|
||||
f'{proj_name}_passages_reps_32_l-8_h-768_b-512-512.dat',
|
||||
dtype='float32',
|
||||
mode='r',
|
||||
# shape=(wiki40b_snippets.num_rows, 128),
|
||||
shape=(len(marvel_snippets), 128),
|
||||
shape=(len(content_snippets), 128),
|
||||
)
|
||||
|
||||
marvel_index_flat = faiss.IndexFlatIP(128)
|
||||
marvel_gpu_index = faiss.index_cpu_to_gpu(faiss_res, 1, marvel_index_flat)
|
||||
marvel_gpu_index.add(marvel_passage_reps)
|
||||
content_index_flat = faiss.IndexFlatIP(128)
|
||||
content_gpu_index = faiss.index_cpu_to_gpu(faiss_res, 1, content_index_flat)
|
||||
content_gpu_index.add(content_passage_reps)
|
||||
|
||||
# generative model
|
||||
qa_s2s_tokenizer = AutoTokenizer.from_pretrained('yjernite/bart_eli5')
|
||||
|
@ -62,17 +56,12 @@ def full_test():
|
|||
_ = qa_s2s_model.eval()
|
||||
|
||||
# run examples
|
||||
questions = [
|
||||
"who is iron man?",
|
||||
"who is Tony Stark?",
|
||||
"who directed iron man?",
|
||||
]
|
||||
answers = []
|
||||
|
||||
for question in questions:
|
||||
# create support document with the dense index
|
||||
doc, res_list = query_qa_dense_index(
|
||||
question, qar_model, qar_tokenizer, marvel_snippets, marvel_gpu_index, n_results=5, device='cuda:0'
|
||||
question, qar_model, qar_tokenizer, content_snippets, content_gpu_index, n_results=ir_results, device='cuda:0'
|
||||
)
|
||||
# concatenate question and support document into BART input
|
||||
question_doc = "question: {} context: {}".format(question, doc)
|
||||
|
@ -91,9 +80,11 @@ def full_test():
|
|||
|
||||
print(question)
|
||||
print("Generative Answer: " + gen_answer)
|
||||
print("Context: " + doc.replace("<P> ", ""))
|
||||
ex_answer_span, ex_answer_sent = extractive_qa(question, doc.replace("<P> ", ""))
|
||||
print("Extractive Answer: " + ex_answer_span + " - " + ex_answer_sent)
|
||||
# print("Context: " + doc.replace("<P> ", ""))
|
||||
|
||||
if use_eqa:
|
||||
ex_answer_span, ex_answer_context = extractive_qa(question, doc.replace("<P> ", ""))
|
||||
print("Extractive Answer: " + ex_answer_span)
|
||||
|
||||
|
||||
def short_test():
|
||||
|
@ -151,48 +142,19 @@ def short_test():
|
|||
print(answers)
|
||||
|
||||
|
||||
def extractive_qa(question, context):
|
||||
'''
|
||||
Uses Extractive QA server.
|
||||
Input: question and context
|
||||
Response: short span with the answer and full sentence that contains this span or 'Not found'
|
||||
'''
|
||||
url = "http://35.193.226.52:9000/longformqa"
|
||||
payload = (
|
||||
f'{{\r\n"question": "{question}",\r\n\"context\": "{context}",\r\n'
|
||||
f'"maxLength": 128,\r\n"minLength": 1,\r\n "numBeams": 8\r\n}}'
|
||||
)
|
||||
headers = {
|
||||
'Content-Type': "application/json",
|
||||
'User-Agent': "PostmanRuntime/7.18.0",
|
||||
'Accept': "*/*",
|
||||
'Cache-Control': "no-cache",
|
||||
'Postman-Token': "30549445-ea95-416a-bd74-8ab14ad2036d,0dd97345-55e6-4517-970c-f7032bd1a0d3",
|
||||
'Host': "35.193.226.52:9000",
|
||||
'Accept-Encoding': "gzip, deflate",
|
||||
'Content-Length': "1513",
|
||||
'Connection': "keep-alive",
|
||||
'cache-control': "no-cache",
|
||||
}
|
||||
|
||||
print(payload)
|
||||
response = requests.request("POST", url, data=payload, headers=headers)
|
||||
if response.ok == True:
|
||||
print(response.text)
|
||||
response_dict = json.loads(response.text)
|
||||
return (response_dict['result_eqa'], response_dict['context'])
|
||||
else:
|
||||
print("Answer not found in the context")
|
||||
return ('Not found', 'Not found')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# load_data("/home/vgetselevich/data/marvel/wiki/", 100)
|
||||
# short_test()
|
||||
full_test()
|
||||
questions = [
|
||||
"what is minecraft?",
|
||||
"who created minecraft game?",
|
||||
"which modes minecraft game has?",
|
||||
]
|
||||
|
||||
# question = "Who were the survivors of Titan?"
|
||||
question = "Who is Vlad?"
|
||||
# load_data("/home/vgetselevich/data/minecraft/", 100)
|
||||
# short_test()
|
||||
full_test("/home/vgetselevich/data/minecraft/", "minecraft", questions, ir_results=1, use_eqa=True)
|
||||
|
||||
'''
|
||||
question = "Who is Stark?"
|
||||
context = (
|
||||
"Anthony Edward Stark is a fictional character portrayed by Robert Downey Jr in the Marvel Cinematic "
|
||||
"Universe (MCU) film franchise based on the Marvel Comics character of the same name commonly known "
|
||||
|
@ -209,4 +171,9 @@ if __name__ == '__main__':
|
|||
"and his armies, who traveled through time to collect the Infinity Stones, saving the universe "
|
||||
"from decimation, and leaving behind a legacy as one of Earth's most revered superheroes."
|
||||
)
|
||||
# extractive_qa(question, context)
|
||||
answer_span, context = extractive_qa(question, context)
|
||||
print(answer_span)
|
||||
|
||||
full_answer, content = answer_extender(question, answer_span)
|
||||
print(full_answer)
|
||||
'''
|
||||
|
|
113
examples/nlp/conditional_generation/data/iron_man/iron_man_1.txt
Normal file
113
examples/nlp/conditional_generation/data/iron_man/iron_man_1.txt
Normal file
|
@ -0,0 +1,113 @@
|
|||
Iron Man is a 2008 American superhero film based on the Marvel Comics character of the same name. Produced by Marvel Studios and distributed
|
||||
by Paramount Pictures. It is the first film in the Marvel Cinematic Universe. It was directed by Jon Favreau from a screenplay
|
||||
by the writing teams of Mark Fergus and Hawk Ostby, and Art Marcum and Matt Holloway, and stars Robert Downey Jr. as Tony Stark / Iron Man
|
||||
alongside Terrence Howard, Jeff Bridges, Shaun Toub, and Gwyneth Paltrow. In the film, following his escape from captivity by a terrorist group,
|
||||
world famous industrialist and master engineer Tony Stark builds a mechanized suit of armor and becomes the superhero Iron Man.
|
||||
|
||||
A film featuring the character was in development at Universal Pictures, 20th Century Fox, and New Line Cinema at various times since 1990,
|
||||
before Marvel Studios reacquired the rights in 2006. Marvel put the project in production as its first self-financed film,
|
||||
with Paramount Pictures distributing. Favreau signed on as director in April 2006, and faced opposition from Marvel when trying
|
||||
to cast Downey in the title role; the actor was signed in September. Filming took place from March to June 2007, primarily in California
|
||||
to differentiate the film from numerous other superhero stories that are set in New York City-esque environments.
|
||||
During filming, the actors were free to create their own dialogue because pre-production was focused on the story and action.
|
||||
Rubber and metal versions of the armor, created by Stan Winston's company, were mixed with computer-generated imagery to create the title character.
|
||||
|
||||
Iron Man premiered in Sydney on April 14, 2008, and was released in the United States on May 2, as the first film in Phase One of the MCU.
|
||||
It grossed over $585 million on its $140 million budget, becoming the eighth-highest grossing film of 2008.
|
||||
The film was praised by critics for its acting (particularly Downey's), screenplay, direction, visual effects, and action sequences.
|
||||
It was selected by the American Film Institute as one of the ten best films of 2008 and received two nominations at the 81st Academy Awards
|
||||
for Best Sound Editing and Best Visual Effects. It was followed by two sequels, Iron Man 2 in 2010 and Iron Man 3 in 2013.
|
||||
|
||||
Plot
|
||||
Tony Stark, who has inherited the defense contractor Stark Industries from his father Howard Stark, is in war-torn Afghanistan with his friend
|
||||
and military liaison, Lieutenant Colonel James Rhodes, to demonstrate the new "Jericho" missile.
|
||||
After the demonstration, the convoy is ambushed and Stark is critically wounded by a missile used by the attackers: one of his company's own.
|
||||
He is captured and imprisoned in a cave by a terrorist group called the Ten Rings. Yinsen, a fellow captive doctor, implants an electromagnet
|
||||
into Stark's chest to keep the shrapnel shards that wounded him from reaching his heart and killing him. Ten Rings leader Raza offers Stark
|
||||
freedom in exchange for building a Jericho missile for the group, but he and Yinsen know that Raza will not keep his word.
|
||||
|
||||
Stark and Yinsen secretly build a small, powerful electric generator called an arc reactor to power Stark's electromagnet and a prototype suit
|
||||
of powered armor to aid in their escape. Although they keep the suit hidden almost to completion, the Ten Rings discover their hostages'
|
||||
intentions and attack the workshop. Yinsen sacrifices himself to divert them while the suit fully charges. The armored Stark battles his way
|
||||
out of the cave to find the dying Yinsen, then burns the Ten Rings' weapons in anger and flies away, crashing in the desert and destroying the suit.
|
||||
After being rescued by Rhodes, Stark returns home and announces that his company will cease manufacturing weapons. Obadiah Stane,
|
||||
his father's old partner and the company's manager, advises Stark that this may ruin Stark Industries and his father's legacy.
|
||||
In his home workshop, Stark builds a sleeker, more powerful version of his improvised armor suit as well as a more powerful arc reactor for it
|
||||
and his chest. Personal assistant Pepper Potts places the original reactor inside a small glass showcase. Though Stane requests details,
|
||||
a suspicious Stark decides to keep his work to himself.
|
||||
|
||||
At a charity event held by Stark Industries, reporter Christine Everhart informs Stark that his company's weapons were recently delivered
|
||||
to the Ten Rings and are being used to attack Yinsen's home village, Gulmira. Stark dons his new armor and flies to Afghanistan,
|
||||
where he saves the villagers. While flying home, Stark is attacked by two fighter jets. He reveals his secret identity to Rhodes over the phone
|
||||
in an attempt to end the attack. Meanwhile, the Ten Rings gather the pieces of Stark's prototype suit and meet with Stane,
|
||||
who has been trafficking arms to criminals worldwide and has staged a coup to replace Stark as Stark Industries' CEO by hiring the Ten Rings
|
||||
to kill him. He subdues Raza and has the rest of the group killed. Stane has a massive new suit reverse engineered from the wreckage.
|
||||
Seeking to track his company's illegal shipments, Stark sends Potts to hack into its database. She discovers that Stane hired the Ten Rings
|
||||
to kill Stark, but the group reneged when they realized they had a direct route to Stark's weapons. Potts meets with Agent Phil Coulson
|
||||
of S.H.I.E.L.D., an intelligence agency, to inform him of Stane's activities.
|
||||
|
||||
Stane's scientists cannot duplicate Stark's miniaturized arc reactor, so Stane ambushes Stark at his home and takes the one from his chest.
|
||||
Stark manages to get to his original reactor to replace it. Potts and several S.H.I.E.L.D. agents attempt to arrest Stane, but he dons his suit
|
||||
and attacks them. Stark fights Stane but is outmatched without his new reactor to run his suit at full capacity. The fight carries Stark
|
||||
and Stane to the top of the Stark Industries building, and Stark instructs Potts to overload the large arc reactor powering the building.
|
||||
This unleashes a massive electrical surge that causes Stane and his armor to fall into the exploding reactor, killing him. The next day,
|
||||
at a press conference, Stark defies suggestions from S.H.I.E.L.D. and publicly admits to being "Iron Man."
|
||||
|
||||
In a post-credits scene, S.H.I.E.L.D. Director Nick Fury visits Stark at home, telling him that Iron Man is not "the only superhero in the world",
|
||||
and explaining that he wants to discuss the "Avenger Initiative".
|
||||
|
||||
Cast
|
||||
Robert Downey Jr. as Tony Stark / Iron Man:
|
||||
An industrialist, genius inventor, and consummate playboy, he is CEO of Stark Industries and chief weapons manufacturer for the U.S. military.
|
||||
Director Jon Favreau felt that Downey's past made him an appropriate choice for the part and that the actor could not only make Stark
|
||||
a "likable asshole," but also portray an authentic emotional journey, once he had won over the audience. Favreau was also attracted
|
||||
to Downey because of his performance in Kiss Kiss Bang Bang. Downey frequently spoke with that film's director, Shane Black,
|
||||
about the script and dialogue in Iron Man. Downey had an office next to Favreau during pre-production, which allowed him greater
|
||||
involvement in the screenwriting process, specially when it came to adding humor to the film.
|
||||
Downey explained, "What I usually hate about these superhero movies is when suddenly the guy that you were digging turns into Dudley Do-Right,
|
||||
and then you're supposed to buy into all his 'Let's go do some good!' That Eliot Ness-in-a-cape-type thing. What was really important to me
|
||||
was to not have him change so much that he's unrecognizable. When someone used to be a schmuck and they're not anymore,
|
||||
hopefully they still have a sense of humor." To get into shape, Downey spent five days a week weight training and practiced martial arts,
|
||||
which he said benefited him because "it's hard not to have a personality meltdown after about several hours in that suit.
|
||||
I'm calling up every therapeutic moment I can think of to just get through the day."
|
||||
|
||||
Terrence Howard as James "Rhodey" Rhodes:
|
||||
A friend of Stark's and the liaison between Stark Industries and the United States Air Force in the department of acquisitions,
|
||||
specifically weapons development. Favreau cast Howard because he felt he could play War Machine in a sequel.
|
||||
Howard prepared for the role by visiting Nellis Air Force Base on March 16, 2007, where he ate with the pilots and observed HH-60 Pave Hawk
|
||||
rescue helicopters and F-22 Raptors. While Rhodes is roguish in the comics after he meets Stark, his previous role as a disciplinarian
|
||||
creates a dynamic tension with Stark's character. He is unsure whether Stark's actions are acceptable.
|
||||
"Rhodey is completely disgusted with the way Tony has lived his life, but at a certain point he realizes that perhaps there is a different way,
|
||||
" Howard said. "Whose life is the right way: Is it the strict military life, or the life of an independent?"
|
||||
Howard and his father are Iron Man fans, partly because Rhodes was one of the few black superheroes when Howard was a child.
|
||||
He has been a Downey fan since he saw him in Weird Science; the two competed physically on set.
|
||||
|
||||
Jeff Bridges as Obadiah Stane / Iron Monger:
|
||||
Stark's business second-in-command, mentor, and friend, who turns on him to take over the company, eventually building a giant exosuit
|
||||
to fight Stark. Bridges read the comics as a boy and liked Favreau's modern, realistic approach. He shaved his head, something he had wanted
|
||||
to do for some time, and grew a beard for the role. Bridges googled the Book of Obadiah, and was surprised to learn retribution is a major theme
|
||||
in that book of the Bible, something that Stane represents. Many of Stane's scenes were cut to focus more on Stark, but the writers
|
||||
felt Bridges's performance allowed the application of "less is more" when editing the film.
|
||||
|
||||
Shaun Toub as Ho Yinsen:
|
||||
Stark's fellow captive, who grafts an electromagnet to Stark's chest "to keep the shrapnel shell shards that wounded him from reaching
|
||||
his heart and killing him" and helps Stark build the first Iron Man suit.
|
||||
|
||||
Gwyneth Paltrow as Virginia "Pepper" Potts:
|
||||
Stark's personal assistant and budding love interest. Paltrow asked Marvel to send her any comics they would consider relevant to her
|
||||
understanding of the character, whom she considered to be very smart, levelheaded, and grounded. She said she liked "the fact that
|
||||
there's a sexuality that's not blatant.” Favreau wanted Potts' and Stark's relationship to be reminiscent of a 1940s comedy,
|
||||
something which Paltrow considered to be fun in an "innocent yet sexy" way.
|
||||
|
||||
Additionally, Faran Tahir appears as Raza, the leader of the Ten Rings;
|
||||
Paul Bettany voices J.A.R.V.I.S., Stark's personal AI system;
|
||||
Leslie Bibb portrays Christine Everhart, a reporter for Vanity Fair;
|
||||
and Clark Gregg appears as Phil Coulson, an agent of S.H.I.E.L.D.
|
||||
Will Lyman provides the voice-over during the opening award ceremony.
|
||||
Director Jon Favreau plays Happy Hogan, Stark's bodyguard and chauffeur, and Samuel L. Jackson makes a cameo appearance as Nick Fury,
|
||||
director of S.H.I.E.L.D., in a post-credits scene. Jackson's face was previously used as the model for the Ultimate Marvel imprint version
|
||||
of Nick Fury.
|
||||
Other cameos in the film include Stan Lee as himself, being mistaken for Hugh Hefner by Stark at a party;
|
||||
Peter Billingsley as William Ginter Riva, a scientist who works for Stane;
|
||||
Tom Morello, who provided guitar music for the film, as a terrorist guard and Jim Cramer as himself.
|
||||
Ghostface Killah had a cameo in a scene where Stark briefly stays in Dubai, but the scene was cut from the theatrical release for pacing reasons.
|
121
examples/nlp/conditional_generation/data/iron_man/iron_man_2.txt
Normal file
121
examples/nlp/conditional_generation/data/iron_man/iron_man_2.txt
Normal file
|
@ -0,0 +1,121 @@
|
|||
Iron Man 2 is a 2010 American superhero film based on the Marvel Comics character Iron Man. Produced by Marvel Studios and distributed
|
||||
by Paramount Pictures. It is the sequel to Iron Man (2008) and the third film in the Marvel Cinematic Universe (MCU).
|
||||
Directed by Jon Favreau and written by Justin Theroux, the film stars Robert Downey Jr. as Tony Stark / Iron Man alongside Gwyneth Paltrow,
|
||||
Don Cheadle, Scarlett Johansson, Sam Rockwell, Mickey Rourke, and Samuel L. Jackson. Six months after Iron Man, Tony Stark resists calls
|
||||
from the United States government to hand over the Iron Man technology, which is causing his declining health. Meanwhile,
|
||||
Russian scientist Ivan Vanko uses his own version of the technology to pursue a vendetta against the Stark family.
|
||||
|
||||
Following the critical and commercial success of Iron Man in May 2008, Marvel Studios announced and immediately set to work on producing a sequel.
|
||||
In July, Theroux was hired to write the script and Favreau was signed to return as director. Downey, Paltrow, and Jackson were set to reprise
|
||||
their roles from Iron Man, while Cheadle was brought in to replace Terrence Howard in the role of James Rhodes. In the early months of 2009,
|
||||
Rourke (Vanko), Rockwell, and Johansson filled out the supporting cast. Filming took place from April to July 2009, mostly in California
|
||||
like the first film except for a key sequence in Monaco. Unlike its predecessor, which mixed digital and practical effects,
|
||||
the sequel primarily relied on computer-generated imagery to create the Iron Man suits.
|
||||
|
||||
Iron Man 2 premiered at the El Capitan Theatre on April 26, 2010, and was released in the United States on May 7, as part of Phase One of the MCU.
|
||||
The film received generally positive reviews for Downey's performance as well as the action sequences, musical score, and visual effects,
|
||||
but many critics deemed it to be inferior to the first film and criticized the villain and pacing.
|
||||
The sequel grossed over $623.9 million at the worldwide box office, making it the seventh-highest-grossing film of 2010.
|
||||
It received an Academy Award nomination for Best Visual Effects. A third installment of the series, Iron Man 3, was released on May 3, 2013.
|
||||
|
||||
Plot
|
||||
In Russia, the media covers Tony Stark's disclosure of his identity as Iron Man. Ivan Vanko, whose father, Anton Vanko, has just died,
|
||||
sees this and begins building a miniature arc reactor similar to Stark's. Six months later, Stark is a superstar and uses his Iron Man suit
|
||||
for peaceful means, resisting government pressure to sell his designs. He reinstitutes the Stark Expo in Flushing Meadows, New York to continue
|
||||
his father Howard's legacy.
|
||||
|
||||
Later, Stark learns that the palladium core in the arc reactor that keeps him alive and powers the armor is slowly poisoning him,
|
||||
and he cannot find a substitute. Growing increasingly reckless and despondent about his impending death, and choosing not to tell anyone
|
||||
about his condition, Stark appoints his personal assistant Pepper Potts as CEO of Stark Industries, and hires Stark employee Natalie Rushman
|
||||
to replace her as his personal assistant. Stark competes in the Monaco Historic Grand Prix, where he is attacked in the middle of the race by Vanko,
|
||||
wielding electrified whips. Stark dons his armor and defeats Vanko, but the suit is severely damaged. Vanko explains his intention was to prove
|
||||
to the world that Iron Man is not invincible. Impressed by Vanko's performance, Stark's rival, Justin Hammer, fakes Vanko's death while
|
||||
breaking him out of prison and asks him to build a line of armored suits to upstage Stark. During what he believes is his final birthday party,
|
||||
Stark gets drunk while wearing the Iron Man suit. Disgusted, Stark's best friend, U.S. Air Force Lieutenant Colonel James Rhodes,
|
||||
dons Stark's prototype armor and tries to restrain him. The fight ends in a stalemate, and Rhodes confiscates the armor for the U.S. Air Force.
|
||||
|
||||
Nick Fury, director of S.H.I.E.L.D., approaches Stark, revealing that "Rushman" is Agent Natasha Romanoff and that Howard Stark was
|
||||
a S.H.I.E.L.D. founder whom Fury knew personally. Fury explains that Vanko's father and Stark invented the arc reactor together, but when
|
||||
Anton tried to sell it, Stark had him deported. The Soviets sent Anton to the Gulag. Fury gives Stark some of his father's old material.
|
||||
Tony discovers a hidden message in the diorama of the 1974 Stark Expo; it proves to be a diagram of the atomic structure of a new element.
|
||||
With the aid of his A.I., J.A.R.V.I.S., Stark synthesizes it. When he learns that Vanko is still alive, he places the new element in his arc
|
||||
reactor and ends his palladium dependency. At the Expo, Hammer unveils Vanko's armored drones, led by Rhodes in a heavily weaponized version
|
||||
of the prototype armor. Stark arrives to warn Rhodes, but Vanko takes remote control of all the drones and Rhodes' armor and attacks Stark.
|
||||
Hammer is arrested while Romanoff and Stark's bodyguard Happy Hogan go after Vanko at Hammer's factory. Vanko escapes, but Romanoff returns
|
||||
control of Rhodes' armor to him. Together, Stark and Rhodes defeat Vanko and his drones. Vanko commits suicide by blowing up his suit,
|
||||
along with the defeated drones. At a debriefing, Fury informs Stark that because of his difficult personality, S.H.I.E.L.D. intends
|
||||
to use him only as a consultant. Stark and Rhodes receive medals for their heroism. In a post-credits scene, S.H.I.E.L.D. agent Phil Coulson
|
||||
reports the discovery of a large hammer at the bottom of a crater in a desert in New Mexico.
|
||||
|
||||
Cast
|
||||
Robert Downey Jr. as Tony Stark / Iron Man:
|
||||
A billionaire who escaped captivity in Afghanistan with a suit of armor he created, he now struggles to keep his technology out of
|
||||
the government's hands. Downey and Favreau, who had been handed a script and worked from it on the first movie, conceived part of
|
||||
the film's story themselves. On Stark being a hero, Downey said "It's kind of heroic, but really kind of on his own behalf. So I think
|
||||
there's probably a bit of an imposter complex and no sooner has he said, 'I am Iron Man–' that he's now really wondering what that means.
|
||||
If you have all this cushion like he does and the public is on your side and you have immense wealth and power, I think he's way too insulated
|
||||
to be okay." Downey put on 20 pounds of muscle to reprise the role. Six-year-old Davin Ransom portrays Tony Stark as a child.
|
||||
|
||||
Gwyneth Paltrow as Pepper Potts:
|
||||
Stark's closest friend, budding love interest, and business partner; Pepper is promoted to CEO of Stark Industries. On her character's promotion,
|
||||
Paltrow opined "When we start Iron Man 2 Pepper and Tony are very much in the same vibe as the movie progresses,
|
||||
Pepper is given more responsibility and she's promoted and it's nice to see her sort of grow up in that way.
|
||||
I think it really suits her, the job fits her really well."[13] Paltrow expressed excitement about working with Johansson.
|
||||
|
||||
Don Cheadle as James "Rhodey" Rhodes / War Machine:
|
||||
An officer in the U.S. Air Force and Tony Stark's close personal friend who later operates the War Machine armor.
|
||||
Cheadle replaces Terrence Howard from the first film. Cheadle only had a few hours to accept the role and did not even know what
|
||||
storyline Rhodes would undergo. He commented that he is a comic book fan, but had not previously participated in comics-themed
|
||||
films due to the scarcity of black superheroes. Cheadle said he thought Iron Man was a robot before the first film came out.
|
||||
On how he approached his character, Cheadle stated "I go, what's the common denominator here? And the common denominator was really
|
||||
his friendship with Tony, and that's what we really tried to track in this one. How is their friendship impacted once Tony comes out
|
||||
and owns 'I am Iron Man'?". Cheadle said his suit was 23 kilograms (50 lb) of metal, and that he could not touch his face while wearing it.
|
||||
Cheadle signed a six-picture deal.
|
||||
|
||||
Scarlett Johansson as Natasha Romanoff / Black Widow:
|
||||
An undercover spy for S.H.I.E.L.D. posing as Stark's new assistant. Johansson dyed her hair red before she landed the part, hoping that
|
||||
it would help convince Favreau that she was right for the role. On why she chose the role, Johansson said, "the Black Widow character
|
||||
resonated with me. She is a superhero, but she's also human. She's small, but she's strong. She is dark and has faced death so many times
|
||||
that she has a deep perspective on the value of life. It's hard not to admire her." She stated that she had "a bit of a freak-out moment"
|
||||
when she first saw the cat-suit. When asked about fighting in the costume, Johansson responded "a big part of me is like 'can I move in this?
|
||||
Can I run in it? Can I like throw myself over things with this?' And I think just the prep, you just have to put in the hours.
|
||||
That's what I realized is that just putting in the hours and doing the training and repetition and basically just befriending the stunt team
|
||||
and spending all day, every day, just over and over and over and over until you sell it."
|
||||
|
||||
Sam Rockwell as Justin Hammer:
|
||||
A rival weapons manufacturer. Sam Rockwell was considered for the role of Tony Stark in the first film, and he accepted the role of Hammer
|
||||
without reading the script. He had never heard of the character before he was contacted about the part, and was unaware Hammer is
|
||||
an old Englishman in the comics. Rockwell said, "I worked with Jon Favreau on this film called Made. And Justin Theroux, who wrote the script,
|
||||
is an old friend of mine, they sort of cooked up this idea and pitched it to Kevin Feige. What they did, they were maybe going to do one villain
|
||||
like they did with Jeff Bridges, but then they decided to split the villains. And really Mickey Rourke is the main villain, but I come to his aid.
|
||||
Rockwell described his character as "plucky comic relief, but he's got a little bit of an edge".
|
||||
|
||||
Mickey Rourke as Ivan Vanko / Whiplash:
|
||||
A Russian physicist and ex-convict who builds a pair of arc reactor-based electric whips to exact vengeance on the Stark family.
|
||||
The character is an amalgam of Whiplash and Crimson Dynamo. Rourke visited Butyrka prison to research the role, and he suggested half
|
||||
of the character's dialogue be in Russian. He also suggested the addition of tattoos, gold teeth and a fondness for a pet cockatoo,
|
||||
paying for the teeth and bird with his own money. Rourke explained that he did not want to play a "one-dimensional bad guy", and wanted
|
||||
to challenge the audience to see something redeemable in him. Not knowing anything about computers, Rourke described pretending to be
|
||||
tech-savvy as the hardest part of the role.
|
||||
|
||||
Samuel L. Jackson as Nick Fury:
|
||||
Director of S.H.I.E.L.D.; Jackson signed a nine-film contract to play the character. On the subject of his character not seeing any action
|
||||
in the film, Jackson said "We still haven't moved Nick Fury into the bad-ass zone. He's still just kind of a talker."
|
||||
|
||||
The director, Jon Favreau, reprises his role as Happy Hogan, Tony Stark's bodyguard and chauffeur, while Clark Gregg and Leslie Bibb
|
||||
reprise their roles as S.H.I.E.L.D. Agent Phil Coulson and reporter Christine Everhart, respectively.
|
||||
|
||||
John Slattery appears as Tony's father Howard Stark and Garry Shandling appears as United States Senator Stern,
|
||||
who wants Stark to give Iron Man's armor to the government. Favreau stated that Shandling's character was named after radio
|
||||
personality Howard Stern. Paul Bettany again voices Stark's computer, J.A.R.V.I.S. Olivia Munn originally appeared as an unnamed character
|
||||
who was subsequently cut from the film.
|
||||
Favreau then gave her the role of Chess Roberts, a reporter covering the Stark expo.
|
||||
Yevgeni Lazarev appears as Ivan Vanko's father Anton Vanko, Kate Mara portrays a Process Server who summons Tony to the government hearing,
|
||||
and Stan Lee appears as himself (but is mistaken for Larry King).
|
||||
|
||||
Additionally, news anchor Christiane Amanpour and political commentator Bill O'Reilly play themselves in newscasts.
|
||||
Adam Goldstein appears as himself and the film is dedicated to his memory.
|
||||
Further cameos include Tesla Motors CEO Elon Musk and Oracle Corporation CEO Larry Ellison.
|
||||
Favreau's son Max appears as a child wearing an Iron Man mask whom Stark saves from a drone.
|
||||
This was retroactively made as the introduction of a young Peter Parker to the MCU, as confirmed in June 2017 by eventual Spider-Man actor
|
||||
Tom Holland, Feige and Spider-Man: Homecoming director Jon Watts.
|
165
examples/nlp/conditional_generation/data/iron_man/iron_man_3.txt
Normal file
165
examples/nlp/conditional_generation/data/iron_man/iron_man_3.txt
Normal file
|
@ -0,0 +1,165 @@
|
|||
Iron Man 3 is a 2013 American superhero film based on the Marvel Comics character Iron Man, produced by Marvel Studios and distributed
|
||||
by Walt Disney Studios Motion Pictures. It is the sequel to Iron Man (2008) and Iron Man 2 (2010), and the seventh film in the Marvel
|
||||
Cinematic Universe. The film was directed by Shane Black from a screenplay he co-wrote with Drew Pearce, and stars Robert Downey Jr.
|
||||
as Tony Stark / Iron Man alongside Gwyneth Paltrow, Don Cheadle, Guy Pearce, Rebecca Hall, Stéphanie Szostak, James Badge Dale, Jon Favreau,
|
||||
and Ben Kingsley. In Iron Man 3, Tony Stark wrestles with the ramifications of the events of The Avengers during a national terrorism campaign
|
||||
on the United States led by the mysterious Mandarin.
|
||||
|
||||
After the release of Iron Man 2 in May 2010, director Favreau chose not to return for a third film. Black was hired to write and direct
|
||||
the sequel in February 2011, working with Pearce to make the script more character-centric, focus on thriller elements, and use concepts
|
||||
from Warren Ellis's "Extremis" comic book story arc. The film's supporting cast, including Kingsley, Pearce, and Hall, were brought on
|
||||
throughout April and May 2012. Filming took place from May 23 to December 17, 2012, primarily at EUE/Screen Gems Studios in Wilmington,
|
||||
North Carolina. Additional filming took place around North Carolina as well as in Florida, Los Angeles, and China; an extended version
|
||||
of the film specifically for Chinese audiences was created. Seventeen companies provided the film's visual effects.
|
||||
|
||||
Iron Man 3 premiered at the Grand Rex in Paris on April 14, 2013, and released in the United States on May 3, as the first film in
|
||||
Phase Two of the MCU. It received praise from critics for its performances, visual effects, action sequences, humor, and Brian Tyler's
|
||||
musical score, while critics and audiences gave a mixed reception to its Mandarin plot twist. The film was a box office success,
|
||||
grossing over $1.2 billion worldwide making it the second highest-grossing film of 2013 and the sixteenth film to gross over $1 billion.
|
||||
At the time it also became the fifth highest-grossing film of all time while its opening weekend became the sixth-highest of all time.
|
||||
The film received Best Visual Effects nominations at the Academy Awards and the BAFTA Awards.
|
||||
|
||||
Plot
|
||||
At a New Year's Eve party in 1999, Tony Stark meets scientist Maya Hansen, the inventor of an experimental regenerative treatment named
|
||||
Extremis that allows recovery from crippling injuries. Disabled scientist Aldrich Killian offers them a place in his company
|
||||
Advanced Idea Mechanics, but Stark rejects him. In December 2012, seven months after the battle of New York, Stark is suffering
|
||||
from post-traumatic stress disorder and is having frequent panic and anxiety attacks due to his experiences during the alien invasion
|
||||
and subsequent battle. Restless, he has built dozens of new Iron Man suits to cope with his insomnia, creating friction with
|
||||
his girlfriend Pepper Potts.
|
||||
|
||||
A string of bombings claimed by a terrorist known as the Mandarin has left intelligence agencies bewildered by a lack of forensic evidence.
|
||||
Stark's security chief Happy Hogan is badly injured in one such attack at the TCL Chinese Theatre, prompting Stark to boldly issue
|
||||
a televised threat to the Mandarin, revealing his home address in the process. The Mandarin sends gunship helicopters to destroy Stark's home.
|
||||
Hansen, who came to warn Stark, survives the attack with Potts. Stark escapes in an experimental new Iron Man suit, which his
|
||||
artificial intelligence J.A.R.V.I.S. pilots to rural Tennessee, following a flight plan from Stark's investigation into the Mandarin.
|
||||
Stark's new armor is not fully functional and lacks sufficient power to return to California, leaving the world to believe him dead.
|
||||
|
||||
Stark investigates the remains of a local explosion bearing the hallmarks of a Mandarin attack. He discovers the "bombings" were triggered
|
||||
by soldiers subjected to Extremis whose bodies explosively rejected the treatment. These explosions were falsely attributed
|
||||
to a terrorist plot in order to cover up Extremis's flaws. Stark witnesses Extremis first hand when Mandarin agents Savin and Brandt
|
||||
attack him: Stark kills Brandt and incapacitates Savin. Meanwhile, Killian resurfaces and kidnaps Potts with assistance from Hansen.
|
||||
American intelligence agencies continue to search for the Mandarin's location, with James Rhodes—the former War Machine,
|
||||
now re-branded as the Iron Patriot—lured into a trap to steal his Iron-Man-like armor.
|
||||
|
||||
Stark traces the Mandarin to Miami and infiltrates his headquarters using improvised weapons. Inside, he discovers the Mandarin is actually
|
||||
an English actor named Trevor Slattery, who is oblivious to the actions carried out in his image. Killian, who appropriated
|
||||
Hansen's Extremis research as a cure for his own disability and expanded the program to include injured war veterans, reveals he is
|
||||
the real Mandarin behind Slattery's cover. After capturing Stark, Killian reveals he has subjected Potts to Extremis in the hope Stark
|
||||
will help fix Extremis's flaws while trying to save her. Killian kills Hansen when she tries to stop him.
|
||||
|
||||
Stark escapes and reunites with Rhodes, discovering that Killian intends to attack President Ellis aboard Air Force One,
|
||||
using the Iron Patriot armor, controlled by Savin. Stark kills Savin, saving the passengers and crew, but cannot stop Killian
|
||||
from abducting Ellis and destroying Air Force One. They trace Killian to an impounded damaged oil tanker where Killian intends
|
||||
to kill Ellis on live television. The Vice President will become a puppet leader, following Killian's orders, in exchange for Extremis to cure
|
||||
his young daughter's disability. On the platform, Stark works to save Potts, as Rhodes goes after the President. Stark summons his remaining Iron Man suits,
|
||||
controlled remotely by J.A.R.V.I.S., to provide air support. Rhodes secures the President and takes him to safety, while Stark discovers Potts
|
||||
has survived the Extremis procedure; before he can save her, a rig collapses around them and she falls to the platform below,
|
||||
causing Stark to believe her dead. Stark fights Killian, but finds himself cornered. Potts, whose Extremis powers allowed her to survive her fall,
|
||||
intervenes and kills Killian to save Stark.
|
||||
|
||||
Stark orders J.A.R.V.I.S. to remotely destroy all the Iron Man suits as a sign of his devotion to Potts, while the Vice President and Slattery
|
||||
are arrested. With Stark's help, Potts's Extremis effects are stabilized; and Stark promises to scale back his life as Iron Man,
|
||||
undergoing surgery to remove the shrapnel near his heart and throwing his obsolete chest arc reactor into the sea. He muses that, even without
|
||||
the technology, he will always be Iron Man.
|
||||
|
||||
Cast
|
||||
Robert Downey Jr. as Tony Stark / Iron Man:
|
||||
A self-described genius, billionaire, playboy, and philanthropist with mechanical suits of armor of his own invention.
|
||||
Stark now struggles to come to terms with his near-death experience in The Avengers, suffering from anxiety attacks. On making a third Iron Man film,
|
||||
Downey said, "My sense of it is that we need to leave it all on the field—whatever that means in the end.
|
||||
You can pick several different points of departure for that." On following up The Avengers, Downey said they "tried to be practical,
|
||||
in a post-Avengers world. What are his challenges now? What are some limitations that might be placed on him? And what sort of threat would have him,
|
||||
as usual, ignore those limitations?" Screenwriter Drew Pearce compared Tony to an American James Bond for both being "heroes with a sense of danger to them,
|
||||
and unpredictab[le]" even if Stark was a "free agent" instead of an authority figure like Bond. He also likened Tony to the protagonists of 1970s films
|
||||
such as The French Connection, where "the idiosyncrasies of the heroes is what made them exciting."
|
||||
|
||||
Gwyneth Paltrow as Virginia "Pepper" Potts:
|
||||
Stark's girlfriend, longtime associate, and the current CEO of Stark Industries. Paltrow says of her character's relationship to Tony,
|
||||
"She still adores Tony, but she absolutely gets fed up with him. He gets caught in a feedback loop." Kevin Feige commented on Pepper's role in the film:
|
||||
"The love triangle in this movie is really between Tony, Pepper and the suits. Tony, Pepper and his obsession with those suits, and the obsession
|
||||
with technology." Feige also stated the film uses the character to play with the damsel in distress trope, and posits the question,
|
||||
"Is Pepper in danger or is Pepper the savior?"
|
||||
|
||||
Don Cheadle as James "Rhodey" Rhodes / Iron Patriot:
|
||||
Stark's best friend and the liaison between Stark Industries and the U.S. Air Force in the department of acquisitions. Rhodes operates
|
||||
the redesigned/upgraded War Machine armor, taking on an American flag-inspired color scheme similar to the Iron Patriot armor from the comics.
|
||||
Feige said of Rhodes and the armor, "The notion in the movie is that a red, white and blue suit is a bold statement, and it's meant to be.
|
||||
With Rhodey, he's very much the foil to Tony's eccentricities, and in this one you get to see this and be reminded of the trust and friendship
|
||||
between them in that great Shane Black buddy-cop fashion." In the film, the president asks Rhodey to take up the moniker "Iron Patriot," and don the red,
|
||||
white, and blue suit, in order to be the government's "American hero" in response to the events in The Avengers.
|
||||
|
||||
Guy Pearce as Aldrich Killian:
|
||||
The creator of the Extremis virus and the founder and owner of the science and development organization Advanced Idea Mechanics who adopts the mantle
|
||||
of the Mandarin as his own. Killian develops Extremis to cure his own debilitating disability; in addition to his regenerative healing qualities,
|
||||
he has superhuman strength and the ability to generate extreme heat. Prolonged exposure to Extremis also grants him the ability to breathe fire.
|
||||
On taking the role, Pearce said, "I feel a little more experimental in what I'll take on these days, but I still don't know that I would want to play
|
||||
the superhero myself, since I'm playing a different kind of character in this film ... The main difference was that, when I did The Time Machine,
|
||||
I was pretty much in all of it, so it was a really grueling experience. Prometheus and Iron Man are really kind of cameo stuff, so the experience
|
||||
of shooting them ... I mean, on some level, it's tricky because you feel like a bit of an outsider. You don't really live the experience that
|
||||
you do when you're there all day every day with everybody. But at the same time, it can be more fun sometimes because you're just working
|
||||
in concentrated spurts." Pearce described his character as a man "who came into this world with a number of physical disabilities.
|
||||
He's never been able to accept those limitations though and has spent most of his life trying to overcome them in any way he can.
|
||||
His tenacity and blind determination in fighting for a better life are seen by some as irritating, as he often comes across as obnoxious.
|
||||
He just won't accept the cards he was dealt, and being as intelligent as he is, has real drive to change and become a different person."
|
||||
Shane Black specified, "Ultimately we do give you the Mandarin, the real guy, but it's Guy Pearce in the end with the big dragon tattooed on his chest."
|
||||
He elaborated, "Do they hand me a blank check and say, 'Go break something!' Or, 'Go violate some long-standing comic book treaty that fans
|
||||
have supported for years?' No, but they'll say: 'Let's break something together.' So it's okay to come up with these crazy things, these far out ideas
|
||||
and they'll fly. It's just that the Marvel guys have to be in the room."
|
||||
|
||||
Rebecca Hall as Maya Hansen:
|
||||
A geneticist whose work helped Killian create Extremis. Hall said Hansen would be a "strong female character," and described her decision to take the role,
|
||||
saying, "I decided to do Iron Man 3 because I've never done the 'hurry up and wait' movie before. Even the studio movies I've done have been
|
||||
small studio movies, or indie films that we made on a wing and a prayer. I love those, but Iron Man is refreshing in a way because it's something
|
||||
out of my realm of experiences." Hall confirmed her character's role was greatly reduced in the final film, saying, "I signed on to do something
|
||||
that was a substantial role. She wasn't entirely the villain—there have been several phases of this—but I signed on to do something very different
|
||||
to what I ended up doing."
|
||||
|
||||
Ty Simpkins as Harley Keener:
|
||||
A child who lives in Rose Hill, Tennessee. He assists Tony Stark when the latter breaks into his garage in order to repair his suit. He later helps
|
||||
Stark investigate various incidents associated with the Extremis project, and afterwards he is rewarded by Stark with a garage-full of modern
|
||||
engineering tools and equipment. Simpkins reprises his role as Harley in a cameo in Avengers: Endgame. Simpkins has stated he has a three-picture deal
|
||||
with Marvel Studios.
|
||||
|
||||
Stéphanie Szostak as Ellen Brandt:
|
||||
A war veteran who becomes an assassin after her exposure to Extremis. Describing Brandt, Szostak says, ". Extremis was a second chance at life.
|
||||
We talked about what you feel like and I think it almost makes you a fuller version of who you are, all your weakness and your qualities—just
|
||||
everything gets enhanced. I saw it as very freeing, almost you become your true-self and your fantasy-self all at once."
|
||||
The writers originally envisioned Brandt as Killian's main henchman, which would return throughout the movie to fight Tony, but eventually that role
|
||||
was reassigned to Eric Savin.
|
||||
|
||||
James Badge Dale as Eric Savin:
|
||||
Killian's Extremis-powered henchman. Dale stated his character in the film was "loosely based on" the comic version of the character.
|
||||
According to Dale, "Ben Kingsley is the mouthpiece. Guy Pearce is the brain. I'm the muscle."
|
||||
|
||||
Jon Favreau as Happy Hogan:
|
||||
Tony Stark's former bodyguard and chauffeur who now serves as Stark Industries' head of security department. Favreau, who served as both actor
|
||||
and director on the previous two Iron Man films, said participating in the new film was "like being a proud grandfather who doesn't have to change
|
||||
the diapers but gets to play with the baby."
|
||||
|
||||
Ben Kingsley as Trevor Slattery:
|
||||
A British actor whom Killian hired to portray the Mandarin, a terrorist persona in jammed television broadcasts in which he is depicted as the leader
|
||||
of the international terrorist organization the Ten Rings.[34] Kingsley was filming Ender's Game when he was cast, and said that,
|
||||
"Quite soon I'll be with everybody and we'll be discussing the look and the feel and the direction of the character. It's very early days yet,
|
||||
but I'm so thrilled to be on board."On his performance, Kingsley stated: "I wanted a voice that would disconcert a Western audience.
|
||||
I wanted a voice that would sound far more homegrown and familiar—a familiarity like a teacher's voice or a preacher's voice.
|
||||
The rhythms and tones of an earnest, almost benign, teacher—trying to educate people for their own good."
|
||||
The Mandarin was initially set to appear in the first Iron Man film, but he was put off for a sequel as the filmmakers felt that he was
|
||||
"too ambitious for a first film." On the character, Feige stated, "The Mandarin is Iron Man's most famous foe in the comics mainly because he's been
|
||||
around the longest. If you look, there's not necessarily a definitive Mandarin storyline in the comics. So it was really about having an idea."
|
||||
Shane Black explains Ben Kingsley's Mandarin is not Chinese in the film as he is in the comics in order to avoid the Fu Manchu stereotype:
|
||||
"We're not saying he's Chinese, we're saying he, in fact, draws a cloak around him of Chinese symbols and dragons because it represents
|
||||
his obsessions with Sun Tzu in various ancient arts of warfare that he studied." The filmmakers also cited Colonel Kurtz from Apocalypse
|
||||
Now as an influence for the character. The videos where the Mandarin gives historical background to the attacks expressed how it emerged
|
||||
as the product of "a think tank of people trying to create a modern terrorist." Thus the Mandarin "represents every terrorist in a way,"
|
||||
from South American insurgency tactics to the videos of Osama bin Laden.
|
||||
|
||||
Paul Bettany reprises his role from previous films as J.A.R.V.I.S., Stark's AI system. Ashley Hamilton portrays Taggart, one of the Extremis soldiers.
|
||||
William Sadler plays President Ellis, (named after Warren Ellis, who wrote the "Extremis" comics arc that primarily influenced the film's story)
|
||||
and Miguel Ferrer plays Vice President Rodriguez. Adam Pally plays Gary, a cameraman who helps Stark. Shaun Toub reprises his role
|
||||
as Yinsen from the first Iron Man film in a brief cameo, and Stan Lee makes a cameo appearance as a beauty pageant judge.
|
||||
Dale Dickey plays Mrs. Davis, mother of an Extremis subject that is framed as a terrorist.
|
||||
Wang Xueqi briefly plays Dr. Wu in the general release version of the film.
|
||||
A cut of the film produced for release exclusively in China includes additional scenes featuring Wang and an appearance by Fan Bingbing
|
||||
as one of his assistants. Mark Ruffalo makes an uncredited cameo appearance, reprising his role as Bruce Banner from The Avengers,
|
||||
in a post-credits scene. Comedians Bill Maher and Joan Rivers, and Fashion Police co-host George Kotsiopoulos have cameo appearances
|
||||
as themselves on their respective real-world television programs, as do newscasters Josh Elliott, Megan Henderson, Pat Kiernan, and Thomas Roberts.
|
53
examples/nlp/conditional_generation/data/minecraft/wiki1.txt
Normal file
53
examples/nlp/conditional_generation/data/minecraft/wiki1.txt
Normal file
|
@ -0,0 +1,53 @@
|
|||
Minecraft is a sandbox video game developed by Mojang Studios. The game was created by Markus Notch Persson in the Java programming language.
|
||||
Following several early test versions, it was released as a paid public alpha for personal computers in 2009 before officially releasing in November 2011,
|
||||
with Jens Bergensten taking over development. Minecraft has since been ported to several other platforms and is the best-selling video game of all time,
|
||||
with 200 million copies sold and 126 million monthly active users as of 2020.
|
||||
|
||||
In Minecraft, players explore a blocky, procedurally-generated 3D world with infinite terrain, and may discover and extract raw materials, craft tools and items,
|
||||
and build structures or earthworks. Depending on game mode, players can fight computer-controlled mobs, as well as cooperate with or compete against
|
||||
other players in the same world. Game modes include a survival mode, in which players must acquire resources to build the world and maintain health, and a creative mode,
|
||||
where players have unlimited resources. Players can modify the game to create new gameplay mechanics, items, and assets.
|
||||
|
||||
Minecraft has been critically acclaimed, winning several awards and being cited as one of the greatest video games of all time.
|
||||
Social media, parodies, adaptations, merchandise, and the annual MineCon conventions played large roles in popularizing the game.
|
||||
It has also been used in educational environments, especially in the realm of computing systems, as virtual computers and hardware devices have been built in it.
|
||||
In 2014, Mojang and the Minecraft intellectual property were purchased by Microsoft for US$2.5 billion.
|
||||
A number of spin-off games have also been produced, such as Minecraft: Story Mode, Minecraft Dungeons, and Minecraft Earth.
|
||||
|
||||
Minecraft is a 3D sandbox game that has no specific goals to accomplish, allowing players a large amount of freedom in choosing how to play the game.
|
||||
However, there is an achievement system, known as advancements in the Java Edition of the game.
|
||||
The game world is composed of rough 3D objects, mainly cubes and fluids, and commonly called blocks representing various materials,
|
||||
such as dirt, stone, ores, tree trunks, water, and lava. The core gameplay revolves around picking up and placing these objects.
|
||||
These blocks are arranged in a 3D grid, while players can move freely around the world. Players can mine blocks and then place them elsewhere,
|
||||
enabling them to build things.
|
||||
Many commentators have described the game's physics system as unrealistic;
|
||||
liquids continuously flow for a limited horizontal distance from source blocks, which can be removed by placing a solid block in its place or by scooping it into a bucket.
|
||||
The game also contains a material known as redstone, which can be used to make primitive mechanical devices, electrical circuits, and logic gates,
|
||||
allowing for the construction of many complex systems.
|
||||
|
||||
The game world is virtually infinite and procedurally generated as players explore it, using a map seed that is obtained from the system clock at the time of world creation
|
||||
or manually specified by the player. There are limits on vertical movement, but Minecraft allows an infinitely large game world to be generated on the horizontal plane.
|
||||
Due to technical problems when extremely distant locations are reached, however, there is a barrier preventing players from traversing to locations beyond
|
||||
30,000,000 blocks from the center. The game achieves this by splitting the world data into smaller sections called chunks that are only created or loaded
|
||||
when players are nearby. The world is divided into biomes ranging from deserts to jungles to snowfields; the terrain includes plains, mountains, forests, caves,
|
||||
and various lava water bodies. The in-game time system follows a day and night cycle, and one full cycle lasts 20 realtime minutes.
|
||||
|
||||
When starting a new world, players must choose one of five game modes, as well as one of four difficulties, ranging from peaceful to hard.
|
||||
Increasing the difficulty of the game causes the player to take more damage from mobs, as well as having other difficulty-specific effects.
|
||||
For example, the peaceful difficulty prevents hostile mobs from spawning, and the hard difficulty allows players to starve to death if their hunger bar is depleted.
|
||||
Once selected, the difficulty can be changed, but the game mode is locked and can only be changed with cheats.
|
||||
|
||||
New players have a randomly selected default character skin of either Steve or Alex, but the option to create custom skins was made available in 2010.
|
||||
Players encounter various non-player characters known as mobs, such as animals, villagers, and hostile creatures.
|
||||
Passive mobs, such as cows, pigs, and chickens, can be hunted for food and crafting materials. They spawn in the daytime, while hostile mobs including large spiders,
|
||||
skeletons, and zombies spawn during nighttime or in dark places such as caves. Some hostile mobs, such as zombies, skeletons and drowned (underwater versions of zombies),
|
||||
burn under the sun if they have no headgear. Other creatures unique to Minecraft include the creeper (an exploding creature that sneaks up on the player)
|
||||
and the enderman (a creature with the ability to teleport as well as pick up and place blocks).
|
||||
There are also variants of mobs that spawn in different conditions; for example, zombies have husk variants that spawn in deserts.
|
||||
|
||||
Minecraft has two alternative dimensions besides the overworld (the main world): the Nether and the End. The Nether is a hell-like dimension accessed
|
||||
via player-built portals; it contains many unique resources and can be used to travel great distances in the overworld, due to every block traveled in the Nether
|
||||
being equivalent to 8 blocks traveled in the overworld. The player can build an optional boss mob called the Wither out of materials found in the Nether.
|
||||
The End is a barren land consisting of many islands. A boss dragon called the Ender Dragon dwells on the main island.
|
||||
Killing the dragon opens access to an exit portal, which upon entering cues the game's ending credits and a poem written by Irish novelist Julian Gough.
|
||||
Players are then teleported back to their spawn point and may continue the game indefinitely.
|
95
examples/nlp/conditional_generation/data/minecraft/wiki2.txt
Normal file
95
examples/nlp/conditional_generation/data/minecraft/wiki2.txt
Normal file
|
@ -0,0 +1,95 @@
|
|||
Minecraft is an indie survival sandbox construction video game designed by Markus Notch Persson and Mojang Studios and developed on Java.
|
||||
The game allows players to collect, assemble, or destroy a variety of blocks in a three-dimensional, procedurally-generated environment.
|
||||
The game takes inspiration from multiple sources, specifically the game Infiniminer.
|
||||
Development began in May 2009, with pre-orders for the full game starting June 13, 2009. The game was officially released by Notch in mid-November 2011 during MineCon.
|
||||
During late 2019, Minecraft has sold over 176 million copies worldwide across all platforms, making it the 2nd highest selling video game of all time, only behind Tetris.
|
||||
|
||||
Blocks make up the Minecraft landscape and are integral to gameplay. They can be broken, collected, and placed in an infinite number of arrangements.
|
||||
They can be used in crafting and manipulated in many other ways. The face of a block is 16 by 16 pixels, and each block is proportionately one cubic meter.
|
||||
|
||||
Minecraft is a game that has no specific goals to accomplish, allowing players a large amount of freedom in choosing how to play it.
|
||||
However, there is an achievements system. While the gameplay revolves through the players' experiences, the game encourages many players to choose their own way of adventure.
|
||||
There is no right or wrong way to play the game, players can play the game however they want it to be.
|
||||
There are two game modes in the game: Survival and Creative. In Survival mode, players must gather resources from the Overworld, hunt for food to replenish health and hunger,
|
||||
and protect themselves from the deadly hostile mobs that attack them during nighttime, or in cave systems. T
|
||||
he most prominent objective in Survival mode, is to mine diamonds to upgrade certain weapons or tools or make convenient armors that would help them throughout their journeys.
|
||||
In Creative mode, players are free to roam in the world wherever they want, and just simply build anything that comes within their imagination, like cities,
|
||||
redstone machines, etc.
|
||||
|
||||
The gameplay is in the first-person perspective by default, but players have the option for a third-person perspective.
|
||||
The game also contains a material known as redstone, which can be used to make mechanical devices, electrical circuits, and logic gates, allowing for the construction
|
||||
of many complex systems. Players can select any customized skin whenever they want to, but new players start with the default character skin of either Steve or Alex.
|
||||
Players encounter various non-player characters known as mobs, such as animals, villagers, and hostile creatures. Passive mobs, such as cows, pigs, and chickens,
|
||||
can be hunted for food and crafting materials. They spawn in the daytime, while hostile mobs, including large spiders, skeletons, and zombies—spawn during nighttime
|
||||
or in dark places such as caves. Some hostile mobs, such as the Zombie, Skeleton, and Drowned (underwater versions of Zombies), burn under the sun if they have no headgear.
|
||||
Other creatures unique to Minecraft include the Creeper (an exploding creature that sneaks up on the player) and the Enderman (a creature with the ability to teleport,
|
||||
pick up, and place blocks). There are also variants of mobs that spawn in different conditions; for example, Zombies have Husk variants that spawn in deserts.
|
||||
|
||||
Minecraft has two alternate dimensions besides the overworld (the main world): the Nether and the End. The Nether is a hell-like dimension accessed via player-built portals;
|
||||
it contains many unique resources and can be used to travel great distances in the overworld. The player can build an optional boss mob called the Wither out of materials
|
||||
found in the Nether. The End is a barren land consisting of many islands. A boss dragon called the Ender Dragon dwells on the main island.
|
||||
Killing the dragon opens access to an exit portal, which upon entering cues the game's ending credits and a poem written by Irish novelist Julian Gough.
|
||||
There is also another portal that access the outer islands of The End, in which players could access the outer islands. Players are then allowed to teleport back
|
||||
to their original spawn point in the Overworld and continue the game indefinitely.
|
||||
|
||||
Survival game mode.
|
||||
The original and core gameplay element of the game. In this mode, players have to gather natural resources such as wood and stone found in the environment in order
|
||||
to craft certain blocks and items. Depending on the difficulty, monsters spawn in darker areas outside a certain radius of the character, requiring players to build
|
||||
a shelter at night. Players are required to fight off the hostile mobs that attack them in order to protect themselves from certain damages.
|
||||
The mode also has a health bar which is depleted by attacks from monsters, falls, drowning, falling into lava, suffocation, starvation, and other events.
|
||||
Players also have a hunger bar, which must be periodically refilled by eating food in-game, except in peaceful difficulty. If the hunger bar is depleted,
|
||||
automatic healing will stop and eventually health will deplete. Health replenishes when players have a nearly full hunger bar or continuously on peaceful difficulty.
|
||||
Players may also trade goods with Villagers or Piglins NPCs throughout a trading or bartering system, which involves trading emeralds or gold for different goods and vice versa.
|
||||
Players may acquire experience points by killing mobs and other players, mining, smelting ores, breeding animals, and cooking food.
|
||||
Experience can then be spent on enchanting tools, armor and weapons. Enchanted items are generally more powerful, last longer, or have other special effects.
|
||||
|
||||
Crafting.
|
||||
Since the uses of natural blocks are limited, it is imperative that players make use of the crafting interface to survive. Players can combine items in a 2x2 interface
|
||||
(extended to 3x3 by use of a crafting table), with each item taking up one square of the grid. Different arrangements of items create usable items,
|
||||
which players can exploit to further their collection of resources, and in turn create more items.
|
||||
Players can craft a wide variety of items in Minecraft. Craftable items include armor, which mitigates damage from attacks; weapons (such as swords),
|
||||
which allows monsters and animals to be killed more easily; and tools, which break certain types of blocks more quickly. Some items have multiple tiers depending
|
||||
on the material used to craft them, with higher-tier items being more effective and durable. Players can construct furnaces, which can cook food, process ores,
|
||||
and convert materials into other materials.
|
||||
|
||||
Inventory.
|
||||
The game has an inventory system, allowing players to carry a limited number of items. Upon dying, items in the players' inventories are dropped,
|
||||
and players re-spawn at their spawn point, which by default is where players first spawn in the game, and can be reset by sleeping in a bed or using a respawn anchor.
|
||||
Dropped items can be recovered if players can reach them before they disappear, or despawn, after 5 minutes.
|
||||
|
||||
Objectives.
|
||||
While they are no specific objectives in the game, The main goals of Survival, is to simply survive, gather important resources, construct and expand your
|
||||
shelter before nighttime, explore your world, have fun, upgrade your tools, materials or equipments, find diamonds, protect their companions, and fight monsters
|
||||
that try to attack them. Survival also has an ending, that is optional to players, and that is to kill the hostile boss mob, Ender Dragon.
|
||||
Players can also build the Wither boss by obtaining the right materials from the nether, and defeat it in order to craft a beacon.
|
||||
They also have the option to protect the villagers from an pillager raid, which is triggered by the player itself.
|
||||
Progress can be made once the player does all of these. Players can also beat the game's achievements, or advancements, but this is completely optional.
|
||||
|
||||
Creative game mode.
|
||||
In creative mode, players have access to all resources and items in the game through the inventory menu, and can place or remove them instantly.
|
||||
Players can toggle the ability to fly freely around the game world at will, and their characters do not take any damage and are not affected by hunger.
|
||||
The game mode helps players focus on building and creating projects of any size without disturbance.
|
||||
|
||||
Hardcore game mode.
|
||||
Hardcore mode is a survival mode variant that is locked to the hardest setting and has permadeath. If a player dies in a hardcore world,
|
||||
they are no longer allowed to interact with it, so they can either be put into spectator mode and explore the world or return to title screen.
|
||||
You cant change difficulty if you set it to hardcore once unlike survival mode.
|
||||
|
||||
Music.
|
||||
Minecraft's music and sound effects were produced by German musician Daniel Rosenfeld (born: May 9, 1989 [age 31]), better known as C418.
|
||||
The background music in Minecraft is simply instrumental ambient music. On 4 March 2011, Rosenfeld released a soundtrack, titled Minecraft – Volume Alpha;
|
||||
it includes most of the tracks featured in Minecraft, as well as other music not featured in the game.
|
||||
Kirk Hamilton of Kotaku chose the music in Minecraft as one of the best video game soundtracks of 2011. On 9 November 2013, Rosenfeld released the second official soundtrack,
|
||||
titled Minecraft – Volume Beta, which includes the music that was added in later versions of the game.
|
||||
A physical release of Volume Alpha, consisting of CDs, black vinyl, and limited-edition transparent green vinyl LPs, was issued by indie electronic
|
||||
label Ghostly International on 21 August 2015.
|
||||
|
||||
Multiplayer.
|
||||
Multiplayer in Minecraft is available through direct game-to-game multiplayer, LAN play, local split screen, and servers (player-hosted and business-hosted).
|
||||
It enables multiple players to interact and communicate with each other on a single world. Players can run their own servers, use a hosting provider,
|
||||
or connect directly to another player's game via Xbox Live. Single-player worlds have local area network support, allowing players to join a world on locally
|
||||
interconnected computers without a server setup. Minecraft multiplayer servers are guided by server operators, who have access to server commands such as setting
|
||||
the time of day and teleporting players. Operators can also set up restrictions concerning which usernames or IP addresses are allowed or disallowed to enter the server.
|
||||
Multiplayer servers have a wide range of activities, with some servers having their own unique rules and customs. The largest and most popular server is Hypixel,
|
||||
which has been visited by over 14 million unique players. Player versus player combat (PvP) can be enabled to allow fighting between players.
|
||||
Many servers have custom plugins that allow actions that are not normally possible.
|
113
examples/nlp/conditional_generation/data/minecraft/wiki3.txt
Normal file
113
examples/nlp/conditional_generation/data/minecraft/wiki3.txt
Normal file
|
@ -0,0 +1,113 @@
|
|||
Minecraft is a sandbox construction video game originally created by Markus Notch Persson. It is maintained by Mojang Studios, a part of Xbox Game Studios,
|
||||
which in turn is part of Microsoft.
|
||||
From its creation, Minecraft was developed almost exclusively by Notch until Jens Bergensten started working with him, and has since become head of its development.
|
||||
It features music by Daniel Rosenfeld and paintings by Kristoffer Zetterstrand. Initially released as what is now known as Minecraft Classic on May 17, 2009,
|
||||
the game was fully released on November 18, 2011. Since its release, Minecraft has expanded to mobile devices and consoles. On November 6, 2014,
|
||||
Minecraft and all of Mojang Studios' assets were acquired by Microsoft for US$2.5 billion. Notch has since left Mojang, and is no longer working on Minecraft.
|
||||
|
||||
Minecraft focuses on allowing the player to explore, interact with, and modify a dynamically-generated map made of one-cubic-meter-sized blocks.
|
||||
In addition to blocks, the environment features plants, mobs, and items. Some activities in the game include mining for ore, fighting hostile mobs, and crafting new blocks
|
||||
and tools by gathering various resources found in the game. The game's open-ended model allows players to create structures, creations, and artwork
|
||||
on various multiplayer servers or their single-player maps. Other features include redstone circuits for logic computations and remote actions,
|
||||
minecarts and tracks, and a mysterious underworld called the Nether. A designated but completely optional goal of the game is to travel to a dimension called the End,
|
||||
and defeat the ender dragon.
|
||||
|
||||
Player.
|
||||
The player is the person that the user controls in the world. When the user starts a game, the player is put in a world, generated by a random or specified seed,
|
||||
with an empty inventory. If the bonus chest option is enabled, a chest filled with basic items generates near the player.
|
||||
The player has a health bar with 10 hearts, and can be damaged by falls, suffocation, drowning, fire, lava, lightning, cacti, sweet berry bushes,
|
||||
falling into the Void, falling anvils and being hit by mobs and other players. Damage to health can be mitigated by armor or Resistance potion and health
|
||||
can be restored by eating food and drinking specific potions, or if difficulty is set to Peaceful, health regenerates on its own.
|
||||
Hunger is also a factor if the difficulty is not set to Peaceful, depleting over time and even faster while sprinting, jumping or swimming.
|
||||
Food replenishes the hunger level, however, eating rotten flesh and raw chicken has a chance of giving the player a hunger effect.
|
||||
Depending on the difficulty level, a low hunger level depletes a player's health.
|
||||
A player can change their skin on the profile page of Minecraft.net or in the launcher.
|
||||
|
||||
Blocks.
|
||||
The world of Minecraft takes place within a three-dimensional grid of cubes, with each cube being occupied by a certain type of block (not all of which are necessarily cubic).
|
||||
here are different types of blocks; natural blocks such as grass, stone, and ores are randomly generated within the world. There are also blocks that players can craft,
|
||||
such as a crafting table and a furnace. Resources can be extracted from blocks by hand or by using tools. Some of these resources are simply blocks in the player's
|
||||
inventory that can be placed elsewhere, while others are used as material to create other blocks or tools. Others yield no practical use whatsoever.
|
||||
Some blocks cannot be broken through normal survival means, e.g. bedrock, end portal frames, command blocks, and barriers.
|
||||
|
||||
Mining.
|
||||
Various ores (in proximity of lava) that can be mined with a pickaxe.
|
||||
Mining is one of the main aspects of Minecraft and is done to extract ore and other materials mainly from below the surface of the map.
|
||||
These ores include coal, iron, gold, redstone, diamond, lapis lazuli, and emerald. Mining can involve digging a hole from the surface or going down through a cave.
|
||||
Mineshafts create extra areas that may contain resources, since they are usually rich in ores.
|
||||
|
||||
Crafting and Smelting.
|
||||
A crafting table, used to create most of the blocks and items in Minecraft.
|
||||
Crafting allows players to create new tools and blocks using items from their inventory. Subsequent versions often contain crafting recipes for new blocks and items.
|
||||
To craft, a player can use the 2×2 grid in the inventory or the 3×3 grid provided by a crafting table. Smelting requires a furnace in addition to fuel,
|
||||
and processes blocks into a more useful form such as iron ores into iron ingots.
|
||||
|
||||
Brewing and Enchanting.
|
||||
An Enchantment Table with glyphs being absorbed into it.
|
||||
Brewing creates potions from various ingredients and water using a brewing stand. They are stored in a glass bottle and then consumed by the player or thrown
|
||||
at other mobs to generate a certain effect based on the ingredients used to create the potion. Enchanting is also used to upgrade armor,
|
||||
tools, or weapons with an enchanting table. More powerful enchantments can be accessed by gaining experience and placing bookshelves around the enchanting table.
|
||||
|
||||
Mobs.
|
||||
A creeper in a forest. Creepers stalk the player and then explode once they get near.
|
||||
Mobs (short for mobiles) are the animals and other creatures that inhabit the map. Hostile mobs attack the player while passive mobs do not. Neutral mobs attack when provoked.
|
||||
The Overworld contains many passive mobs that may be killed for food or bred with one another; these include:
|
||||
Pigs: drop porkchops upon death and can be ridden using a saddle.
|
||||
Cows: drop beef upon death and can be milked using a bucket.
|
||||
Sheep: drop mutton and 1 wool upon death and can be shorn to produce 1–3 wool.
|
||||
Chickens: drop chicken meat and feathers upon death and lay eggs.
|
||||
Horses: drop leather upon death and can be ridden using a saddle, traveling much faster than pigs.
|
||||
Bats: ambient mobs that fly around caves.
|
||||
|
||||
Common hostile mobs found throughout the Overworld include:
|
||||
Zombies: attack by melee damage.
|
||||
Skeletons: have a bow and infinitely many arrows.
|
||||
Spiders: jump large distances and can climb walls.
|
||||
Witches: use potions.
|
||||
Creepers: explode when near the player.
|
||||
Endermen: tall, black creatures with purple eyes and turn aggressive when the player looks at them.
|
||||
The Overworld also contains some rarer mobs that spawn only on occasion or in specific biomes:
|
||||
|
||||
Spider jockeys: a skeleton riding a spider.
|
||||
Chicken jockeys: a baby zombie riding a chicken.
|
||||
Slimes: spawn deep within the map and in swamplands.
|
||||
Villagers: inhabit villages and can trade with the player.
|
||||
Parrots: can imitate the sounds of nearby mobs.
|
||||
Wolves: can be tamed by the player and attack enemy mobs if the player engages or is attacked by them
|
||||
Mooshrooms: mushroom variants of cows that spawn in mushroom field biomes.
|
||||
Vindicator: spawn in woodland mansions
|
||||
Pillager: spawn in pillager outposts
|
||||
Evoker: spawn in Woodland Mansions
|
||||
|
||||
Some mobs can be found exclusively in the Nether, including:
|
||||
Ghasts: flying mobs that shoot exploding fireballs at the player.
|
||||
Zombified piglins: wield golden swords and attack in hordes if provoked.
|
||||
Wither skeletons: tall, black variants of regular skeletons that wield stone swords and drop coal and, occasionally, wither skeleton skulls that
|
||||
can be used to summon the wither.
|
||||
Blazes: shoot fireballs at players and hover above the ground.
|
||||
Magma cubes: similar to Overworld slimes.
|
||||
The End contains the ender dragon, which is the main boss mob in Minecraft and allows the player to exit back to the Overworld when it dies.
|
||||
Withers are the second boss mob in Minecraft, and are created by the player by placing wither skeleton skulls on top of soul sand in a specific pattern.
|
||||
When spawned, they shoot wither skulls at nearby non-undead mobs.
|
||||
|
||||
The Nether.
|
||||
The Nether is a dimension in Minecraft, accessible from the Overworld by a nether portal. It consists of five biomes, those being the Nether Wastes,
|
||||
the Basalt Deltas, the Crimson and Warped Forests and the Soul Sand Valleys: each biome has unique generation and terrain.
|
||||
It is populated by zombified piglins, blazes, ghasts, wither skeletons, magma cubes, piglins and hoglins.
|
||||
|
||||
The End.
|
||||
The End is another dimension of the game where the player battles the ender dragon. The End is accessible by entering an end portal found in a stronghold.
|
||||
The End is composed of end stone and is inhabited by endermen. It also contains tall obsidian pillars on top of which are end crystals that heal the ender dragon.
|
||||
Once the ender dragon is slain, the exit portal is created in the center of the map, and an end gateway portal is created near an edge of the map,
|
||||
which transports the player to the expansive outer end islands.
|
||||
|
||||
Multiplayer.
|
||||
Minecraft multiplayer servers have developed to include their own rules and customs, guided by their administrators and moderators.
|
||||
The term griefer, meaning a player who causes grief, is a typical term on the Internet but has taken up its definition on Minecraft servers: a person who destroys
|
||||
or defiles other users' creations on servers. Griefers are the reason many server administrators make rules, but this has been taken a step further with modifications
|
||||
to the Minecraft server and even plugin-based replacement servers such as Bukkit. Because of these plugin-based servers, new user-created features have shown
|
||||
up in Minecraft. This includes features like money, vehicles, protection, RPG elements and more. These features normally do not require modification to a user's
|
||||
client and can be accessed by using chat commands. With the default controls, the chat screen is brought up by pressing T.
|
||||
One popular game on multiplayer servers is Spleef (a play on the word grief), a game where the player aims to make another player drop through the floor
|
||||
by destroying blocks beneath the opponent's feet. This is typically played in a designated area and is usually run automatically using server plugins.
|
||||
Many popular multiplayer servers exist that may contain custom minigames or large Survival or Creative worlds.
|
|
@ -50,41 +50,50 @@ def load_data(directory, max_size):
|
|||
for chunk in text_chunks:
|
||||
print(f'{len(chunk.split())} - {chunk}')
|
||||
|
||||
print('-----------------------------')
|
||||
|
||||
return text_chunks
|
||||
|
||||
qa_url = "http://34.72.18.118/qa_api"
|
||||
def extractive_qa(question, content):
|
||||
payload = f'{{ \
|
||||
"question": "{question}", \
|
||||
"input_context": "{content}" \
|
||||
}}'
|
||||
|
||||
def extractive_qa(question, context):
|
||||
'''
|
||||
Uses Extractive QA server.
|
||||
Input: question and context
|
||||
Response: short span with the answer and full sentence that contains this span or 'Not found'
|
||||
'''
|
||||
url = "http://35.193.226.52:9000/longformqa"
|
||||
payload = (
|
||||
f'{{\r\n"question": "{question}",\r\n\"context\": "{context}",\r\n'
|
||||
f'"maxLength": 128,\r\n"minLength": 1,\r\n "numBeams": 8\r\n}}'
|
||||
)
|
||||
headers = {
|
||||
'Content-Type': "application/json",
|
||||
'User-Agent': "PostmanRuntime/7.18.0",
|
||||
'Accept': "*/*",
|
||||
'Cache-Control': "no-cache",
|
||||
'Postman-Token': "30549445-ea95-416a-bd74-8ab14ad2036d,0dd97345-55e6-4517-970c-f7032bd1a0d3",
|
||||
'Host': "35.193.226.52:9000",
|
||||
'Accept-Encoding': "gzip, deflate",
|
||||
'Content-Length': "1513",
|
||||
'Connection': "keep-alive",
|
||||
'cache-control': "no-cache",
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
|
||||
print(payload)
|
||||
response = requests.request("POST", url, data=payload, headers=headers)
|
||||
if response.ok == True:
|
||||
print(response.text)
|
||||
response_dict = json.loads(response.text)
|
||||
return (response_dict['result_eqa'], response_dict['context'])
|
||||
response = requests.request("POST", qa_url, headers=headers, data=payload)
|
||||
# print(response.text.encode('utf8'))
|
||||
response_dict = json.loads(response.text)
|
||||
|
||||
if response_dict['result']:
|
||||
#print(response_dict['result'])
|
||||
return (response_dict['result'], response_dict['context'])
|
||||
else:
|
||||
#print("Answer not found in the context")
|
||||
return ('Not found', 'Not found')
|
||||
|
||||
|
||||
qa_url = "http://34.72.18.118/gen_qa"
|
||||
def answer_extender(question, content):
|
||||
payload = f'{{ \
|
||||
"question": "{question}", \
|
||||
"input_context": "{content}" \
|
||||
}}'
|
||||
|
||||
headers = {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
|
||||
response = requests.request("POST", qa_url, headers=headers, data=payload)
|
||||
response_dict = json.loads(response.text)
|
||||
|
||||
if response_dict['result']:
|
||||
return (response_dict['result'], response_dict['context'])
|
||||
else:
|
||||
print("Answer not found in the context")
|
||||
return ('Not found', 'Not found')
|
||||
|
||||
|
||||
|
|
|
@ -38,33 +38,32 @@ def load_models():
|
|||
|
||||
@st.cache(allow_output_mutation=True)
|
||||
def load_indexes(qar_model, qar_tokenizer):
|
||||
marvel_snippets = load_data("/home/vgetselevich/data/marvel/wiki/", 100)
|
||||
snippets = load_data("/home/vgetselevich/data/minecraft/", 100)
|
||||
|
||||
# prepare IR index
|
||||
if not os.path.isfile('marvel_passages_reps_32_l-8_h-768_b-512-512.dat'):
|
||||
if not os.path.isfile('minecraft_passages_reps_32_l-8_h-768_b-512-512.dat'):
|
||||
print("*** Generating dense index ***")
|
||||
make_qa_dense_index_text_chunks(
|
||||
qar_model,
|
||||
qar_tokenizer,
|
||||
# wiki40b_snippets,
|
||||
marvel_snippets,
|
||||
snippets,
|
||||
device='cuda:0',
|
||||
index_name='marvel_passages_reps_32_l-8_h-768_b-512-512.dat',
|
||||
index_name='minecraft_passages_reps_32_l-8_h-768_b-512-512.dat',
|
||||
)
|
||||
|
||||
faiss_res = faiss.StandardGpuResources()
|
||||
# wiki40b_passages = nlp.load_dataset(path="wiki_snippets", name="wiki40b_en_100_0")["train"]
|
||||
marvel_passage_reps = np.memmap(
|
||||
"marvel_passages_reps_32_l-8_h-768_b-512-512.dat",
|
||||
"minecraft_passages_reps_32_l-8_h-768_b-512-512.dat",
|
||||
dtype="float32",
|
||||
mode="r",
|
||||
shape=(len(marvel_snippets), 128),
|
||||
shape=(len(snippets), 128),
|
||||
)
|
||||
wiki40b_index_flat = faiss.IndexFlatIP(128)
|
||||
wiki40b_gpu_index_flat = faiss.index_cpu_to_gpu(faiss_res, 1, wiki40b_index_flat)
|
||||
wiki40b_gpu_index_flat.add(marvel_passage_reps) # TODO fix for larger GPU
|
||||
|
||||
return (marvel_snippets, wiki40b_gpu_index_flat)
|
||||
return (snippets, wiki40b_gpu_index_flat)
|
||||
|
||||
|
||||
qar_tokenizer, qar_model, s2s_tokenizer, s2s_model = load_models()
|
||||
|
@ -111,21 +110,21 @@ def answer_question(
|
|||
return (answer, support_list)
|
||||
|
||||
|
||||
st.title("Marvel Universe Question Answering")
|
||||
st.title("Minecraft Question Answering")
|
||||
|
||||
# Start sidebar
|
||||
# header_html = "<img src='https://huggingface.co/front/assets/huggingface_logo.svg'>"
|
||||
# header_html = "<img src='iron_man.png'>"
|
||||
header_html = "<img width='150' height='200' src='https://vignette.wikia.nocookie.net/marvelcinematicuniverse/images/f/f2/Iron_Man_Armor_-_Mark_LXXXV.png/revision/latest/top-crop/width/360/height/450?cb=20190401222437'>"
|
||||
header_html = "<img width='200' height='150' src='https://cdn.vox-cdn.com/thumbor/auxLh0jMJyEywGb5SyA02trm6ag=/1400x1400/filters:format(jpeg)/cdn.vox-cdn.com/uploads/chorus_asset/file/4093800/image.0.jpg'>"
|
||||
|
||||
header_full = """
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
.img-container {
|
||||
padding-left: 70px;
|
||||
padding-right: 70px;
|
||||
padding-top: 50px;
|
||||
padding-bottom: 50px;
|
||||
padding-left: 50px;
|
||||
padding-right: 100px;
|
||||
padding-top: 100px;
|
||||
padding-bottom: 100px;
|
||||
background-color: #f0f3f9;
|
||||
}
|
||||
</style>
|
||||
|
@ -143,11 +142,11 @@ st.sidebar.markdown(
|
|||
header_full, unsafe_allow_html=True,
|
||||
)
|
||||
|
||||
# Generative QA on Marvel Universe
|
||||
# Generative QA on Minecraft data
|
||||
description = """
|
||||
---
|
||||
This demo presents generative and extractive answers to Marvel Universe content questions.
|
||||
First dense IR model fetches a set of relevant snippets from Marvel wiki docs given the question,
|
||||
This demo presents generative and extractive answers to Minecraft content questions.
|
||||
First dense IR model fetches a set of relevant snippets from Minecraft wiki docs given the question,
|
||||
and then Bart model use them as a context to generate and answer and
|
||||
extractive QA model creates an alternative answer.
|
||||
"""
|
||||
|
@ -222,9 +221,9 @@ if generate_options:
|
|||
# start main text
|
||||
questions_list = [
|
||||
"<MY QUESTION>",
|
||||
"Who is iron man?",
|
||||
"who is Tony Stark?",
|
||||
"who directed iron man?",
|
||||
"what is minecraft?",
|
||||
"who created minecraft game?",
|
||||
"which modes minecraft game has?",
|
||||
]
|
||||
question_s = st.selectbox(
|
||||
"What would you like to ask? ---- select <MY QUESTION> to enter a new query", questions_list, index=1,
|
||||
|
@ -237,8 +236,8 @@ else:
|
|||
if st.button("Show me!"):
|
||||
if action in [0, 1, 3]:
|
||||
if index_type == "mixed":
|
||||
_, support_list_dense = make_support(question, source=wiki_source, method="dense", n_results=10)
|
||||
_, support_list_sparse = make_support(question, source=wiki_source, method="sparse", n_results=10)
|
||||
_, support_list_dense = make_support(question, source=wiki_source, method="dense", n_results=5)
|
||||
_, support_list_sparse = make_support(question, source=wiki_source, method="sparse", n_results=5)
|
||||
support_list = []
|
||||
for res_d, res_s in zip(support_list_dense, support_list_sparse):
|
||||
if tuple(res_d) not in support_list:
|
||||
|
@ -248,7 +247,7 @@ if st.button("Show me!"):
|
|||
support_list = support_list[:10]
|
||||
question_doc = "<P> " + " <P> ".join([res[-1] for res in support_list])
|
||||
else:
|
||||
question_doc, support_list = make_support(question, source=wiki_source, method=index_type, n_results=10)
|
||||
question_doc, support_list = make_support(question, source=wiki_source, method=index_type, n_results=5)
|
||||
if action in [0, 3]:
|
||||
# Geenerative QA
|
||||
answer, support_list = answer_question(
|
||||
|
@ -263,17 +262,17 @@ if st.button("Show me!"):
|
|||
temp=temp,
|
||||
)
|
||||
|
||||
# Extractive QA
|
||||
ex_answer_span, ex_answer_sent = extractive_qa(question, question_doc.replace("<P> ", ""))
|
||||
|
||||
st.markdown("### The model generated answer is:")
|
||||
st.markdown("### The Generative Answer is:")
|
||||
st.write(answer)
|
||||
|
||||
st.markdown("### The model extractive answer is:")
|
||||
st.write(ex_answer_span + " - " + ex_answer_sent)
|
||||
# Extractive QA
|
||||
ex_answer_span, ex_answer_context = extractive_qa(question, question_doc.replace("<P> ", ""))
|
||||
|
||||
st.markdown("### The Extractive Answer is:")
|
||||
st.write(ex_answer_span)
|
||||
|
||||
if action in [0, 1, 3] and wiki_source != "none":
|
||||
st.markdown("--- \n ### The model is drawing information from the following Marvel snippets:")
|
||||
st.markdown("--- \n ### The model is drawing information from the following Minecraft snippets:")
|
||||
for i, res in enumerate(support_list):
|
||||
wiki_url = "https://en.wikipedia.org/wiki/{}".format(res[0].replace(" ", "_"))
|
||||
sec_titles = res[1].strip()
|
||||
|
|
116
examples/nlp/conditional_generation/server.py
Normal file
116
examples/nlp/conditional_generation/server.py
Normal file
|
@ -0,0 +1,116 @@
|
|||
from lfqa_utils import *
|
||||
import socket
|
||||
|
||||
HOST = '10.110.42.102'
|
||||
PORT = 25556
|
||||
|
||||
|
||||
def load_models():
|
||||
qar_tokenizer = AutoTokenizer.from_pretrained("yjernite/retribert-base-uncased")
|
||||
qar_model = AutoModel.from_pretrained("yjernite/retribert-base-uncased").to("cuda:0")
|
||||
_ = qar_model.eval()
|
||||
|
||||
s2s_tokenizer = AutoTokenizer.from_pretrained("yjernite/bart_eli5")
|
||||
s2s_model = AutoModelForSeq2SeqLM.from_pretrained("yjernite/bart_eli5").to("cuda:0")
|
||||
# save_dict = torch.load("seq2seq_models/eli5_bart_model_blm_2.pth")
|
||||
# s2s_model.load_state_dict(save_dict["model"])
|
||||
_ = s2s_model.eval()
|
||||
|
||||
return (qar_tokenizer, qar_model, s2s_tokenizer, s2s_model)
|
||||
|
||||
|
||||
def load_indexes(qar_model, qar_tokenizer):
|
||||
snippets = load_data("/home/vgetselevich/data/minecraft/", 100)
|
||||
|
||||
# prepare IR index
|
||||
if not os.path.isfile('minecraft_passages_reps_32_l-8_h-768_b-512-512.dat'):
|
||||
print("*** Generating dense index ***")
|
||||
make_qa_dense_index_text_chunks(
|
||||
qar_model,
|
||||
qar_tokenizer,
|
||||
snippets,
|
||||
device='cuda:0',
|
||||
index_name='minecraft_passages_reps_32_l-8_h-768_b-512-512.dat',
|
||||
)
|
||||
|
||||
faiss_res = faiss.StandardGpuResources()
|
||||
# wiki40b_passages = nlp.load_dataset(path="wiki_snippets", name="wiki40b_en_100_0")["train"]
|
||||
passage_reps = np.memmap(
|
||||
"minecraft_passages_reps_32_l-8_h-768_b-512-512.dat",
|
||||
dtype="float32",
|
||||
mode="r",
|
||||
shape=(len(snippets), 128),
|
||||
)
|
||||
wiki40b_index_flat = faiss.IndexFlatIP(128)
|
||||
wiki40b_gpu_index_flat = faiss.index_cpu_to_gpu(faiss_res, 1, wiki40b_index_flat)
|
||||
wiki40b_gpu_index_flat.add(passage_reps) # TODO fix for larger GPU
|
||||
|
||||
return (snippets, wiki40b_gpu_index_flat)
|
||||
|
||||
|
||||
def get_answer(question, qar_tokenizer, qar_model, qa_s2s_tokenizer, qa_s2s_model, snippets, gpu_dense_index, use_eqa=True):
|
||||
# create support document with the dense index
|
||||
doc, res_list = query_qa_dense_index(
|
||||
question, qar_model, qar_tokenizer, snippets, gpu_dense_index, n_results=5, device='cuda:0'
|
||||
)
|
||||
# concatenate question and support document into BART input
|
||||
question_doc = "question: {} context: {}".format(question, doc)
|
||||
# generate an answer with beam search
|
||||
gen_answer = qa_s2s_generate(
|
||||
question_doc,
|
||||
qa_s2s_model,
|
||||
qa_s2s_tokenizer,
|
||||
num_answers=1,
|
||||
num_beams=8,
|
||||
min_len=10,
|
||||
max_len=50,
|
||||
max_input_length=1024,
|
||||
device="cuda:0",
|
||||
)[0]
|
||||
|
||||
print(question)
|
||||
print("Generative Answer: " + gen_answer)
|
||||
print("Context: " + doc.replace("<P> ", ""))
|
||||
|
||||
ex_answer_span = ''
|
||||
|
||||
if use_eqa:
|
||||
ex_answer_span, ex_answer_context = extractive_qa(question, doc.replace("<P> ", ""))
|
||||
print("Extractive Answer: " + ex_answer_span)
|
||||
|
||||
return (gen_answer, ex_answer_span)
|
||||
|
||||
|
||||
def main():
|
||||
qar_tokenizer, qar_model, qa_s2s_tokenizer, qa_s2s_model = load_models()
|
||||
snippets, gpu_dense_index = load_indexes(qar_model, qar_tokenizer)
|
||||
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.bind((HOST, PORT))
|
||||
|
||||
print(f"IR + QA server is running on: {HOST}:{PORT}")
|
||||
s.listen()
|
||||
|
||||
while True:
|
||||
conn, addr = s.accept()
|
||||
with conn:
|
||||
print('Connected by', addr)
|
||||
while True:
|
||||
data = conn.recv(1024).decode()
|
||||
if not data:
|
||||
break
|
||||
|
||||
gen_answer, ex_answer_span = get_answer(data, qar_tokenizer, qar_model, qa_s2s_tokenizer,
|
||||
qa_s2s_model, snippets, gpu_dense_index, use_eqa=False)
|
||||
if ex_answer_span:
|
||||
conn.sendall(ex_answer_span.encode('utf-8'))
|
||||
else:
|
||||
conn.sendall(gen_answer.encode('utf-8'))
|
||||
|
||||
# response = f'Extractive: {ex_answer_span} Generative: {gen_answer}'
|
||||
# conn.sendall(response.encode('utf-8'))
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in a new issue