HuggingMapper tutorial#
# uncomment if colab
#!pip install pandas hugging-mapper
Getting Embeddings.
Start by importing HuggingMapper
from hugger.mapper import HuggingMapper
Initializing HuggingMapper will load the given huggingface model
# init
mapper = HuggingMapper(
model_name="sentence-transformers/all-MiniLM-L6-v2",
)
Warning: You are sending unauthenticated requests to the HF Hub. Please set a HF_TOKEN to enable higher rate limits and faster downloads.
WARNING:huggingface_hub.utils._http:Warning: You are sending unauthenticated requests to the HF Hub. Please set a HF_TOKEN to enable higher rate limits and faster downloads.
BertModel LOAD REPORT from: sentence-transformers/all-MiniLM-L6-v2
Key | Status | |
------------------------+------------+--+-
embeddings.position_ids | UNEXPECTED | |
Notes:
- UNEXPECTED: can be ignored when loading from different task/architecture; not ok if you expect identical arch.
Get embeddings for given text
# generate embedding for a single text
embedding = mapper.embed_text("Good morning")
print(embedding.shape)
# generate embeddings for a list of texts
embeddings = mapper.embed_text(["Hello world", "Good evening", "Lunch time!"])
print(embeddings.shape)
torch.Size([1, 384])
torch.Size([3, 384])