Embeddings और Vector Database क्या हैं?#
Modern AI applications में सिर्फ text को search करना पर्याप्त नहीं होता। कई बार हमें ऐसा content ढूँढना होता है जिसका meaning user के question से मिलता-जुलता हो, भले ही दोनों में exact keywords अलग हों।
यहीं पर Embeddings और Vector Databases काम आते हैं।
Embedding किसी text, image या दूसरी supported data item की numerical vector representation होती है। इसे एक machine-learning model generate करता है। अच्छी तरह trained embedding model related content को vector space में इस तरह represent करने की कोशिश करता है कि similarity search करना आसान हो सके।
Vector Database ऐसा database या data platform है जो vectors store करने, similarity search करने और relevant records retrieve करने में मदद करता है।
Example:
आपकी educational website पर तीन articles हैं:
- JavaScript में arrays कैसे काम करती हैं?
- React में state management कैसे करें?
- Python में lists का उपयोग कैसे करें?
अगर user पूछता है, “JavaScript में multiple values store कैसे करें?”, तो semantic search पहला article खोजने में मदद कर सकता है, भले ही user ने article का exact title न लिखा हो।
Simple words mein:
- Embedding: Content का numerical representation।
- Vector Database: Vectors और उनसे जुड़ा data store करके similar items खोजने का system।
- Vector Search: Query के लिए similar vectors और उनके associated records खोजना।
Google Cloud की documentation भी embeddings को semantic meaning represent करने वाले numerical vectors और vector search को similar items खोजने की technique के रूप में explain करती है. Official reference
Embeddings की जरूरत क्यों पड़ती है?#
Traditional keyword search आमतौर पर exact words, text matching और ranking rules पर निर्भर करती है।
लेकिन natural language में लोग एक ही बात कई तरीकों से पूछ सकते हैं।
उदाहरण:
- “पासवर्ड भूल गया हूँ”
- “How can I reset my password?”
- “Account password recover कैसे करूँ?”
इन sentences में exact words अलग हैं, लेकिन meaning related है।
Semantic search में embedding model इन inputs की numerical representations generate कर सकता है। फिर system vector similarity के आधार पर related documents retrieve करता है।
Common Use Cases
- Semantic search
- AI chatbots
- RAG applications
- Document retrieval
- Product recommendations
- Similar images या documents खोजना
- Duplicate या near-duplicate content पहचानना
- Support ticket classification
- Educational content discovery
ध्यान दें: Embeddings similarity खोजने में मदद करती हैं, लेकिन हर situation में सही answer या perfect match की guarantee नहीं देतीं।
Vector क्या होता है?#
Vector numbers की एक ordered list होती है।
उदाहरण के लिए, एक छोटा illustrative vector:
[0.12, -0.45, 0.78, 0.21]इसमें चार numerical values हैं। हर value को एक dimension से जोड़ा जा सकता है।
Real embedding models सैकड़ों या हजारों dimensions वाले vectors generate कर सकते हैं। Exact dimension embedding model पर निर्भर करती है।
ऊपर दिया गया vector केवल समझाने के लिए है। यह किसी वास्तविक embedding model से generate किया गया vector नहीं है।
Vector को कैसे समझें?
2D graph में किसी point को (x, y) से represent कर सकते हैं।
Point A = (2, 3)
Point B = (5, 7)यहाँ हर point के दो coordinates हैं।
इसी तरह, high-dimensional vector में कई numerical coordinates होते हैं। Embedding model इन coordinates को training के दौरान सीखे गए patterns के अनुसार generate करता है।
Important: Embedding की हर dimension का कोई स्पष्ट human-readable meaning होना जरूरी नहीं है। किसी एक number को देखकर यह कहना सही नहीं होगा कि वह “happiness” या “technology” को represent करता है।
Embedding कैसे generate होती है?#
एक typical text embedding workflow इस तरह होता है:
- Text input तैयार किया जाता है।
- चुने गए embedding model को text दिया जाता है।
- Model text को process करके numerical vector generate करता है।
- Application vector को document ID और metadata के साथ store करती है।
- Search के समय user query का embedding generate किया जाता है।
- Query vector की stored vectors से similarity या distance calculate की जाती है।
- सबसे relevant candidate records retrieve किए जाते हैं।
Example:
Document:
"React state changes can trigger re-rendering."
↓ Embedding Model
Vector:
[0.12, -0.45, 0.78, ...]
↓ Store
Vector Databaseजब user पूछता है:
Why does my React component render again?
तो query का embedding generate करके stored document vectors के साथ compare किया जा सकता है।
Actual embedding values model-specific होती हैं। एक model से बने vectors को दूसरे incompatible model के vectors के साथ blindly compare नहीं करना चाहिए।
Dense और Sparse Embeddings#
Embeddings के अलग-अलग types हो सकते हैं।
| Type | Description | Common Use |
|---|---|---|
| Dense embedding | अधिकतर dimensions में non-zero values वाला vector | Semantic similarity |
| Sparse representation | बहुत कम non-zero values वाला high-dimensional vector | Keyword-related retrieval |
| Multimodal embedding | Supported text, image या दूसरे modalities को represent करने वाला vector | Cross-modal search |
ये categories implementation और model के अनुसार vary कर सकती हैं।
Dense embeddings semantic relationships capture करने के लिए उपयोगी हैं। Sparse representations exact terms और lexical matching में useful हो सकती हैं।
कुछ search systems दोनों approaches को combine करते हैं। इसे Hybrid Search कहते हैं।
Vector Database कैसे काम करता है?#
Vector database केवल numbers रखने की जगह नहीं है। Practical applications में vectors के साथ original content, identifiers और metadata भी store किए जाते हैं।
एक simplified record:
{
"id": "article-101",
"text": "React state management explained",
"embedding": [0.12, -0.45, 0.78],
"metadata": {
"category": "React",
"language": "en",
"published": true
}
}यह illustrative structure है। Real embedding की dimensions और metadata fields आपके model और application के अनुसार होंगे।
Vector Database के मुख्य Parts
- Vector: Numerical embedding।
- Record ID: Document या item की unique पहचान।
- Original Content: Text या document reference।
- Metadata: Category, language, date, permissions जैसे fields।
- Similarity Metric: Vectors compare करने का तरीका।
- Index: Large collections में search तेज करने के लिए data structure।
- Query: Search के लिए दिया गया vector या supported query input।
Search का Simplified Flow
User Question
↓
Query Embedding
↓
Vector Similarity Search
↓
Top Relevant Records
↓
Optional Metadata Filtering
↓
Application / LLM
↓
Answer or Search ResultsMetadata filtering और vector search का exact execution order database और query configuration पर निर्भर कर सकता है।
Vector Database और Traditional Database में अंतर#
| Traditional Database | Vector Database |
|---|---|
| Structured fields और relational queries के लिए उपयोगी | Vector similarity search के लिए specialized |
| Exact matching, joins और business rules | Semantic similarity और nearest-neighbor retrieval |
| SQL databases में tables, rows और indexes | Vector collections, embeddings और vector indexes |
| उदाहरण: Orders, Users, Payments | उदाहरण: Similar documents या semantic search |
| Relational constraints और transactions महत्वपूर्ण हो सकते हैं | Similarity, recall और retrieval quality महत्वपूर्ण होते हैं |
यह कहना सही नहीं है कि traditional databases similarity search नहीं कर सकते। कुछ relational databases extensions के माध्यम से vector search भी support करते हैं।
उदाहरण के लिए, PostgreSQL में pgvector extension vectors store करने और similarity search करने की सुविधा देता है। इसलिए हर project के लिए अलग vector database खरीदना जरूरी नहीं है।
Official reference: pgvector on GitHub
Similarity Search क्या है?#
Similarity search का उद्देश्य query vector के करीब या उससे संबंधित vectors खोजना है।
मान लीजिए user query का vector Q है और database में तीन vectors हैं:
A: React hooks documentationB: PHP arrays documentationC: React component lifecycle documentation
Search system चुने गए similarity metric के आधार पर Q के nearest candidates identify करता है।
लेकिन “nearest” का meaning metric पर निर्भर करता है। इसलिए सही metric और embedding model चुनना महत्वपूर्ण है।
Cosine Similarity#
Cosine similarity दो vectors के बीच angle के cosine को measure करती है।
Formula:
\frac{A \cdot B}{|A||B|}
]
जहाँ:
- (A \cdot B) = dot product
- (|A|) = vector A का magnitude
- (|B|) = vector B का magnitude
Non-zero vectors के लिए cosine similarity आमतौर पर (-1) से (1) के बीच होती है।
1: Same direction0: Orthogonal directions-1: Opposite directions
Embedding search में actual scores और उनका interpretation model तथा data पर निर्भर करते हैं। Score को सीधे percentage या probability नहीं समझना चाहिए।
Cosine Similarity और Cosine Distance
कुछ databases similarity के बजाय distance operator use करते हैं।
एक common definition:
[
\text{Cosine Distance}=1-\text{Cosine Similarity}
]
इस definition में lower distance अधिक similar direction indicate करती है।
ध्यान दें कि libraries और systems अलग-अलग score conventions expose कर सकते हैं। हमेशा अपने database या SDK की documentation देखें।
Euclidean Distance (L2 Distance)#
Euclidean distance दो vectors के बीच straight-line distance calculate करती है।
[
d(A,B)=\sqrt{\sum_{i=1}^{n}(A_i-B_i)^2}
]
छोटा distance मतलब vectors numerical space में एक-दूसरे के करीब हैं।
यह metric useful हो सकती है, लेकिन इसकी usefulness embedding model, vector normalization और application पर निर्भर करती है।
Dot Product और Inner Product#
Dot product दो vectors की corresponding values multiply करके उनका sum निकालता है।
[
A \cdot B=\sum_{i=1}^{n} A_iB_i
]
कुछ embedding systems dot product या inner product का उपयोग similarity ranking के लिए करते हैं।
महत्वपूर्ण बात: Dot product की magnitude vector lengths से भी प्रभावित हो सकती है। इसलिए इसे cosine similarity के बराबर नहीं मानना चाहिए, जब तक relevant normalization और assumptions पूरी न हों।
कौन-सा Metric चुनें?
| Metric | क्या measure करता है? | कब consider करें? |
|---|---|---|
| Cosine similarity / distance | Vector directions की similarity | Semantic embeddings के लिए common choice |
| Euclidean / L2 distance | Vectors के बीच straight-line distance | जब model और task के लिए appropriate हो |
| Dot / inner product | Corresponding coordinates का product sum | जब embedding model और retrieval setup इसे support करें |
Best practice: Embedding model की recommendations follow करें और representative search queries से metrics evaluate करें।
Chunking क्या है?#
जब आप बड़ी PDF, article या documentation को AI application में use करते हैं, तो पूरी file को एक ही block में process करना हमेशा सही नहीं होता।
Chunking का मतलब बड़े document को छोटे sections में divide करना है।
Example:
Original Article
↓
Chunk 1: Introduction
Chunk 2: Basic Concepts
Chunk 3: Code Examples
Chunk 4: Troubleshootingहर chunk का embedding generate करके अलग record के रूप में store किया जा सकता है।
Chunking क्यों जरूरी है?
- Relevant section retrieve करना आसान होता है।
- LLM को केवल relevant context देना संभव होता है।
- Long documents को manageable pieces में divide किया जा सकता है।
- Source references और document sections track किए जा सकते हैं।
Chunking Strategies
1. Fixed-size chunking
Document को target length के छोटे sections में divide किया जाता है।
2. Overlapping chunking
Adjacent chunks के बीच कुछ content repeat किया जाता है, ताकि section boundary पर context न छूटे।
3. Structure-aware chunking
Headings, paragraphs, code blocks या document sections के आधार पर chunks बनाए जाते हैं।
4. Semantic chunking
Content के meaning और topic changes को ध्यान में रखकर sections divide किए जाते हैं।
हर strategy का result अलग हो सकता है। सही chunk size dataset, content type, embedding model और retrieval task के आधार पर test करना चाहिए।
Chunking Example
Original content:
## React State
State stores information that can change
over time in a component.
## React Props
Props pass data from a parent component
to a child component.Structure-aware chunks:
Chunk 1:
React State
State stores information that can change
over time in a component.Chunk 2:
React Props
Props pass data from a parent component
to a child component.Headings को chunk में include करने से retrieved text का context समझने में मदद मिल सकती है।
Metadata और Filtering#
Metadata वह additional information है जो document या vector record के साथ store की जाती है।
Example:
{
"document_id": "react-101",
"category": "React",
"language": "en",
"published": true,
"access_level": "public"
}Metadata की मदद से आप search results को filter कर सकते हैं।
उदाहरण:
- केवल React articles खोजें।
- केवल Hindi content खोजें।
- Published documents तक results सीमित रखें।
- किसी specific course के documents खोजें।
Security Warning
Metadata filtering को authorization का substitute न समझें।
अगर documents अलग-अलग users या organizations के हैं, तो backend पर tenant और access permissions enforce करें। User द्वारा भेजे गए arbitrary filter values पर blind trust न करें।
Vector retrieval में भी data isolation और access control जरूरी हैं।
Vector Index क्या है?#
जब database में बहुत सारे vectors होते हैं, तो हर query के लिए हर vector से exact comparison करना expensive हो सकता है।
Vector index search को efficient बनाने के लिए data structure तैयार करता है।
दो common approximate nearest-neighbor index approaches हैं:
- HNSW: Hierarchical graph-based search structure।
- IVFFlat: Vectors को groups या lists में organize करके selected lists में search करता है।
इन approaches के बीच build time, memory use, search latency और recall के trade-offs होते हैं।
Exact Search और Approximate Search
| Exact Search | Approximate Search |
|---|---|
| सभी relevant candidates के against exact distance calculation कर सकती है | Search space कम करके तेजी से candidates खोज सकती है |
| छोटे datasets में practical हो सकती है | बड़े datasets में latency कम करने के लिए उपयोगी |
| Search results के लिए exact nearest-neighbor comparison | कुछ nearest neighbors miss हो सकते हैं |
| Computation बढ़ सकती है | Speed और recall में trade-off हो सकता है |
Approximate search हमेशा गलत नहीं होती, और exact search हमेशा production में सबसे efficient नहीं होती। अपने workload पर latency और retrieval quality दोनों measure करें।
pgvector: PostgreSQL में Vector Search#
अगर आपका project पहले से PostgreSQL use करता है, तो pgvector एक useful option हो सकता है।
यह PostgreSQL में vector data store करने और vector similarity queries करने के लिए extension है।
Official documentation: pgvector – GitHub
Step 1: Extension Enable करें
CREATE EXTENSION vector;यह command उस PostgreSQL database में extension enable करती है जहाँ pgvector installed और available हो।
Step 2: Vector Column वाली Table बनाएं
CREATE TABLE documents (
id BIGSERIAL PRIMARY KEY,
content TEXT NOT NULL,
embedding VECTOR(3)
);यहाँ VECTOR(3) केवल demonstration के लिए है। Real embedding model के लिए सही dimension use करें।
Step 3: Example Vectors Insert करें
INSERT INTO documents (content, embedding)
VALUES
('Document A', '[1,2,3]'),
('Document B', '[2,3,4]'),
('Document C', '[3,2,1]');ये artificial vectors हैं, actual text embeddings नहीं।
Step 4: Nearest Vectors Search करें
SELECT
id,
content,
embedding <-> '[1,2,3]' AS distance
FROM documents
ORDER BY embedding <-> '[1,2,3]'
LIMIT 3;pgvector में <-> Euclidean distance operator है। यह query छोटे demonstration dataset में nearest vectors निकालती है।
Step 5: Cosine Distance का उपयोग
SELECT
id,
content,
embedding <=> '[1,2,3]' AS cosine_distance
FROM documents
ORDER BY embedding <=> '[1,2,3]'
LIMIT 3;यह query cosine distance operator का उपयोग करती है।
इस छोटे example में कोई vector index create नहीं किया गया है। Production में indexing, model dimensions, query performance और data volume को ध्यान में रखें।
Vector Database के Options#
अलग-अलग projects में अलग storage solutions suitable हो सकते हैं।
| Option | कब consider करें? |
|---|---|
| PostgreSQL + pgvector | जब relational data और vector search एक ही PostgreSQL system में रखना हो |
| Dedicated vector database | जब vector retrieval आपका major workload हो और specialized operational features चाहिए हों |
| Managed cloud vector search | जब managed infrastructure और cloud integration प्राथमिकता हो |
| Existing analytical database with vector search | जब embeddings और analytical data एक ही platform पर manage करना हो |
किसी product को केवल popular होने की वजह से select न करें। Dataset size, filtering requirements, access control, operational complexity, latency, backup और cost compare करें।
Embeddings के साथ RAG कैसे काम करता है?#
RAG का full form Retrieval-Augmented Generation है।
इस approach में application relevant documents retrieve करके LLM को context देती है, ताकि generated answer available source material पर आधारित हो सके।
Indexing Pipeline
- Documents collect करें।
- Text extract और clean करें।
- Documents को chunks में divide करें।
- हर chunk का embedding generate करें।
- Chunk text, vector, source ID और metadata store करें।
- Documents update या delete होने पर index synchronize करें।
Query Pipeline
- User question submit करता है।
- Question का embedding generate होता है।
- Vector search relevant chunks retrieve करती है।
- Optional filtering और reranking से results improve किए जाते हैं।
- Retrieved chunks LLM को context के रूप में दिए जाते हैं।
- LLM answer generate करता है।
- Application source references और response validate करती है।
RAG का Example
User question:
What is the difference between React props and state?
Retrieved context:
Source 1:
Props pass data from a parent component
to a child component.
Source 2:
State stores information that can change
over time in a component.LLM retrieved context का उपयोग करके answer generate कर सकता है।
लेकिन RAG भी perfect नहीं है। अगर relevant chunks retrieve नहीं हुए, documents outdated हैं या context incomplete है, तो answer गलत हो सकता है।
Embeddings बनाम Fine-tuning#
| Embeddings + Retrieval | Fine-tuning |
|---|---|
| Relevant content retrieve करने में मदद करता है | Model behavior या task performance adapt करने के लिए additional training |
| Documents update होने पर re-indexing की जरूरत हो सकती है | Updated training data के साथ retraining या further fine-tuning करनी पड़ सकती है |
| Source documents से grounded answers बनाने में useful | Consistent style, patterns या specialized tasks के लिए useful हो सकता है |
| Model parameters को retrain करना जरूरी नहीं | Training process की जरूरत होती है |
दोनों techniques अलग problems solve करती हैं। कई systems में इन्हें साथ भी use किया जा सकता है।
Semantic Search बनाम Keyword Search#
Keyword search और semantic search के strengths अलग हैं।
| Keyword Search | Semantic Search |
|---|---|
| Exact terms और lexical matching पर focus | Meaning और vector similarity पर focus |
| Product IDs, exact names और error codes के लिए useful | Paraphrased questions और conceptual search के लिए useful |
| Exact phrase matching में अच्छा हो सकता है | Related concepts खोजने में मदद कर सकता है |
| Wording बदलने पर relevant result miss हो सकता है | Exact identifiers के लिए हमेशा best नहीं होता |
Hybrid Search
Hybrid search दोनों approaches combine करती है।
Example: User किसी error code E1042 के साथ पूछता है कि checkout क्यों fail हो रहा है।
- Keyword search exact error code ढूँढ सकती है।
- Semantic search संबंधित troubleshooting documents खोज सकती है।
- Hybrid ranking दोनों results को combine कर सकती है।
Hybrid search का implementation database और search framework पर निर्भर करता है।
Retrieval Quality कैसे Evaluate करें?#
Vector search में केवल query का response देखना पर्याप्त नहीं है। आपको यह check करना चाहिए कि system relevant documents retrieve कर रहा है या नहीं।
Useful evaluation metrics:
- Precision@K: Top K results में कितने relevant हैं?
- Recall@K: सभी relevant documents में से कितने top K में retrieve हुए?
- MRR: पहला relevant result कितनी जल्दी मिलता है?
- Latency: Search में कितना समय लगता है?
- Groundedness: Final answer retrieved sources से supported है या नहीं?
Evaluation के लिए representative questions और उनके expected relevant documents का test dataset बनाएं।
अगर query का सही document top results में नहीं आता, तो ये factors investigate करें:
- Embedding model
- Chunking strategy
- Query formulation
- Metadata filters
- Similarity metric
- Index configuration
- Hybrid search या reranking
Common Mistakes#
- हर text को एक ही document में embed करना: Long content को sensible chunks में divide करना अक्सर बेहतर होता है।
- Chunking बिना testing के करना: बहुत छोटे chunks context खो सकते हैं; बहुत बड़े chunks irrelevant information बढ़ा सकते हैं।
- Incompatible embedding models mix करना: Query और document embeddings compatible model setup से generate होने चाहिए।
- Similarity score को probability समझना: Similarity score अपने आप answer correctness नहीं बताता।
- Vector database को LLM समझना: Database search करता है; answer generation के लिए अलग model की जरूरत हो सकती है।
- केवल vector search पर निर्भर रहना: Exact identifiers और rare terms के लिए keyword search भी जरूरी हो सकती है।
- Metadata filtering ignore करना: Language, category, date और permissions retrieval को बेहतर बना सकते हैं।
- Indexing के बाद content updates भूल जाना: Changed documents के embeddings और records को synchronize करें।
- Retrieval evaluate न करना: Relevant documents retrieve हो रहे हैं या नहीं, यह test करें।
- Sensitive documents बिना access control के index करना: Permissions और tenant isolation लागू करें।
Quick Reference Cheat Sheet#
| Term | Meaning |
|---|---|
| Vector | Ordered list of numerical values |
| Embedding | Data की learned numerical representation |
| Embedding Model | Vectors generate करने वाला model |
| Vector Database | Vectors store और search करने वाला system |
| Semantic Search | Meaning-related search |
| Similarity Metric | Vectors compare करने का measure |
| Cosine Similarity | Vector directions की similarity |
| Euclidean Distance | Vectors के बीच straight-line distance |
| Chunking | बड़े documents को छोटे sections में divide करना |
| Metadata | Record के साथ stored additional information |
| Vector Index | Similarity search को efficient बनाने वाला structure |
| ANN | Approximate Nearest Neighbor search |
| HNSW | Graph-based approximate nearest-neighbor index |
| IVFFlat | List-based approximate vector index |
| Hybrid Search | Keyword और semantic search का combination |
| RAG | Retrieval के साथ LLM generation |
| Reranking | Retrieved candidates को relevance के आधार पर दोबारा rank करना |
| pgvector | PostgreSQL के लिए vector search extension |
Interview Questions: Embeddings & Vector DB#
1. What is an embedding?
Embedding data की numerical vector representation है, जिसे machine-learning model generate करता है और जिसका उपयोग similarity, retrieval या दूसरे ML tasks में किया जा सकता है।
2. Why are embeddings useful?
वे semantic relationships को numerical space में represent करने में मदद करती हैं, जिससे similar content खोजा जा सकता है।
3. What is a vector database?
ऐसा database या search system जो vectors store करने और similarity-based retrieval करने के लिए designed हो।
4. What is cosine similarity?
यह दो non-zero vectors के बीच angle के cosine को measure करती है। इसका उपयोग vector similarity compare करने में किया जाता है।
5. What is the difference between cosine similarity and cosine distance?
एक common convention में cosine distance, 1 - cosine similarity होती है। Similarity में larger values और distance में smaller values अधिक similar directions indicate करती हैं।
6. Why do we use chunking in RAG?
Chunking बड़े documents को छोटे sections में divide करती है ताकि retrieval अधिक targeted हो सके और LLM को relevant context दिया जा सके।
7. What is the difference between exact and approximate nearest-neighbor search?
Exact search distance comparisons के आधार पर exact nearest neighbors निकाल सकती है। Approximate search speed improve करने के लिए कुछ candidates miss कर सकती है।
8. What is metadata filtering?
Vector search results को additional record attributes, जैसे category, language या access scope, के आधार पर limit करना।
9. Can PostgreSQL be used as a vector database?
हाँ। pgvector extension के माध्यम से PostgreSQL में vector storage और similarity search की जा सकती है।
10. Does RAG eliminate hallucinations?
नहीं। RAG relevant source material उपलब्ध करा सकता है, लेकिन retrieval errors, incomplete sources और unsupported generation का risk बना रहता है।
Practice Exercises#
Exercise 1: Semantic Search Design करें
इन queries के लिए संभावित matching documents identify करें:
- “I forgot my password.”
- “How do I reset login credentials?”
- “Change the account password.”
सोचें कि keyword search और semantic search के results कैसे अलग हो सकते हैं।
Exercise 2: Chunking Strategy Compare करें
एक लंबा technical article लें और उसे दो तरीकों से divide करें:
- Fixed-size chunks
- Heading-based chunks
Compare करें कि कौन-सी strategy specific questions के लिए अधिक useful results retrieve करती है।
Exercise 3: pgvector की Basic Query चलाएँ
PostgreSQL और pgvector उपलब्ध होने पर:
- Extension enable करें।
- Demo table बनाएं।
- Artificial vectors insert करें।
- Euclidean distance से nearest vectors खोजें।
- Cosine distance query चलाएं।
ध्यान दें कि demo vectors वास्तविक text embeddings नहीं हैं।
Exercise 4: Mini Semantic Search Project
अपनी 10 educational articles की collection से शुरुआत करें।
- Content extract करें।
- Articles को chunks में divide करें।
- एक compatible embedding model से embeddings generate करें।
- Vectors और metadata store करें।
- User query का embedding generate करें।
- Top relevant chunks retrieve करें।
- Results को manually evaluate करें।
Exercise 5: Mini RAG Project
Semantic search project को आगे बढ़ाएं:
- Retrieved chunks को LLM context में दें।
- Model से source-based answer generate कराएं।
- Answer के साथ source titles दिखाएं।
- Check करें कि answer retrieved content से supported है।
- गलत retrieval और unsupported answers के examples record करें।
Summary#
Embeddings और Vector Databases modern AI search systems के महत्वपूर्ण building blocks हैं।
Embeddings content को numerical vectors में represent करती हैं। Vector search इन vectors के बीच similarity या distance का उपयोग करके related items retrieve करती है। Chunking, metadata, indexing और evaluation search quality तथा production performance को प्रभावित करते हैं।
एक developer के रूप में इन concepts पर focus करें:
- Embeddings और vector dimensions
- Similarity metrics
- Semantic और hybrid search
- Chunking और metadata
- Vector indexes और approximate search
- pgvector और database integration
- RAG retrieval pipeline
- Evaluation, security और data updates
याद रखने वाली बात: अच्छा AI search system केवल सही embedding model से नहीं बनता। Data quality, chunking, retrieval, filtering और evaluation भी उतने ही महत्वपूर्ण हैं।
आगे क्या सीखें?#
अगला topic है:
RAG (Retrieval-Augmented Generation) Cheat Sheet – Complete Guide in Hindi
इसमें आप सीखेंगे:
- RAG क्या है और इसकी जरूरत क्यों है?
- Document ingestion और chunking
- Embeddings और vector retrieval
- Prompt में retrieved context कैसे जोड़ें
- Sources के आधार पर answers generate करना
- RAG evaluation, security और common mistakes
- एक practical document-question-answering architecture
Suggested learning sequence:
- AI Fundamentals Cheat Sheet
- LLMs Cheat Sheet
- Prompt Engineering Cheat Sheet
- Embeddings / Vector DB Cheat Sheet
- RAG Cheat Sheet
- AI Agents / MCP Cheat Sheet