A nano-LLM trained from scratch on personal chat data to mimic a conversational style.
Project description
Personal Chat SLM (Small Language Model)
A command-line tool to train a "nano" language model from scratch on your personal chat history. This project takes a raw chat export (like from WhatsApp) and builds a character-level Transformer model that learns to mimic the unique style, vocabulary, and rhythm of your conversations.
Think of it as creating a "digital conversational ghost" from your chat data. It's designed primarily as an educational tool to understand how language models are built from the ground up, rather than a large-scale, general-purpose chatbot.
Features
- Builds from Scratch: Doesn't use pre-trained models. You build and train your own Transformer architecture.
- Character-Level Learning: Learns the statistical patterns of your chat one character at a time, allowing it to capture unique spellings, slang, and emoji usage.
- CLI Interface: A simple, powerful command-line interface to manage the entire workflow: cleaning data, training the model, and generating text.
- Packaged for Distribution: Published as a public package on PyPI, so anyone can install and use it.
How It Works
The tool follows a three-step process, managed entirely by the command-line interface:
- Clean: It ingests a raw chat file (e.g.,
_chat.txtfrom WhatsApp) and strips away all metadata like timestamps, sender names, and system messages (<Media omitted>). This produces a clean text corpus. - Train: It uses this clean corpus to train a decoder-only Transformer model (like GPT). The model learns the probability of which character is likely to follow a given sequence of characters.
- Generate: Once trained, the model can be given a starting prompt. It then generates new text character-by-character based on the patterns it learned, effectively mimicking the conversational style of the training data.
Installation
You can install personal-chat-slm directly from PyPI using pip:
pip install personal-chat-slm
Usage: The 3-Step Workflow
Using the tool involves preparing your data and then running the three main commands in order.
Step 1: Prepare Your Data
You need a raw chat log file. The tool is designed to work with WhatsApp chat exports.
- In WhatsApp, go to a chat, tap the three dots -> More -> Export chat -> Without media.
- Save the resulting
.txtfile inside adata/folder in your project directory. Let's assume you name itdata/my_chat.txt.
Step 2: Clean the Data
Run the clean command to process your raw chat file.
# This command will read your raw chat file and create a clean version.
custom-llm clean --input-file data/my_chat.txt --output-file data/chat_clean.txt
Step 3: Train the Model
Now, use the cleaned data to train your model. This step will take time and is best run on a machine with a GPU.
# This command starts the training process and saves the final model.
custom-llm train --data_path data/chat_clean.txt --max-iters 5000
--max-iters: The number of training steps. 5000 is a good starting point. More iterations can lead to a better model but will take longer.- The trained model will be saved by default to
models/nano_llm_model.pth.
Step 4: Generate Text
Once your model is trained, you can use it to generate text from any prompt.
# Provide a prompt directly on the command line.
custom-llm generate "Hey, what are you doing tonight?" --max-new-tokens 300
The model will load your trained weights and generate text that continues the prompt in the style it has learned.
For Developers (Local Setup)
If you want to contribute or modify the source code, follow these steps:
-
Clone the repository:
git clone [https://github.com/yourusername/personal-chat-slm.git](https://github.com/yourusername/personal-chat-slm.git) cd personal-chat-slm
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install in editable mode: This command links the
custom-llmcommand to your source code, so any changes you make are immediately reflected.pip install -e .
Ethical Considerations & Disclaimer
This project deals with highly sensitive personal data. Ethical use is paramount.
- Consent: Do not use any chat log without the explicit, informed consent of all participants in the chat.
- Privacy: Never upload your private chat data or trained models derived from it to public repositories like GitHub. The
.gitignorefile in this project is configured to prevent this automatically. Handle the data with extreme care. - Disclaimer: This tool is provided for educational purposes. The generated text is a statistical artifact and may not always be coherent or appropriate. The creators are not responsible for the model's output or any misuse of this software.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file personal_chat_slm-0.1.0.tar.gz.
File metadata
- Download URL: personal_chat_slm-0.1.0.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccec78a46833bf71b93d6ea21bf8885a0a4b42915e5f0529d818db0071ee652a
|
|
| MD5 |
efd640145fb41bcef428826a729497b3
|
|
| BLAKE2b-256 |
4db3bd0547a6e37dd312ee533376f3e5530e28ebfb529a9cbea5eb7224d02d7e
|
File details
Details for the file personal_chat_slm-0.1.0-py3-none-any.whl.
File metadata
- Download URL: personal_chat_slm-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d095ad1bfef13d83ead04cb8d35533260ff455c64a4ba29e19d779905b49b46
|
|
| MD5 |
e0fae1ab3ff4f0365b0828e0066ab955
|
|
| BLAKE2b-256 |
d64c0aeed922f14a0786130ddfeb26f5434e48dc4bd2106c9c2080695ab19f38
|