ILikeAI / AlwaysReddy

AlwaysReddy is a LLM voice assistant that is always just a hotkey away.
MIT License
621 stars 61 forks source link

Support for alternative system prompts + New system prompts #63

Closed Jobus0 closed 3 months ago

Jobus0 commented 3 months ago

Summary

Prompt Loader & Options

prompt.py's prompts list has been replaced with a get_initial_prompt() function that takes a prompt name as argument: the ACTIVE_PROMPT config option. The options for that is based on the file names within the system_prompts folder. The nested type of structure with "default_prompt":{"description":"PLACEHOLDER", "messages":, was removed since it was unused.

Currently, system_prompts contains two prompt files: default_prompt.py and chat_prompt.py. Therefore, the valid options for ACTIVE_PROMPT is "default_prompt", or "chat_prompt". If a user creates their own prompt file like custom_prompt.py, then they can put "custom_prompt" in ACTIVE_PROMPT to load it.

Additionally, ACTIVE_PROMPT can be set to None so that no system prompt is used at all. This gives the raw out-of-the-box behavior of the model, which is recommended for some models like Microsoft's Phi-3.

Improved default system prompt

I tried to make it more clear and concise, and turned most of it into a bulleted list. "About you" and "Your responses" headers were removed for redundancy. Fixed small formatting inconsistencies in the clipboard examples. Specified how the user can include their clipboard data, so the AI can give correct instructions if asked about it.

The goal is to make the AI understand and adhere to the instructions better without changing the personality.

Benchmark

I ran a comparison test with Llama 3 8B. I made 20 different questions that naturally beg for longer answers, such as:

What I was looking for was to see how frequently each system prompt would make a long list instead of naturally flowing sentences, and also how often it would put the information into the clipboard unprompted.

Out of the 20 questions, the old system prompt made lists 9 times and put information into the clipboard 11 times. Meanwhile, the new system prompt made lists only 3 times and put information into the clipboard zero(!) times.

I made sure that the new one isn't worse at copying to the clipboard if you actually do ask for it. In fact, it is slightly better at that too.

I also tested how well the new system prompt follows the "Do not ask the user how you can assist or help them" instruction: When I started with a single-word greeting, the old system prompt asked how it can help or assist 7 out of 10 times. The new one asked only once out of those 10 times.

I'm quite surprised by the results, but keep in mind that this was just with Llama 3 8B. Your mileage may vary with other models.

New chat system prompt

A simpler version that focuses on friendly back-and-forth conversations. Testing with Llama 3 8B, it is very good at asking questions back to maintain the conversation. I opted not to include the clipboard save instructions to reduce the risk of confusion and improve prompt adherence, especially for smaller models. But it can still read from the clipboard, of course, and will likely try to start a casual conversation about it.

ILikeAI commented 3 months ago

You have gone above and beyond again! I love it, thanks man