embedding_models
langroid/embedding_models/init.py
EmbeddingModel
¶
Bases: ABC
Abstract base class for an embedding model.
similarity(text1, text2)
¶
Compute cosine similarity between two texts.
Source code in langroid/embedding_models/base.py
OpenAIEmbeddings(config=OpenAIEmbeddingsConfig())
¶
Bases: EmbeddingModel
Source code in langroid/embedding_models/models.py
truncate_texts(texts)
¶
Truncate texts to the embedding model's context length. TODO: Maybe we should show warning, and consider doing T5 summarization?
Source code in langroid/embedding_models/models.py
embedding_model(embedding_fn_type='openai')
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
embedding_fn_type |
str
|
"openai" or "sentencetransformer" # others soon |
'openai'
|
Returns: EmbeddingModel