Skip to main content

Alibaba Cloud PAI Python SDK

Project description

PAI Python SDK

English | 简体中文

The PAI Python SDK is provided by Alibaba Cloud's Platform for Artificial Intelligence (PAI). It offers a user-friendly High-Level API, enabling machine learning engineers to easily train and deploy models on PAI using Python, streamlining the machine learning workflow.

Installation 🔧

Install the PAI Python SDK using the following command, which supports Python versions >= 3.6 (it is recommended to use Python >= 3.8):

python -m pip install alipai

📖 Documentation

Find detailed documentation, including API references and user guides, in the docs directory or visit PAI Python SDK Documentation.

🛠 Basic Usage

  • Submit a custom training job

The following example demonstrates how to submit a custom training job to PAI:

from pai.estimator import Estimator
from pai.image import retrieve

est = Estimator(
    # Retrieve the latest PyTorch image provided by PAI
    image_uri=retrieve(
        framework_name="PyTorch", framework_version="latest"
    ).image_uri,
    command="echo hello",
    # Optionally, specify the source_dir to upload your training code:
    # source_dir="./train_src",
    instance_type="ecs.c6.large",
)

# Submit the training job
est.fit()

print(est.model_data())
  • Deploy Large Language Model

PAI provides numerous pretrained models that you can easily deploy using the PAI Python SDK:

from pai.model import RegisteredModel

# Retrieve the QWen-7b model provided by PAI
qwen_model = RegisteredModel("qwen-7b-chat-lora", model_provider="pai")

# Deploy the model
p = qwen_model.deploy(service_name="qwen_service")

# Call the service
p.predict(
    data={
        "prompt": "How to install PyTorch?",
        "system_prompt": "Act like you are programmer with 5+ years of experience.",
        "temperature": 0.8,
    }
)

For more details, please refer to the PAI Python SDK Documentation.

🤝 Contributing

Contributions to the PAI Python SDK are welcome. Please read our contribution guidelines in the CONTRIBUTING file.

📝 License

PAI Python SDK is developed by Alibaba Cloud and licensed under the Apache License (Version 2.0).

📬 Contact

For support or inquiries, please open an issue on the GitHub repository or contact us in the DingTalk group:

DingTalkGroup

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

alipai-0.4.5.dev0.tar.gz (11.3 MB view details)

Uploaded Source

Built Distribution

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

alipai-0.4.5.dev0-py3-none-any.whl (320.2 kB view details)

Uploaded Python 3

File details

Details for the file alipai-0.4.5.dev0.tar.gz.

File metadata

  • Download URL: alipai-0.4.5.dev0.tar.gz
  • Upload date:
  • Size: 11.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.18

File hashes

Hashes for alipai-0.4.5.dev0.tar.gz
Algorithm Hash digest
SHA256 97ccb526f4a972c45c56da1f2675685231eee6c0c125c1e5b44527787e6110dd
MD5 296723db2b20059c223f80213d8164d6
BLAKE2b-256 4e7ab65c628e39c8155ac1d9eff48574b6f88d507298dc79bf322e40d62d5aad

See more details on using hashes here.

File details

Details for the file alipai-0.4.5.dev0-py3-none-any.whl.

File metadata

  • Download URL: alipai-0.4.5.dev0-py3-none-any.whl
  • Upload date:
  • Size: 320.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.18

File hashes

Hashes for alipai-0.4.5.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5e8ec1da5bd2730753c05efbe7024e285409555ea6f8703c83573eb717a016a
MD5 44c58d8f60cc457383e290ed4707fadf
BLAKE2b-256 0a98b11a0a19238cd026f08bf0fd52ec3f63306433154617a4b9ebf7a3f7a44c

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