Build a Q&A Bot over Your Company Docs with Pinecone + Claude (Python, SDK v10)
Description and use
Build a command‑line Q&A bot that ingests company docs, stores embeddings in Pinecone, retrieves and reranks relevant chunks, and generates cited answers with Claude.
Problem
New hires cannot quickly find internal policies and current rules, and keyword‑based wiki search often fails to surface relevant documents.
Outcome
The script provides a ready‑to‑run pipeline that ingests markdown/text files, stores embeddings in Pinecone, retrieves and reranks relevant chunks, and generates cited answers with Claude, all while respecting Pinecone Starter plan limits.
Workflow
- Set up Pinecone and Anthropic API keys
- Install dependencies (pinecone==10.3.0, anthropic==2.4.0)
- Define environment variables (PINECONE_API_KEY, ANTHROPIC_API_KEY, optional PINECONE_INDEX, PINECONE_NAMESPACE, USE_RERANK)
- Chunk documents using a 500‑char limit with 80‑char overlap
- Upsert chunks into a Pinecone index (serverless, AWS us‑east‑1)
- Query the index with a user question, retrieve top 12 chunks
- Optionally rerank top 4 chunks with bge‑reranker‑v2‑m3
- Build a prompt that includes the question and retrieved chunks
- Send prompt to Claude (claude‑sonnet‑5‑5) via Messages API
- Return answer with citations
- Estimate costs and monitor rate limits
Evidence
Once a company has enough internal docs, the same problems show up: new hires can't find the leave policy, nobody remembers which version of the expense rules is current, and wiki search only works if you guess the exact words the author used
This walkthrough builds a command-line Q&A bot with Pinecone (managed vector database with hosted embedding and rerank models) and Claude (Anthropic's LLM, for answer generation)
The Pinecone SDK changed a lot in v10. Many tutorials still use the v5–v7 style (create_index_for_model, upsert_records, ServerlessSpec), which may fail or emit deprecation warnings.
Embedding, storage and reranking all happen on Pinecone's side, so you don't install PyTorch or host an embedding model.
- Record date: 2026-11-04T02:13:53.878Z