Middle+
How were embeddings obtained? Through which model and how was it run?
sobes.tech AI
Answer from AI
Embeddings are usually obtained using pre-trained models such as BERT, GPT, or specialized embedding models (e.g., Sentence-BERT). In Python, libraries like Hugging Face Transformers or SentenceTransformers are often used for this purpose.
Example of obtaining embeddings using SentenceTransformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer('all-MiniLM-L6-v2') # load the model
sentences = ["Example text for embedding", "Another example"]
embeddings = model.encode(sentences)
print(embeddings.shape) # (2, 384) - two embeddings with 384 features each
The model runs locally or in the cloud, depending on the infrastructure. It is important to properly prepare the text (tokenization, normalization) before passing it to the model to obtain a vector representation.