📜 Real-time Embeddings Inference
Text embeddings are condensed and semantically rich representations of textual data that capture the contextual and semantic meaning of words, sentences, or documents.
While real-time text embeddings can boost model performance for applications such as recommendation systems, fraud detection, and content moderation, building a production embeddings inference system can be quite the challenge. With Tecton, you can run text embedding inference in real-time with plain Python and deploy it in production in minutes!
This tutorial assumes some basic familiarity with Tecton. If you are new to Tecton, we recommend first checking out Building a Production AI Application with Tecton which walks through an end-to-end journey of building a real-time ML application with Tecton.
In this tutorial we will:
- Create a custom environment with an embeddings library
- Create an On-Demand Feature View that runs the embedding model
- Retrieve the embedding with the HTTP API
Before you start:
- Install the Tecton SDK with
pip install tecton
. We recommend doing so in a virtual environment. - Run
tecton login [your-org-account-name].tecton.ai
in your CLI. Be sure to fill in your organization's Tecton account name. - Run these commands to create a new Tecton repo:
mkdir tecton-feature-repo
cd tecton-feature-repo
tecton init
🌏 Create a custom environment with an embeddings library
We will be using the FastEmbed library
for embeddings generation. In the feature repo, let's create a
requirements.txt
file with the following entries:
tecton-runtime
fastembed
urllib3==1.26.6
Next, we'll use the Tecton CLI to create an environment in Tecton by running the following commands:
tecton environment create --name "embeddings-env" --description "Embeddings custom environment" --requirements /path/to/requirements.txt
Once the environment creation command completes, we can check the status of the environment with:
tecton environment get --name "embeddings-env"
Id Name Status Created At
========================================================================================================================
5c83b9014e2e4f1eb68c58eba6bc0796 embeddings-env REMOTE_ENVIRONMENT_STATUS_PENDING 2023-12-21 20:18:55 UTC
You will require admin privileges to create custom environments via the Tecton CLI.