Back to Llama Index

Aleph Alpha Embeddings

docs/examples/embeddings/alephalpha.ipynb

0.14.211.6 KB
Original Source

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

Aleph Alpha Embeddings

If you're opening this Notebook on colab, you will probably need to install LlamaIndex 🦙.

python
%pip install llama-index-embeddings-alephalpha
python
!pip install llama-index
python
# Initialise with your AA token
import os

os.environ["AA_TOKEN"] = "your_token_here"

With luminous-base embeddings.

  • representation="Document": Use this for texts (documents) you want to store in your vector database
  • representation="Query": Use this for search queries to find the most relevant documents in your vector database
  • representation="Symmetric": Use this for clustering, classification, anomaly detection or visualisation tasks.
python
from llama_index.embeddings.alephalpha import AlephAlphaEmbedding

# To customize your token, do this
# otherwise it will lookup AA_TOKEN from your env variable
# embed_model = AlephAlpha(token="<aa_token>")

# with representation='query'
embed_model = AlephAlphaEmbedding(
    model="luminous-base",
    representation="Query",
)

embeddings = embed_model.get_text_embedding("Hello Aleph Alpha!")

print(len(embeddings))
print(embeddings[:5])
python
# with representation='Document'
embed_model = AlephAlphaEmbedding(
    model="luminous-base",
    representation="Document",
)

embeddings = embed_model.get_text_embedding("Hello Aleph Alpha!")

print(len(embeddings))
print(embeddings[:5])