This path uses Pinecone Inference, Pinecone’s hosted embedding service, to turn your text into vectors. If you already generate your own embeddings, skip this and go to Bring your own vectors instead.
Prerequisites
- A Pinecone account and API key (get one).
- Python 3.10+.
- The Pinecone Python SDK:
pip install --upgrade pinecone.
Ingest your own files and search
1
Set your API key
Set your API key as an environment variable so the SDK can authenticate:
2
Extract text from your files
Convert each file (PDF, DOCX, HTML, and so on) to plain text using a parser of your choice. This step happens outside Pinecone. The result should be a list of records, each with an
id and text, like the docs list below. It runs as-is, so you can complete the quickstart first and swap in your own extracted text after.If you’re embedding images instead of text, skip this step and the chunking step. Embed your images directly with a multimodal embedding model, then upsert the resulting vectors following Bring your own vectors.
3
Chunk the text
Split your text into smaller pieces so each fits your embedding model’s input limit. The function below is a simple length-based split you can run as-is. For smarter approaches (by sentence, token, or document structure), see chunking strategies.
4
Create an index with a dense-vector field
Set
dimension to match your embedding model. llama-text-embed-v2 outputs 1024 dimensions. Only the vector field goes in the schema; other fields are stored on the documents (non-schema fields are stored as metadata, capped at 40 KB per document).5
Embed the chunks and upsert
Use Pinecone Inference to embed the chunks (in batches of 96, this model’s per-call limit), then
upsert the vectors alongside the text. For a large dataset, use batch_upsert or Import instead.6
Search your documents
To search, embed the query with the same model you used for the documents, then rank documents by vector similarity.
Next steps
Match keywords
Add a
full_text_search field to your schema for keyword search, or combine it with your vectors for hybrid search.Bulk import
Load large document sets efficiently