Retrieving vectors

Building AI Applications with Pinecone

James Chapman

Curriculum Manager, DataCamp

Recap...

An index being created.

Building AI Applications with Pinecone

Recap...

Several records being ingested into the index. The index fullness increases once the records are added.

Building AI Applications with Pinecone

Accessing vectors

 

Fetching

  • Retrieve vectors based on their IDs

A book being retrieved based on its ISBN.

 

Querying

  • Retrieve similar vectors to an input vector

Amazon book recommendations.

Building AI Applications with Pinecone

Fetching vectors

index.fetch(

ids=['0', '1']
)
{'namespace': '',
 'usage': {'read_units': 1},
 'vectors': {'0': {'id': '0',
                   'metadata': {"genre": "productivity", "year": 2020},
                   'values': [0.025525547564029694, ...]},
             '1': {'id': '1',
                   'metadata': {"genre": "action", "year": 2023},
                   'values': [-0.0131468913, ...]}}
}
1 https://docs.pinecone.io/guides/data/fetch-data
Building AI Applications with Pinecone

Read units

 

  • Measure of the resources consumed during read operations:
    • Fetching → 1RU / 10 records
    • Querying
    • Listing

 

Pinecone starter account pricing.

1 https://www.pinecone.io/pricing/
Building AI Applications with Pinecone

Fetching vectors from namespaces

index.fetch(
    ids=['0', '1']

namespace='namespace1'
)
{'namespace': 'namespace1',
 'usage': {'read_units': 1},
 'vectors': {'0': {'id': '0',
                   'metadata': {"genre": "productivity", "year": 2020},
                   'values': [0.025525547564029694, ...]},
             '1': {'id': '1',
                   'metadata': {"genre": "action", "year": 2023},
                   'values': [-0.0131468913, ...]}}
}
Building AI Applications with Pinecone

Let's practice!

Building AI Applications with Pinecone

Preparing Video For Download...