Cog lets you create a Docker image from a machine learning repository with very little code. But wouldn’t it be better if you didn’t have to write any code? Enter AutoCog!
Inspired by tools like Auto-GPT and BabyAGI, AutoCog uses GPT-4 to not only write code, but to run and fix the code. The algorithm is roughly:
cog predict
shell command to run a prediction based on the generated filescog predict
commandcog.yaml
, predict.py
, or the cog predict
command. Repeat from the previous step up to five times.AutoCog is pretty magical when it works. But a lot of the times it doesn’t. Sometimes it doesn’t know the exact Python package versions, and sometimes it just goes down a bad path that makes things worse at every attempt.
In those cases, you might just want to hit Ctrl-C and fix it yourself. Luckily your fix doesn’t have to be perfect either, since AutoCog has a --continue
flag that picks up where you left off. Most of the time, a gentle nudge from a human is all that’s needed to help AutoCog reach a working solution.
AutoCog itself was written by a human, me. Writing a tool like this is like being a micromanager for a technically excellent programmer with poor judgement. After a while you develop empathy for GPT-4, and you break up the task into smaller subtasks that GPT-4 has a chance of achieving.
The subtasks are comprised of a prompt and some code to parse the output. For example, the prompt to order the Python files in the directory is:
The reason we order the paths before we send them to GPT-4 is the length of the context window. A repository often has more Python code than the 8096 tokens GPT-4 accepts, so AutoCog truncates the input files it passes them to GPT-4.
The limited context window is one of the main hurdles when writing a tool like AutoCog. The prompts need to be constructed in a way that includes as much information as possible, without going over the limit.
You can run AutoCog on your own project by installing AutoCog from PyPI. There is more documentation on how to use it on the GitHub README at andreasjansson/AutoCog.