How to get the same or at least similar results between playground and API

Hello community,

I’m going here for advice. I’m quite newbie in python (but I’m still to learn).
I have created script which generate Wordpress articles with openai api. Basicly this script “text_render” values from csv file what is input. In csv file I have main keyword , keyword for images , keyword for subtitle 1-X… The key is get long creative paraghraphs (some)without injected start and end sentences with davinci-003 as I can get from playground.

I use 1000 max tokens, 0.95 temperature

I’m giving example here:

When I try to post article I only get short output of paraghraph like this
### How to travel to Ostrava?
 Ostrava is a city just bursting with life and culture. From its bustling nightlife to its vast array of music festivals, this Czech gem has something for everyone.

The city of Ostrava is focused on providing the highest quality of living to its citizens and visitors. The public transit system here is award-winning and among the best in Central Europe, and the city has invested in modern infrastructure to accommodate the influx of new citizens. There’s a vibrant atmosphere that blends the old and the new, the past and present and the traditional with the modern.

Ostrava’s culture is as diverse as its citizens. Every weekend, the main square hosts events to celebrate art and music, both modern and traditional.

When I tried to put this prompt into playground I get this:

This is part of article.Write for me a long paragraph which contains more than 300 words with a conversational tone of speech and high creativity without repetitive sentences from previous paragraphs How to travel to Ostrava?

Traveling to Ostrava is one of the best experiences of a lifetime! The atmosphere of this unique city and its attractions is simply extraordinary. From the traditional wooden houses in the old town to the modern skyscrapers and entertainment centers, there is a little bit of something for everyone here. The city offers many transportation options, so whether you’re wanting to travel by train, bus, car or even mountain bike, you’ll be able to find a way to get there quickly, conveniently and affordably.

Perhaps the most convenient way to travel to Ostrava is by train. The connections from major cities like Prague, Vienna, and Warszawa are excellent and the journey is usually quite comfortable and usually takes between 1,5 to 2 hours. Trains depart several times a day and are quite reliable, so this makes them the preferred choice to get there. Once you arrive in Ostrava, you’ll have plenty of options to explore the city, including taking a tram or bus to get around.

For those who have their own vehicles, traveling to Ostrava by car is also an option. The highway A2 connects Prague to Ostrava and the drive takes approximately 3.5 hours. There are plenty of sights to take in along your journey and the road itself is a beautiful one, with plenty of forests, hills, and meadows. Be sure to plan your fuel and stops accordingly, as the journey can be quite long.

If you’re looking for a more adventurous mode of transport, then why not try taking a mountain bike? You can ride along the Moravian-Silesian region, which boasts many trails, hills and rivers, and you’ll be able to take in some of the amazing scenery as you ride. Of course, this mode of transport would require a good level of fitness, but it’s an opportunity for an exhilarating experience that is sure to be unforgettable.

No matter your travel preference, Ostrava has something to offer everyone. Once you arrive in this wonderful city, you’ll find yourself surrounded by a vibrant buzz of activities and events. Enjoy the hospitality and culture of Ostrava and make the most of your visit - you’ll be sure to come back home again with amazing memories that will last a lifetime.

Here is prompt what I use in code:
sub_head1_para = text_render(0.95, openai_token, f’Blog Section Title: {subtitle1}. '‘Write for me a long paragraph which contains more than 300 words with a conversational tone of speech and high creativity without repetitive sentences from previous paragraphs:’)

or this I tried to used this :
sub_head7_para = text_render(0.95, openai_token, f’“”“\nBlog Section Title: {subtitle7}, Main Keyword: {keyword}\n”“”\nWrite for me long paragraph which contains more than 300 words with conversational tone of speech and high creativity without repative sentences from previous paraphraphs:')

Can help with this , please? What Am I doing wrong?
Thank you.
Have a nice rest of day.

ChatGPT is probably a fine-tuned model of davinci-003, so it generates different (and probably longer) output. To mimic this on davinci without fine-tuning, you’ll probably need to prompt engineer more.

For example asking it to write x paragraphs. It is bad at counting, but if you ask it to write “three paragraphs”, maybe it knows what’s 3 paragraphs.
Notice I have put “three” and not “3”. The model performs better on things it had seen a lot, so it has most likely seen more instance of “Three paragraphs” than “3 paragraphs”, as it looks more gramatically correct. Can’t explain why, but try it.

Prompt engineering is a fiddly task. Try asking things that, in the wild, indicate a start of a long text. Any buzzword should be enough, like in above example “paragraph”.

1 Like

So many thanks for reply and valuable advices.

I asked the same question to model davinci-003 in playground not to chatGPT. Question is what’s wrong in my code (or prompt).

I don’t know the Python module for OpenAI :frowning: , but from what I’ve seen your prompts could change a bit.

Like I said previously, it’s bad at counting. If you ask it for “300 words”, it will probably do more or even less. Things like those “could” interfere with the prompt. Try removing overly specific words or stuff and focus on words that are well known in articles, books, etc. It will likely give you a better answer.

Remember: GPT3 is just a fancy autocomplete. It does what it has seen the most. That’s why words like “Paragraph”, “Summarize” and others produce very specific styles of text. In training it has likely seen that 95% of the time that an article that begun with the word “summary”, it followed with a specific style of text. It has “learned” that. Also, for this exact reason don’t use specific numbers (unless they’re extremely common).
Base your prompts on that knowledge and you’ll get pretty good at it :slight_smile: