- Manual
- Cursor
- Claude Code
Use a Pinecone SDK to create an index, upsert data, and perform semantic search.After signing up, you’ll receive an API key in the console. Save this key. You’ll need it to authenticate your requests to Pinecone.Upsert the sample dataset into a new namespace in your index.Because your index is integrated with an embedding model, you provide the textual statements and Pinecone converts them to dense vectors automatically.Pinecone is eventually consistent, so there can be a slight delay before new or changed records are visible to queries. You can view index stats to check if the current vector count matches the number of vectors you upserted (50):The response looks like this:Notice that most of the results are about historical structures and monuments. However, a few unrelated statements are included as well and are ranked high in the list, for example, a statement about Shakespeare.Notice that all of the most relevant results about historical structures and monuments are now ranked highest.
To get started in your browser, use the Quickstart colab notebook.
1. Sign up
If you’re new to Pinecone, sign up at app.pinecone.io and choose a free plan:- Starter plan: Free access to most features, but you’re limited to one cloud region and need to stay under Starter plan limits.
- Standard plan trial: 21 days and $300 in credits with access to Standard plan features and higher limits that let you test Pinecone at scale.
You cannot switch from the Starter plan to the Standard plan trial, so be sure to select the right plan for your needs.
2. Install an SDK
Pinecone SDKs provide convenient programmatic access to the Pinecone APIs.Install the SDK for your preferred language:3. Create an index
In Pinecone, there are two types of indexes for storing vector data: Dense indexes store for semantic search, and sparse indexes store for lexical/keyword search.For this quickstart, create a dense index that is integrated with an embedding model hosted by Pinecone. With integrated models, you upsert and search with text and have Pinecone generate vectors automatically.If you prefer to use external embedding models, see Bring your own vectors.
4. Upsert text
Prepare a sample dataset of factual statements from different domains like history, physics, technology, and music. Model the data as as records with an ID, text, and category.To control costs when ingesting large datasets (10,000,000+ records), use import instead of upsert.
5. Semantic search
Search the dense index for ten records that are most semantically similar to the query, “Famous historical structures and monuments”.Again, because your index is integrated with an embedding model, you provide the query as text and Pinecone converts the text to a dense vector automatically.6. Rerank results
To get a more accurate ranking, search again but this time rerank the initial results based on their relevance to the query.7. Improve results
Reranking results is one of the most effective ways to improve search accuracy and relevance, but there are many other techniques to consider. For example:- Filtering by metadata: When records contain additional metadata, you can limit the search to records matching a filter expression.
- Hybrid search: You can add lexical search to capture precise keyword matches (e.g., product SKUs, email addresses, domain-specific terms) in addition to semantic matches.
- Chunking strategies: You can chunk your content in different ways to get better results. Consider factors like the length of the content, the complexity of queries, and how results will be used in your application.
8. Clean up
When you no longer need your example index, delete it as follows:For production indexes, consider enabling deletion protection.