0Pricing
LangChain / RAG / Vector DBs · Lekcja

Embeddingi i bazy wektorowe

Dowiedz się, jak embeddingi tekstowe zamieniają znaczenie na wektory oraz jak bazy wektorowe umożliwiają etap wyszukiwania będący sercem RAG.

Embeddingi i bazy wektorowe to bezpłatna lekcja LangChain / RAG / Vector DBs na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej LangChain / RAG / Vector DBs, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs LangChain / RAG / Vector DBs zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

From Words to Vectors

Computers cannot compare meaning directly. An embedding is a vector of numbers representing a text’s meaning, so similar texts land close together.

What an Embedding Looks Like

An embedding model maps text to a fixed-length vector with hundreds or thousands of dimensions. The numbers are not readable — what counts is their geometric relationships.

text = 'a cup of coffee'
embedding = [0.12, -0.04, 0.88, 0.31]  # simplified
print('dimensions:', len(embedding))

Semantic Similarity

Because meaning maps to position, "dog" sits near "puppy" but far from "database". That is what powers semantic search — matching by meaning, not exact keywords.

Measuring Closeness

The go-to closeness metric is cosine similarity — the cosine of the angle between two vectors. 1 means nearly identical, 0 means unrelated.

def cosine(a, b):
    dot = sum(x*y for x, y in zip(a, b))
    na = sum(x*x for x in a) ** 0.5
    nb = sum(y*y for y in b) ** 0.5
    return dot / (na * nb)

print(round(cosine([1, 0, 1], [1, 0, 1]), 2))
print(round(cosine([1, 0, 0], [0, 1, 0]), 2))

Why a Vector Database?

RAG must find the most relevant chunks among millions of vectors, fast. A vector database stores embeddings and finds nearest neighbors — something SQL is not built for.

Approximate Nearest Neighbor

Comparing a query to every vector is too slow at scale. Vector DBs use ANN indexes like HNSW that trade a sliver of accuracy for huge speed gains.

Indexing Documents

To build a knowledge base, index your docs: split into chunks, embed each one, and store the vector with its text and metadata. This is RAG’s offline ingestion step.

chunks = ['intro paragraph', 'pricing details', 'support hours']
for c in chunks:
    vec = embed(c)        # call embedding model
    db.upsert(vec, text=c)

Querying

At query time, embed the user’s question with the same model, then ask the vector DB for the top-k nearest chunks — that becomes the LLM’s context.

q_vec = embed('when is support open?')
results = db.search(q_vec, top_k=3)
for r in results:
    print(r.text, r.score)

Metadata Filtering

Vector DBs also support metadata filtering: combine similarity search with filters like language, date range, or owner to sharpen relevance.

db.search(q_vec, top_k=3, filter={'lang': 'en', 'year': 2026})

Choosing a Vector Store

Your vector store options span libraries (FAISS), dedicated DBs (Pinecone, Weaviate, Qdrant, Milvus), and extensions like pgvector. Pick by scale, hosting, and data needs.

Embeddings in the RAG Pipeline

Embeddings and the vector DB are the retrieval half of RAG: index once, then for every question embed, search, and hand the top chunks to the LLM as grounding.

Quick Check

Test your understanding of embeddings and vector search.

Recap

You learned RAG’s retrieval foundation: embeddings turn meaning into vectors, cosine measures closeness, and vector DBs use ANN for fast nearest-neighbor search.

Często zadawane pytania

Czy lekcja „Embeddingi i bazy wektorowe” jest bezpłatna?

Tak — pełny tekst „Embeddingi i bazy wektorowe” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu LangChain / RAG / Vector DBs, przejdź na CoddyKit PRO. Kurs LangChain / RAG / Vector DBs zawiera 4 lekcji w sumie.

Co nauczysz się w „Embeddingi i bazy wektorowe”?

Dowiedz się, jak embeddingi tekstowe zamieniają znaczenie na wektory oraz jak bazy wektorowe umożliwiają etap wyszukiwania będący sercem RAG. Ćwiczysz LangChain / RAG / Vector DBs z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć LangChain / RAG / Vector DBs?

Nie wymagamy żadnego doświadczenia. LangChain / RAG / Vector DBs w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.

Ile czasu zajmuje lekcja „Embeddingi i bazy wektorowe”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji LangChain / RAG / Vector DBs?

Tak. Każda lekcja LangChain / RAG / Vector DBs zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Czym są wielkie modele językowe?
  2. Potrzeba generowania wspomaganego wyszukiwaniem
  3. Podstawowe komponenty systemu RAG
  4. Embeddingi i bazy wektorowe
← Powrót do LangChain / RAG / Vector DBs