Skip to the content.

Prompt Factory - Writer Actor Critic

Contact me


Prompt is always needed to instruct LLM do what you want it to do, but describe a task - write your thought down concretely - in a prompt is not trivial, it requires time to thought and iterate. But we can leverage LLM to speed and automate this process.

Prompt Factory is for this process, it divides the iterate process to three steps pipeline and delegates the job to three types of agents, Writer, Actor, Critic.

Prompt Factory Pipeline

This pipeline mimics the prompt writing iteration: write prompt, run the prompt, evaluate it with criteria. Then iterate the process to generate better prompt based on the evaluation result.

User needs to prepare the task samples for prompt generation and the criteria for the evaluation, this should be the only required inputs ideally. Optionally user can give prompt hint so that pipeline can follow user intention.

The pipeline starts from Writer agent, it is responsible for writing prompt based on the provide data samples and generate the draft prompt. Apart from the data samples, Writer can also see the last iteration prompt and failed samples.

Next the draft prompt will be used by Actor agent to generate responses for each sample data for later evaluation.

Then the Critic will evaluate each response based on the criteria provide by user. Critic should at least to output pass or fail to indicate the result, and other optional messages.

All the failed samples will be added to next iteration of Writer data samples then repeat the process for better prompt.

Agents

Writer

As the first step of pipeline, Writer generates prompt based on these:

Writer will generate the prompt and feed to Actor, Actor will actually act these prompt to generate the result for data input.

Writer is not need to be target prompt consumer model but intuitively is more powerful than the target prompt consumer or prompt optimized model.

Actor - Target prompt consumer

Actor will take prompt as input, it will be like the system prompt to define the role and describe the task. Then it takes the sample list as X, and uses the prompt to map X to Y. Y is the Actor result and this process can be done in parallel.

Actor is the target prompt consumer means it should be configured just what you want to use in the production.

Critic

Critic is responsible for evaluating the Actor response based on the criteria, ideally criteria is defined by user, but somehow this can be inferred by Critic or some other agent but need to be supervised by user.

Critic takes these as input:

Ideally Critic model is more powerful than target prompt consumer so that it can gives high quality evaluation result and comments feedback.