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.5.tar.gz (91.8 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.5-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: multimodel_ai-0.1.5.tar.gz
  • Upload date:
  • Size: 91.8 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.5.tar.gz
Algorithm Hash digest
SHA256 77d473e5fba6e4bd706858acccbfd2267dc973bdb87a2e9ad37268d0037d51e0
MD5 16609f8949c1f460f7f697007eaf7034
BLAKE2b-256 64d1e7924b2d9c0c1737e8c82315af27a5733c6a0239b5ae465538aabe34e86c

See more details on using hashes here.

File details

Details for the file multimodel_ai-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: multimodel_ai-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0bf4b2fc43f85597aab05c40aefa8a2ceac6838890de781bd8061c88259e12a7
MD5 9604e564e7de27bd69e4953e4ae9a2fb
BLAKE2b-256 7db86a5d574e8d6c23c8bd66a2b5cf51e7ce69186c67dc72b6635437713a6e0e

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