0Pricing
Vector Databases: Pinecone, Weaviate & pgvector · レッスン

疎ベクトルと密ベクトルによるハイブリッド検索

Pineconeが密な意味ベクトルと疎なキーワードベクトルを組み合わせ、意味と正確な語句の両方を捉えるハイブリッド検索を実現する仕組みを学びます。

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

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

The Limits of Dense-Only Search

Dense vectors capture meaning but can miss exact terms like product codes, names, or rare keywords. A user searching 'error E4012' may get semantically related but wrong results.

Hybrid search fixes this by adding keyword matching.

Dense vs Sparse Vectors

Two vector kinds:

  • Dense — a few hundred floats encoding semantic meaning
  • Sparse — mostly zeros, with weights only for present terms (like keyword scores)

Sparse vectors behave like classic keyword search.

What Sparse Vectors Look Like

A sparse vector is stored as indices and values for the non-zero terms.

sparse = {'indices': [10, 42, 77], 'values': [0.8, 0.5, 0.3]}
print('non-zero terms:', len(sparse['indices']))

Why Hybrid Wins

Hybrid search combines the strengths:

  • Dense handles synonyms and intent
  • Sparse guarantees exact-term matches
  • Together they boost recall and precision

Pinecone Hybrid Indexes

To use hybrid search in Pinecone, create a dotproduct index and upsert each record with both a dense values array and a sparse_values field. Queries supply both representations of the query.

Upserting a Hybrid Record

A record carries dense and sparse parts together.

record = {
  'id': 'doc1',
  'values': [0.1, 0.2, 0.3],
  'sparse_values': {'indices': [5, 9], 'values': [0.7, 0.4]},
  'metadata': {'title': 'Setup guide'}
}
print(record['id'], 'has', len(record['values']), 'dense dims')

The Alpha Weighting

Hybrid queries use an alpha parameter to weight dense vs sparse. alpha=1 is pure dense, alpha=0 is pure sparse. Tune it for your data.

def weight(dense_vec, sparse_vals, alpha):
    d = [v*alpha for v in dense_vec]
    s = [v*(1-alpha) for v in sparse_vals]
    return d, s

print(weight([1.0], [1.0], 0.7))

Generating Sparse Vectors

Sparse vectors come from keyword models like BM25 or learned sparse encoders (e.g. SPLADE). They map terms to weighted indices that Pinecone can match against stored records.

Tuning Alpha

The right alpha depends on your queries:

  • Keyword-heavy domains (codes, IDs) -> lower alpha
  • Natural-language questions -> higher alpha

Test on real queries and measure both recall and precision.

When to Use Hybrid

Reach for hybrid when exact terms matter: legal, medical, technical docs, or catalogs with SKUs. For purely conversational content, dense alone may be enough and simpler.

Bringing It Together

Hybrid search in Pinecone = a dotproduct index, records with dense and sparse values, queries supplying both, and a tuned alpha. It captures meaning and exact terms in one ranked result set.

Quick Check

Test your understanding of hybrid search.

Recap

You learned that hybrid search combines dense semantic vectors with sparse keyword vectors so Pinecone captures both meaning and exact terms. Use a dotproduct index, upsert both representations, and tune the alpha weighting to your query mix.

よくある質問

「疎ベクトルと密ベクトルによるハイブリッド検索」レッスンは無料ですか?

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

「疎ベクトルと密ベクトルによるハイブリッド検索」で何を学びますか?

Pineconeが密な意味ベクトルと疎なキーワードベクトルを組み合わせ、意味と正確な語句の両方を捉えるハイブリッド検索を実現する仕組みを学びます。 ブラウザで直接実行するハンズオンコードでVector Databases: Pinecone, Weaviate & pgvectorを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Vector Databases: Pinecone, Weaviate & pgvectorを始めるのに経験は必要ですか?

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

「疎ベクトルと密ベクトルによるハイブリッド検索」レッスンにはどのくらい時間がかかりますか?

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

このVector Databases: Pinecone, Weaviate & pgvectorレッスンでコードを書いて実行できますか?

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

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

  1. メタデータによるフィルタリング
  2. 名前空間の管理
  3. リアルタイム更新と削除
  4. 疎ベクトルと密ベクトルによるハイブリッド検索
← Vector Databases: Pinecone, Weaviate & pgvectorに戻る