docs/examples/embeddings/textembed.ipynb
Maintained by Keval Dekivadiya, TextEmbed is licensed under the Apache-2.0 License.
TextEmbed is a high-throughput, low-latency REST API designed for serving vector embeddings. It supports a wide range of sentence-transformer models and frameworks, making it suitable for various applications in natural language processing.
Ensure you have Python 3.10 or higher installed. You will also need to install the required dependencies.
Install the required dependencies:
!pip install -U textembed
Start the TextEmbed server with your desired models:
!python -m textembed.server --models sentence-transformers/all-MiniLM-L12-v2 --workers 4 --api-key TextEmbed
Here's a simple example to get you started with llama-index:
from llama_index.embeddings.textembed import TextEmbedEmbedding
# Initialize the TextEmbedEmbedding class
embed = TextEmbedEmbedding(
model_name="sentence-transformers/all-MiniLM-L12-v2",
base_url="http://0.0.0.0:8000/v1",
auth_token="TextEmbed",
)
# Get embeddings for a batch of texts
embeddings = embed.get_text_embedding_batch(
[
"It is raining cats and dogs here!",
"India has a diverse cultural heritage.",
]
)
print(embeddings)
For more information, please read the documentation.