Skip to main content

Train a basic engine

Engines are used for all retrieval and ranking in Shaped. Simple engines can be used for semantic search, while complex engines may do behavior-based retrieval.

Engines are configured declaratively with YAML or JSON. This guide will show you how to configure a basic engine and create it in your account.

Prerequisites

Write your engine config

Here is an example of a minimal semantic search engine:

# engine.yaml
version: v2
name: basic_engine
data:
item_table:
name: movielens_items # change this to your table name
type: table
index:
embeddings:
- name: content_embedding # enables vector search
encoder:
type: hugging_face
model_name: sentence-transformers/all-MiniLM-L6-v2
item_fields: # update these to your table's text columns
- movie_title
- description

Create your engine via CLI

Upload the config file via CLI:

shaped create-engine --file engine.yaml

Patch your engine

If you make changes to your config and want to re-train your engine, use the update-engine command:

shaped update-engine --file engine.yaml

Shaped will automatically detect what has changed and only retrain or reindex the affected components. For more details on how patching works, see the Engines documentation.