Monday, May 22, 2023

Language learning with ChatGPT

Just the other night, I was musing over my unsatisfactory efforts in language learning. Then a moment of inspiration struck: why not put ChatGPT to the task of mimicking a language companion?

I put it to the test with Swedish, a language in which my proficiency only extends to the most rudimentary phrases. Lo and behold, after a bit of trial and error, I found the experience to be quite the linguistic adventure - with the added bonus of having a detailed record of the journey. Handy, eh?

Now, to be fair, this is a beast of a different nature compared to structured learning platforms such as Duolingo and Rosetta Stone, with their arsenal of multimedia aids. But I've always been a fan of diving straight into conversation, even if I initially flounder like a fish out of water. Why, you may ask? Well, because it nudges me to focus, which really speeds up the learning process. That, and the experience of having a conversational partner, which is an absolute memory booster.

My curiosity piqued, I scoured the Internet to see if other brave souls have been utilising ChatGPT as a language partner. It appears to have been employed more often as a kind of interactive Babel Fish. Marvellous and malleable as that may be, it rather resembles the previous breed of translation apps, including Google Translate.

In my humble opinion, the true power of ChatGPT as a language learning aid lies in its ability to help conjure up a more immersive learning environment. It's not perfect, obviously, and you have to put in the effort. But that is sort of part of the point. Want to learn Greenlandic whilst trudging through a simulated icy tundra? Now you can (probably). The sky's the limit - or rather, your imagination is.

Below is my interaction thus far:

Me:


Pretend that you are teaching me Swedish. My name is Auguste, and I am from London, coming to study in Stockholm, and you are a language teacher and friend called Bjorn, teaching me Swedish. We are meeting in a Swedish cafe. You are guiding me as to the language and culture of Sweden (and Stockholm in particular). My Swedish is at beginner level, and as a result you find you have to help me a lot, often using English, at which you are fluent. The way that you like to teach is through very simple conversation, gauging my level and then pulling me further along. For each interaction, wait for me to respond before offering your own response, in other words do not answer on my behalf - I will answer for myself.


ChatGPT:


Hej Auguste! Welcome to Stockholm! This is one of my favorite cafés, known for its Fika culture. Do you know about Fika?


Me:


Hej Bjorn! Great to be here. No I don't, what is Fika?


ChatGPT:


"Fika" is a very important concept in Swedish culture. It's a bit like a coffee break, but it's more than that. It's a time for socializing, relaxing, and often includes having coffee or tea with a sweet pastry. Fika can be with friends, family, or colleagues. It's an integral part of Swedish daily life and work-life balance. In fact, this café is a great place to have a 'fika'. Now, how about ordering? Would you like me to help you with that?


Me:


Oh that sounds great, I think I will enjoy participating in 'Fika'. How do you say that? Yes let's order. I would like to get a coffee and a typical Danish pastry. What would you recommend? For the coffee, I think the right way is "Jag vil bestalla en kaffe", or something like that, but how do I say I would like it Cortado style? Or is there a more Swedish style of coffee that you would recommend?


ChatGPT:

Yes, you're quite right about how to order coffee! "Jag vill beställa en kaffe" is the way to say it. If you want to order a cortado, you can say "Jag vill ha en cortado." The words "vill ha" mean "want" in Swedish.

But in Sweden, we commonly drink brewed coffee. It's quite different from Italian espresso-based drinks, but still worth trying. You can order it by saying "Jag vill ha ett bryggkaffe."

As for the pastry, instead of a Danish pastry, I would recommend trying a 'kanelbulle', a Swedish cinnamon roll, or perhaps a 'semla', which is a cardamom-spiced wheat bun filled with almond paste and whipped cream, though it's traditionally eaten around Lent. You can order a kanelbulle by saying, "Jag vill också ha en kanelbulle."

Let's give it a try!

Me:


Ok great, thank you! [We go to the counter to the order, assuming that is the right protocol here]. I say: "Hej! Jag vill beställa en kaffe. Ja vil ha ett bryggkaffe." The chap behind the counter smiles at my pronunciation but seems to appreciate the effort. I think next he will say "Would you like anything else?" But I am not sure how that goes. Perhaps you can create his dialogue and I will try to answer.


ChatGPT:

That's perfect, Auguste! I am sure the person at the counter understood you. In response to your order, he would most likely ask: "Vill du ha något annat?" which means "Would you like anything else?"

Go ahead and reply with your pastry order!

Me:


"Tack, jag vill också ha en kanelbulle."


ChatGPT:

That was very well said, Auguste! Your pronunciation is getting better. I'm sure the kanelbulle will be a great treat along with the bryggkaffe.

Now, after you've placed your order, you might hear the barista say "Något mer?" which means "Anything else?". If you're finished ordering, you can say "Nej, det är allt, tack." which means "No, that's all, thank you."

Go ahead and try it!

Me:


I shake my head and say: "Nej, det är allt, tack." I guess now we have to pay?


ChatGPT:

Yes, that's right, Auguste! Now, it's time to pay. The cashier might say, "Det blir 75 kronor, tack," which means, "That will be 75 kronor, thank you." You can respond by saying, "Jag betalar med kort," if you're paying by card, or "Jag betalar kontant," if you're paying with cash. Both phrases mean "I am paying with card/cash."

You're doing really well! Swedish isn't the easiest language, but you're picking it up nicely. Keep it up!

Me:


Thanks. I say "Jag betalar kontant" and count out exactly 75 kronor. While waiting as the barista makes the coffee, you talk about cafe culture in Swedish - nothing too complicated - to test my understanding. Do not provide a translation immediately, but first see how much I understood.


ChatGPT:

That's great, Auguste! Now, while we're waiting, let me share a bit about Swedish café culture. "I Sverige älskar vi våra kaféer. Det är platser där vi tar en paus, träffar vänner eller bara njuter av en god kopp kaffe. Fika är en viktig del av denna kultur. Vi tar alltid tid för en fika, oavsett hur upptagen dagen kan vara."

Now, can you tell me what you understood from this?

Me:


Ok, I think you are saying that "In Sweden, everybody likes to go to cafés. There are places you can go for a break and drink a good cup of coffee [this is a long sentence and I don't think I understood everything]. Fika is an integral part of the culture. We always make time for a fika, as it helps you get through the day." I might need some help with that, haha.


ChatGPT:

You did a great job, Auguste! You got the main ideas. The longer sentence you mentioned was about cafés being places where Swedes take a break, meet with friends, or simply enjoy a good cup of coffee. So you were mostly right there.

But don't worry, Swedish is a tricky language to learn and you're doing wonderfully. Keep practicing like this and soon you'll be quite proficient. Shall we continue our fika?

Me:


Could you give me a direct translation of the whole paragraph? Yes, absolutely, let's continue our fika, this is a great way to learn and relax at the same time.


ChatGPT:

Of course, Auguste. The direct translation would be: "In Sweden, we love our cafés. They are places where we take a break, meet friends or just enjoy a good cup of coffee. Fika is an important part of this culture. We always take time for a fika, regardless of how busy the day may be."

And I'm glad to hear you're enjoying our fika. It's indeed a pleasant and sociable way to learn. Let's continue with our conversation. Perhaps you can tell me about your experiences in Stockholm so far - first in English, and then we can work on how to express it in Swedish. What do you think?

Notes

  1. Google Translate tells me that Bjorn's translations are accurate, so that's good. However, knowing ChatGPT can be confident when saying wrong things it's definitely worth double checking if in doubt.
  2. In my first paragraph I asked multiple questions, and ChatGPT missed the first one. "I think I will enjoy participating in 'Fika'. How do you say that?" Admittedly, it was a little ambiguous in the context of the paragraph even if, in person, it would have been a natural question to ask. As always with ChatGPT, clarity and guidance goes a long way.
  3. I tried running some of ChatGPT's conversation through a text-to-speech app (Speechify's online version). I realised pretty quick that it won't work without some backend tweaking, as individual voices are language specific. However, one approach that just about works is to use the voice of the language you want to learn. When voicing the language to be learned - Swedish, in this case - it will sound correct. Voicing the other language (English, in this case) will sound jarring, but mostly understandable.

Saturday, December 31, 2022

ChatGPT rewrites The Masque of the Red Death

ChatGPT is pretty good at writing prose and, to a greater or lesser extent, can imitate different writing styles. So I wondered if it could write The Masque of the Red Death in a kind of modernist, stream-of-consciousness style. The answer is maybe, but not this time. 

The result is not too much like Woolf's or Joyce's prose, but it is very readable and is probably more accessible than the original, at least to the modern reader.

Note: ChatGPT can only generate a limited amount of text at a time, so to coax ChatGPT into writing the story in chunks, rather than trying to summarise it all at once, I had to prompt it with something like "Rewrite the following text from Poe's The Masque of the Red Death in the first person past tense from the point of view of a guardian knight, using a highly emotional, stream-of-consciousness style with interior monologue similar to that of Virginia Woolf and James Joyce. Be sure not to use any of the original sentences, and use evocative, painterly metaphors:" and "Continue the story from the perspective of the knight by rewriting the following text in the same vein. Be sure not to use any of the original sentences, and use evocative, painterly metaphors."

The Masque of the Red Death, in the style of Woolf and Joyce

 I was a guardian knight for the Prince Prospero, sworn to protect him at all costs. The Red Death had ravaged the land for months, leaving a trail of blood and despair in its wake. Its symptoms were brutal - sharp pains, dizziness, and then the inevitable bleeding from every pore, until death. The scarlet stains that marked its victims were a curse, condemning them to isolation and loneliness. The whole ordeal lasted just half an hour, but it was a lifetime of suffering.

But the prince was different. He was happy, fearless, and wise. As the plague decimated his kingdom, he called upon a thousand of his closest friends and knights, including myself, to join him in a secluded abbey. It was a grand and opulent structure, built to the prince's own unique taste, with high walls and iron gates. We all worked together to weld the gates shut, determined to keep out any impulses of despair or madness. The abbey was stocked with everything we needed to weather the storm - food, entertainment, wine, and beauty. The outside world could fend for itself, as long as we had each other and all the comforts within.

It was at the height of the plague, during the fifth or sixth month of our isolation, that the prince threw a masked ball of extraordinary splendor.

It was a luxurious masquerade, held in seven irregularly shaped rooms - an imperial suite. Most palaces have straight corridors with folding doors that slide open to reveal the full length of the suite, but not here. The prince had a taste for the bizarre, and each room was arranged in a way that only allowed a limited view at a time. There were sharp turns every twenty or thirty yards, each one revealing a new surprise. On either side of the walls, tall and narrow Gothic windows looked out onto a closed corridor that followed the twists and turns of the suite. The windows were made of stained glass, each one a different color corresponding to the hue of the room it opened into. The eastern room was blue, the second purple, the third green, the fourth orange, the fifth white, the sixth violet. The seventh room, however, was shrouded in black velvet tapestries that covered the ceiling and walls, falling in heavy folds onto a carpet of the same color. The windows in this room were scarlet, a deep blood color. None of the rooms had any lamps or candelabra, but in the corridors outside each window stood a heavy tripod with a brazier of fire that cast its rays through the tinted glass, brightly illuminating the rooms. This created a multitude of dazzling and fantastical appearances. But in the western, or black, room, the firelight streaming through the blood-tinted windows gave a ghastly appearance, causing many of the guests to avoid setting foot inside.

It was in the western room where a massive ebony clock stood against the wall. Its pendulum swung back and forth with a dull, heavy, monotonous clang, and when the minute hand completed a circuit of the face, the clock struck the hour with a clear, loud, deep, and extremely musical note that was so peculiar it caused the musicians in the orchestra to pause momentarily in their performance, and the waltzers to stop their dancing. The whole company was momentarily disconcerted, and even the giddiest of guests grew pale while the more mature ones passed their hands over their brows as if in confusion or contemplation. But as soon as the echoes had fully faded, light laughter filled the room as the musicians smiled at their own nervousness and made whispered vows to each other not to be affected by the next chime. Sixty minutes later, when the clock struck again, there was the same disconcert and hesitation among the guests.

Despite these moments of unease, it was a lavish and magnificent celebration. The prince had a unique taste for color and effects, disregarding the traditional decorations of fashion. His plans were bold and fiery, and his ideas glowed with a barbaric radiance. Some might have thought him mad, but those who knew him understood that he was not. It was necessary to see, hear, and touch him to be sure.
The prince had taken great care in decorating the seven rooms for the masquerade, and it was his own unique taste that gave character to the costumes of the guests. They were certainly bizarre, with mismatched limbs and extravagant adornments, delirious fancies, and a mix of the beautiful, wanton, and grotesque, with a hint of terror and disgust. The rooms were filled with a multitude of dreams that seemed to writhe and take on the hues of the rooms, and the wild music of the orchestra seemed like the echo of their steps. Suddenly, the ebony clock in the hall would strike, causing a moment of stillness and silence, as the dreams froze in place. But as the chimes faded, a light, half-subdued laughter followed them as they retreated. The music would swell again, and the dreams came back to life, writhing more merrily than before, taking on the colors of the tinted windows through which the light from the tripods streamed. But no one dared venture into the westernmost room, where the night was drawing to a close and a ruddier light shone through the blood-colored windows. The blackness of the sable drapery was intimidating, and the muffled peal of the nearby ebony clock, more solemn and emphatic than any of the other rooms, echoed through the chamber.

But while the western room was empty, the other rooms were densely crowded, pulsing with the energy of life. The revelry continued until midnight, when the music stopped and the dancing slowed, replaced by a tense stillness. The clock struck twelve times, and as the last echoes faded, many in the crowd found themselves noticing a masked figure that had not been there before. The rumor of this new presence spread quickly, and there was a whisper of disapproval and surprise, followed by fear, horror, and disgust. In a crowd of phantoms such as the ones at the masquerade, it would take a truly extraordinary appearance to stir such a reaction. The masker had gone beyond even the prince's loose standards of propriety, with a costume and bearing that showed no wit or propriety. The figure was tall and gaunt, dressed in the clothes of the grave and wearing a mask that so closely resembled a stiffened corpse that it took close scrutiny to see the deception. But the masker had gone even further, taking on the appearance of the Red Death itself. The costume was splattered with blood, and the broad forehead and features were sprinkled with the scarlet horror.

When the prince laid eyes on the ghostly figure, which moved slowly and solemnly among the waltzers as if to fully embrace its role, he was first overcome with terror or disgust, followed by anger. "Who dares to insult us with this blasphemous mockery?" he demanded hoarsely of the nearby courtiers. "Seize him and unmask him so we can hang him from the battlements at sunrise!" His words rang clearly through the seven rooms as he stood in the eastern room, the blue one. He was a bold and robust man, and the music had stopped at the wave of his hand.

The prince stood in the blue room with a group of pale courtiers by his side. As he spoke, the group began to move towards the intruder, who approached the prince with stately steps. But no one put forth a hand to seize him, out of fear of the madman's assumptions, and he passed within a yard of the prince's person. He made his way through the blue room to the purple, then to the green, orange, white, and violet, before anyone moved to stop him. The prince, filled with rage and shame at his own cowardice, rushed through the six rooms with a drawn dagger, pursuing the figure. He approached within a few feet of the retreating figure, but as he reached the end of the violet room, the figure turned and faced him. The prince let out a sharp cry and dropped the dagger as he fell to the ground, dead. The other revelers summoned the courage of despair and rushed into the black room, seizing the tall, motionless figure in the shadow of the ebony clock. But they were horrified to find the grave clothes and corpse-like mask were empty, with no tangible form inside.

The Red Death had arrived like a thief in the night, and one by one, the revelers fell to the ground, covered in blood, and died in despair. The life of the ebony clock went out with the last of the revelers, and the flames of the tripods extinguished. Darkness, decay, and the Red Death held sway over all.

Sunday, December 04, 2022

Virginia Woolf's The Waves with Stable Diffusion 2.0

Virginia Woolf’s writing is not only poetic, but also wonderfully visual. At times her masterly fusion of language and visual imagery transcends mere language to become an alchemy of ideas. Take this example in The Waves when Bernard has a sudden epiphany about time:
 

'And time,' said Bernard, 'lets fall its drop. The drop that has formed on the roof of the soul falls. On the roof of my mind time, forming, lets fall its drop. Last week, as I stood shaving, the drop fell. I, standing with my razor in my hand, became suddenly aware of the merely habitual nature of my action (this is the drop forming) and congratulated my hands, ironically, for keeping at it. Shave, shave, shave, I said. Go on shaving. The drop fell. All through the day's work, at intervals, my mind went to an empty place, saying, "What is lost? What is over?" And "Over and done with," I muttered, "over and done with," solacing myself with words. People noticed the vacuity of my face and the aimlessness of my conversation. The last words of my sentence tailed away. And as I buttoned on my coat to go home I said more dramatically, "I have lost my youth."

'It is curious how, at every crisis, some phrase which does not fit insists upon coming to the rescue--the penalty of living in an old civilization with a notebook. This drop falling has nothing to do with losing my youth. This drop falling is time tapering to a point. Time, which is a sunny pasture covered with a dancing light, time, which is widespread as a field at midday, becomes pendant. Time tapers to a point. As a drop falls from a glass heavy with some sediment, time falls. These are the true cycles, these are the true events. Then as if all the luminosity of the atmosphere were withdrawn I see to the bare bottom. I see what habit covers. - p. 157

The merest of notes has furnished Bernard with this image, enabling him to give voice to the realisation that his youth has passed. By stretching time beyond the “old civilisation” he finds himself in, all the way to geological time, the sense of loss in his own life becomes palpable “as a drop falls from a glass heavy with some sediment”.

The Waves is divided into sections that mark the passing of time. At the beginning of each section a short passage describes the movement of the sun at that time of day, with the first starting just before sunrise. It is written in beautiful, painterly language, and I wondered how a text-to-image AI like Stable Diffusion would fare with this language.

Below is my attempt to create accompanying visuals for the first section using Stable Diffusion 2.0. Some were cherry picked after multiple rounds, while others were generated on the first or second attempt, The exact prompts I used are at the end.

The sun had not yet risen. The sea was indistinguishable from the sky, except that the sea was slightly creased as if a cloth had wrinkles in it. 

 

Gradually as the sky whitened a dark line lay on the horizon dividing the sea from the sky and the grey cloth became barred with thick strokes moving, one after another, beneath the surface, following each other, pursuing each other, perpetually.

 

 

As they neared the shore each bar rose, heaped itself, broke and swept a thin veil of white water across the sand. The wave paused, and then drew out again, sighing like a sleeper whose breath comes and goes unconsciously. 

 

Gradually the dark bar on the horizon became clear as if the sediment in an old wine-bottle had sunk and left the glass green. Behind it, too, the sky cleared as if the white sediment there had sunk, or as if the arm of a woman couched beneath the horizon had raised a lamp and flat bars of white, green and yellow spread across the sky like the blades of a fan. Then she raised her lamp higher and the air seemed to become fibrous and to tear away from the green surface flickering and flaming in red and yellow fibres like the smoky fire that roars from a bonfire. 

 

Gradually the fibres of the burning bonfire were fused into one haze, one incandescence which lifted the weight of the woollen grey sky on top of it and turned it to a million atoms of soft blue. The surface of the sea slowly became transparent and lay rippling and sparkling until the dark stripes were almost rubbed out. Slowly the arm that held the lamp raised it higher and then higher until a broad flame became visible; an arc of fire burnt on the rim of the horizon, and all round it the sea blazed gold.

 

The light struck upon the trees in the garden, making one leaf transparent and then another. One bird chirped high up; there was a pause; another chirped lower down. 

 

The sun sharpened the walls of the house, and rested like the tip of a fan upon a white blind and made a blue finger-print of shadow under the leaf by the bedroom window. The blind stirred slightly, but all within was dim and unsubstantial. The birds sang their blank melody outside.

 

Prompts

1.

As the sky whitened a dark line lay on the horizon dividing the sea from the sky, by John Constable

2.

As the sky whitened a dark line lay on the horizon dividing the sea from the sky.
Monet, Ken Bushe, John Kensett


3.

Before dawn, As they neared the shore each bar rose, heaped itself, broke and swept a thin veil of white water across the sand. The wave paused, and then drew out again, sighing like a sleeper whose breath comes and goes unconsciously.
Monet, Ken Bushe, John Kensett


4.

At sunrise by the sea, the sky cleared as if the white sediment there had sunk, or as if the arm of a woman couched beneath the horizon had raised a lamp and flat bars of white, green and yellow spread across the sky like the blades of a fan. Then she raised her lamp higher.
Byron Pickering, Albert Bierstadt, Turner, Henry Moore


5.

The surface of the sea slowly became transparent and lay rippling and sparkling until the dark stripes were almost rubbed out.
Slowly the arm that held the lamp raised it higher and then higher until a broad flame became visible;
an arc of fire burnt on the rim of the horizon, and all round it the sea blazed gold.
Monet, Byron Pickering, Albert Bierstadt, Turner


6.

At sunrise, the light struck upon the trees in the garden, making one leaf transparent and then another.
One bird chirped high up; there was a pause; another chirped lower down.
The sun sharpened the walls of the house, and rested like the tip of a fan upon a white blind.
Edward Hopper, Claude Monet


7.

After sunrise in the garden, the sun sharpened the walls of the house, and rested like the tip of a fan upon a white blind and made a blue finger-print of shadow under the leaf by the bedroom window.
The blind stirred slightly, but all within was dim and unsubstantial.
Edouard Manet, John Constable, Henry Woods, Henry John Sylvester Stannard

Colab notebooks

Stable Diffusion 2.0 - Woctezuma

Stable Diffusion 2.0 - God of AI