Vì sao tìm “automobile” lại ra ghi chú về “car”?
Tìm kiếm ngữ nghĩa: embedding và độ tương đồng cosine · Cơ bản · 5 phút · embeddings, rag · học sau Embedding
Tìm kiếm ngữ nghĩa biến câu tìm và mọi tài liệu thành embedding, những dãy số có hướng đi theo nghĩa, rồi trả về tài liệu chỉ gần hướng câu tìm nhất (độ tương đồng cosine), kể cả khi không chung chữ nào.
1 Đoán trước
2 Xem
Search by meaning
1 / 4keyword search: notes that contain a word of “automobile”
No note contains that word.
search by meaning: the three closest notes
- My car won’t start in the cold.0.29
- Automatic door repair service0.23
- Best tyres for a family hatchback0.16
measured with all-MiniLM-L6-v2 (384 numbers per text) · cosine similarity · 2026-10-23
No note says “automobile”. Keywords find nothing; meaning finds the car.
Biến câu tìm và mọi ghi chú thành điểm; bộ tìm kiếm trả về những điểm gần nhất, dù chúng dùng chữ gì.
Đây là tìm kiếm ngữ nghĩa (semantic search, tìm theo nghĩa). Một mô hình embedding biến mỗi ghi chú thành 384 con số, làm một lần từ trước. Câu tìm của bạn có 384 số riêng, và bộ tìm kiếm so hướng: độ tương đồng cosine, 1 là cùng hướng, gần 0 là không liên quan. “Automobile” và “car” hay đi cùng những chữ giống nhau, nên hướng của chúng khớp.
4 Bạn là model
Bạn là bộ tìm kiếm. Với bốn câu tìm, chọn ghi chú chỉ gần câu tìm nhất: ghi chú mà all-MiniLM-L6-v2 xếp đầu.
you are the search · pick the note that points closest to the query
Search: “feline”
measured with all-MiniLM-L6-v2 (384 numbers per text) · cosine similarity · 2026-10-23
You are the search. Which note points closest?5 Kiểm tra
Hai thói quen cho app thật. Đặt điểm tối thiểu, để “không có gì gần” cũng là một câu trả lời. Và giữ cả tìm theo từ khóa: embedding làm nhòe những thứ chính xác như mã lỗi, tên riêng và chữ “not”. Nhiều công cụ trộn cả hai (hybrid search). Trong RAG, những đoạn gần nhất là thứ được dán vào prompt.
7 Nói lại bằng lời bạn
8 Nhiệm vụ · 5 phút
Chép key miễn phí trên trang embeddings của Jina (không cần thẻ) và embed bốn đoạn trong một request với "normalized": true: “automobile”, “My car won’t start”, “Automatic door repair”, “Mobile phone deals”. Với vector đã chuẩn hóa, cosine chỉ là tích vô hướng (SUMPRODUCT trong bảng tính). Ghi chú về xe có thắng mà không chung chữ nào không?
Ba câu nhanh
Rút ngẫu nhiên từ bộ câu hỏi của bài; lần sau sẽ khác.
Xong chưa?
Đọc thêm
Nguồn
- Cosine similarities measured with sentence-transformers/all-MiniLM-L6-v2 (https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2: 384 dimensions, mean pooling, normalised) on 2026-10-23 by scripts/explain-data/semantic-search.ts (plain forward pass, no torch), which reproduces the published example below exactly
- https://sbert.net/docs/sentence_transformer/usage/semantic_textual_similarity.html (checked 2026-10-23): all-MiniLM-L6-v2 on “The weather is lovely today.”, “It’s so sunny outside!”, “He drove to the stadium.” gives 0.6660, 0.1046, 0.1411
- Scores used (query → note): automobile → car 0.288, automatic door 0.233, tyres 0.162, phone deals 0.116, cat on the sofa −0.080; feline → kitten 0.312, cat 0.271; my vehicle broke down → car 0.387, door 0.256, bicycle 0.217; airplane tickets → flights 0.343, phone deals 0.303; quantum physics homework → pasta 0.132 (best of nine)
- Pairs: “I love this car.” / “I do not love this car.” 0.775; “Flights from London to Paris” / “Flights from Paris to London” 0.997; “Error code E-4012” / “Error code E-4013” 0.908
- The nine notes and five queries were written for the lesson. The 2-D map is the first two principal components of their 14 embeddings, scaled to 5–95; nearest notes and scores use all 384 numbers
- https://jina.ai/embeddings/ (checked 2026-10-23): new users get an auto-generated API key with free tokens; free keys 100 RPM and 100K TPM; endpoint https://api.jina.ai/v1/embeddings, jina-embeddings-v5-text-small recommended for text; aifree.dev catalog jina-ai-free-api-tokens (verified 2026-10-12): 10M tokens per new API key, no card
Đăng Oct 23, 2026 · cập nhật Oct 23, 2026