Convert natural language to SQL queries using RAG-powered LLM.
graph TD
subgraph UI
A[User]
B[Streamlit Dashboard]
end
subgraph Service
C[No More SQL Service]
D[Query Processor]
end
subgraph Components
E[LLM via Ollama]
F[FAISS Search]
G[SQLite DB]
end
A --> B
B --> C
C --> D
D --> E
D --> F
D --> G
- Start Ollama container:
docker run -d \
--name ollama \
--gpus all \
--runtime=nvidia \
-e NVIDIA_VISIBLE_DEVICES=all \
-e NVIDIA_DRIVER_CAPABILITIES=all \
-p 11434:11434 \
-v ollama:/root/.ollama \
ollama/ollama- Pull required model:
docker exec ollama ollama pull llama3.1:70b2a. If installing on 6 containers for distributing load:
for i in {0..5}; do echo -e "\nPulling llama3.1:70b on ollama-gpu$i:"; docker exec ollama-gpu$i ollama pull llama3.2:1b; done
2b. To see all models on each container:
for i in {0..5}; do echo -e "\nOllama GPU $i Models:"; docker exec ollama-gpu$i ollama list 2>/dev/null || echo "Container not running or command failed"; done
- Start the application:
sudo systemctl start no-more-sql- LLM: llama3.3:70b via Ollama
- RAG: FAISS for semantic search
- Frontend: Streamlit dashboard
- Storage: SQLite for feedback
When running, the app is accessible at:
- Local:
http://localhost:8504 - Network:
http://anlpa1.mskcc.org:8504
- CUDA-capable GPU
- Python 3.10
- Docker with NVIDIA runtime
- Create FAISS index on first run (will be generated from your data)
- Root directory:
/data/docker - Models stored in:
/data/docker/volumes/ollama/_data/models/ - Current models:
- llama3.3:70b (42GB)
- deepseek-r1:1.5b (1.1GB)
# Start/Stop service
sudo systemctl start/stop no-more-sql
# View logs
sudo journalctl -u no-more-sql -f
# Restart after changes
sudo systemctl restart no-more-sqlTo make the Streamlit app accessible on a GPU server, you need to configure the server to listen on all network interfaces and adjust firewall settings to allow incoming traffic on the specified port.
-
Run Streamlit with Network Access: Use the following command to start the app, ensuring it listens on all network interfaces:
streamlit run code/main.py --server.address=0.0.0.0 --server.port=8504
-
Override Firewall Settings: Use
iptablesto allow incoming traffic on the port the app is running on:sudo iptables -I INPUT -p tcp --dport 8504 -j ACCEPT
This command inserts a rule to accept TCP traffic on port 8504, which is necessary if a firewall is blocking access by default.
- Check service status:
sudo systemctl status no-more-sql- Verify Ollama:
docker logs ollama
nvidia-smi # Check GPU usage- Common issues:
- Connection refused → Check if Ollama is running
- Slow responses → Monitor GPU usage
- Permission denied → Check service user and paths
- Application:
/home/porwals/GitHub/projects/no-more-sql - Service config:
/etc/systemd/system/no-more-sql.service - Database:
data/feedback.db - FAISS index:
text_to_sql_index.faiss
- Service runs as user 'porwals'
- Port 8504 must be accessible
- Consider implementing authentication
The "No More SQL" Streamlit app is deployed as a systemd service on the server. This allows the app to run as a background service, automatically start on boot, and be managed using standard systemd commands.
The service file is located at /etc/systemd/system/no-more-sql.service. Below is the configuration used:
[Unit]
Description=No More SQL Streamlit App
After=network.target
[Service]
User=porwals
WorkingDirectory=/home/porwals/GitHub/projects/no-more-sql
Environment="PATH=/home/porwals/GitHub/projects/no-more-sql/.venv/bin:/usr/local/bin:/usr/bin:/bin"
ExecStart=/home/porwals/GitHub/projects/no-more-sql/.venv/bin/streamlit run code/main.py --server.port=8504 --server.address=0.0.0.0
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target-
List All Services: View all systemd services on the system:
systemctl list-units --type=service
-
List Running Services: Show only active services:
systemctl list-units --type=service --state=running
-
View Service Status: Check status of a specific service:
systemctl status no-more-sql
-
Create Service File: Create a new systemd service file in
/etc/systemd/system/:sudo nano /etc/systemd/system/your-app-name.service
-
Service File Template:
[Unit] Description=Your App Description After=network.target [Service] User=your_username WorkingDirectory=/path/to/your/app Environment="PATH=/path/to/your/virtualenv/bin:/usr/local/bin:/usr/bin:/bin" ExecStart=/path/to/your/virtualenv/bin/streamlit run code/main.py --server.port=XXXX --server.address=0.0.0.0 Restart=always RestartSec=5 [Install] WantedBy=multi-user.target
-
Enable and Start Service:
sudo systemctl daemon-reload # Reload systemd manager configuration sudo systemctl enable your-app-name # Enable service to start on boot sudo systemctl start your-app-name # Start the service
-
Configure Network Access:
sudo iptables -I INPUT -p tcp --dport XXXX -j ACCEPT # Allow traffic on your port
# Basic service control
sudo systemctl start service-name # Start a service
sudo systemctl stop service-name # Stop a service
sudo systemctl restart service-name # Restart a service
sudo systemctl status service-name # Check service status
# Service configuration
sudo systemctl enable service-name # Enable service on boot
sudo systemctl disable service-name # Disable service on boot
# Log viewing
sudo journalctl -u service-name -f # View and follow service logsNote: Replace your-app-name, your_username, and XXXX with your specific values when deploying a new service.