Embeddings with Clarifai
LlamaIndex has support for Clarifai embeddings models.
You must have a Clarifai account and a Personal Access Token (PAT) key. Check here to get or create a PAT.
Set CLARIFAI_PAT as an environment variable.
!export CLARIFAI_PAT=YOUR_KEY
If you’re opening this Notebook on colab, you will probably need to install LlamaIndex 🦙.
!pip install llama-index
Models can be referenced either by the full URL or by the model_name, user ID, and app ID combination.
from llama_index.embeddings import ClarifaiEmbedding
embed_model = ClarifaiEmbedding(
model_url="https://clarifai.com/clarifai/main/models/BAAI-bge-base-en"
)
# Alternatively
embed_model = ClarifaiEmbedding(
model_name="BAAI-bge-base-en", user_id="clarifai", app_id="main"
)
embeddings = embed_model.get_text_embedding("Hello World!")
print(len(embeddings))
print(embeddings[:5])