Skip to main content

Module: batteries/prompts

This module provides some basic prompts for LLMs.

Prompting is still a developing field. There are many different ways to prompt an LLM. This file attempts to provide some good defaults as a starting point.

Functions

Prompt

Prompt(«destructured»): Element

A prompt collection with some useful defaults to get you started. By default all prompts are disabled to make it easier to combine them.

There is no guarantee that the model will follow the prompts, but LLMs have shown great adaptability to prompts.

We intend to improve this collection over time and welcome contributions.

Note: even though a SystemPrompt component is used, you can think of this as a default value. For example:

  • if used in a Completion model, the SystemPrompt will be ignored;
  • if wrapped with a UserMessage, the SystemPrompt will be stripped.

Example

 <ChatCompletion>
<Prompt persona="A cat with a PhD in physics" />
<UserMessage>What is the meaning of life?</UserMessage>
</ChatCompletion>

Parameters

NameTypeDescription
«destructured»Object-
› apolitical?booleanasks the model to not offer opinions on political topics
› concise?booleanasks the model to be concise
› hhh?booleanrefers to the prompt "helpful, harmless, and honest assistant"
› noInternalKnowledge?booleanasks the model to only use the given context to answer instead of baked-in knowledge. This is useful for knowledge-grounded question answering (DocsQA).
› persona?null | stringasks the model to respond with a certain persona. LLMs are trained to output the average response even if it's wrong. A simple nudge can sometimes get the model to output better responses. Example values: - an expert in astrophysics - Albert Einstein - a 5 year old - a tactful politician. See - https://arxiv.org/pdf/2305.14930.pdf - https://arxiv.org/pdf/2111.02080.pdf
› stepByStep?booleanasks the model to work out the answer in a step-by-step way. See PromptStepByStep for more info

Returns

Element

Defined in

packages/ai-jsx/src/batteries/prompts.tsx:32


PromptStepByStep

PromptStepByStep(): Element

Zero-shot Chain-of-Thought prompt.

This specific prompt was proposed in APE paper (https://arxiv.org/pdf/2211.01910.pdf) See Table 7 in Appendix C for comparison.

Example

  <ChatCompletion>
<UserMessage>What is the 4th word in the phrase "I am not what I am"?</UserMessage>
<PromptStepByStep />
</ChatCompletion>

Returns

Element

Defined in

packages/ai-jsx/src/batteries/prompts.tsx:94