- Python 100%
| assets | ||
| docker | ||
| Bernie.py | ||
| CHANGELOG.md | ||
| README.md | ||
| TODO.md | ||
Bernie chats bot
An IRC bot that learns from IRC logs and generates NPC-style messages using Markov chains, Ollama, LM Studio, or a local CUDA/Hugging Face Transformers model.
The bot can optionally support:
!say!rss <feed-url>- RSS/Atom/Git feed announcements
- periodic NPC-style speech
- live learning from channel messages
- random automatic replies
- Shabbat quiet mode
- local CUDA model generation
The !bernie command has been removed.
Table of Contents
- Features
- Installation
- Quick Start
- Docker
- IRC Commands
- Removed Commands
- Command-Line Options
- Brain Backends
- Markov Backend
- Ollama Backend
- LM Studio Backend
- Local CUDA Backend
- RSS Usage
- Examples
- Troubleshooting
- Security and Identity Notes
- License
Features
- Import IRC logs from a file or directory
- Build and save a reusable Markov brain
- Generate fictional NPC-style IRC messages
- Use one of four brain backends:
markovollamalmstudiolocalcuda
- Use local LLMs through:
- Ollama
- LM Studio
- PyTorch/Hugging Face Transformers
- Fall back to Markov generation if an LLM backend fails
- Add RSS/Atom/Git feeds at runtime
- Periodically announce RSS feed updates
- Optionally learn from live channel messages
- Optionally generate random replies
- Optionally suppress generated speech during Shabbat
Installation
Basic dependencies
pip install requests feedparser
Make the bot executable:
chmod +x irc_smart_log_bot.py
Optional local CUDA dependencies
Only needed if using:
--brain-backend localcuda
Install:
pip install torch transformers accelerate
For the correct CUDA-specific PyTorch command, check:
https://pytorch.org/get-started/locally/
Optional Ollama setup
Install Ollama:
https://ollama.com/
Start Ollama:
ollama serve
Pull a model:
ollama pull llama3.1:8b
Optional LM Studio setup
Install LM Studio:
https://lmstudio.ai/
Then:
- Load a model.
- Start the local server.
- Confirm the API base URL.
Default local API URL:
http://127.0.0.1:1234/v1
Quick Start
Example Markov bot with !say enabled:
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick StyleBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--brain-backend markov \
--enable-say-command
IRC Commands
Commands are typed directly in IRC.
!say
Generate one NPC/brain line.
Usage
!say
Requires
--enable-say-command
Example response
[rkl-npc] yeah that sounds about right
If --enable-say-command is not enabled, the bot ignores !say.
!rss <feed-url>
Add an RSS, Atom, or Git feed at runtime.
Usage
!rss <feed-url>
Example
!rss https://github.com/example/project/commits/main.atom
Requires
--enable-rss --enable-rss-command
If RSS polling is not enabled, the bot will not add or announce feeds.
Removed Commands
!bernie
The !bernie command has been removed.
There is no built-in IRC help command by default. Use this README as the command reference.
Command-Line Options
IRC Connection Options
| Option | Description | Example |
|---|---|---|
--server |
IRC server hostname | --server irc.libera.chat |
--port |
IRC server port | --port 6697 |
--tls |
Enable TLS/SSL | --tls |
--nick |
Bot nickname | --nick StyleBot |
--channel |
Channel to join | --channel '#test' |
--password |
Optional server password | --password secret |
--username |
IRC username | --username stylebot |
--realname |
IRC real name field | --realname "Style Bot" |
Log and Brain Options
| Option | Description | Default |
|---|---|---|
--logs |
File or directory containing IRC logs | ./logs |
--target-nick |
Nickname to learn from in logs | none |
--brain |
Saved Markov brain file | brain.pkl |
--rebuild-brain |
Rebuild the brain from logs | disabled |
--markov-order |
Markov chain order | 2 |
Example:
--logs ./logs --target-nick rkl --brain brain.pkl --rebuild-brain
NPC Output Options
| Option | Description | Default |
|---|---|---|
--npc-name |
Fictional NPC name used in prompts | npc |
--npc-prefix |
Prefix added to generated messages | [npc] |
Example:
--npc-name rkl --npc-prefix "[rkl-npc] "
Using an NPC prefix is recommended so generated messages are not confused with real users.
Feature Flags
| Option | Description |
|---|---|
--enable-say-command |
Enables the !say IRC command |
--enable-rss |
Enables RSS/Atom/Git feed polling |
--enable-rss-command |
Enables the !rss <feed-url> IRC command |
--enable-periodic-brain |
Enables automatic periodic NPC messages |
--enable-live-learning |
Learns from non-command channel messages while running |
--enable-random-replies |
Allows occasional automatic replies |
--enable-shabbat |
Suppresses generated speech during Shabbat quiet mode |
Random Reply Options
| Option | Description | Default |
|---|---|---|
--random-reply-chance |
Chance of replying to a normal message | 0.02 |
Example:
--enable-random-replies --random-reply-chance 0.05
RSS Options
| Option | Description | Default |
|---|---|---|
--rss-feed |
Add an RSS/Atom/Git feed at startup. Can be used multiple times. | none |
--rss-interval |
RSS polling interval in seconds | 300 |
Example:
--enable-rss \
--rss-feed https://github.com/example/project/commits/main.atom \
--rss-interval 300
Periodic NPC Options
| Option | Description | Default |
|---|---|---|
--periodic-min-seconds |
Minimum delay between periodic messages | 300 |
--periodic-max-seconds |
Maximum delay between periodic messages | 1200 |
Example:
--enable-periodic-brain \
--periodic-min-seconds 600 \
--periodic-max-seconds 1800
Brain Backends
The bot supports four brain backends:
--brain-backend markov
--brain-backend ollama
--brain-backend lmstudio
--brain-backend localcuda
| Backend | Description |
|---|---|
markov |
Uses a local Markov chain trained from IRC logs |
ollama |
Uses a local Ollama HTTP API model |
lmstudio |
Uses LM Studio's OpenAI-compatible local API |
localcuda |
Uses PyTorch/Hugging Face Transformers directly |
Markov Backend
The Markov backend is the default backend.
It imports IRC logs and builds a Markov chain.
Usage
--brain-backend markov
Example
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick StyleBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--brain-backend markov \
--enable-say-command
Ollama Backend
The Ollama backend uses a local Ollama model through the Ollama HTTP API.
Requirements
Install Ollama:
https://ollama.com/
Start Ollama:
ollama serve
Pull a model:
ollama pull llama3.1:8b
Usage
--brain-backend ollama
Options
| Option | Description | Default |
|---|---|---|
--ollama-host |
Ollama API host | http://127.0.0.1:11434 |
--ollama-model |
Ollama model name | llama3.1:8b |
Example
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick StyleBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--brain-backend ollama \
--ollama-host http://127.0.0.1:11434 \
--ollama-model llama3.1:8b \
--llm-fallback-markov \
--enable-say-command
LM Studio Backend
The LM Studio backend uses LM Studio's OpenAI-compatible local API.
Requirements
Install LM Studio:
https://lmstudio.ai/
Then:
- Load a model in LM Studio.
- Start the local server.
- Confirm the local server URL.
Default:
http://127.0.0.1:1234/v1
Usage
--brain-backend lmstudio
Options
| Option | Description | Default |
|---|---|---|
--lmstudio-base-url |
LM Studio OpenAI-compatible API base URL | http://127.0.0.1:1234/v1 |
--lmstudio-model |
LM Studio model name | local-model |
Example
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick StyleBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--brain-backend lmstudio \
--lmstudio-base-url http://127.0.0.1:1234/v1 \
--lmstudio-model local-model \
--llm-fallback-markov \
--enable-say-command
Local CUDA Backend
The local CUDA backend uses PyTorch and Hugging Face Transformers directly.
This is useful if Ollama or LM Studio are not available.
Requirements
Install dependencies:
pip install torch transformers accelerate
For NVIDIA CUDA, use the correct PyTorch installation command from:
https://pytorch.org/get-started/locally/
Usage
--brain-backend localcuda
Options
| Option | Description | Default |
|---|---|---|
--localcuda-model |
Hugging Face model name or local model path | mistralai/Mistral-7B-Instruct-v0.2 |
--localcuda-device |
Device to use: cuda or cpu |
cuda |
Example
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick CudaBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--brain-backend localcuda \
--localcuda-model mistralai/Mistral-7B-Instruct-v0.2 \
--localcuda-device cuda \
--llm-fallback-markov \
--enable-say-command
CPU mode
You can force CPU mode:
--brain-backend localcuda --localcuda-device cpu
CPU mode may be very slow for large models.
LLM Options
These options apply to:
ollamalmstudiolocalcuda
| Option | Description | Default |
|---|---|---|
--llm-max-new-tokens |
Maximum generated tokens | 120 |
--llm-temperature |
Randomness of generated output | 0.8 |
--llm-top-p |
Nucleus sampling value | 0.95 |
--llm-fallback-markov |
Fall back to Markov if LLM generation fails | disabled |
Example:
--llm-max-new-tokens 120 \
--llm-temperature 0.8 \
--llm-top-p 0.95 \
--llm-fallback-markov
RSS Usage
Add feeds at startup
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick FeedBot \
--channel '#test' \
--enable-rss \
--rss-feed https://github.com/example/project/commits/main.atom
Add feeds from IRC
Start with:
--enable-rss --enable-rss-command
Then type in IRC:
!rss https://github.com/example/project/commits/main.atom
The bot announces new entries like:
[rss] Commit title https://github.com/example/project/commit/abc123
Examples
Example 1: Simple Markov bot with !say
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick StyleBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--brain-backend markov \
--enable-say-command
Example 2: Ollama bot with Markov fallback
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick StyleBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--brain-backend ollama \
--ollama-model llama3.1:8b \
--llm-fallback-markov \
--enable-say-command
Example 3: LM Studio with RSS
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick StudioBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--brain-backend lmstudio \
--lmstudio-base-url http://127.0.0.1:1234/v1 \
--lmstudio-model local-model \
--llm-fallback-markov \
--enable-say-command \
--enable-rss \
--enable-rss-command
Example 4: Local CUDA with Markov fallback
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick CudaBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--brain-backend localcuda \
--localcuda-model mistralai/Mistral-7B-Instruct-v0.2 \
--localcuda-device cuda \
--llm-fallback-markov \
--enable-say-command
Example 5: Periodic NPC messages
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick NPCBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--enable-periodic-brain \
--periodic-min-seconds 600 \
--periodic-max-seconds 1800
Example 6: Live learning and random replies
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick ChatBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--enable-live-learning \
--enable-random-replies \
--random-reply-chance 0.03
Example 7: RSS feed bot
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick FeedBot \
--channel '#test' \
--enable-rss \
--enable-rss-command \
--rss-feed https://github.com/example/project/commits/main.atom \
--rss-interval 300
Example 8: Shabbat quiet mode
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick QuietBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--enable-say-command \
--enable-periodic-brain \
--enable-random-replies \
--enable-shabbat
Troubleshooting
!say does nothing
Make sure the bot was started with:
--enable-say-command
!rss does nothing
Make sure the bot was started with:
--enable-rss --enable-rss-command
Also install:
pip install feedparser
Ollama generation fails
Make sure Ollama is running:
ollama serve
Check installed models:
ollama list
Pull a model if needed:
ollama pull llama3.1:8b
LM Studio generation fails
Check that:
- A model is loaded.
- The local server is running.
- The base URL is correct.
Default:
http://127.0.0.1:1234/v1
Local CUDA generation fails
Install dependencies:
pip install torch transformers accelerate
Check CUDA availability:
python3 -c "import torch; print(torch.cuda.is_available())"
If CUDA is not available, either fix your PyTorch/CUDA install or use:
--localcuda-device cpu
CPU mode may be very slow for large models.
Model download fails
Some Hugging Face models require accepting a license or logging in.
Install the Hugging Face CLI:
pip install huggingface_hub
Login:
huggingface-cli login
Then retry.
Out of memory with local CUDA
Try:
- a smaller model
- a quantized model
- lower
--llm-max-new-tokens - closing other GPU applications
- using Ollama or LM Studio instead
Example smaller model:
--localcuda-model gpt2
Markov output is empty
Check that:
--logspoints to the correct file or directory--target-nickmatches the nick in your logs- the logs contain normal IRC messages
- the brain was rebuilt after changing logs
Rebuild with:
--rebuild-brain
RSS feed updates repeat after restart
The bot tracks seen feed entries in memory.
If the bot restarts, it may announce recent feed entries again.
Security and Identity Notes
Generated messages should be treated as fictional NPC-style output.
Recommended:
--npc-prefix "[npc] "
or:
--npc-prefix "[rkl-npc] "
This helps users distinguish generated text from real user messages.
Do not use this bot to impersonate real users.
CUDA and GPU Notes
CUDA/GPU can be used in three ways:
- Through Ollama
- Through LM Studio
- Directly through
--brain-backend localcuda
When using Ollama or LM Studio, GPU configuration is handled by those tools.
When using localcuda, GPU configuration is handled by PyTorch and Transformers.
Bernie chats bot
An IRC bot that learns from IRC logs and generates NPC-style messages using Markov chains, Ollama, LM Studio, or a local CUDA/Hugging Face Transformers model.
The bot can optionally support:
!say!rss <feed-url>- RSS/Atom/Git feed announcements
- periodic NPC-style speech
- live learning from channel messages
- random automatic replies
- Shabbat quiet mode
- local CUDA model generation
The !bernie command has been removed.
Table of Contents
- Features
- Installation
- Quick Start
- Docker
- IRC Commands
- Removed Commands
- Command-Line Options
- Brain Backends
- Markov Backend
- Ollama Backend
- LM Studio Backend
- Local CUDA Backend
- RSS Usage
- Examples
- Troubleshooting
- Security and Identity Notes
- License
Features
- Import IRC logs from a file or directory
- Build and save a reusable Markov brain
- Generate fictional NPC-style IRC messages
- Use one of four brain backends:
markovollamalmstudiolocalcuda
- Use local LLMs through:
- Ollama
- LM Studio
- PyTorch/Hugging Face Transformers
- Fall back to Markov generation if an LLM backend fails
- Add RSS/Atom/Git feeds at runtime
- Periodically announce RSS feed updates
- Optionally learn from live channel messages
- Optionally generate random replies
- Optionally suppress generated speech during Shabbat
Installation
Basic dependencies
pip install requests feedparser
Make the bot executable:
chmod +x irc_smart_log_bot.py
Optional local CUDA dependencies
Only needed if using:
--brain-backend localcuda
Install:
pip install torch transformers accelerate
For the correct CUDA-specific PyTorch command, check:
https://pytorch.org/get-started/locally/
Optional Ollama setup
Install Ollama:
https://ollama.com/
Start Ollama:
ollama serve
Pull a model:
ollama pull llama3.1:8b
Optional LM Studio setup
Install LM Studio:
https://lmstudio.ai/
Then:
- Load a model.
- Start the local server.
- Confirm the API base URL.
Default local API URL:
http://127.0.0.1:1234/v1
Quick Start
Example Markov bot with !say enabled:
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick StyleBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--brain-backend markov \
--enable-say-command
IRC Commands
Commands are typed directly in IRC.
!say
Generate one NPC/brain line.
Usage
!say
Requires
--enable-say-command
Example response
[rkl-npc] yeah that sounds about right
If --enable-say-command is not enabled, the bot ignores !say.
!rss <feed-url>
Add an RSS, Atom, or Git feed at runtime.
Usage
!rss <feed-url>
Example
!rss https://github.com/example/project/commits/main.atom
Requires
--enable-rss --enable-rss-command
If RSS polling is not enabled, the bot will not add or announce feeds.
Removed Commands
!bernie
The !bernie command has been removed.
There is no built-in IRC help command by default. Use this README as the command reference.
Command-Line Options
IRC Connection Options
| Option | Description | Example |
|---|---|---|
--server |
IRC server hostname | --server irc.libera.chat |
--port |
IRC server port | --port 6697 |
--tls |
Enable TLS/SSL | --tls |
--nick |
Bot nickname | --nick StyleBot |
--channel |
Channel to join | --channel '#test' |
--password |
Optional server password | --password secret |
--username |
IRC username | --username stylebot |
--realname |
IRC real name field | --realname "Style Bot" |
Log and Brain Options
| Option | Description | Default |
|---|---|---|
--logs |
File or directory containing IRC logs | ./logs |
--target-nick |
Nickname to learn from in logs | none |
--brain |
Saved Markov brain file | brain.pkl |
--rebuild-brain |
Rebuild the brain from logs | disabled |
--markov-order |
Markov chain order | 2 |
Example:
--logs ./logs --target-nick rkl --brain brain.pkl --rebuild-brain
NPC Output Options
| Option | Description | Default |
|---|---|---|
--npc-name |
Fictional NPC name used in prompts | npc |
--npc-prefix |
Prefix added to generated messages | [npc] |
Example:
--npc-name rkl --npc-prefix "[rkl-npc] "
Using an NPC prefix is recommended so generated messages are not confused with real users.
Feature Flags
| Option | Description |
|---|---|
--enable-say-command |
Enables the !say IRC command |
--enable-rss |
Enables RSS/Atom/Git feed polling |
--enable-rss-command |
Enables the !rss <feed-url> IRC command |
--enable-periodic-brain |
Enables automatic periodic NPC messages |
--enable-live-learning |
Learns from non-command channel messages while running |
--enable-random-replies |
Allows occasional automatic replies |
--enable-shabbat |
Suppresses generated speech during Shabbat quiet mode |
Random Reply Options
| Option | Description | Default |
|---|---|---|
--random-reply-chance |
Chance of replying to a normal message | 0.02 |
Example:
--enable-random-replies --random-reply-chance 0.05
RSS Options
| Option | Description | Default |
|---|---|---|
--rss-feed |
Add an RSS/Atom/Git feed at startup. Can be used multiple times. | none |
--rss-interval |
RSS polling interval in seconds | 300 |
Example:
--enable-rss \
--rss-feed https://github.com/example/project/commits/main.atom \
--rss-interval 300
Periodic NPC Options
| Option | Description | Default |
|---|---|---|
--periodic-min-seconds |
Minimum delay between periodic messages | 300 |
--periodic-max-seconds |
Maximum delay between periodic messages | 1200 |
Example:
--enable-periodic-brain \
--periodic-min-seconds 600 \
--periodic-max-seconds 1800
Brain Backends
The bot supports four brain backends:
--brain-backend markov
--brain-backend ollama
--brain-backend lmstudio
--brain-backend localcuda
| Backend | Description |
|---|---|
markov |
Uses a local Markov chain trained from IRC logs |
ollama |
Uses a local Ollama HTTP API model |
lmstudio |
Uses LM Studio's OpenAI-compatible local API |
localcuda |
Uses PyTorch/Hugging Face Transformers directly |
Markov Backend
The Markov backend is the default backend.
It imports IRC logs and builds a Markov chain.
Usage
--brain-backend markov
Example
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick StyleBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--brain-backend markov \
--enable-say-command
Ollama Backend
The Ollama backend uses a local Ollama model through the Ollama HTTP API.
Requirements
Install Ollama:
https://ollama.com/
Start Ollama:
ollama serve
Pull a model:
ollama pull llama3.1:8b
Usage
--brain-backend ollama
Options
| Option | Description | Default |
|---|---|---|
--ollama-host |
Ollama API host | http://127.0.0.1:11434 |
--ollama-model |
Ollama model name | llama3.1:8b |
Example
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick StyleBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--brain-backend ollama \
--ollama-host http://127.0.0.1:11434 \
--ollama-model llama3.1:8b \
--llm-fallback-markov \
--enable-say-command
LM Studio Backend
The LM Studio backend uses LM Studio's OpenAI-compatible local API.
Requirements
Install LM Studio:
https://lmstudio.ai/
Then:
- Load a model in LM Studio.
- Start the local server.
- Confirm the local server URL.
Default:
http://127.0.0.1:1234/v1
Usage
--brain-backend lmstudio
Options
| Option | Description | Default |
|---|---|---|
--lmstudio-base-url |
LM Studio OpenAI-compatible API base URL | http://127.0.0.1:1234/v1 |
--lmstudio-model |
LM Studio model name | local-model |
Example
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick StyleBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--brain-backend lmstudio \
--lmstudio-base-url http://127.0.0.1:1234/v1 \
--lmstudio-model local-model \
--llm-fallback-markov \
--enable-say-command
Local CUDA Backend
The local CUDA backend uses PyTorch and Hugging Face Transformers directly.
This is useful if Ollama or LM Studio are not available.
Requirements
Install dependencies:
pip install torch transformers accelerate
For NVIDIA CUDA, use the correct PyTorch installation command from:
https://pytorch.org/get-started/locally/
Usage
--brain-backend localcuda
Options
| Option | Description | Default |
|---|---|---|
--localcuda-model |
Hugging Face model name or local model path | mistralai/Mistral-7B-Instruct-v0.2 |
--localcuda-device |
Device to use: cuda or cpu |
cuda |
Example
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick CudaBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--brain-backend localcuda \
--localcuda-model mistralai/Mistral-7B-Instruct-v0.2 \
--localcuda-device cuda \
--llm-fallback-markov \
--enable-say-command
CPU mode
You can force CPU mode:
--brain-backend localcuda --localcuda-device cpu
CPU mode may be very slow for large models.
LLM Options
These options apply to:
ollamalmstudiolocalcuda
| Option | Description | Default |
|---|---|---|
--llm-max-new-tokens |
Maximum generated tokens | 120 |
--llm-temperature |
Randomness of generated output | 0.8 |
--llm-top-p |
Nucleus sampling value | 0.95 |
--llm-fallback-markov |
Fall back to Markov if LLM generation fails | disabled |
Example:
--llm-max-new-tokens 120 \
--llm-temperature 0.8 \
--llm-top-p 0.95 \
--llm-fallback-markov
RSS Usage
Add feeds at startup
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick FeedBot \
--channel '#test' \
--enable-rss \
--rss-feed https://github.com/example/project/commits/main.atom
Add feeds from IRC
Start with:
--enable-rss --enable-rss-command
Then type in IRC:
!rss https://github.com/example/project/commits/main.atom
The bot announces new entries like:
[rss] Commit title https://github.com/example/project/commit/abc123
Examples
Example 1: Simple Markov bot with !say
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick StyleBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--brain-backend markov \
--enable-say-command
Example 2: Ollama bot with Markov fallback
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick StyleBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--brain-backend ollama \
--ollama-model llama3.1:8b \
--llm-fallback-markov \
--enable-say-command
Example 3: LM Studio with RSS
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick StudioBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--brain-backend lmstudio \
--lmstudio-base-url http://127.0.0.1:1234/v1 \
--lmstudio-model local-model \
--llm-fallback-markov \
--enable-say-command \
--enable-rss \
--enable-rss-command
Example 4: Local CUDA with Markov fallback
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick CudaBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--brain-backend localcuda \
--localcuda-model mistralai/Mistral-7B-Instruct-v0.2 \
--localcuda-device cuda \
--llm-fallback-markov \
--enable-say-command
Example 5: Periodic NPC messages
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick NPCBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--enable-periodic-brain \
--periodic-min-seconds 600 \
--periodic-max-seconds 1800
Example 6: Live learning and random replies
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick ChatBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--enable-live-learning \
--enable-random-replies \
--random-reply-chance 0.03
Example 7: RSS feed bot
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick FeedBot \
--channel '#test' \
--enable-rss \
--enable-rss-command \
--rss-feed https://github.com/example/project/commits/main.atom \
--rss-interval 300
Example 8: Shabbat quiet mode
python3 irc_smart_log_bot.py \
--server irc.libera.chat \
--port 6697 \
--tls \
--nick QuietBot \
--channel '#test' \
--logs ./logs \
--target-nick rkl \
--npc-name rkl \
--npc-prefix "[rkl-npc] " \
--enable-say-command \
--enable-periodic-brain \
--enable-random-replies \
--enable-shabbat
Troubleshooting
!say does nothing
Make sure the bot was started with:
--enable-say-command
!rss does nothing
Make sure the bot was started with:
--enable-rss --enable-rss-command
Also install:
pip install feedparser
Ollama generation fails
Make sure Ollama is running:
ollama serve
Check installed models:
ollama list
Pull a model if needed:
ollama pull llama3.1:8b
LM Studio generation fails
Check that:
- A model is loaded.
- The local server is running.
- The base URL is correct.
Default:
http://127.0.0.1:1234/v1
Local CUDA generation fails
Install dependencies:
pip install torch transformers accelerate
Check CUDA availability:
python3 -c "import torch; print(torch.cuda.is_available())"
If CUDA is not available, either fix your PyTorch/CUDA install or use:
--localcuda-device cpu
CPU mode may be very slow for large models.
Model download fails
Some Hugging Face models require accepting a license or logging in.
Install the Hugging Face CLI:
pip install huggingface_hub
Login:
huggingface-cli login
Then retry.
Out of memory with local CUDA
Try:
- a smaller model
- a quantized model
- lower
--llm-max-new-tokens - closing other GPU applications
- using Ollama or LM Studio instead
Example smaller model:
--localcuda-model gpt2
Markov output is empty
Check that:
--logspoints to the correct file or directory--target-nickmatches the nick in your logs- the logs contain normal IRC messages
- the brain was rebuilt after changing logs
Rebuild with:
--rebuild-brain
RSS feed updates repeat after restart
The bot tracks seen feed entries in memory.
If the bot restarts, it may announce recent feed entries again.
Security and Identity Notes
Generated messages should be treated as fictional NPC-style output.
Recommended:
--npc-prefix "[npc] "
or:
--npc-prefix "[rkl-npc] "
This helps users distinguish generated text from real user messages.
Do not use this bot to impersonate real users.
CUDA and GPU Notes
CUDA/GPU can be used in three ways:
- Through Ollama
- Through LM Studio
- Directly through
--brain-backend localcuda
When using Ollama or LM Studio, GPU configuration is handled by those tools.
When using localcuda, GPU configuration is handled by PyTorch and Transformers.
Docker
On the Docker host, install the NVIDIA driver and NVIDIA Container Toolkit.
Test host GPU
nvidia-smi
Test Docker GPU passthrough
docker run --rm --gpus all nvidia/cuda:12.4.1-runtime-ubuntu22.04 nvidia-smi
If that works, Compose GPU passthrough should work.
Run GPU Version
mkdir -p logs data hf-cache
docker compose -f docker-compose.gpu.yml up -d --build
View logs:
docker compose -f docker-compose.gpu.yml logs -f
Optional .env
IRC_SERVER=irc.libera.chat
IRC_PORT=6697
IRC_NICK=BernieBot
IRC_CHANNEL=#test
TARGET_NICK=rkl
NPC_NAME=rkl
NPC_PREFIX=[rkl-npc]
LOCALCUDA_MODEL=mistralai/Mistral-7B-Instruct-v0.2
Smaller Test Model
If your GPU does not have enough VRAM, test with a smaller model first:
LOCALCUDA_MODEL=gpt2
Then run:
docker compose -f docker-compose.gpu.yml up -d --build
