A local AI assistant developed in Python that combines a local Large Language Model (LLM) with a fine-tuned transformer model for text classification.
The project consists of two connected parts:
- Part 1: Local AI Chat Assistant using Ollama and Tkinter.
- Part 2: German customer message classification using DistilBERT.
The classifier is integrated into the GUI and automatically predicts the category of every user message before the AI generates its response.
Local-AI-Assistant/
β
βββ teil1/
β βββ chat.py
β βββ gui.py
β βββ main.py
β
βββ teil2/
β βββ data/
β β βββ dataset_teil2.csv
β βββ model/
β β βββ final_model/
β βββ check_dataset.py
β βββ classifier.py
β βββ predict.py
β βββ train.py
β
βββ images/
β βββ teil1_chat.png
β βββ training_model_teil2.png
β
βββ README.md
βββ requirements.txt
βββ .gitignore
Develop a desktop AI assistant that communicates with a locally running Large Language Model using Ollama.
- Python
- Tkinter
- Ollama
- Llama 3.2:3b
- Local AI chatbot
- Graphical User Interface (GUI)
- Conversation history
- Communication with Ollama
- Automatic text classification
- Category prediction
- Confidence score display
Fine-tune a transformer model to classify German customer messages into predefined categories.
- Anfrage
- Reklamation
- Rechnung
- Sonstiges
The dataset was manually created.
It contains:
- 200 text examples
- 4 categories
- 50 examples per category
The dataset is stored as a CSV file.
- Python
- Pandas
- PyTorch
- Hugging Face Transformers
- Hugging Face Datasets
- Scikit-Learn
The training process consists of the following steps:
- Load the dataset.
- Encode category labels into numerical IDs.
- Split the dataset into training and test sets.
- Convert the data into Hugging Face Dataset format.
- Tokenize the text.
- Fine-tune DistilBERT.
- Evaluate the model.
- Save the trained model.
- Save the tokenizer.
| Parameter | Value |
|---|---|
| Model | distilbert-base-german-cased |
| Dataset size | 200 |
| Classes | 4 |
| Training samples | 160 |
| Test samples | 40 |
| Epochs | 3 |
| Batch size | 8 |
| Learning rate | 2e-5 |
| Training time | ~0.82 min |
| Evaluation Loss | 0.8794 |
| Test Accuracy | 87.50 % |
Input
Ich habe meine Rechnung nicht erhalten.
Output
Kategorie: Rechnung
Confidence: 87.50 %
Every user message is automatically classified before the AI generates a response.
Example
Sie:
Ich habe meine Rechnung nicht erhalten.
Kategorie:
Rechnung (87.50 %)
KI:
NatΓΌrlich helfe ich Ihnen.
Bitte senden Sie mir Ihre Bestellnummer oder Rechnungsnummer,
damit ich Ihnen weiterhelfen kann.
- Python 3.10+
- Ollama installed
- Llama 3.2:3b downloaded locally
Clone the repository
git clone https://github.com/FootballOnlooker/Local-AI-Assistant.gitCreate a virtual environment
python -m venv .venvActivate it
Windows
.venv\Scripts\activateInstall dependencies
pip install -r requirements.txtollama pull llama3.2:3bpython teil2/train.pyThe training process creates
teil2/model/final_model/
python teil1/main.pypython teil2/predict.py- transformers
- datasets
- torch
- pandas
- numpy
- scikit-learn
- ollama
- tkinter
This project was created for educational purposes.
It demonstrates:
- Local LLM integration using Ollama
- Transformer fine-tuning with Hugging Face
- Text classification using DistilBERT
- Desktop GUI development with Tkinter
- Integration of a classifier into a local AI assistant
The classifier is trained on a manually created dataset containing 200 German customer messages.
Although the achieved accuracy is 87.50%, the model may still produce incorrect predictions for previously unseen or ambiguous messages.
The displayed confidence score is the highest Softmax probability produced by the classifier. A high confidence value indicates that the model strongly prefers one category over the others, but it does not guarantee that the prediction is correct.
This project was created for educational and demonstration purposes.

