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.3.tar.gz (45.6 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.3-py3-none-any.whl (41.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: multimodel_ai-0.1.3.tar.gz
  • Upload date:
  • Size: 45.6 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.3.tar.gz
Algorithm Hash digest
SHA256 1defa77b278e3979f5e123438691307083def3dfb0fd1e9f6295c7ec044a17bb
MD5 f99413d2f8678470d1c9a020ad586310
BLAKE2b-256 e2276d5f92a112490cf605183267098c66b4b9e115eee578b230a01cd82b352a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multimodel_ai-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 41.3 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 febd8ea60e108bfc4860faea88668667224ef6c157dbbaa0a06d5d2596915c18
MD5 bb8df0a10ba310a126c0318a5332b88f
BLAKE2b-256 8e24b287e766fbe1652820495338699b4314b740563120874198c65a02299332

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