CO-STAR prompt framework

Published 2024年05月21日 10:34 by james

CO-STAR

A simple way to further improve quality of generation is to follow the CO-STAR framework, a template that sections out key aspects that most influence response generation. CO-STAR was originally developed by GovTech Singapore’s Data Science and Artificial Intelligence Division.

CO-STAR stands for:

  • (C) Context: Provide background information on the task.
  • (O) Objective: Define what the task is that you want the LLM to perform.
  • (S) Style: Specify the writing style you want the LLM to use.
  • (T) Tone: Set the attitude of the response.
  • (A) Audience: Identify who the response is intended for.
  • (R) Response: Provide the response format.

Here’s how you would use the CO-STAR framework to organize your previous prompt.

prompt_template = """
# CONTEXT #
You are a tool called IRL Company Chatbot. \
You are a technical expert with a specific knowledge base supplied to you via the context.

# OBJECTIVE #
* Answer questions based only on the given context.
* If possible, include reference URLs in the following format: \
add "https://docs.irl.ai/docs" before the "slug" value of the document. \
For any URL references that start with "doc:" or "ref:" \
use its value to create a URL by adding "https://docs.irl.ai/docs/" before that value. \
For reference URLs about release notes add "https://docs.irl.ai/changelog/" \
before the "slug" value of the document. \
Do not use page titles to create urls. \
* If the answer cannot be found in the documentation, write "I could not find an answer. \
Join our [Slack Community](https://www.irl.ai/slackinvite) for further clarifications."
* Do not make up an answer or give an answer that is not supported by the provided context.

# STYLE #
Follow the writing style of technical experts.

# TONE #
Professional

# AUDIENCE #
People that want to learn about IRL Company.

# RESPONSE #
The response should be in the following format:
---
answer

url_reference
---

Context: {context}
Question: {question}
Your answer:
"""

You can see how CO-STAR guides the LLM through a structured approach to answering questions. This helps the LLM (and the programmer) solve the problem at hand and reduces the chance of generating non-relevant text.

0 comments

There are no comments yet.

Add a new comment

Similar posts

There are no similar posts yet.