One of the most important parts of the Kodexa Platform is the ability to create and manage models. Models are the core of the platform and are used to extract data from documents. Models are created by using Python and the Kodexa SDK.In its simplest form, a model is simply a small Python script that receives a Document and returns a Document. The model can be as simple as:
To deploy the model, we need to also create a model.yml file that describes the model. This file is used to describe the model, and also to provide the metadata that is used to deploy the model to the Kodexa Platform.
Copy
Ask AI
# A very simple first model that isn't trainableslug: my-modelversion: 1.0.0orgSlug: kodexatype: storestoreType: MODELname: My Modelmetadata: atomic: true trainable: false modelRuntimeRef: kodexa/base-model-runtime type: model contents: - model/*
The model definition is simple, it has a slug, version, orgSlug, type, storeType, name and metadata. The metadata is the most important part of the model definition. The metadata is used to describe the model and is used to deploy the model to the Kodexa Platform. In our first model, we said the model is not trainable and has no options for inference. We can now deploy this model to try it out.If you are logged in, you can deploy the model using the command line tools.
Sometimes you will want to understand what is in a deployment of a model. There are a couple of things you can do to understand what is on the server.First, you can set the deploy to keep a ZIP representation. This will allow you to see what was finally packaged in the model, you do this by updating the model.yml, i.e.
Copy
Ask AI
# A very simple first model that isn't trainableslug: my-modelversion: 1.0.0orgSlug: kodexatype: storestoreType: MODELname: My Modelmetadata: atomic: true trainable: false # Adding Keep Zip will mean the implementation ZIP file is not cleaned up # when you run kodexa deploy <model.yml> keepZip: true modelRuntimeRef: kodexa/base-model-runtime type: model contents: - model/*
The second way you can use is to download an implementation from the server, this is also useful for debugging if there is an issue in your deployment setup.You can use the Kodexa CLI to run: