A real-time chat application with a Polish language model, built with FastAPI backend and Astro+React frontend.
redis-server
```Redis Server in Docker/Podman
docker run --name valkey -p 6379:6379 -d valkey/valkeycd backend
uv pip install -r requirements.txt
uv run python api/main.pycd frontend
npm install
npm run build
npm run devVisit: http://localhost:3000
- Real-time chat with WebSocket
- Polish language model integration
- Clean chat history (🗑️ button)
- Message storage in Valkey (Redis)
- Responsive design with Tailwind CSS
Frontend (React+Astro) → WebSocket → Backend (FastAPI) → Valkey (Redis)
Input Corpus file 'polish_corpus.txt'
Tokenizer Output polish_bpe_32k.json
cd backend
python main.py --train_tokenizerpolish_wiki_val_000000.npy
python main.py --prepare_datasetpolish_small_model.pt
python main.py --train_modelpython main.py --inference "Your prompt here"data/
├── raw/
│ └── polish_corpus.txt # Raw Polish text data
└── processed/
├── models/
│ ├── tokenizers/ # Trained tokenizers
│ │ └── polish_bpe_32k.json
│ └── polish_small_model.pt # Trained model
└── shards/ # Tokenized dataset shards
Edit backend/configs/tokenizer_config.json:
{
"vocab_size": 32000,
"min_frequency": 2,
"special_tokens": ["<|endoftext|>", "[UNK]", "[PAD]"]
}- Python 3.10+
- PyTorch (with CUDA for GPU acceleration)
- HuggingFace tokenizers
- NumPy
- FastAPI
- Redis
- Node.js 16+
- npm or pnpm
# Backend tests
cd backend
pytest
# Frontend tests (TODO)
cd frontend
npm test# Frontend build
cd frontend
pnpm run build
# Backend (use production server)
uv run --host 0.0.0.0 --port 8000 api.main:app# Build images
docker build -t polish-llm-frontend:latest frontend/
docker build -t polish-llm-backend:latest backend/
# Run containers
docker run -p 3000:80 polish-llm-frontend:latest
docker run -p 8000:8000 polish-llm-backend:latestkubectl apply -f frontend/k8s/
kubectl apply -f backend/k8s/# Initialize OpenTofu
tofu init
# Review the execution plan
tofu plan -f infra/main.tf
# Apply the configuration
tofu apply -f infra/main.tf- CUDA Out of Memory: Reduce batch size
- Tokenizer Errors: Verify UTF-8 encoding
- Slow Training: Use GPU acceleration
- WebSocket Failed: Verify backend running
- No Response: Check backend logs
- Redis Errors: Ensure Redis is running
MIT License
- Paweł Aksiutowicz - Lead Developer
- Code generation and optimization supported by Mistral AI
- Special thanks for invaluable resources, code and strong support in learning:
- Arkadiusz Słota @Maggio333
- Kacper Wikieł @kwikiel
- Slayer AI Labs @slayerlabs