Back to Llama Index

Baseten Embeddings

docs/examples/embeddings/baseten.ipynb

0.14.211.1 KB
Original Source

<a href="https://colab.research.google.com/github/run-llama/llama_index/blob/main/docs/examples/llm/openai.ipynb" target="_parent"></a>

Baseten Embeddings

This guide how to use performant open source embeddings and rerankers in the Baseten library. First we need to install LlamaIndex and the Baseten dependencies.

python
%pip install llama-index llama-index-embeddings-baseten

Start a dedicated endpoint of your choice with the embedding you want here and paste your Baseten API key below.

python
from llama_index.embeddings.baseten import BasetenEmbedding
python
# Using dedicated endpoint
embed_model = BasetenEmbedding(
    model_id="BASETEN_MODEL_ID",  # 8 character string
    api_key="BASETEN_API_KEY",
)

# Single embedding
embedding = embed_model.get_text_embedding("Hello, world!")

# Batch embeddings
embeddings = embed_model.get_text_embedding_batch(
    ["Hello, world!", "Goodbye, world!"]
)
print(embeddings)