A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://python.langchain.com/docs/integrations/text_embedding/model2vec/ below:

model2vec | 🦜️🔗 LangChain

model2vec

Model2Vec is a technique to turn any sentence transformer into a really small static model model2vec can be used to generate embeddings.

Setup
pip install -U langchain-community
Instantiation

Ensure that model2vec is installed

Indexing and Retrieval
from langchain_community.embeddings import Model2vecEmbeddings
embeddings = Model2vecEmbeddings("minishlab/potion-base-8M")
query_text = "This is a test query."
query_result = embeddings.embed_query(query_text)
document_text = "This is a test document."
document_result = embeddings.embed_documents([document_text])
Direct Usage

Here's how you would directly make use of model2vec

from model2vec import StaticModel


model = StaticModel.from_pretrained("minishlab/potion-base-8M")


embeddings = model.encode(["It's dangerous to go alone!", "It's a secret to everybody."])


token_embeddings = model.encode_as_sequence(["It's dangerous to go alone!", "It's a secret to everybody."])
API Reference

For more information check out the model2vec github repo


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4