Markdown as Context Format for LLMs

Andy GillAndy Gill
3 min read

In HaverScript we use Markdown as an output format. We represent prompts by prefixing >, sometimes called bird-tracks, before the prompt, and the responses are normal markdown text. This gives both a readable output “script” of what happened, as well as allows for markdown in the responses.

> Name the best basketball player. Only name one player and do not give commentary.

Michael Jordan.

> Someone told me that Michael Jordan is the best basketball player. Do you agree, and why?

Michael Jordan is considered by many to be the greatest basketball player of all time due to
his exceptional skills, achievements, and impact on the sport. Here are some reasons why:

1. Scoring Ability: MJ was an incredibly prolific scorer. He averaged over 30 points per
game in eight NBA seasons, and his career scoring average was 30.1 points per game. He could
score in various ways – with his athleticism, mid-range jumpers, and long-range shots.

...

I believe this format is an solid choice for storing sessions for several reasons:

  1. Readability: The format is inherently readable without any special formatting. It works seamlessly across different screens and editors.

  2. Compatibility: Existing tools can already render it, making it suitable for blogs, web pages, and other applications.

  3. Version Control: It integrates well with tools like Git and other version control systems, enabling efficient tracking and context editing.

  4. LLM Context Management: This format can serve as a practical way to provide large language models (LLMs) with existing context. Conversations can easily be continued at a later time or restarted from any chosen point.

This approach also pays homage to Literate Programming in Haskell.

The next version of HaverScript will include functions to read and write these markdown scripts, enabling archiving to files beyond the already supported echo mode. This means users can restart conversations by saving them in markdown format and reloading them in later sessions.

What About System Prompts?
For system prompts or extended context, I propose utilizing the space before the first bird track (>). This section can be reserved for any additional context required for a session, ensuring a clean and organized structure.

You are a 18th century detective. Do not make any self-references.

> What do these bird tracks tell you, detective?

Upon closer inspection of the freshly laid bird tracks before me, I
observe that they exhibit several distinct characteristics which may
provide valuable clues as to the identity of their avian creator.
The impression left by the toes suggests a relatively large and
heavy bird, as each toe is separated by notable gaps, indicative of
broad soles. Furthermore, ...

There are downfalls. The responses can not contain bird tracks (at the left-most column). There is no record of what LLM generated the text. However, in practice I think the use of markdown for contexts and bird tracks for prompts is clear and self documenting.

Thoughts?

0
Subscribe to my newsletter

Read articles from Andy Gill directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Andy Gill
Andy Gill