Train ChatGPT to Answer your Frequently Asked Questions

Enrich ChatGPT with your knowledge base.

Jesko Rehberg
6 min readFeb 7, 2023
Build your knowledge base on ChatGPT (image by Sergio)

Background

Suppose we have questions that ChatGPT can’t answer. An example is the question about which country won the 2022 Soccer World Cup.

import openai
COMPLETIONS_MODEL = "text-davinci-003"
openai.api_key = "Your_API_KEY"
prompt = """Answer the question as truthfully as possible, and if you're unsure of the answer, say "Sorry, I don't know".

Q: Who won the world cup 2022?
A:"""

openai.Completion.create(
prompt=prompt,
temperature=0, # We use temperature of 0.0 because it gives the most predictable, factual answer.
max_tokens=4056, # This model's maximum context length is 4097 tokens, but 41 already included in prompt
model=COMPLETIONS_MODEL
)["choices"][0]["text"].strip(" \n")

Since ChatGPT was trained in a period before this World Cup, ChatGPT does not know the answer to this question yet.

In this article, we will learn how to teach ChatGPT these new topics. You can use this knowledge to let ChatGPT learn and answer your own (company-specific) Frequently Asked Questions (FAQ).

Solution

An interesting aspect of ChatGPT is that it often tries to give us an answer. That is, even if ChatGPT is not sure if the…

--

--

Jesko Rehberg
Jesko Rehberg

Written by Jesko Rehberg

Data scientist at https://digitalsalt.com. Views and opinions expressed are entirely my own and may not necessarily reflect those of my company