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

add rules to promptmixing #421

Closed
wants to merge 9 commits into from
Closed
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/shared/src/prompt/prompt-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ export class PromptMixin {
* Prepends all mixins to `humanMessage`. Modifies and returns `humanMessage`.
*/
public static mixInto(humanMessage: InteractionMessage): InteractionMessage {
const rules =
"Rules: Provide full workable code as code snippets. Reference only verified file names/paths. Don't make assumptions or fabricate information. Think step-by-step. Answer only if certain or tell me you don't know."
Copy link
Contributor

Choose a reason for hiding this comment

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

I am unsure about this. I have seen the agent take prompts like "Provide full workable code as code snippets" and other input which doesn't require code generation, and have it "force it" by generating weird code, or complaining about not being able to generate code.

Re: don't make assumptions or fabricate information, my anecdotal experience is that it's usually more reliable to tell it what to do. For example, for improved explain-code, I have been asking it to write down facts and then reference those facts when it summarizes.

Re: "Think step-by-step" Anthropic recommends that has the agent ask to think step-by-step, and then the human says "OK."

Copy link
Contributor

Choose a reason for hiding this comment

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

Reference for the Anthropic step-by-step recommendation: https://docs.anthropic.com/claude/docs/ask-claude-to-think-step-by-step

Copy link
Contributor Author

@abeatrix abeatrix Jul 28, 2023

Choose a reason for hiding this comment

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

Your test plan appears to be about naming as Cody, but it looks like that change is already in.

@dominiccooney The transcript before the naming as Cody shows the differences after adding the Provide full workable code when applicable rule (which i later changed to Provide full workable code as code snippets). Will make an update to be more specific.

My gut feeling is, yes, reiterating some rules makes sense. But I think we need to do a more thorough evaluation of the effect of this on some different queries to be sure.

Something I'm trying to understand: if we are already adding the same rules at the start of the conversation, why reiterating the same rules would be a problem when those are (almost) the same rules we want Cody to follow initially?

IMO adding the basic rules (e.g. asking it not to make stuff up) that apply to most questions would help the chat experience overall, as it sets the standard/fallback for each response. Plus they can be easily overwritten by user input.

For Example, right now we have the Reply as Cody rule (which is already included in the stable release), and you can ask Cody to:Reply as Rick from Rick and Morty and tell me how to create a button in react.

Now Cody will now reply as Rick:

image

(An uneducated guess) it seems to me if we ever want Cody to ignore the "rules", we just need to be more specific in the prompts we build for each use case? Am I misunderstanding how this works? :think:

What are your thoughts on this?

Re: don't make assumptions or fabricate information

I was trying to shorten the example provided by Anthropic Answer the following question only if you know the answer or can make a well-informed guess; otherwise tell me you don't know it. 😆 I guess the Answer only if certain or tell me you don't know. should be enough lol ?

const mixins = [...this.mixins, ...this.customMixin].map(mixin => mixin.prompt).join('\n\n')
if (mixins) {
// Stuff the prompt mixins at the start of the human text.
// Note we do not reflect them in displayText.
return { ...humanMessage, text: `${mixins}\n\n${humanMessage.text}` }
return { ...humanMessage, text: `${rules}\n\n${mixins}\n\n${humanMessage.text}` }
}
return humanMessage
}
Expand All @@ -48,7 +50,7 @@ export class PromptMixin {
*/
export function languagePromptMixin(languageCode: string): PromptMixin {
return new PromptMixin(
`(Reply as Cody developed by Sourcegraph in the language with RFC5646/ISO language code "${languageCode}" unless instructed) Hi, I need your help.`
`(Reply as Cody created by Sourcegraph in the language with RFC5646/ISO language code "${languageCode}") Hi, I need your help.`
)
}

Expand Down
Loading