Tag Archives: ml

Sentence Gradients with Neural Networks

Peter in his blog pointed to a fascinating posting by Robin Sloan about ‘sentence gradients’. His posting describes how he created a tool that make gradients out of text, much like the color gradients we know. It uses neural networks (neuronal networks we called them when I was at university). Neural networks, in other words machine learning, are used to represent texts as numbers (color gradients can be numbers e.g., on just one dimension. If you keep adding dimensions you can represent things that branch off in multiple directions as numbers too.) Sentences are more complex to represent numerically but if you can then it is possible, just like with colors, to find sentences that are numerically between a starting sentence and an ending sentence. Robin Sloan demonstrates the code for it in his blog (go there and try it!), and it creates fascinating results.

Mostly the results are fascinating I think because our minds are hardwired to determine meaning. So when we see a list of sentences we want, we need, we very much need, to find the intended meaning that turns that list into a text.

I immediately thought of other texts that are sometimes harder to fully grasp, but where you know or assume there must be deeper meaning: poems.

So I took a random poem from one of Elmine’s books, and entered the first and last sentence into the tool to make a sentence gradient.

The result was:

I think it is a marvellous coincidence that the word Ceremony comes up.
The original poem is by Thomas Hardy, and titled ‘Without Ceremony’. (Hardy died in 1928, so the poem is in the public domain and can be shown below)

Without Ceremony

It was your way, my dear,
To vanish without a word
When callers, friends, or kin
Had left, and I hastened in
To rejoin you, as I inferred.

And when you’d a mind to career
Off anywhere – say to town –
Your were all on a sudden gone
Before I had thought thereon
Or noticed your trunks were down.

So, now that you disappear
For ever in that swift style,
Your meaning seems to me
Just as it used to be:
‘Good-bye is not worth wile’