Models Service | Kamiwaza Docs

This is documentation for Kamiwaza 1.0.0, which is no longer actively maintained. For the current GA release, see 1.0.1.

Version: 1.0.0

Overview

The Model Service (ModelService) provides comprehensive model management functionality for the Kamiwaza AI Platform. Located in kamiwaza_sdk/services/models.py, this service handles model lifecycle management, including creation, deployment, file management, and configuration.

Key Features

Model Management

Basic Operations

# Get a specific model

model = client.models.get_model(model_id)

# Create a new model

model = client.models.create_model(CreateModel(

name="my-model",

description="My custom model"

))

# List all models

models = client.models.list_models(load_files=True)

# Delete a model

client.models.delete_model(model_id)

Model Search

# Search for models

models = client.models.search_models(

query="bert",

exact=False,

limit=100,

hubs_to_search=["huggingface"]

)

# Get model by repo ID

model = client.models.get_model_by_repo_id("bert-base-uncased")

Model Download Management

Available Methods

# Download a model

download_info = client.models.initiate_model_download(

repo_id="llama2-7b",

quantization="q6_k"

)

# Check download status

status = client.models.check_download_status("llama2-7b")

Model File Management

Available Methods

# List model files

files = client.models.list_model_files()

# Get files for specific model

model_files = client.models.get_model_files_by_model_id(model_id)

# Search hub files

files = client.models.search_hub_model_files(HubModelFileSearch(

hub="huggingface",

model="bert-base-uncased"

))

Model Configuration Management

Available Methods

# Create model configuration

config = client.models.create_model_config(CreateModelConfig(

model_id=model_id,

parameters={"temperature": 0.7}

))

# Get configurations for model

configs = client.models.get_model_configs(model_id)

Memory Usage Tracking

Available Methods

# Check model memory usage

memory_usage = client.models.get_model_memory_usage(model_id)

Error Handling

The service includes built-in error handling for common scenarios:

try:

model = client.models.get_model(model_id)

except APIError as e:

print(f"Operation failed: {e}")

Best Practices

  1. Always check model compatibility before downloading
  2. Monitor download status for large models
  3. Use appropriate quantization for your use case
  4. Clean up unused model files to manage storage
  5. Keep track of model configurations
  6. Monitor memory usage for large models