0Pricing
Vector Databases: Pinecone, Weaviate & pgvector · Урок

Гибридный поиск с разреженными и плотными векторами

Узнайте, как Pinecone объединяет плотные семантические векторы с разреженными векторами ключевых слов, обеспечивая гибридный поиск по смыслу и точным терминам.

«Гибридный поиск с разреженными и плотными векторами» — бесплатный урок Vector Databases: Pinecone, Weaviate & pgvector на CoddyKit. Это урок 4 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения 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/7) и разблокировать остальной курс Vector Databases: Pinecone, Weaviate & pgvector, подпишись на CoddyKit PRO. Курс Vector Databases: Pinecone, Weaviate & pgvector содержит 4 уроков всего.

Чему я научусь в уроке «Гибридный поиск с разреженными и плотными векторами»?

Узнайте, как Pinecone объединяет плотные семантические векторы с разреженными векторами ключевых слов, обеспечивая гибридный поиск по смыслу и точным терминам. Ты практикуешь Vector Databases: Pinecone, Weaviate & pgvector с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.

Нужен ли мне опыт, чтобы начать Vector Databases: Pinecone, Weaviate & pgvector?

Предыдущий опыт не требуется. Vector Databases: Pinecone, Weaviate & pgvector на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 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