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

AI messages include AI: or Jupyter AI: prefix #143

Closed
dlqqq opened this issue May 4, 2023 · 2 comments
Closed

AI messages include AI: or Jupyter AI: prefix #143

dlqqq opened this issue May 4, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@dlqqq
Copy link
Member

dlqqq commented May 4, 2023

Description

Conversations with some language models on the model-config branch result in the model prepending its output with AI: or Jupyter AI:. Take this example with ai21:j2-jumbo-instruct:

Screen Shot 2023-05-04 at 2 06 39 PM

It looks like this is being caused by a failure to include an empty AI message, which indicates the the language model that it should not attempt to generate its own message prefix. This can be observed from the server logs:

(DefaultActor pid=40821) > Entering new ConversationChain chain...
(DefaultActor pid=40821) Prompt after formatting:
(DefaultActor pid=40821) System: The following is a friendly conversation between a human and an AI, whose name is Jupyter AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.
(DefaultActor pid=40821) Human: Hello!
(DefaultActor pid=40821)
(DefaultActor pid=40821) > Finished chain.

Contrast this with a log from the documentation examples:

> Entering new ConversationChain chain...
Prompt after formatting:
The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.

Current conversation:

Human: Hi there!
AI:

> Finished ConversationChain chain.
@dlqqq dlqqq added the bug Something isn't working label May 4, 2023
@dlqqq
Copy link
Member Author

dlqqq commented May 4, 2023

This is happening because we are overriding the default prompt template defined in langchain::langchain/chains/conversation/prompt.py:

_DEFAULT_TEMPLATE = """The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.

Current conversation:
{history}
Human: {input}
AI:"""
PROMPT = PromptTemplate(
    input_variables=["history", "input"], template=_DEFAULT_TEMPLATE
)

When the default is overridden, an empty AI message must be supplied.

@JasonWeill
Copy link
Collaborator

Fixed by #144, which is merged. I can no longer repro this with code in main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants