Quick Start
Installation
Use pip to install the required dependencies
Setting up your environment
Add the FirstBatch API key to your environment. If you don't have one, go to the FirstBatch Dashboard.
Set up the vector database credentials as environment variables. We're using Pinecone for this example.
Later use the os
package to access environment variables.
Initializing
FirstBatch operates with a vector database. We initialize a vector database client.
Then to initialize FirstBatch SDK, we call FirstBatch class with our configuration.
FirstBatch creates a sketch of vector databases based on the data distribution of a small sample to provide exploration methods for the vector space. Here we call the add_vdb
method, only required to run once for each index. It may take up to ~2m.
We may add multiple vector databases with different indices and embedding sizes by calling the same method.
Building Personalized Experiences
Sessions are the starting point for personalized experiences. All sessions and state changes are managed by FirstBatch. There are three fundamental operations to consider:
Session
: A session object with an id, algorithm type, and vector database id. User embeddings are created per session.Batch
: Get personalized data based on user embeddings of a specific session.Signal
: Send data to update user embeddings of a specific session
We create our session by selecting the algorithm and the id of the vector database.
Get personalized results based on your algorithm
Update User Embeddings
Here is the complete code for creating a session with the "SIMPLE" type algorithm
Last updated