Introduction
Finding the meaning of sentences in a way that computers understand is tricky. We need a method to turn sentences into numbers that capture their meaning so machines can compare and use them easily.
Jump into concepts and practice - no test required
Imagine you have a library where each book is summarized into a short code that captures its story. When you want a book like another, you just compare these codes instead of reading every book again.
┌─────────────────────┐
│ Input Sentence │
└─────────┬───────────┘
│
▼
┌─────────────────────┐
│ Transformer Model │
│ (understands context)│
└─────────┬───────────┘
│
▼
┌─────────────────────┐
│ Sentence Embedding │
│ (number list output) │
└─────────┬───────────┘
│
▼
┌─────────────────────┐
│ Applications: Search,│
│ Compare, Group │
└─────────────────────┘from sentence_transformers import SentenceTransformer
model = SentenceTransformer('all-MiniLM-L6-v2')
sentence = 'Hello world'
embedding = model.encode(sentence)
print(type(embedding))from sentence_transformers import SentenceTransformer
model = SentenceTransformer('all-MiniLM-L6-v2')
sentences = ['Hello world', 'Hi there']
embeddings = model.encode(sentences)
print(embeddings.shape)