Module 1 : Lesson 10 : Lab

I am taking this course on Coursera and at Lesson 10 of Mudule 1, each time while creating a poem with a given number of lines, the returned result doesn’t have the # of lines i have specified to llm. ANyone else faced this?

Example
Use print_llm_response() to print a poem with the specified number of lines. Use the

number_of_lines = 10
prompt = f"““Write a poem with {number_of_lines} lines””"
print_llm_response(prompt)

In the still of night, the stars shine bright,
Whispers of the wind, a gentle delight.
Moonlight dances on the silent sea,
A symphony of nature’s harmony.

The world sleeps, wrapped in dreams,
Silent shadows, not all as they seem.
Nature’s lullaby, a soothing song,
In the darkness, we all belong.

Another example:
number_of_lines = 13
prompt = f"““Write a poem with {number_of_lines} lines””"
print_llm_response(prompt)

In the still of night, the stars softly gleam,
Whispers of dreams in the moon’s gentle beam.
Silent shadows dance in the pale moonlight,
Echoes of memories, lost in the night.

A symphony of silence fills the air,
As the world sleeps without a care.
Nature’s lullaby soothes the weary soul,
Embracing darkness, making us whole.

In the quietude, we find our peace,
A moment of solace, a sweet release.

1 Like

Hi @yas1say,

This is a great demonstration that LLMs are not perfect. They are prone to making mistakes, which is why we should not rely on their responses 100% without first verifying.

The solution would be to try a different, but similar prompt, which could be a bit more specific. For example:

number_of_lines = 10
prompt = f"““Write a {number_of_lines}-line poem””"
print_llm_response(prompt)

I'm here to help,
But keep it brief.
A 10-line poem,
Is your request, chief.

Let's get started,
With words that rhyme.
Crafting a poem,
In no wasted time.

There you have it,
A 10-line verse.

Best,
Mubsi

2 Likes

thanks @Mubsi