Files
2023-03-30 08:34:14 -07:00

3.3 KiB

Aleph Alpha

There are two possible ways to use Aleph Alpha's semantic embeddings. If you have texts with a dissimilar structure (e.g. a Document and a Query) you would want to use asymmetric embeddings. Conversely, for texts with comparable structures, symmetric embeddings are the suggested approach.

Asymmetric

In [2]:
from langchain.embeddings import AlephAlphaAsymmetricSemanticEmbedding
In [3]:
document = "This is a content of the document"
query = "What is the contnt of the document?"
In [ ]:
embeddings = AlephAlphaAsymmetricSemanticEmbedding()
In [ ]:
doc_result = embeddings.embed_documents([document])
In [ ]:
query_result = embeddings.embed_query(query)

Symmetric

In [ ]:
from langchain.embeddings import AlephAlphaSymmetricSemanticEmbedding
In [4]:
text = "This is a test text"
In [ ]:
embeddings = AlephAlphaSymmetricSemanticEmbedding()
In [ ]:
doc_result = embeddings.embed_documents([text])
In [ ]:
query_result = embeddings.embed_query(text)
In [ ]: