This repo was meant to experiment mimicking my typing style in my groupchat. Obviously as this is a privacy sensitive thing I chose to finetune and host my bot locally.
- Download Telegram Data
- Telegram -> Settings -> Advanced -> Export Telegram Data -> JSON
- Run
json_preprocessing.ipynb, using your respective filename and intended groupchat- Creates
data_export/{grpchat_name}.json - Creates
{grpchat}-df.pkl
- Creates
- Follow steps in
Qwen3_(14B)_Reasoning_Conversational, taken from the official repo to create a model directory i.e. lora_model_John- If the training steps take too long you can reduce the number of "steps" taken. I think 6000 training steps is not too bad and takes about 1 night of training
- Configure Bot
- Search Botfather on Telegram and follow the wizard to create a telegram bot and get its name, username (@) and token
- For each bot you have, copy sample.env and rename it, and fill in the name, username (@) and token, as well as your prompt injection
- Leave .env_global as the default
- Go to
main.pyand add the paths to your respective envs to PERSONALITY_FILES- If adding multiple bots, remember that the first entry is the MasterBot so all messages will filter through this
- Run
main.py
The bots will take the last 10 minutes of messages as context and generate new messages with /generate
Bots can also operate in groupchats, but BotFather -> Bot -> Bot Settings -> Allow Groups ENABLED -> Group Privacy Disabled must be done. The MasterBot in your main must also be in the groupchat to read and ask the other bots to generate messages.
You can also play around with some of the parameters through /config especially if responses are either too random or too repetitive:
Temperature [0.00 : 2.00] : Affects the randomness of responses
/config temp 0.7
TOP_P [0.00 : 1.00] : Confidence Interval of responses. Hence a higher value creates more random responses
/config top_p 0.97
Top_K [0 : 1000??] : The generated message is chosen from a random sample among the top K responses. Having a higher top_k means less likely responses are also considered.
/config top_k 150
/clear will clear the context. Do this if the bot is repeating itself
/recent shows the context. Mainly for debug
Each bot takes up a certain amount of DRAM so at least my computer with 16 GB of DRAM is limited to ~4 bots at max. The inference is sequential so the GPU is not the bottleneck to scalability.
At the time of writing (August 2025) I chose to go with QWEN3 4-bit 8B model as my hardware was just a RTX4070 Super with 12GB of VRAM and 16GB of DRAM
[X] Let the bots communicate with each other (MasterBot architecture) [ ] Add sticker support (i.e. emoji support) [ ] Smarter responses [ ] Logging