STOP using RAG for Everything, Do this (ft. Tiger Data)
Key Takeaways
This video teaches how to use Tiger Data as an alternative to RAG for search tasks
Full Transcript
stop using rag for everything. Most of the time when people say they need rag for their AI agents, they don't need rag. Actually, all they need is highly scalable semantic search and implementing a highly scalable semantic search is generally very difficult. It's a tough engineering problem until now. Tiger data has launched agentic posgress on tiger cloud. This is their fully managed posgress cloud platform and they are offering a free tier. Thanks to tiger data for sponsoring this video. So in the next couple of minutes I'm going to teach you how to implement a hybrid search which is a combination of a keyword search using BM25 and also a semantic search where we going to use TF. You can always replace this with your own embering like open a embering. Before we move forward important things that you need to know about a tiger data agentic posgress transforms vanilla posgress into a database that is required for the AI agent era. It has got four new primitives. One is focable infrastructure, interfaced control agents, integrated search and persistent memory. First of all, all you have to do is link it in the YouTube description. You can just straight away click the link and then get started. Once you do that, like you have to sign up with your Google. Once you do that, once you log in, you're going to see something like this. You're going to see all your projects. In your case, probably you wouldn't have any projects. You might have the database name, but you wouldn't have anything else. The first step that you have to do is you have to click new service. Once you click new service, you can see what are the things that you're going to do with the new service. The most important thing you have to understand is you're going to get 750 MB per month for free and it is going to be hosted in the US. So you don't have to be worry about your data security. So this is a posgress SQL with time scale DB and there are some vector extensions that are available. So I'm going to click create a service. Once you click create a service, you have two options. One to download the text credentials. The second one is to download the environment file. So if you're going to use it uh for any cloud-based project, I would strongly encourage you to download environment file so that env file so that you don't leak your API keys. But in our case, in this case, I want to do everything within the web service, their own service. So I can just straight away simply click skip this step and then go to the next step. Once I click skip this step, then finally you have the option to connect it with any AI tool. For example, if you're using cursor claude, you want MCP support, you can just simply use this and then do it. You can see my service is currently ready. That means I can go ahead and then see here. So if I click services, you can see I've got two services. Both the services are currently running. In one of the service, I've already created all this information. So you can see DB3085 875. I've got uh the table, I've got the data, everything. Let me quickly show you a demo before we actually go through the code. So let's say I've this is a solution for pharmaceuticals or an e-commerce website that sells pharmaceuticals. Pharmaceuticals is very critical because you're not just going to search by the tablet's name or the medicine's name. You are also going to have the value um you know the dosage of it and sometimes you like customers might come and search just based on the symptoms that they have got. So all these things have to be kept in mind when you're designing a highly scalable search solution and it could be like feeding directly into an AA agent. So first thing I'm going to do is I'm going to just go here simply search for ibuprofen 200. I'm going to run the code in front of you and you can see I've just ran the code and less than a second we have got ibuprofen 200 as the top item. So we have got a hybrid score. I'll come back to the score later but you can see I proof 200 is the top one. Then I proof 400 we have got. So I'm going to go back and then search something else. So I'm going to search for Adill 200. So now Advil is also Irroofen. Okay, it's just like the brand name. And when I search for Adill 200, you can still see that I've got Ibuprofen 200. So that indicates that we have successfully implemented both the keyword search which means like the 200 comes up at the start and also when I search for Adill 200 I still get a booofen in fact I can go here and then say the powerful painkiller and once I search for this most likely I should get yeah I've I've gotten the powerful IU proof in our database which is ibuprofen 800. So how did we arrive at this particular place? So in your case like when you create a new service all you have to do is go here and click the service that you want and after you click the service that you want you can just click the SQL editor and get started. So the SQL editor I have is exactly the same. I'll share the entire SQL in the YouTube description so you can get started if you want to get started with my example that I've provided here. First thing that we have to make sure is we have to enable the extension pg search pg tick search then we have to enable the extension vector which is for PG vector. See again u this is very important for you to understand because Postgress has been like there for a very very long time and one of the most beloved RDBM systems people have been using and what we are trying to do here is we are trying to use the agentic posgress or like the newest version of Postgress that can help us build AI agents on top of it. So now we have got the both PG tech search and vector enabled and the next thing that we have to do is we just like sanity we are going to drop the table if it doesn't exist. Now we're going to add some sample data. So I'm going to create very simple table schema here. I've got like bunch of things. Most importantly I've got an ID which is highly irrelevant at this particular point. But you can see that I've got generic names, brand names, form strength and then you know adverse effects um um like other informations including an embedding. This is where if you're using open a embedding a Gemini embedding you will insert your embedding here which is like a 384 dimension embedding. In this tutorial, I'm going to show you TF based embedding which is just to make it easier for you to understand. The next thing is we're going to insert sample data for different tablets like we have got midformin uh which is like a diabetes uh tablet. We have got ibuprofen. So pain, fever, OTC um it's it's an OTC tablet. So we have got all the other tablets available here. So we are just inserting these rows in the table that we have created. Once we have that, we're going to normalize the data in such a way that it is easier for us to use with BM25 search. And honestly, like I said, like BM25 search is one of the most preferred searches these days. And you can literally implement it for any client that you want. So the next thing is we're going to create TF based embeddings. TF stands for term frequency. IDF stands for inverse document frequency. It's one of the most popular technique in NLP natural language processing. So we're going to create a TF based 384 dimensional vectors here. So we have created that once like this is this is the part where we have created that once we have created that we have literally added that as a vector within the embedding field. So we have done all those things. So in fact I can probably show you that. So I can say select a star from drug strength um documents drug strength documents. I'm going to run this run the selection. So you can see here we've got ID, we have got the generic name, we've got the brand name, we have got the form tablet or whatever it is, we've got strength and we have got a bunch of other information along with the embedding that we have created. So we have our initial data ready. Probably in your company you don't have to do do this. You already have data. All you're going to do is implement an optimize search at scale. So once we have this, we are going to create two indices. We're going to create the first index which is a BM25 index. And one important thing here is we are going to keep the text configuration simple so that the numerals like 500 are kept plainly as tokens. Second thing is is we're going to create an index. So we're going to create the index drug strength_x and index based on the embedding that we have created. So we have got two index. One is for uh the keyword search. The second one is for semantic search. So now I'm going to just simply show you an example about just to show you that the keyword search actually works. So we've got metformin 500 mg GI diarrhea. I'm going to run this. When I run this, you're going to see that the metformin 500 exactly as we expected it worked. So the next thing is what we're going to do is uh we know at this point the BM25 search has successfully worked. So the next thing is we're going to create a hybrid search. It's a combination of BM25 and the vector similarity search. And the method that we're going to use is called reciprocal rank fusion RRF. Again, one of the most popular methods currently to combine two different methods. People also use it in rag. But in this case, even with semantic search, this is like a very powerful method to combine two different rankings. One is the ranking from vector search. The other one is the ranking from keyword based search. So we have got BM25 with semantic similarity search. After we have all these things um very simple code that combines two one important factor here is that you would see like there is a weightage element here. So the weightage element is what you have to go change whatever that you want to do. But again like these are like few things that you can always optimize for. Uh I'm going to run this. When I run this uh you can see it probably giving me yeah so you can see it has given me ibuprofen 800 which is um which is the most powerful painkiller here. So I'm going to say powerful metformin. Okay, let's see if it gives us metformin thousand. Yeah, it gives us metformin,000. Now this entire thing is running on agentic posgress. This is like a database that has been built by tiger data for the agentic world currently running on the free tier of tiger cloud which you can just access for free. Thanks to tiger data for the partnership. I hope you learned something that is very critical in production. You can do a lot of consultation simply using this code and then make money. But if you're in an organization where you're implementing search, I think this could be really helpful. Let me know in the comment section what do you feel about it. Just try agentic posgress free on tigercloud today. Link is in the description. You don't need any credit card to get started. See you another video. Happy prompting.
Original Description
Sign up for Free Tiger Cloud - https://tsdb.co/1littlecoder
Thanks to Tiger Data for sponsoring this tutorial!
Most of the time people don't need RAG, they don't need the LLM component because they simply need a GREAT search - hence Production-ready Hybrid Search for scale - a combination of BM25 and Semantic Search which you can use with OpenAI or Gemini Embeddings
Code used in the video - https://github.com/amrrs/hybrid-search/blob/main/hybridsearch.sql
Make sure to replace the semantic search part with the right embedding of 384 dimensions (eg: OpenAI Embeddings or Gemini Embeddings)
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from 1littlecoder · 1littlecoder · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
How to create your Free Data Science Blog on Github with Fastpages from Fastai
1littlecoder
Making Interactive Matplotlib Plots for Data Science Visualizations on Jupyter (Python)
1littlecoder
Create your first Data Science Web App using R Shiny
1littlecoder
How to create a Reproducible Example in R using reprex
1littlecoder
No Code Visualization using esquisse with Tableau-like Drag and Drop GUI in R
1littlecoder
Scrape HTML Table using rvest and Process them for insights using tidyverse in R
1littlecoder
Google Teachable Machine Learning Build No Code AI solution
1littlecoder
Create meaningful fake tidy datasets in R using fakir [#rstats Package]
1littlecoder
How to enable using R Programming with Visual Studio VS Code
1littlecoder
Python, Community, Books - with Abhiram R - Bangpypers Co-organizers | 1littlecoder podcast
1littlecoder
Growing a Tech Community across India - Anubha Maneshwar, Founder Girlscript | 1littlecoder Podcast
1littlecoder
Intro to Google Colab - How to use Colab
1littlecoder
Intro to Plotly Express - Complex Interactive Charts with One-Line of Python Code
1littlecoder
Indic NLP Python Toolkit Open Source Development - iNLTK Creator Gaurav Arora | 1littlecoder Podcast
1littlecoder
Do you want a career in Data Science - Tamil Webinar
1littlecoder
Android Smartphone Analysis in R [Live Coding Screencast]
1littlecoder
Programmatically create Images, Memes, Watermarks using Python with imgmaker
1littlecoder
Kaggle Walkthrough to get you started with Data Science - Webinar
1littlecoder
Community, Corporate Job, Coding - Gnana Lakshmi T C aka Gyan, WomenWhoCode Leadership Fellow
1littlecoder
Easy ggplot2 Theme Customization with {ggeasy} | Data Visualization in R
1littlecoder
Excel to R - Pivot + Bar Chart in Excel & R using tidyverse [Live Coding]
1littlecoder
Excel to R #2 - VLOOKUP in Excel to LEFT_JOIN, MERGE in R
1littlecoder
5 websites to get Free Real-World Datasets for Data Science/ML Projects
1littlecoder
Excel to R #3 - APPROXIMATE VLOOKUP in Excel to FUZZY LEFT_JOIN in R
1littlecoder
Correlation-alternative PPS (Predictive Power Score) Python Package Demo
1littlecoder
Automated Website Screenshots in R using {webshot}
1littlecoder
Installing Custom RStudio Theme (Synthwave85)
1littlecoder
Analyse Google Trends Search Data in R using {gtrendsR}
1littlecoder
3 Tips to ask question on Stack Overflow the right way to get answers
1littlecoder
Learn Data Science with R - Mini Projects - Web Scraping Zomato
1littlecoder
Easily make Dumbbell Chart using {ggcharts} | Data Visualization in R
1littlecoder
GET Hackernews Front Page Results using REST API in R
1littlecoder
Quickly deploy ML WebApps from Google Colab using ngrok
1littlecoder
Use Jupyter Notebooks within VSCode (Visual Studio Code) in 2020
1littlecoder
Plotly Interactive Plots as Pandas Plotting Backend df.plot()
1littlecoder
Stack Overflow Developer Survey 2020 Highlights for New Programmers
1littlecoder
Matplotlib Animation Charts in Python using Celluloid
1littlecoder
Coding, Postwoman, Passion Project Book - Liyas Thomas Open Source Developer - 1littlecoder podcast
1littlecoder
Aspiring Data Scientist, Tips on How to learn Business Domain Knowledge
1littlecoder
Bokeh Interactive Charts as Pandas Plotting Backend df.plot_bokeh()
1littlecoder
Easy Fast Python Pandas Summary with Sidetable | Pandas Tips & Tricks
1littlecoder
Inception, Content Ideas, Consistency - Srivatsan Srinivasan AIEngineering YouTube Content Creator
1littlecoder
ggplot2 Text Customization with ggtext | Data Visualization in R
1littlecoder
Penguins Dataset Overview - iris alternative | EDA Data Visualization in R
1littlecoder
YouTube Growth Tips, Content Creation - Bhavesh Bhatt, YouTuber (Data Science & Machine Learning) #7
1littlecoder
Matplotlib Animated Bar Chart Race in Python | Data Visualization
1littlecoder
Simple Python GUI Development using {guietta}
1littlecoder
#8 Niche, Growth, Monetization - David Langer - YouTuber Dave on Data
1littlecoder
Simple Fast 3-step Python OCR using Deep Learning 40+ Languages
1littlecoder
Github New Feature Profile Summary/Mini-Resume - Profile Views
1littlecoder
Otto ML Assistant, GPT-3 on Philosophers, Nvidia-ARM - 3 ML Tech News
1littlecoder
What is OpenAI GPT-3 - Hype, Examples, Worries
1littlecoder
Julia 1.5, Datamuse API, Live HDR+ Pixel 4a - Machine Learning Tech News
1littlecoder
Self-driving Car Engineer sentenced, arXiv Dataset, AI/ML Startup Idea - Machine Learning Tech News
1littlecoder
GPT-3 Explorer, Ciphey (Automated Decryption), Py-Sudoku - ML Tech News
1littlecoder
How to use Advanced Google Search to extract Email Ids from Linkedin
1littlecoder
Cartoonizer Toon-IT (AI Web App), GPT-3 Advice, Android Earthquake Detection - ML Tech News
1littlecoder
Flow - R Package to visualize code logic, functions as a Flow Diagram
1littlecoder
Build GPT-3-like Language Model on Google Colab with minGPT [PyTorch]
1littlecoder
Create a Pencil Sketch Portrait with Python OpenCV
1littlecoder
More on: LLM Foundations
View skill →Related Reads
📰
📰
📰
📰
Add a Freshness Gate Before Your RAG Model Call
Dev.to AI
Optimizing RAG at Scale: Chunking, Retrieval, and the Bayesian Search That Cut Latency 40%
Dev.to AI
Optimizing RAG at Scale: Chunking, Retrieval, and the Bayesian Search That Cut Latency 40%
Dev.to AI
Optimizing RAG at Scale: Chunking, Retrieval, and the Bayesian Search That Cut Latency 40%
Dev.to AI
🎓
Tutor Explanation
DeepCamp AI