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.6.tar.gz (5.7 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.6-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: multimodel_ai-0.1.6.tar.gz
  • Upload date:
  • Size: 5.7 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.6.tar.gz
Algorithm Hash digest
SHA256 63d6cda8b624b08272f79de984fd0c752e34af5dcd7f1abb45bb910c8f0a0ade
MD5 043238cb57c193204402c40bebb79657
BLAKE2b-256 267636bb1e5283983e52fbe7fad3fe60e0926969e07cfeb95a375212c920730e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multimodel_ai-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 5.9 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1681fe0acaf25bb58ac37750975bb361f3f2bcb3895f9f324f8bd698c0640090
MD5 4de7287b7d915cbd60cd70ee3141e2ca
BLAKE2b-256 6a1ee82a00a76a338c3dc7243ab3bcef04224ef37d7a8d231ab817316a1d2ecf

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