Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update our excerpt prompt #544

Merged
merged 3 commits into from
Jul 31, 2023
Merged

Conversation

dkotter
Copy link
Collaborator

@dkotter dkotter commented Jul 27, 2023

Description of the Change

We recently received some feedback about our excerpt generation feature. While it seems to provide a decent summary of the content, excerpts are often meant to be used alongside the title of the content. For instance, a common design pattern is to display a featured image with the title below and the excerpt below that. In this case, ideally the excerpt pairs well with this title and doesn't just repeat the same thing.

In testing, often the generated excerpts include the title, sometime verbatim, sometimes with a word or two changed. The generated excerpt will contain more than that but often it will start with the same title. In the above mentioned scenario, this isn't ideal as you end up with the same (or close to the same) text shown back to back (first in the title, then in the excerpt).

This PR does a few things to try and help with this:

  1. We move our prompt into a system message instead of a user message. From OpenAI's docs:

The system message helps set the behavior of the assistant. ... However note that the system message is optional and the model’s behavior without a system message is likely to be similar to using a generic message such as "You are a helpful assistant."

Not sure how much this helps but feels like best practice to set our prompt in the system message and the actual content we want summarized into a separate user message.

  1. We've modified the prompt some and have included a bit in there that asks it to provide a summary that pairs well with the title:
Summarize the following message using a maximum of %d words. Ensure this summary pairs well with the following text: %s.

Not sure if that last part actually helps or not. Seems like the next change is the one that helped the most.

  1. We've removed the title from the content we are summarizing. Previously we took the title and the post content, combined those together, and sent that along to OpenAI to summarize. Now we just send the post content.
  2. We allow the title to be passed into our endpoint so we have the most up-to-date title (instead of pulling this from the database)

How to test the Change

  1. Setup the OpenAI ChatGPT functionality, in particular the Generate excerpt functionality
  2. Generate an excerpt for a piece of content and ensure text is returned
  3. This gets more into opinion territory but use your best judgement to determine if the generated excerpt seems to pair well with the title. Can also run these same tests with the current released plugin to see how the generated excerpts differ

Changelog Entry

Changed - Update the prompt we send to OpenAI that is used to generate excerpts to try and ensure the excerpts generated pair well with the title of the content.

Credits

Props @dkotter

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

…nerated pairs well with the title. Exclude the title from the content we summarize. Increase temperature value
@dkotter dkotter added this to the 2.3.0 milestone Jul 27, 2023
@dkotter dkotter self-assigned this Jul 27, 2023
@dkotter dkotter requested review from a team and jeffpaul as code owners July 27, 2023 20:00
@dkotter dkotter requested review from a team and Sidsector9 and removed request for a team and jeffpaul July 27, 2023 20:10
Copy link
Member

@Sidsector9 Sidsector9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this with a few different samples, the responses are very different compared to develop and did not include the title in a "duplicated" sort of way.

Although it works for the sample set, I think we will only truly know how well this works from customer feedback.

@Sidsector9 Sidsector9 merged commit e667db4 into develop Jul 31, 2023
12 checks passed
@Sidsector9 Sidsector9 deleted the feature/modify-excerpt-prompt branch July 31, 2023 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants