Back to blog

What is RAG and Why Does it Matter?
Retrieval Augmented Generation (RAG) is the process by which developers can enhance AI model output by providing it useful context in addition to the user’s original prompt. If you were to imagine a teacher standing in front of a group of kindergartners asking them what the caterpillar did in the book The Very Hungry Caterpillar before the kids read the book, that would effectively be what prompting an AI model is like without RAG. However, if the teacher reads the book to the students and then asks the same question, the students can “retrieve” memories of the book to help influence their answer.
Even if you were unaware of RAG before this article, there’s a good chance you’ve interacted with it. Many support bots on websites use RAG. Many knowledge bases. Some games. RAG has become a critical piece of building AI-powered software.
But, creating a RAG pipeline has been tedious and time-consuming. Traditionally, developers had to:
- Generate a piece of information (or fetch it from some other data source)
- Create a vector embedding of the information
- Store the vector embedding in a vector database
- Store the original file information in a traditional database or in object storage (like Pinata)
- Create metadata in the vector database pointing to the original file
Then, when retrieving information using RAG, the process has been equally frustrating, with many moving parts and opportunities for mistake.
- Receive a text input from a user
- Create a vector embedding of the text input
- Using the vector database’s search functionality to do a similarity search between the vectorized user input and the embeddings in the database to find the top matches
- Grab the metadata from any of the matches that are needed to send to the AI model
- Look up and retrieve the original source data based on the metadata from the vector database
- Send the original data along with the user prompt to the AI model as part of the overall prompt context
The more moving parts, the more chances for bugs. Keeping data in-sync has been a nightmare, and ensuring the AI models get the correct data at the right time is difficult. Because of this, Pinata wanted to take a stab at solving these problems based on our experience handling files for the last 6+ years.
File Vectors with Pinata
Pinata has dramatically simplified this complex pipeline with a built-in vectorization system that treats vector search as a first-class feature of file storage.
Instead of manually managing a vector database, developers using Pinata can now vectorize a file directly ****on ****upload and query ****those vectors using natural language—all without ever leaving Pinata’s ecosystem.
Here's how easy it is:
- Upload a file — such as a support doc, game asset, or internal memo — to Pinata’s private IPFS network.
- Enable vectorization with
.vectorize()
when uploading using the Pinata SDK. - Store all relevant metadata with
.keyvalues()
for enhanced querying and filtering. - Done.
There’s no need to separately generate embeddings, manage another database, or link back to the original content. Vector metadata and file content live side by side, fully queryable and always in sync.
Upload and Vectorize in One Step
Here’s what uploading and vectorizing a file looks like using the Pinata SDK:
import { PinataSDK } from "pinata";
const pinata = new PinataSDK({ pinataJwt: process.env.PINATA_JWT });
const file = new File([blob], "my-doc.txt", { type: "text/plain" });
const uploadResponse = await pinata.upload.private.file(file)
.name("my-doc.txt")
.keyvalues({ category: "support" })
.vectorize(); // This triggers automatic vector embedding generation
That’s it. The file is now vectorized and ready for semantic search.
Querying: Natural Language And Native Retrieval
Once you’ve uploaded and vectorized your files, querying them is as easy as:
const results = await pinata.files.private.queryVectors({
groupId: "your-group-id",
query: "How can users reset their password?",
returnFile: true
});
This performs a semantic similarity search against your vectorized files and returns the best matches. If returnFile
is set to true
, it includes the actual file content or metadata, so you can pass it straight into your AI model.
This eliminates the need for:
- Embedding new user inputs manually
- Connecting to a separate vector DB
- Mapping vector matches back to original content
- Juggling ACLs or storage buckets
Built for Real-World Applications
Whether you’re building:
- A support chatbot that pulls from documentation
- An AI-powered search engine across internal knowledge
- A dynamic story engine for your game
- A smart file browser that suggests contextually relevant files
Pinata's file vectors unlock fast, relevant retrieval with zero infrastructure burden. Just:
- Upload →
.vectorize()
- Query →
queryVectors()
- Ship.
If you’re ready to test out Pinata’s Vector Storage, sign up today or check out the docs.