- December 2024 (7)
- September 2024 (1)
- August 2024 (2)
- July 2024 (2)
- May 2024 (2)
- April 2024 (2)
- February 2024 (2)
- April 2023 (1)
- March 2023 (2)
- September 2022 (1)
- February 2022 (1)
- November 2021 (1)
- March 2021 (1)
- February 2021 (2)
- August 2019 (1)
- November 2018 (1)
- May 2017 (1)
- December 2016 (1)
- April 2016 (1)
- August 2015 (1)
- December 2014 (1)
- August 2014 (1)
- March 2014 (1)
- December 2013 (1)
- October 2013 (3)
- September 2013 (4)
- August 2013 (2)
- July 2013 (1)
- June 2013 (1)
- February 2013 (1)
- October 2012 (1)
- June 2012 (1)
- May 2012 (1)
- April 2012 (1)
- February 2012 (1)
- October 2011 (1)
- June 2011 (1)
- May 2011 (1)
- April 2011 (1)
- March 2011 (1)
- February 2011 (1)
- January 2011 (1)
- December 2010 (3)
- November 2010 (1)
- October 2010 (1)
- September 2010 (1)
- August 2010 (1)
- July 2010 (1)
- May 2010 (3)
- April 2010 (1)
- March 2010 (2)
- February 2010 (3)
- January 2010 (4)
- December 2009 (2)
- November 2009 (5)
- October 2009 (2)
- September 2009 (2)
- August 2009 (3)
- July 2009 (1)
- May 2009 (1)
- April 2009 (1)
- March 2009 (5)
- February 2009 (5)
- January 2009 (5)
- December 2008 (3)
- November 2008 (7)
- October 2008 (4)
- September 2008 (2)
- August 2008 (1)
- July 2008 (1)
- June 2008 (1)
- May 2008 (1)
- April 2008 (1)
- January 2008 (5)
- December 2007 (3)
- March 2007 (3)
- February 2007 (1)
- January 2007 (2)
- December 2006 (4)
- November 2006 (18)
- 3D (5)
- AI (21)
- Admin (3)
- Blogging (5)
- Business of Software (9)
- Copyright (1)
- Dirigible (3)
- Django (1)
- Eee (3)
- Finance (6)
- Fine-tuning LLMS (10)
- Funny (11)
- GPU Computing (2)
- Gadgets (8)
- JavaScript (1)
- Linux (13)
- Memes (2)
- Meta (7)
- Music (4)
- NSLU2 offsite backup project (13)
- OLPC XO (2)
- Oddities (4)
- Personal (3)
- Politics (3)
- Programming (68)
- Python (43)
- PythonAnywhere (12)
- Quick links (2)
- Rants (4)
- Raspberry Pi (1)
- Resolver One (22)
- Resolver Systems (18)
- Robotics (8)
- Space (2)
- Talks (3)
- Uncategorized (5)
- VoIP (2)
- Website design (4)
An AI chatroom (a few steps further)
Still playing hooky from "Build a Large Language Model (from Scratch)" -- I was on our support rota today and felt a little drained afterwards, so decided to finish off my AI chatroom. The the codebase is now in a state where I'm reasonably happy with it -- it's not production-grade code by any stretch of the imagination, but the structure is acceptable, and it has the basic functionality I wanted:
- A configurable set of AIs
- Compatibility with the OpenAI API (for OpenAI itself, Grok and DeepSeek) and with Anthropic's (for Claude).
- Persistent history so that you can start a chat and have it survive a restart of the bot.
- Pretty reasonable behaviour of the AIs, with them building on what each other say.
Here's a short chat with them:
The important thing I found today was that, as I suspected, the AIs find it
very confusing if all messages from bots have the assistant
role. They're
trained in a way that seems to map to "assistant
means you", so if other messages
come in with that role, they get confused about what they have said and what was
said by others. So changing things so that each AI receives only its messages
with that role, while the others were all tagged with a role of user
, seemed
to improve matters a lot.
It was also important to make sure that the assistant
messages matched what they
had actually said. You can see from the image above that messages from the AIs
have bot emojis then their names with square brackets in front of them. That's
important for the UI -- so that the humans can tell which bot is which -- and also
useful when sending the non-assistant
messages to the AIs so that they can do
likewise. However, when that kind of "decorator" was in front of the assistant
messages -- so they did not match what the AI had said in the past -- it seemed
to cause confusion.
Once I'd worked that out, I had to do some prompt engineering work to stop them from putting their own "signatures" in front of their responses. Claude and DeepSeek seemed particularly keen on doing that. I was eventually able to stop them from doing that with
These identifiers are provided by the chat system, you should NOT under any circumstances start your own messages with {ai_identifier},
...but then DeepSeek decided to interpret that in the silliest possible way, and managed to make Claude have what appears to be an existential crisis:
So I had to extend that to:
These identifiers are provided by the chat system, you should NOT under any circumstances start your own messages with {ai_identifier}, or anything that makes it look like you are a different AI.
...and add this to the top:
You are {ai_identifier}, a helpful AI assistant.
This seems to work surprisingly well! I'll spend some time chatting with it over the coming days. Maybe, working together, Claude, ChatGPT, Grok and DeepSeek can help me get over this hump with understanding self-attention. Or perhaps the conversations will degenerate in to AI surrealism. Should be fun either way!