In this instructional video, I showcase Pinecone Serverless and how to get set up in Node.JS/Bun/Javascript. I go over a high level overview of the benefits of pinecone and walk through a step by step tutorial in Node.JS 🔥 Don't forget to like, share, and subscribe for more! 🔗 Relevant Links: Repo:https://github.com/developersdigest/Pinecone-Serverless https://www.pinecone.io/ https://www.pinecone.io/blog/serverless/ https://www.pinecone.io/pricing/ 👉 Follow me on Twitter for updates: [@dev__digest]
--- type: transcript date: 2024-01-17 youtube_id: z-_KHGkljkc --- # Transcript: Pinecone Serverless: 8-Minute Crash Course in this video I'm going to be showing you pine cone serverless and why it's an exciting addition to the AI app developers toolkit we'll explore the key features and I'll guide you through a Hands-On example by the end of this video so don't worry if you never used Vector storage or pine cone before this example that I'm going to be showing you is designed so that anyone regardless of their previous experience can easily get started in incorporating it within their project so let's dive in Pine Cone serverless is a new development in Vector databases offering the potential for up to 50x cost reductions it is currently in a public preview and you can try it now with $100 in free credits so some of the distinct features within pine cone serverless include the separation of reads writes and storage aiming to reduce cost for various workloads there's also a unique architecture that enables efficient low latency Vector searches across extensive data sets at a lower cost within pinec con server list there's custom developed indexing and retrieval algorithms for Effective Vector search from blob storage there's a multi-tenant compute layer that facilitates a serous EXP experience freeing developers from infrastructure management and just some notes for the public preview phase of pine cone server lless the pricing model may not be fully suitable for high throughput applications quite yet right now serverless indexes are only available within AWS however availability in Google cloud and Azure are coming soon to access the $100 in free credits you will have to attach a credit card to your account to be able to use these credits if you haven't used pine cone before Pine cone's goal is to assist engineers in building Advanced AI applications such as semantic search and recommendation engines the use of pine con's Vector database for retrieval augmented generation is crucial for enhancing the quality of generative AI applications pine cone is recognized for its user friendliness reliability and scalability making it a popular choice for rag applications Studies have shown that by using rag in combination with gp4 can reduce inaccuracies and hallucinations by a considerable amount one thing I'd encourage you to check out is their pricing page you can go ahead and check out some different examples that they have preset here for reg applications classification and search and then you can go ahead and just play around with this so say you have an application and you're using open aai we'll set the vector Dimension to 1536 and then let's say you're using a relatively small amount of Records let's put that down to 100,000 now for a lot of applications that amount of Records might be larger than what you need and potentially for some applications you might not even need to have this many rights per month so if you just go ahead and look at the query per month you can go ahead and really draw this down to really being just pennies a month especially if you're a hobbyist or just tinkering around with a project idea so that $100 of free credits will certainly go quite a long way so to get started with pine cone it's really easy to sign up you can just go ahead sign up for an account you can plug in your credit card details to get that $100 of free credits the other nice thing with serverless pine cone compared to their pod structure is you're able to have a number of different serverless indexes whereas if you were just on their pod tier it would be very expensive to have multiple pods so this allows you to easily create a multi-tenant approach where you can segment users data in a way that's appropriate by having different indexes and then subsequently different name spaces within the indexes I'm also going to be showing you how to set up everything programmatically so this is just for demonstration sake so if you want to make a new index you can go ahead create an index you can give it a name you can give it the number of dimensions that's specified from your embedding model you can choose the metric you want to use for measuring the similarities so if you want to use cosine or ukian or what have you the other nice thing within the model is you can just go ahead and click setup by model and then you can specify the embeddings model if it's within this list without having to go and find all of these different metrics so if you're using open AI you can go ahead and click that and then it will go ahead and pull the correct Dimensions as well as the metric for you so right now like I mentioned you're only able to use AWS as your cloud provider and it's only available within Oregon or us West 2 but like I mentioned Google Cloud platform as well as Azure is coming soon now the one thing I did want to mention is pods are still available so if you do have a higher throughput that you do want to manage is you are able to go in here specify your pod type and then it gets started with creating your index that way as well so that's still there it's still going to be there now the other nice thing is within the gooey here is you can go ahead and estimate cost straight within here and there are some good metrics here that you can play around with I do like that they did include the metadata size within this just be mindful of the metadata that add within your vector database because if you're adding things that you aren't going to be using is you are going to be incurring a higher monthly cost now to get into the example I'm going to show you how to set this up with bun or mpm so to get started with a new project you can either go mpm init Dy or you can go ahead and bun in it we're going to go ahead and install two dependencies the pine con as well as the open aisk once you've run that you can go ahead and touch. EnV this is going to be where we're going to put our environment variables in this example I'm going to be using open AI you can go ahead and get your API key from platform. open.com AI Keys then you can get your pine cone API key from the left hand side of the pine cone guey once you're all set up and logged in once that's set up we're going to go ahead and start working through our index JS so the first thing we're going to do is we're going to import open AI from open AI we're going to import pine cone we're going to import EnV to reach for our environment variables then we're going to load up all our environment variables from the EnV file next we're going to set up a configuration object So within here there's a handful of different values on where you can specify things like the name space that you want the index name the embeddings ID the dimension the metric the class and a bunch of other things so in this example I'm just going to do a very simple example of what's my dog's name and look for the top first result but you can go ahead and change these things so if you want to actually return the vectors or if you want to return the metadata or not you can go ahead and toggle these things back and forth so the top case if you want the top three results you could just go ahead and specify that to three just as an example so once we have that set up we're going to go ahead and set up some data that we're going to embed to open AI so what we're going to send to open AI to be embedded is is this line here this text to embed line and then all of these values are going to be what we put within a data of our pine cone database next we're going to go ahead and initialize the open a client so you don't necessarily need to specify API key if you've put it within this environment variable like it's specified here so you could just go ahead and remove that if you want next we're going to go ahead and initialize our pine cone client with our API key then from there we're going to set up a function to store our embeddings so the first thing that we're going to do is we're going to Loop through all of our data embeddings that we just saw right up here and then once we Loop through them what we're going to do with each of them is we're going to create a unique embedding using the opening i m point in this case we're going to be using the text embeddings 8 to 2mo and then we're going to be passing in like I mentioned the text to embed value so from there this is where we're going to specify the ID of when we go ahead and upsert it within pine cone so here you see we're adding all of the keys within that object and then we're going to be uploading The Returned embeddings response from open AI to our pine cone database and then we're just going to Simply log that out next what we're going to do is we're going to create a function that queries the embeddings within pine cone we're going to be passing in what we had within our configuration query which is what is my dog's name and then we're going to go ahead and embed that it's going to perform that similarity search between that Vector of the query as well as what's within pine cone based on the numerical representation of the embeddings it's going to go ahead and perform that comparison and see which Bings are closest to what you have queried next to perform the query what we're going to do is we're going to be simply passing in the index the Nam space and then we're going to be passing in the configuration that we had for the similarity query so this is going to be where it passes in whether you want metadata to include values and the number of results that you want to have then we're simply going to log out the queries from there we're going to just have a simple helper function what this does is first we're going to check on whether the index exists and if it exists it will allow you to either create or delete it depending on the string that you've passed in if we want to specify to create a new index you can just go ahead and run manage index pass in create first going to check whether it's already there if it is already there it's not going to do anything otherwise it's going to create it similar to delete it it's not going to go ahead and try and delete something that doesn't ex once we have that all set up you can just go ahead and run this so if the index isn't created it will go ahead and create one for you and then here you can see that it's returning the top result and you can see that there's a relatively high score for what we're asking here you can go ahead and use the metadata say if you have a reference and you want to point it back to a particular document or URL that would be the place that you want to put it is within the metad data here but that's pretty much it for this one if you found this video useful please like comment share and subscribe and otherwise until the next one
Technical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
Weekly deep dives on AI agents, coding tools, and building with LLMs - delivered to your inbox.
Free forever. No spam.
Subscribe FreeNew tutorials, open-source projects, and deep dives on coding agents - delivered weekly.