Working with Models

Working with Models

Working with Models

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:

def infer(document):
    return document

You would put this code in a module, i.e.

model/
    __init__.py
    model.py

Deployment

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.

# A very simple first model that isn't trainable

slug: my-model
version: 1.0.0
orgSlug: kodexa
type: store
storeType: MODEL
name: My Model
metadata:
  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.

$ kodexa deploy model.yml

← Previous

Models