Aleph Alpha
有兩種可能的方式可以使用 Aleph Alpha 的語義嵌入。如果您有結構不同的文本(例如,文件和查詢),您會想要使用非對稱嵌入。相反地,對於結構相似的文本,建議使用對稱嵌入。
非對稱
from langchain_community.embeddings import AlephAlphaAsymmetricSemanticEmbedding
document = "This is a content of the document"
query = "What is the content of the document?"
embeddings = AlephAlphaAsymmetricSemanticEmbedding(normalize=True, compress_to_size=128)
doc_result = embeddings.embed_documents([document])
query_result = embeddings.embed_query(query)
對稱
from langchain_community.embeddings import AlephAlphaSymmetricSemanticEmbedding
API 參考文件:AlephAlphaSymmetricSemanticEmbedding
text = "This is a test text"
embeddings = AlephAlphaSymmetricSemanticEmbedding(normalize=True, compress_to_size=128)
doc_result = embeddings.embed_documents([text])
query_result = embeddings.embed_query(text)