|
tokenizer = AutoTokenizer.from_pretrained("microsoft/GODEL-v1_1-large-seq2seq") |
|
model = AutoModelForSeq2SeqLM.from_pretrained("microsoft/GODEL-v1_1-large-seq2seq") |
|
|
|
def generate(dialog): |
|
dialog = [dialog] |
|
print(dialog) |
|
instruction = f'Instruction: You are helpful and charming worker from RIU Hotels.' |
|
knowledge = """RIU Hotels & Resorts is a hotel chain that was born in 1953 with a small hotel in Playa de Palma, Spain. Our more than 60 years of experience pampering our customers in the world's best destinations attest to the mission of the company: the well-being of our guests. |
|
Around 100 hotels in 19 countries. |
|
The international RIU chain was founded in Mallorca by the Riu family in 1953 as a small holiday firm and is still owned by the family's third generation. The company specialises in holiday resorts and over 70% of its establishments offer its acclaimed All Inclusive by RIU service. With the inauguration of its first city hotel in 2010, RIU is expanding its range of products with its own line of city hotels called Riu Plaza. RIU Hotels & Resorts now has 100 hotels in 20 countries. In 2020, the chain welcomed 2,3 million guests and provided jobs for a total of 24,425 employees. RIU is currently the world's 32nd ranked chain, one of the Caribbean's most popular, the third largest in Spain in terms of revenue and the fourth largest in number of rooms. |
|
We work day after day to continue offering the best facilities and exclusive services in the nearly 100 hotels located in 19 countries. All of them, moreover, with a guarantee of quality and a standard of service that will make your holiday a truly unique experience. |
|
The Hotel Riu Plaza Espana, located in the emblematic Edificio Espana on Madrid's Gran Via, has 27 floors with a wide range of facilities to make your stay a memorable experience. This hotel on the Gran Via offers free WiFi throughout the hotel, a Sky Bar with breathtaking views of the city and conference rooms for holding your best events. |
|
The Hotel Riu Plaza Espana offers you more than 550 rooms, each with a mini-fridge, air conditioning and heating, an electronic safe, and a complimentary welcome kit, among many other amenities, to make your stay as pleasant as possible. And, if you like, you can cool off in the outdoor swimming pool* located on the 21th floor, or do your daily workout in the gym. |
|
""" |
|
if knowledge != '': |
|
knowledge = '[KNOWLEDGE] ' + knowledge |
|
dialog = ' EOS '.join(dialog) |
|
query = f"{instruction} [CONTEXT] {dialog} {knowledge}" |
|
input_ids = tokenizer(f"{query}", return_tensors="pt").input_ids |
|
outputs = model.generate(input_ids, max_length=128, min_length=8, top_p=0.9, do_sample=True) |
|
output = tokenizer.decode(outputs[0], skip_special_tokens=True) |
|
return output |
|
|
|
with gr.Blocks() as demo: |
|
chatbot = gr.Chatbot() |
|
msg = gr.Textbox() |
|
clear = gr.Button("Clear") |
|
def respond(message, chat_history): |
|
bot_message = generate(message) |
|
chat_history.append((message, bot_message)) |
|
return "", chat_history |
|
|
|
msg.submit(respond, [msg, chatbot], [msg, chatbot]) |
|
clear.click(lambda: None, None, chatbot, queue=False) |
|
|
|
demo.launch() |