Mastering Natural Language to SQL with LangChain and LangSmith | NL2SQL | With Code 👇

  Рет қаралды 19,417

Pradip Nichite

Pradip Nichite

2 ай бұрын

Embark on a journey to redefine database querying with "Mastering Natural Language to SQL with LangChain | NL2SQL." This in-depth video guide will navigate you through the revolutionary process of converting natural language queries into SQL commands using LangChain. Here's what we'll cover:
🌟 Introduction to NL2SQL: Understand the basics of translating natural language to SQL with LangChain.
🔨 Building Your First NL2SQL Model: Step-by-step guide on creating a foundational NL2SQL model.
🎯 Incorporating Few-Shot Learning: How to enhance model accuracy using few-shot examples.
🔄 Dynamic Few-Shot Example Selection: Tailor your model's learning process with dynamic example selection for improved relevance.
🔍 Identifying Relevant Database Tables Dynamically: Techniques to automatically determine which tables to query, streamlining your SQL commands.
✍️ Customizing Prompts for Accurate Responses: Learn to customize prompts for clearer, more precise model outputs.
💬 Adding Conversational Memory: Enable your model to handle follow-up questions by integrating memory into your chatbot.
Designed for data scientists, developers, and anyone interested in leveraging AI for more intuitive database management, this video equips you with the knowledge to make your data querying as simple as having a conversation. Explore the forefront of natural language processing technology and transform your approach to database interactions.
👉 Code and explanation: blog.futuresmart.ai/mastering...
If you're curious about the latest in AI technology, I invite you to visit my project, AI Demos, at www.aidemos.com/. It's a rich resource offering a wide array of video demos showcasing the most advanced AI tools.
For even more in-depth exploration, be sure to visit my KZbin channel at / @aidemos.futuresmart . Here, you'll find a wealth of content that delves into the exciting future of AI and its various applications.
🚀 Top Rated Plus Data Science Freelancer with 8+ years of experience, specializing in NLP and Back-End Development. Founder of FutureSmart AI, helping clients build custom AI NLP applications using cutting-edge models and techniques. Former Lead Data Scientist at Oracle, primarily working on NLP and MLOps.
💡 As a Freelancer on Upwork, I have earned over $100K with a 100% Job Success rate, creating custom NLP solutions using GPT-3, ChatGPT, GPT-4, and Hugging Face Transformers. Expert in building applications involving semantic search, sentence transformers, vector databases, and more.
#NL2SQL #LangChain #NaturalLanguageProcessing #DataScience #AI #DatabaseManagement #SQL

Пікірлер: 77
@raumwerk09
@raumwerk09 24 күн бұрын
Excellent! I've already watched some 10+ other tutorials on LangChain SQL chats, but none of these really got beyond the basic demo for simplistic databases, completely ignoring the problems of token limits and providing custom table info to the LLM for more complex databases...so this one really stands out. Kind Thanks for the insights, and Greetings from Germany :-)
@FutureSmartAI
@FutureSmartAI 24 күн бұрын
Glad it was helpful!
@JohnBoen
@JohnBoen 8 күн бұрын
I have been a database engineer for decades. I dream SQL... You made the *perfect* tutorial for me :)
@user-cq7mu7fu6o
@user-cq7mu7fu6o 12 күн бұрын
really amzing content sir , i learn so much from this vdeo thank sir :) love from hyderabad
@diptimanraichaudhuri6477
@diptimanraichaudhuri6477 2 ай бұрын
Very well explained Pradip! Keep up the good work !
@user-zl4vl6oo1l
@user-zl4vl6oo1l 2 ай бұрын
GREAT session. You are legend, smart, and helpful. thank you.
@aguntuk10
@aguntuk10 Ай бұрын
very good expalnation Pradip , really helpful . Thanks a ton
@SanjayRoy-vz5ih
@SanjayRoy-vz5ih 2 ай бұрын
Absolutely fantastic tutorial...only question that you on "top-k"... remember it is used only in case of vector embedding for neighborhood similarity search, or as it is called cosine similarity... otherwise it is of no use...if you are not embedding
@RAJARAMRamamoorthi
@RAJARAMRamamoorthi 2 ай бұрын
Have you used any GraphQL chain , if so, pls do a detailed view on that , very helpful session thanks
@YatanveerSingh
@YatanveerSingh Ай бұрын
Hi Pradip, Thanks for your blog and this video. This helped me to understand how to use NLP to SQL in a very easy way. I am able to use this on my database, however sometime I am getting list index out of range. This is happening specially if there are lot of rows in my tables. So I am not sure if I use this in Production. Can you advice. Thanks Yatan
@user-zl4vl6oo1l
@user-zl4vl6oo1l 18 күн бұрын
thank you very much, what do you think about chatgroq ? can we use it for the same purpose?
@kallolbecs
@kallolbecs 2 ай бұрын
Great video, can u make one for nl 2 mongodb as well?
@KumR
@KumR 2 ай бұрын
Hey Pradip . Can we connect this to Oracle Fusion ERP
@Rasmiya_M
@Rasmiya_M 17 күн бұрын
Sir can I get a data science internship at your company?
@sakalyamitra9935
@sakalyamitra9935 2 ай бұрын
Went through the video and it is greatly explained in detail. The chaining explanation along with parallel visualization in Langsmith made it super easy to understand how the things are getting executed. Great video to master NL2SQL using Langchain.
@FutureSmartAI
@FutureSmartAI 2 ай бұрын
You're very welcome!
@shaktidharreddy6822
@shaktidharreddy6822 2 ай бұрын
@@FutureSmartAI pls need streamlit code, gitrepo doesnt have
@kenchang3456
@kenchang3456 Ай бұрын
Hi Pradit, thank you very much for a detailed video. It was valuable and insightful for my POC.
@FutureSmartAI
@FutureSmartAI 20 күн бұрын
Glad it was helpful!
@soumyaparida9231
@soumyaparida9231 Ай бұрын
Great session.But can you tell how to implement it using gemini pro?
@SarbaniMaiti
@SarbaniMaiti 2 ай бұрын
This is awesome Pradip, you just built an application ready to go in production :)..very useful.
@FutureSmartAI
@FutureSmartAI 2 ай бұрын
Glad it was helpful!
@polly28-9
@polly28-9 15 күн бұрын
Can you tell me with what LLM model learn ( try to know ) the structure of our database? How the LLM model knows the structure of our database? Only with connection and it learn it? I am confused
@wealth_developer_researcher
@wealth_developer_researcher 2 ай бұрын
Thanks for nice video. I have one question. What if I am treating this .py file as API Endpoint. And want to use same chain per user. Here I can see you have used Streamlit cache resource so it comes from cache on same server. But my requirement is to use this as endpoint so that i can call it from any server
@polly28-9
@polly28-9 16 күн бұрын
Is this create_extraction_chain_pydantic deprecated? What to use instead? Any alternatives? I got error: ValueError: A pending deprecation cannot have a scheduled removal. Please, help me!
@chihebnouri5541
@chihebnouri5541 Ай бұрын
i think building sql llm with gemini is better no?
@prashanthganna2545
@prashanthganna2545 22 күн бұрын
Hi Pradip, Im using Azure OpenAI. How can i generate dynamic few shot examples?
@aryanmishra4594
@aryanmishra4594 18 күн бұрын
I also want it to answer questions other that database outside of this database context how to do that
@YashNanaware-fe5jz
@YashNanaware-fe5jz Ай бұрын
Hi, I have a problem I have data at cloud datamart I want to load it into the db but I am not able to do it as I get connected to the datamart by using UI where in I pass my ID and auntention is done through azure credentials token. Is there any way I can do it as I don't have password for it.
@protimaranipaul7107
@protimaranipaul7107 19 күн бұрын
BadRequestError: Error code: 400 - {'error': {'message': "Sorry! We've encountered an issue with repetitive patterns in your prompt. Please try again with a different prompt.", 'type': 'invalid_prompt', 'param': 'prompt', 'code': None}}
@rsivci
@rsivci 2 ай бұрын
HiPradip, Excellent explanation, I have PrestoDB in our organisation, I some how dont see the connection part between Langchain and this prestoDB, any references you can help me with?
@FutureSmartAI
@FutureSmartAI 2 ай бұрын
you should look for PrestoDB SQL Alchemy URI . check this www.twilio.com/en-us/blog/access-presto-database-python-sqlalchemy
@gan13166
@gan13166 Ай бұрын
how to display the column names.. the output records are coming , but not the column names
@ShivamGupta-ek4rd
@ShivamGupta-ek4rd Ай бұрын
How Can I use this with IBM DB2 Database?
@naveennoelj
@naveennoelj Ай бұрын
Hi Pradip, very detailed explanation on NL2SQL, most comprehensive I have seen. Thank You. One quick Qs: Is it possible to take the output/results of the SQL query and display a chart (bar/pie/line) only if the results can be put on a chart or if the user asks for it. what would it take to do this?
@FutureSmartAI
@FutureSmartAI 20 күн бұрын
Yes. First you should access intermediate steps that gives db results and then ypu can visualise it using normal python libraries
@tanzeelmohammed9157
@tanzeelmohammed9157 Ай бұрын
Hi Pradip.. I have been trying to do the same thing. The problem I do not have credit in OpenAI and i wanted to know if there is any other way using opensource models to achieve the same result..specially in LangChain
@FutureSmartAI
@FutureSmartAI 20 күн бұрын
Yes you can use open source llm instead of Open AI
@pavancharan4236
@pavancharan4236 Ай бұрын
Hi Pradip. Thanks for the explanation. So you say, we crease a csv file for choosing correct tables for handling larger datasets. Correct me if I am wrong. My doubt is How big the csv file can be? How many tables can we use? Does it work good even for 100s of rows in csv file?
@FutureSmartAI
@FutureSmartAI 20 күн бұрын
lets say you have 200 tables and each table has 100 columns, so bsically 20000 lines of information or schema which is not feasible to put inprompt sometime and even if its possbile it will increase cost. As we know most of the queries cabe answered max using 10 tables . So you can create table selection prompt with 2-3 lines for each table description . Once you select table you need to only add schema of those tables in final prompt
@prathamgupta3984
@prathamgupta3984 Ай бұрын
Can anyone help me it shows error of that open AI key credit exhausted I tried every possible way to get some free credit but always failed
@dataacademy369
@dataacademy369 2 ай бұрын
Do you provide any online training on NLP, if someone aspire to become a freelancer?
@FutureSmartAI
@FutureSmartAI 2 ай бұрын
Hi No, Did you check my freelancing playlsit? I shared my experiences and tips there
@rameshh3821
@rameshh3821 Ай бұрын
Hi Pradip. I'm not able to add memory to my chatbot. I'm getting this error- "The SQL result is an error message indicating that the SQL query was not executed successfully. Therefore, the user question cannot be answered based on the given information." Please help.
@rameshh3821
@rameshh3821 Ай бұрын
Anyone getting the same error? Please respond.
@user-wk1ou9lv5w
@user-wk1ou9lv5w 2 ай бұрын
Thanks for video.can please answer my below querie .how can we create dynamic examples,bcz what if we don't know the db domain
@FutureSmartAI
@FutureSmartAI 2 ай бұрын
We can use chatGPT to comeup with few shot examples . Eg we can give tables schema and sample records and ask chatGPT to comeup with pairs of natural and sql queries. But few shot examples needs to be correct and better we curate them or verify them and use. Other approach we can use feedback mechanism, everytime we show user result we can ask for user feedback and later use positive feedback as few shot examples
@user-wk1ou9lv5w
@user-wk1ou9lv5w 2 ай бұрын
@@FutureSmartAI Thanks for your response.i have seen that you made 3 videos of converting text to SQL ..1.using langchain agent 2)using langchain chain(current video) 3) using llamaaindex....so which one is better
@FutureSmartAI
@FutureSmartAI 2 ай бұрын
@@user-wk1ou9lv5w Since those libraries keep changing syntax you should always refer latest video
@Thangarajtest
@Thangarajtest 2 ай бұрын
Hello Sir, Could you pls share the video on how to deploy the this application using langserve?
@FutureSmartAI
@FutureSmartAI 20 күн бұрын
I have already one video on langserve
@n3cr0ph4g1st
@n3cr0ph4g1st 2 ай бұрын
The query after you do invoke is "SQLQuery: " so it never executes anything. you need to include all your package versions as well. Thanks for the replies
@FutureSmartAI
@FutureSmartAI 2 ай бұрын
Hi we dont need any cutom code for langchain . you only need below code snippet which is already in notebook os.environ["LANGCHAIN_TRACING_V2"] = "true" os.environ["LANGCHAIN_API_KEY"] = "" I agree I should include package version. I will update notebook with langchain and other relevant package version
@n3cr0ph4g1st
@n3cr0ph4g1st 2 ай бұрын
@@FutureSmartAI I tried implementing and the AI output always includes "sqlquery:" before the query so the query can never be executed in the lcel chain... Are you seeing this behavior? Could it be related to me using gpt4 instead of 3.5?
@FutureSmartAI
@FutureSmartAI 2 ай бұрын
​@@n3cr0ph4g1st Yes we have seen this behavoir with GPT3.5. basically we are getting something extra with sql query and it resulting in failure while executing. you can use GPT-4. Also you can add post processing fucntion after query generation and before query execution using python.langchain.com/docs/expression_language/how_to/functions
@FutureSmartAI
@FutureSmartAI 2 ай бұрын
you can even modify prompt to explicitly say to dont write anything other than sq query itself
@kamaleshnew
@kamaleshnew 2 ай бұрын
How do you map column values so user need not mention column names for every query
@FutureSmartAI
@FutureSmartAI 2 ай бұрын
Hi can you example of it?
@kamaleshnew
@kamaleshnew 2 ай бұрын
@@FutureSmartAI you have a word 'india' in let say 10 coulmns ....which column to route
@kamaleshnew
@kamaleshnew 2 ай бұрын
@@FutureSmartAI also not all texts has been easily identified and showing data ....
@ajaym4257
@ajaym4257 2 ай бұрын
Hello, I want to "Identifying Relevant Database Tables Dynamically". When i run the same code as you as show below i basically get this [ ] square bracket as output. Can you help? table_details_prompt = f"""Return the names of ALL the SQL tables that MIGHT be relevant to the user question. \ The tables are: {table_details} Remember to include ALL POTENTIALLY RELEVANT tables, even if you're not sure that they're needed.""" table_chain = create_extraction_chain_pydantic(Table, llm, system_message=table_details_prompt) tables = table_chain.invoke({"input": "what is relative utilization is coming from which table?"}) tables
@rameshh3821
@rameshh3821 Ай бұрын
Hi. I'm also getting the same error.
@FutureSmartAI
@FutureSmartAI 20 күн бұрын
What natural query are you asking ? also you can ignore dynamic table selection since it will not work with follow up question. we will need to add hstory to table selection prompt to make it working
@Mostafa_Sharaf_4_9
@Mostafa_Sharaf_4_9 2 ай бұрын
Can we make this code as api using fastapi and deploy it on AWS . If yes, please make more vadios about api ❤
@FutureSmartAI
@FutureSmartAI 2 ай бұрын
Yes it can be integarted in fastapi, Its just normal python code. I have some other videos where I inetgarted open ai and fastapi deployed on aws vm
@shaktidharreddy6822
@shaktidharreddy6822 2 ай бұрын
please post streamlit code also
@FutureSmartAI
@FutureSmartAI 20 күн бұрын
Everything is there , check link in the description
@manikandanr1242
@manikandanr1242 2 ай бұрын
can we create a chatbot so it can answer friendly question 'hi'
@FutureSmartAI
@FutureSmartAI 20 күн бұрын
Yes
@ansumansatpathy3923
@ansumansatpathy3923 2 ай бұрын
I see two audio messages overlap around 56:47, very distracting. Also pls plan your content ahead to avoid revisiting after breaking existing flow.
@FutureSmartAI
@FutureSmartAI 2 ай бұрын
Thanks for pointing. Actually my recorder stopped workign after some and re recorded some part that resulted in some overlap when i combined them
@RaushanKumar-ut2ke
@RaushanKumar-ut2ke Ай бұрын
When i have used semanticsimilarityexampleselector using AzureOpenAIEmbedding i got ->ValueError: Expected EmbeddingFunction.__call__ to have the following signature: odict_keys(['self', 'input']), got odict_keys(['args', 'kwargs']), Can you explain why i am getting this error.
Robust Text-to-SQL With LangChain: Claude 3 vs GPT-4
19:40
Rabbitmetrics
Рет қаралды 2,3 М.
What is LangChain?
8:08
IBM Technology
Рет қаралды 130 М.
Joven bailarín noquea a ladrón de un golpe #nmas #shorts
00:17
OMG 😨 Era o tênis dela 🤬
00:19
Polar em português
Рет қаралды 11 МЛН
CAN YOU HELP ME? (ROAD TO 100 MLN!) #shorts
00:26
PANDA BOI
Рет қаралды 36 МЛН
КАРМАНЧИК 2 СЕЗОН 6 СЕРИЯ
21:57
Inter Production
Рет қаралды 411 М.
OpenAI Embeddings and Vector Databases Crash Course
18:41
Adrian Twarog
Рет қаралды 383 М.
Chat with MySQL Database with Python | LangChain Tutorial
37:11
Alejandro AO - Software & Ai
Рет қаралды 29 М.
LangChain Explained in 13 Minutes | QuickStart Tutorial for Beginners
12:44
Chat with SQL and Tabular Databases using LLM Agents (DON'T USE RAG!)
58:54
Gen AI Course | Gen AI Tutorial For Beginners
3:19:26
codebasics
Рет қаралды 122 М.
Joven bailarín noquea a ladrón de un golpe #nmas #shorts
00:17