Custom models - step 2 (upload)
Onboarding a custom model to aiXplain requires structuring the model according to the aiXplain standard and uploading it to the platform - the following guide details how to upload your already implemented model using a Docker image. If you have yet to implement your model according to the aiXplain standard, begin with Onboarding: Custom Models - Structure (1).
Model uploading also requires an aiXplain account and a TEAM_API_KEY
, which should be set either as an environment variable or passed into each of the CLI commands below.
2.1 Preparing the Repository
For any of the CLI commands, running aixplain [verb] [resource] --help
will display a description of each argument that should be passed into that command. Use the api-key
parameter if the TEAM_API_KEY
environment variable isn't set or you would like to override the existing environment variable.
2.1.1 Register Model and Create Image Repository
Register your model and create an image repository using the command below, which returns a model ID and a repository name.
aixplain create image-repo --name <model_name> --description <model_description> --function <function_name> --source-language <source_language> --input-modality <input_type> --output-modality <output_type> --documentation-url <information_url> [--api-key <TEAM_API_KEY>]
name
: Your model's namedescription
: A short summary of your model's purposefunction
: The function name corresponding to the model class used in your model implementationsource-language
: Your model's source languageinput-modality
: The input type for your model (e.g.,text
,audio
,video
,image
)output-modality
: The output type for your model (e.g.,text
,audio
,video
,image
)documentation-url
: The URL to any additional documentation stored on a different webpage (if applicable)api-key
: Optional
Find the appropriate function name using the following command:
aixplain list functions [--verbose] [--api-key <TEAM_API_KEY>]
verbose
: Optional, set toFalse
by defaultapi-key
: Optional
2.1.2 Obtain Repository Login Credentials
Obtain login credentials for the newly created repository:
aixplain get image-repo-login [--api-key <TEAM_API_KEY>]
These credentials are valid for 12 hours, after which you must log in again for a fresh set of credentials.
2.1.3 Log In
You can use your credentials to log in using the following Docker command:
docker login --username $USERNAME --password $PASSWORD 535945872701.dkr.ecr.us-east-1.amazonaws.com
2.2 Image Building and Repository Push
Here is an example Dockerfile script you will need for building an image:
FROM python:3.8.10
RUN mkdir /code
WORKDIR /code
COPY . /code/
# Optional: Run only if your implementation has a requirements file.
RUN pip install -r --no-cache-dir requirements.txt
# Optional: Run only if your implementation has a bash file.
RUN chmod +x /code/bash.sh
RUN ./bash.sh
CMD python -m model
You can adjust the file according to your model's specific requirements.
More Dockerfile writing guidelines can be found in their official documentation guide.
2.2.1 Build an Image
Build your image.
docker build . -t $REGISTRY/$REPO_NAME:<your-choice-of-tag>
tag
: A descriptor for your specific model, usually a version tag likev0.0.1
2.2.2 Push Image to Repository
Push the newly tagged image to the corresponding repository.
docker push $REGISTRY/$REPO_NAME:<the-tag-you-chose>
2.3 Onboard the Model
Onboard the model once the image has been pushed to its repository. The following command will send an email to an aiXplain associate to finalize the onboarding process.
aixplain onboard model --model-id <model_id> --image-tag <model_image_tag> --image-hash <model_image_hash> --host-machine <host_machine_code> [--api-key <TEAM_API_KEY>]
model-id
: The model ID returned by thecreate image-repo
function used earlierimage-tag
: The string used to tag your model imagesha256
: The image's sha256 hash, obtained by runningdocker images --digests
host-machine
: The machine code on which to host the model
The following command lists the codes of all the available machines on which you can host your model:
aixplain list gpus [--api-key <TEAM_API_KEY>]