Friday, 17 August 2018

An AI writes Doctor Who

So I trained a neural network (it's not really much of an artificial "intelligence", as this post will demonstate) on the entire collection of Hartnell-era Doctor Who scripts. This network was set to use whole words - some only use characters. Very simply, the network tries to follow words with other words which it thinks are likely to be in that position, based on what it 'knows' about the order words appear in the training text. Rinse and repeat.

As the system trains it gets better at putting words in order, but still makes some weird choices:

These files have been edited for clarity, capitalisation, line breaks and so on, but not actual content - that's all from the softwatre.

-------------------------------------

 [ outside the TARDIS ]

(The Doctor is trying to confuse them)

DOCTOR: Oh, it's very kind of you.
BARBARA: Oh, Doctor, what's wrong?
DOCTOR: Oh, it's a huge, isn't it?
IAN: Yes.
DOCTOR: Oh, my dear, I'm sure you're going to be right.
IAN: All right, Doctor, I've got to go and find out.
DOCTOR: Yes, I think we'll go back to the ship.
IAN: Yes, I think we'll go back.
DOCTOR: Yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes. yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes. yes, yes, yes.

 [ laboratory ]

 (The Doctor and Ian are examining their fire)


-------------------------------------

After more training cycles, called "epochs", it starts to make some more sense. Only some. And only for a given value of 'sense'.

In addition, there's a variable during text generation called "temperature", which can be thought of as 'weirdness' - not enough weird and the system loops repeatedly over things that feel 'normal' to it (see the repeated 'yes, yes, yes, yes' above. Too much weirdness and it gets really weird. But if you balance the weirdness just right, that's when you start to get text which sounds much more 'right'

As a general rule the first third of each file linked here is temperature 0.2, which isn't very weird. The middle third is 0.5, which is usually close to the sweet spot and the last third 1.0 which is where it gets very odd. See if you can tell when the temperature changes mid document!

-------------------------------------

DOCTOR: Yes, yes, I think you'd better go back to the TARDIS.
STEVEN: Oh, Doctor, I thought you were going to make her a way.
DOCTOR: Oh, dear, dear, dear, dear, dear, dear, dear, dear. I'm going to have to try out my minds.

[ warriors hall ]

DOCTOR: I'm afraid I'm not quite sure, dear boy. it's quite all right. I'm coming with you.
IAN: What?
DOCTOR: Well, I think the DALEKs are doing the best of us.
SUSAN: Oh, it's the only way out of the lift.

(he goes back to the TARDIS)

IAN: It's all right, Susan. it's all right.
SUSAN: It's all right.

(Barbara on her bed, and she enters the shop)

SUSAN: She's all right.
IAN: Yes, I think I'll do it.
SUSAN: Oh, no, I'll have to forgive you.

More here

-------------------------------------

A couple of training epochs later....

-------------------------------------


(The Doctor and Vicki enter)

BARBARA: We'd really need him.
DOCTOR: Yes, I suppose so. it's quite simple. yes, it's a matter of what you can do about that.
IAN: Well, what do we do now?
DOCTOR: Well, I'm trying to solve this problem, but we'll promise you, will you?

(Barbara takes the tray before, backs into the room, into a glass torpedo. Vasar's hut. A clearing, Ian stops, and a girl gets inside. Vasar bolts. The door comes out, Ian.)

IAN: Vasar!
VASAR: Right.

(Ian crosses to the Barbara over)

IAN: Vasar!

(the door opens)

IAN: Susan!

(Barbara and Susan leave)

IAN: Barbara! Susan!

(Barbara gets and Susan shut up)

DOCTOR: Barbara!
SUSAN: Grandfather!
BARBARA: Susan!
SUSAN: Why?
DOCTOR: No, no, no. the DALEKs have brought you here in my ship.
SUSAN: Grandfather!
DOCTOR: Please, stop it!
SUSAN: Grandfather!
DOCTOR: I'm not going to have a look round, child. come along.

(Susan and Barbara go round)

DOCTOR: What's that?

(he notices the TARDIS, smiles.)

DOCTOR: No, no, no, no, no, no, no. no, no. no, no. no, no, no. no, no, no, you'll have to hold it.
SUSAN: Well, why do you not have a look?

More here

-------------------------------------

And the final training run (at least for now, these are very resource intensive and it took 24+ hours to get to epoch 14 on my laptop):

-------------------------------------

(elsewhere, the DALEKs set in the jungle begin to glow and pulse around the end of the bar.)

DALEK: Do you think it's been too late?
SARA: Yes.
DALEK: Do you think of this?
DOCTOR: Yes, I think so.
DALEK[OC]: Exterminate them! exterminate them! exterminate them! exterminate him! zero!

(the DALEKs trundle off, followed by the zombie.)

BRET: All right.
DOCTOR: All right.

(The Doctor and Bret do the DALEKs.)

[ outside the TARDIS ]

BRET: Doctor, I think we should get back to earth.
DOCTOR: Yes, I think so.
STEVEN: It's too late to get down there.
DOCTOR: Yes, well, I suggest we take a look at Maitland.

(the scanner shows the cave of mouth as Steven fires.)

DOCTOR: What do you want?
CHUMBLEY: Four dawns.
DOCTOR: Well, I think we should experiment further on our tracks.
VICKI: Doctor, it's very good.
DOCTOR: Yes, I think it's a very good idea.
VICKI: Look, Doctor, it's possible.
DOCTOR: Oh, indeed, yes, very well.
VICKI: Doctor, you've got to.
DOCTOR: Yes, I see.
DALEK 1: We are expected.

(the capsule's power falls)


Episode four - the DALEKs