$ npx create-pinecone-app@latest --template namespace-notes
create-pinecone-app
CLI tool to get up and running:1536
You can change this as long as you change the default embedding model.cosine
us-east-1
namespace-notes
directory.
You will need two separate terminal instances, one for running the client and one for the server..env
with relevant keys:.env
with relevant keys:pdf-parse
to stream and parse pdf content and leverage a best effort paragraph chunking strategy with a defined minChunkSize
and maxChunkSize
to
account for documents with longer or shorter paragraph sizes. This helps us provide sizable content chunks for our Pinecone record metadata which will later be used by the LLM during retreival.text-embedding-3-small
:
’ symbol.PineconeRecord
.
This allows us to provide the reference text and url as metadata for use by our retreival system./chat
endpoint for retrieval.
We then send the top_k
most similar results back from Pinecone via our context route.We populate a CONTEXT BLOCK
that is wrapped with system prompt instructions for our chosen LLM to take advantage of in the response output.It’s important to note that different LLMs will have different context windows, so your choice of LLM will influence the top_k
value you should return from Pinecone and along with the size of your chunks.
If the context block / prompt is longer than the context window of the LLM, it will not be fully included in generation results.documentId:
to identify all the chunks associated with a particular document and then we perform deletions until we have successfully deleted all document chunks.deleteAll()
on the relevant namespace.top_k
requested from Pinecone significantly and then constrain the output to a highly relevant set of records ordered by relevance all while abiding by the context length restrictions of the LLM.Follow our RAG series for more optimizationsOptimizing chunking strategyThis project uses a paragraph chunker, which can provide good results for some use cases. Often, the quality of a chunk will play a significant role in the quality of the retrieval system as a whole.Learn more about various chunking strategiesEnhancing metadata structureThe metadata in this project consists simply of a reference url to the original content and the particular text snippet. You could extract richer metadata from the PDFs to provide improved context to the LLM.
This, of course, assumes a given PDF upload contains additional metadata and that it would be useful (page count, title, author(s), etc).Read more about vectorizing structured text.