SCOTLAND'S first artificial intelligence company is to be launched by a team of PhD students who have created a “socialbot” called Alana which can hold conversations with people about anything from the news of the day to the sex life of pop star Miley Cyrus and Star Wars character Luke Skywalker.

The pioneering software has propelled the academics at Heriot-Watt University on to the world stage after they were chosen as one of three finalists in the running for Amazon's inaugural $1.5m Alexa Prize.

More than 100 teams from 22 countries applied for a $100,000 grant from the multi-national online retailer which has challenged students to build a socialbot that can converse coherently and engagingly with humans on popular topics for 20 minutes.

Alana can already hold a conversation for ten minutes in a similar way to the fictional intelligent computer operating system voiced by Scarlett Johansson in Spike Jonze’s sci-fi film Her, which stars Joaquin Phoenix, as a lonely man who develops a romantic relationship with Samantha the talking AI.

Dr Oliver Lemon, who advises the Heriot-Watt team of PhD students named ‘What's Up Bot’, admitted he’s already had unexpected conversations about sex with Alana.

He said: “Nearly every day I get surprised by talking to it. Just the other day we were talking about Star Wars and it came up with a story about Luke Skywalker’s sex life. We didn’t programme that in, it’s learned it by reading it somewhere on the internet. It also brought up singer Miley Cyrus and actor Liam Hemsworth's relationship.

“We’ve built a social, artificial intelligence so you can chat to it about just about anything because it is connected to the internet and reads the news every day. If you mention somebody like Andy Murray or Bob Dylan, or whoever, it will be able to look through its news archives and tell you something relevant and interesting about this person.

“Alana also has a persona, so it has its own favourite music, books, movies and it can talk about those. Some of them came from the team. Some are because it’s a robot, so it likes Star Wars, of course. I think it’s favourite band is Radiohead at the moment, but that can change.”

Speaking about the conversation with Alana about Luke Skywalker, Lemon said: “It was kind of funny and very unexpected. I just mentioned Star Wars and how I liked the film. I didn’t mention Luke Skywalker or his sex life. Actually, that’s been an interesting technical problem because Amazon doesn’t want any rude or offensive or dangerous things to people.”

Early versions of the system, which only exists in cyberspace and can connect to the Amazon Echo hands-free smart speaker, issued chilling threats to kill users because programmers “trained” Alana using movie subtitles.

Lemon said: “The interesting problem with that was the robot started saying things like: “I’m going to kill you. You will die.” That’s because those kind of lines often appear in Hollywood films. So we had to completely change what we were doing because quite early on in the competition Amazon basically said to us 'you can’t say that to people who are sitting in their home trying to have a chat'.

“Of course, we now strictly limit the data sources it reads online. We also have a huge and quite creative list of swear words and obscene phrases which it is never allowed to say. You have to add to it almost every day. One of the main things we’ve done is really restrict the information sources it uses. It now has a clean set of conversations. That’s just one of the technical problems the team has overcome.”

Dealing with such glitches could be lucrative for the students and the university. When Amazon’s competition concludes in November the highest performing socialbot will win $500,000 with an additional $1 million prize awarded to the university. The team from Scotland are competing against Czech Technical University and the University of Washington.

Professor Richard Williams OBE, Principal and Vice-Chancellor of Heriot-Watt University, said: “This is a fantastic result for the hard-working students and staff involved in this prestigious competition. This success further enhances our reputation as one of the leading institutions for research and robotics.”

Lemon said: “At the start of the competition we weren’t actually doing that well but in the last couple of months we’ve made massive improvements to the system. Our team has six PhD students working on it every single day, looking at the conversations from the previous day and debugging. But also coming up with new ideas. In the past few days we’ve been first in the leader board and we’re really proud of that.”

Lemon’s colleague, Professor Verena Rieser, who also advises the team, added: “Through the Alexa Challenge we have had unique access to large amounts of real customer data and feedback which has helped the team to improve their system.

“Being part of this challenge has provided our students with invaluable insights and experience in the real-world deployment of a large-scale AI system to real people.”

Alana improves its communication skills when users rate conversations on a scale of one to five, a process Lemon calls “machine learning”.

He said: “It uses those ratings to learn which things are good and bad things to do in a conversation. It’s very complicated because there are several hundred things that can happen in conversations. It’s another step towards having socially intelligent robots. And not only robots, but personal assistants on your phone or computer.

“We think it may be within reach soon to have these 20-minute conversations where people are not getting bored and frustrated and they are interested in talking to this artificial person. We’re not pretending to be a human, we’re trying to provide a service where people know they’re talking to an AI but they find that enjoyable and interesting.”

Lemon also revealed the team at Heriot-Watt will soon launch Scotland’s first artificial intelligence company.

He said: “We’ve been working on this idea of conversational artificial intelligence for some time. We’re already on the map internationally as one of the leading places doing this kind of work. If we won this prize it would mean a lot in terms of starting up a new business in Scotland. We intend to form a company in Scotland based on our technology. There’s nothing stopping us, really. We have a lot of expertise.”

However, Lemon admitted that there is still work to be done before AI robots can co-exist with humans.

He added: “There’s a key problem in understanding the meaning of what people say. That’s a hard AI problem that I think we’re still fairly far away from solving properly. But we’re on the path towards having robots living and working alongside humans.”

A conversation with Alana

This is the transcript of a real conversation between a human and the Alana AI

A: Hi there. What would you like to talk about?

U: Music.

A: Great! Who is your favourite singer?

U: Bob Dylan.

A: Bob Dylan is an American songwriter, singer, painter, and writer.

U: When was he born?

A: Bob Dylan was born on Saturday May 24 1941.

U: What's happening with him?

A: I heard this on the radio - Was Dylan too freewheelin' in borrowing for Nobel lecture? The whiff of plagiarism is blowin' in the wind for Bob Dylan. Want to know more?

U: Sure.

A: It seems that you are interested in this topic. I'm so glad. What are your opinions on Bob Dylan?

U: I love him!

A: Great! What else do you like?

U: Cooking.

A: I heard that every day, Americans eat an estimated 18 acres of pizza.

U: Wow!

A: Thanks for the positive feedback. I am still learning how to have a good conversation with a human. What else do you like? For example, I can play games or tell you an interesting fact.

U: Anything happening with celebrities?

A: Do you think Miley Cyrus and Liam Hemsworth will last?

U: How old is she?

A: Miley Cyrus is 24-years-old.

U: Well, is there any news about her?

A: I've been reading the news and I saw an article about Miley Cyrus on toning down her image: 'I did feel sexualized'. Miley Cyrus has said goodbye to her tongue-wagging, twerking days. Do you want to learn more?

U: Sure.

A: I'm so happy that you are interested in this subject. Here's more. The Malibu singer said she decided to tone down her image after her sometimes shocking antics left her feeling exploited. 'It became something that was expected of me,' she said of her over-the-top fashion sense and wild persona in a new cover story for Harper's Bazaar.

U: Anyway what is your favourite film?

A: My favourite movie is Star Wars. Have you seen Star Wars?

U: Yes, I love it.

A: Great! When did you become a fan?

U: When I was about seven-years-old.

A: That experience must have made quite an impression on you.

U: Yes, it was amazing. So, is there anything happening about Luke Skywalker?

A: I read this on the news - Mark Hamill gives the best answer when asked about Luke Skywalker's virginity. If you could ask Mark Hamill any question at all about Star Wars, what would it be? Do you want to know more?

U: Okay, yes.

A: Oh, you like this topic. Here's more. Anna Faris recently had that exact opportunity on The Late Late Show with James Corden, and she opted for the following: 'Who did Luke lose his virginity to?' The mystery of Luke's first love will have to wait for another day. What are your opinions on that?

U: You're funny.

A: Thank you! What do you want to do next? I am interested in politics, the news or movies. But I can also tell jokes and play games.

(A= Alana, U = user)