0Pricing
LangChain / RAG / Vector DBs · レッスン

Embedding とベクトルデータベース

テキストの Embeddings が意味をベクトルに変換する仕組みと、ベクトルデータベースが RAG の中核である検索ステップを可能にする方法を理解します。

「Embedding とベクトルデータベース」はCoddyKit上の無料LangChain / RAG / Vector DBsレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはLangChain / RAG / Vector DBs学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 LangChain / RAG / Vector DBsコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

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.

よくある質問

「Embedding とベクトルデータベース」レッスンは無料ですか?

はい。「Embedding とベクトルデータベース」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、LangChain / RAG / Vector DBsコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 LangChain / RAG / Vector DBsコースには全4レッスンが含まれています。

「Embedding とベクトルデータベース」で何を学びますか?

テキストの Embeddings が意味をベクトルに変換する仕組みと、ベクトルデータベースが RAG の中核である検索ステップを可能にする方法を理解します。 ブラウザで直接実行するハンズオンコードでLangChain / RAG / Vector DBsを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

LangChain / RAG / Vector DBsを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのLangChain / RAG / Vector DBsは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。

「Embedding とベクトルデータベース」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このLangChain / RAG / Vector DBsレッスンでコードを書いて実行できますか?

はい。すべてのLangChain / RAG / Vector DBsレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. 大規模言語モデルとは?
  2. 検索拡張生成の必要性
  3. RAGシステムの中核コンポーネント
  4. Embedding とベクトルデータベース
← LangChain / RAG / Vector DBsに戻る