File size: 4,565 Bytes
6e1d723
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline

model_name = "deepset/roberta-base-squad2"

question = input("Your question: ")

context = "Similar to London's Oyster card or New York City's Metrocard, the Nol card is a rechargeable ticket that you can top up and gives you cheaper fares. Nol cards can also be used to pay for fares on other forms of public transportation in the city, including buses, trams and taxis. There are several ticket options available, although tourists usually opt for the Silver Nol card that can be preloaded with up to AED1,000 in credit – ideal if you plan on regularly using public transport during your stay in Dubai. You can purchase a one-time train ticket or Nol card at all Dubai Metro stations, bus stations, and at supermarkets such as Carrefour, Spinneys and Waitrose. To top-up your Nol card, use the vending machines or make your way to the ticket booths at each metro station. The metro system is divided into seven zones across the city, and fares are calculated based on the number of zones passed. The Dubai Metro system currently consists of two lines – Red and Green. The Red line starts from Centrepoint (formerly Rashidiya) station, close to Dubai International airport. This line essentially travels along the city's main highway Sheikh Zayed Road, with stops at key attractions and neighbourhoods, such as Burj Khalifa, The Dubai Mall, Business Bay, Jumeirah Lakes Towers (DMCC station), Dubai Marina (Sobha Realty station) and Mall of the Emirates. At Jabal Ali station, the Red line branches out in two directions – if you are going to Expo City Dubai you can stay on the train and it will continue to your destination. But, if you are looking to go towards Ibn Battuta Mall, you will need to switch trains at Jabal Ali station. The Red line ends at UAE Exchange station, just past the Jebel Ali Industrial Area. The Green line travels from the Etisalat station in the Al Twar area to the historic Dubai Creek. On this line, you can visit cultural highlights such as Al Fahidi Historical Neighbourhood, Deira and the gold and spice souks. The Dubai Metro runs seven days a week, and metro stations are open Monday to Thursday from 5am to 12midnight, Friday from 5am to 1am next day, Saturday from 5am to 12midnight and Sunday from 8am to 12midnight. Tram stations are open Monday to Saturday from 6am to 1am next day and Sunday from 9am to 1am next day. Keep in mind that the first and last train times vary for each station, and metro operating hours can also change during public holidays. Trains run frequently on both lines – usually every four minutes during peak hours, and seven minutes at off-peak times. There are three types of cabins in Dubai Metro trains – Gold, Silver and the Women and Children's cabins. The Gold Class cabins are spacious with plush leather seats and panoramic views. If you want to travel in these cabins, you must purchase the class-specific ticket. These can be easily purchased from the ticket booths. The other areas of the train are dedicated to either silver (or standard) commuters, or for women and children. Dubai Metro trains provide dedicated cabins for women and children, featuring extra space for push-chairs. They are clearly identified with pink signs along station tracks and inside cabins. There's no obligation for female passengers to travel in these sections of the train. They're simply offered as an alternative for additional comfort. people of determination will find convenient lift access available on all metro station levels, and dedicated spaces for wheelchair users on all trains. additional advices for first-time commuters, Trains and stations can be crowded during peak hours, so avoid these times if possible 6am to 8:30am and 5pm to 7pm, If travelling during peak hours, it's worth paying extra to access the Gold class cabins, Eating or drinking is not allowed in in the Dubai Metro cabins, Dubai Metro stations are often named after nearby landmarks, neighbourhoods and even financial institutions. Ask your hotel concierge to recommend the right stops, There's free Wi-Fi on trains, so you can stay connected all through your journey"

# a) Get predictions
nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
QA_input = {
    'question': question,'context': context}
res = nlp(QA_input)
print("Answer: " +res['answer'])
# b) Load model & tokenizer
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)