til/applied-sciences/engineering/vector-database-and-embeddings
vector-database-and-embeddings.mdupdated 2026-07-162879 words
ダブルクリックで英日反転
Applied Sciences · Engineering

Vector Databases & Embeddings — Foundation of Semantic Search

EN

An embedding turns text or images into a numeric vector encoding meaning; vector databases store millions of such vectors and retrieve the nearest neighbors at speed, making semantic search and RAG possible.

What is an Embedding?

  • Text or image → sequence of numbers (vector) representing semantic meaning.
  • "dog" and "cat" are close in vector space; "dog" and "economics" are far apart.
  • Typical dimensionality: hundreds to thousands of numbers per vector.

What is a Vector Database?

  • Stores large volumes of vectors; answers "return top-N closest vectors to this query."
  • Uses ANN (Approximate Nearest Neighbor) — trades tiny accuracy loss for dramatic speed.
  • Key products: Pinecone (managed SaaS), Qdrant (Rust, fast), pgvector (PostgreSQL extension), Chroma (lightweight local).

RAG — Why Vector DBs Matter

  • RAG (Retrieval-Augmented Generation): retrieve external knowledge, pass it to an LLM for answers.
  • Flow: embed docs → store → embed query → retrieve closest docs → LLM generates answer.
  • Lets the LLM use knowledge it never saw during training (internal docs, latest news).

Embedding Services & Tools

  • Paid APIs: Voyage AI (recommended by Anthropic docs), OpenAI Embeddings, Cohere Embed (multilingual), Google Gemini Embeddings.
  • Local/OSS: Ollama (run models on your PC, independent OSS, not Meta), sentence-transformers (Python, HuggingFace).
  • Quick start at zero cost: Chroma + Ollama locally.
Embeddings encode meaning as numbers; vector DBs find nearest neighbors fast; together they power RAG and semantic search.
Applied Sciences · Engineering

ベクトルDBと​埋め込み​(Embeddings)​— セマンティック検索の​基盤

JP

埋め込み​(embedding)は​テキストや​画像を​意味を​表す数値ベクトルに​変換する​技術。​ベクトルDB​(vector database)は​その​大量ベクトルを​格納し近傍検索を​高速に​行う​ことで、​RAGや​セマンティック検索​(意味的類似検索)を​実現する。

埋め込み​(Embedding)とは

  • テキストや​画像を​数値の​列(ベクトル)に​変換し、​意味を​座標​空間で​表現する。
  • 「dog」と​「cat」は​近傍、​「dog」と​「economics」は​遠方に​配置される。
  • 次元数​(数値の​個数)は​一般的に​数百〜数千。

ベクトルDB​(Vector Database)とは

  • 大量の​ベクトルを​格納し​「意味的に​近い​上位N件」を​返す専用ストア。
  • ANN​(近似最近​傍探索=わずかな​精度を​犠牲に​劇的な​速度向上)を​活用。
  • 主要製品: Pinecone​(フルマネージドSaaS)、​Qdrant​(Rust製・高速)、​pgvector​(PostgreSQL拡張)、​Chroma​(ローカル開発向け軽量)。

RAGに​おける​役割

  • RAG​(Retrieval-Augmented Generation=外部​知識を​検索して​LLMに​渡す手法)の​基盤が​ベクトルDB。
  • 流れ: 文書を​埋め込み→DB蓄積→質問を​埋め込み→近傍文書を​取得→LLMが​回答生成。
  • 学習時に​存在しなかった​情報​(社内文書・​最新ニュース)を​LLMに​参照させられる。

埋め込みを​作る​サービスと​ツール

  • 有料API: Voyage AI​(Anthropic公式ドキュメントが​推奨)、​OpenAI Embeddings、​Cohere Embed​(多言語)、​Google Gemini Embeddings。
  • ローカル/OSS: Ollama​(自PCで​モデルを​実行・Metaとは​独立した​OSS)、​sentence-transformers​(Pythonライブラリで​HuggingFaceモデルを​利用)。
  • ゼロコストで​試すなら​ Chroma + Ollama の​組み合わせが​最速。
埋め込みは​意味を​数値化し、​ベクトルDBが​近傍を​高速に​探す。​この​組み合わせが​RAGと​セマンティック検索の​核心。
148 notestil