A simple framework to deploy AI models locally with one command, no containers needed
Project description
tursi-ai
Deploy AI models with unmatched simplicity - zero container overhead. Features efficient model quantization for reduced memory usage and faster inference, perfect for resource-constrained environments like IoT and Edge devices.
Table of Contents
- Features
- Installation
- Quick Start
- Common Use Cases
- Command Reference
- API Reference
- Configuration
- Best Practices
- Development
- Troubleshooting
Features
- Intuitive command-line interface for model deployment
- Zero container overhead - lightweight and efficient
- Optimized for resource-constrained environments
- Simple API interface
- Built-in security features
- Edge-efficient model quantization
- Dynamic and static quantization support
- 4-bit and 8-bit quantization options
- Optimized for CPU inference
- Rate limiting and monitoring
- Automated versioning and releases
Installation
pip install tursi
Quick Start
# Start a model server
tursi up distilbert-base-uncased
# Start with custom settings
tursi up distilbert-base-uncased --port 8000 --quantization dynamic --bits 4
# List running models
tursi ps
# View server logs
tursi logs
# Check resource usage
tursi stats
# Stop the server
tursi down
Making Predictions
# Test with positive sentiment
curl -X POST -H "Content-Type: application/json" \
-d '{"text": "This is a great product! I love it!"}' \
http://localhost:5000/predict
# Example response:
# {"label": "POSITIVE", "score": 0.9998828172683716}
# Test with negative sentiment
curl -X POST -H "Content-Type: application/json" \
-d '{"text": "This product is terrible, I regret buying it."}' \
http://localhost:5000/predict
# Example response:
# {"label": "NEGATIVE", "score": 0.9995611310005188}
Command Reference
tursi up
Start a model server.
tursi up [OPTIONS] MODEL_NAME
Options:
--port, -p INTEGER Port to run the API server on (default: 5000)
--host TEXT Host to bind the API server to (default: 127.0.0.1)
--quantization, -q TEXT Quantization mode: 'dynamic' or 'static' (default: dynamic)
--bits, -b INTEGER Number of bits for quantization (4 or 8) (default: 8)
--rate-limit, -r TEXT API rate limit (default: "100/minute")
--cache-dir, -c PATH Directory to cache models (default: ~/.tursi/models)
-h, --help Show this message and exit
tursi down
Stop a running model server.
tursi down
tursi ps
List running models.
tursi ps
tursi logs
View server logs.
tursi logs [OPTIONS]
Options:
--follow, -f Follow log output
--tail INTEGER Number of lines to show (default: all)
tursi stats
Show resource usage statistics.
tursi stats
API Reference
POST /predict
Endpoint for making predictions using the loaded model.
Request Body:
{
"text": "Your text here"
}
Response:
{
"label": "POSITIVE",
"score": 0.9
}
Configuration
The following environment variables can be set:
RATE_LIMIT: API rate limit (default: "100 per minute")RATE_LIMIT_STORAGE_URI: Storage backend for rate limiting (default: "memory://")QUANTIZATION_MODE: Quantization mode (default: "dynamic")QUANTIZATION_BITS: Number of bits for quantization (default: 8)
Quantization Options
-
Mode:
dynamic: Quantization is performed at runtime (default)- Best for general use cases
- Maintains good accuracy while reducing model size
static: Quantization is performed during model loading- Better performance for specific use cases
- Requires calibration data
-
Bits:
8: 8-bit quantization (default)- Good balance between compression and accuracy
- Recommended for most use cases
4: 4-bit quantization- More aggressive compression
- May impact accuracy
- Best for resource-constrained environments
Development
Setting Up Development Environment
# Clone the repository
git clone https://github.com/BlueTursi/tursi-ai.git
cd tursi-ai
# Install Poetry (if not installed)
curl -sSL https://install.python-poetry.org | python3 -
# Install dependencies
poetry install
# Run tests with coverage
poetry run pytest tests/ -v --cov=tursi --cov-report=xml
# Build package
poetry build
Release Process
For detailed information about the release process, please refer to RELEASE.md.
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests to ensure everything works
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
Acknowledgments
Built with 💙 using:
- Transformers
- Flask
- PyTorch
- Poetry
- ONNX Runtime
- Optimum
Built by BlueTursi.
Common Use Cases
1. Edge Device Deployment
# Deploy a lightweight model optimized for edge devices
tursi up microsoft/squeezebert-mnli --bits 4 --quantization dynamic \
--rate-limit "50/minute" --port 8080
# Monitor resource usage to ensure it fits device constraints
tursi stats
2. Production API Server
# Deploy a robust model with appropriate rate limiting
tursi up bert-base-uncased \
--host 0.0.0.0 \
--port 443 \
--rate-limit "1000/minute" \
--cache-dir /opt/tursi/models
# Monitor the deployment
tursi logs --follow
3. Local Development
# Quick deployment for testing
tursi up distilbert-base-uncased
# In another terminal, test the API
curl -X POST \
-H "Content-Type: application/json" \
-d '{"text": "Testing the model"}' \
http://localhost:5000/predict
4. Multi-Model Setup
# Deploy sentiment analysis model
tursi up distilbert-base-uncased --port 5000
# Deploy named entity recognition model
tursi up dslim/bert-base-NER --port 5001
# List all running models
tursi ps
5. Resource-Constrained Environments
# Deploy with maximum compression
tursi up distilbert-base-uncased \
--bits 4 \
--quantization static \
--rate-limit "20/minute"
# Monitor memory usage
tursi stats
Each use case demonstrates different aspects of Tursi's capabilities:
- Edge deployment with 4-bit quantization for minimal resource usage
- Production setup with appropriate host/port configuration
- Local development workflow
- Running multiple models simultaneously
- Maximum compression for resource-constrained environments
Best Practices
Resource Management
- Start with 8-bit quantization and monitor performance
- Switch to 4-bit if memory constraints are tight
- Use
tursi statsto monitor resource usage - Set appropriate rate limits based on hardware capacity
Production Deployment
- Always set explicit
--hostand--portvalues - Configure appropriate rate limits
- Use a dedicated cache directory
- Monitor logs with
tursi logs --follow - Set up health monitoring using the
/healthendpoint
Development Workflow
- Use default settings for quick iterations
- Test different quantization options
- Monitor memory usage with
tursi stats - Use
curlor Postman for API testing
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 tursi-0.3.0a3.tar.gz.
File metadata
- Download URL: tursi-0.3.0a3.tar.gz
- Upload date:
- Size: 23.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ce01da6365fab8693175982beb490d9dcaa6d6642d819676f70570c3775dcf2
|
|
| MD5 |
7991830972fcb41f821643b1e870f277
|
|
| BLAKE2b-256 |
3163274cb77dea188fa8005a2ff42a67256ef892d37c02488a114f2957935e1d
|
Provenance
The following attestation bundles were made for tursi-0.3.0a3.tar.gz:
Publisher:
release.yml on BlueTursi/tursi-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tursi-0.3.0a3.tar.gz -
Subject digest:
9ce01da6365fab8693175982beb490d9dcaa6d6642d819676f70570c3775dcf2 - Sigstore transparency entry: 201772338
- Sigstore integration time:
-
Permalink:
BlueTursi/tursi-ai@9d7d1dfb950ce52a97aef055979c36d538b658a9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/BlueTursi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9d7d1dfb950ce52a97aef055979c36d538b658a9 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file tursi-0.3.0a3-py3-none-any.whl.
File metadata
- Download URL: tursi-0.3.0a3-py3-none-any.whl
- Upload date:
- Size: 25.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e41b54b7d5e890f6766bd59b0dddb33f29a66ae160f2b6e1ab17ad1d2c5afec9
|
|
| MD5 |
612d5624da0f13ef5293802d3f084ca0
|
|
| BLAKE2b-256 |
d1e475144b83e475fe53e889a84013736b01f8d45d2d4d127c2b90141fce67c2
|
Provenance
The following attestation bundles were made for tursi-0.3.0a3-py3-none-any.whl:
Publisher:
release.yml on BlueTursi/tursi-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tursi-0.3.0a3-py3-none-any.whl -
Subject digest:
e41b54b7d5e890f6766bd59b0dddb33f29a66ae160f2b6e1ab17ad1d2c5afec9 - Sigstore transparency entry: 201772340
- Sigstore integration time:
-
Permalink:
BlueTursi/tursi-ai@9d7d1dfb950ce52a97aef055979c36d538b658a9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/BlueTursi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9d7d1dfb950ce52a97aef055979c36d538b658a9 -
Trigger Event:
workflow_dispatch
-
Statement type: