shreyashankar / gpt3-sandbox

The goal of this project is to enable users to create cool web demos using the newly released OpenAI GPT-3 API with just a few lines of Python.
MIT License
2.9k stars 880 forks source link

Adding configurable premise #47

Open michaellavelle opened 4 years ago

michaellavelle commented 4 years ago

I noticed that many prompts/scrolls include a statement of intent at the start of the prompt ( a "premise" )

for example.

https://github.com/maraoz/gpt-scrolls/blob/master/tweets/twitter-fiction.txt

the premise would be

"Twitter fiction: 21 authors try their hand at 140-character novels We challenged...at Twitter fiction."

This PR adds a premise to GPT which can be set on GPT in a similar way to the examples, and a configurable premise_prefix and premise_suffix to control how this premise appears and the gap between it and the examples etc. If the premise is not set or empty string this prefix and suffix should not be used. Otherwise, if premise is set, this setup allows the prefix-premise-suffix to be prepended to the examples.

Also included is a sample app for this, which uses the Twitter fiction example above. I've also demonstrated with this app how the config parameters and examples could be loaded from a template json file ( for formatting ) and a prompt json file ( for the content ).

Files are currently residing here:

https://github.com/ml4j/gpt-scrolls/tree/master/tweets https://github.com/ml4j/gtp-3-prompt-templates/tree/master/question-answer/default/templates

These are currently set to remote urls simply for demonstration purposes - it would be great if GPT-3 applications had the ability to pull in json files of a standard format from different projects. It would allow the separation of content and formatting - allowing a prompt to be used with different formats or vice versa).

If you like this idea of premises, I can amend this PR to remove the remote urls and commit the json files into the project as part of this PR - if so would you be able to recommend where they could reside ?

shreyashankar commented 4 years ago

Hi! Thanks for making the PR. I have a somewhat busy week at work, so I'll try to take a look later this week or sometime this weekend definitely :)

michaellavelle commented 4 years ago

Hi Shreya - no worries - whenever you get chance - no rush :-)

Hope you week goes well at work,

Michael