Skip to main content

A Python module for efficient multi-model AI inference with memory management

Project description

MultiModel-AI

A Python module for efficient multi-model AI inference with memory management.

Features

  • Efficient memory management for multiple AI models
  • Automatic model loading and unloading
  • Support for various AI model types
  • Easy-to-use API

Installation

pip install multimodel-ai

Usage

from multimodel_ai import ModelManager

# Initialize the model manager
manager = ModelManager()

# Load a model
model = manager.load_model("model_name")

# Use the model
result = model.predict(input_data)

# The model will be automatically unloaded when not in use

Examples

Basic Usage

from multimodel_ai import ModelManager

# Initialize the manager
manager = ModelManager()

# Load a model
model = manager.load_model("gpt2")

# Generate text
text = model.generate("Hello, world!")

# The model will be automatically unloaded

Multiple Models

from multimodel_ai import ModelManager

# Initialize the manager
manager = ModelManager()

# Load multiple models
model1 = manager.load_model("gpt2")
model2 = manager.load_model("bert")

# Use the models
text1 = model1.generate("Hello")
text2 = model2.classify("World")

# Models will be automatically unloaded when not in use

Custom Model Configuration

from multimodel_ai import ModelManager

# Initialize the manager with custom settings
manager = ModelManager(
    max_memory_usage=0.8,  # Use up to 80% of available memory
    model_cache_dir="./models"  # Custom cache directory
)

# Load a model with specific configuration
model = manager.load_model(
    "gpt2",
    device="cuda",
    precision="fp16"
)

# Use the model
result = model.generate("Hello, world!")

Error Handling

from multimodel_ai import ModelManager, ModelError

try:
    manager = ModelManager()
    model = manager.load_model("non_existent_model")
except ModelError as e:
    print(f"Error loading model: {e}")

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

multimodel_ai-0.1.2.tar.gz (43.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

multimodel_ai-0.1.2-py2.py3-none-any.whl (42.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file multimodel_ai-0.1.2.tar.gz.

File metadata

  • Download URL: multimodel_ai-0.1.2.tar.gz
  • Upload date:
  • Size: 43.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for multimodel_ai-0.1.2.tar.gz
Algorithm Hash digest
SHA256 46168ce4a7cde7be3e576d7b79f5bff58543c2ca7f9f12fdfee666ab9b29d0f4
MD5 8fa092085d8aad47f1b0fcc71b2fdad1
BLAKE2b-256 5b6992cf569a8d0d1adc7bc4b588b6af44b6fe375243ce49d77c57b14cc9a428

See more details on using hashes here.

File details

Details for the file multimodel_ai-0.1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: multimodel_ai-0.1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 42.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for multimodel_ai-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a31bcea041d23941e8833c847c875b981b4cf0f78533e4b7a0911b78fc5569d3
MD5 24dc910964adb401afc2f8b003281c72
BLAKE2b-256 e4fbb3c4730a708a72e18787c01af5207534460618869ec695c3e09e15004447

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page