steer

Steer: Enhancing Control Flow and Steerability for Large Language Models

Even after following every possible course on prompt engineering I could find, I still had a hard time getting the model do what I wanted to. Below is a summary of what I found to be the most helpful:

Despite applying all of these tricks, the model was still not sticking to the instructions given. The issue becomes more apparent when the model is tasked to follow a flow control, such as checking conditions and making decisions based on those conditions.

The more I tweaked my prompt, the more it started to look like code. That’s when I realized the best way to handle flow and steerability is to write pseudocode and ask the model to simply execute the given instructions.

That’s why I created a grammar for a new language, called Steer designed to make it easier to control large language models.

Steer is a high-level pseudocode language designed to guide LLMs in performing tasks based on user input. It is specifically designed for users to interact with language models and instruct them to perform operations.

On top of the usual basic control flow operators, loops, variable and function declaration, Steer includes some functionalities tailored for LLM interaction:

Other functionalities that have not been implemented yet are:

The model is fed description of these functionalities so that you can use them out of the box.

An example code written in Steer looks like this:

function gcd(a, b):
    return ai(`find the greatest common divisor between {a} and {b}`)

function main(input_data):
    write("Extracting information from the input data")
    a = extract(input_data, 'a')
    b = extract(input_data, 'b')
    write("Computing the gcd of a and b")
    result = gcd(a, b)
    write(`The gcd is {a}`)

In the repository, there is a steer.g4 file defining the grammar of the language with docs on how to parse steer files locally and use them with OpenAI API.

This is just a pet project that I enjoyed playing with. Feel free to contribute to the project and play with it here.