Robust Text-to-SQL With LangChain: Claude 3 vs GPT-4

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.ค. 2024
  • Generate advanced SQL with LLMs in seconds by building custom LangChain chains.
    The code used in the video can be found here:
    www.rabbitmetrics.com/chattin...
    ▬▬▬▬▬▬ V I D E O C H A P T E R S & T I M E S T A M P S ▬▬▬▬▬▬
    0:00 The state of Chat-to-SQL
    1:22 Connecting to a database (BigQuery) with LangChain
    4:10 Using out-of-the-box SQL chains
    6:42 Using out-of-the-box SQL agents
    10:10 Managing Chat-to-SQL risk
    13:02 Creating your own custom SQL chains
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 14

  • @Shai_Di
    @Shai_Di หลายเดือนก่อน +1

    This is really interesting but I have some concerns about this method, I'd love to hear what you think about them:
    1. We are always sending the entire schema as context. If we want to have a large dataset connected to this "application", we will waste a ton of tokens on that. The agent that LangChain built slowly decides which tables might be relevant, thus reducing the amount of tokens used as context. How would you approach something like this?
    2. Sometimes, tables and column names might not be super intuitive to the LLM, and without sampling the data, it can assume properties, values or anything else. So this requires the user to review the query and make sure it makes sense, which is what we are kind of trying to prevent when we start using AI for queries. What do you think about adding a semi step that will somehow sample the relevant data?

  • @kelvinadungosi1579
    @kelvinadungosi1579 2 หลายเดือนก่อน

    Hi, great tutorial! How would you implement a chat fuctionality? where you can ask follow up questions??

    • @rabbitmetrics
      @rabbitmetrics  2 หลายเดือนก่อน

      Thanks! I would use ChatMessageHistory to manage the conversation and catch the traceback - this is needed for more advanced queries.

  • @AndresAlarcon-bb9ql
    @AndresAlarcon-bb9ql 3 หลายเดือนก่อน

    Hi, question, how do you configure it to use gemini-pro and not gpt-4?

    • @rabbitmetrics
      @rabbitmetrics  3 หลายเดือนก่อน

      Hi, you install the LangChain integrations for Gemini pypi.org/project/langchain-google-genai/ then you import ChatGoogleGenerativeAI and define llm = ChatGoogleGenerativeAI(model="gemini-pro")

    • @AndresAlarcon-bb9ql
      @AndresAlarcon-bb9ql 3 หลายเดือนก่อน

      @@rabbitmetrics I did it, but it doesn't work, it has this error:
      TypeError: Expected a Runnable, callable or dict. Instead got an unsupported type:

    • @rabbitmetrics
      @rabbitmetrics  3 หลายเดือนก่อน

      @@AndresAlarcon-bb9ql you might be passing a string instead of a function in the RunnablePassthrough?

  • @TheBestgoku
    @TheBestgoku 3 หลายเดือนก่อน

    THIS is function-calling but instead of a "json" u get a "sql query". Am i missing something?

    • @rabbitmetrics
      @rabbitmetrics  3 หลายเดือนก่อน +1

      That is one way to think of it. But in this case LangChain is handling the parsing of the LLM output (note the "model.bind(stop=["
      SQLResult:"])" in the chain). When you generate SQL or any other code you'll find that the code is often returned in quotes or with some text explaining the code. The trick is to minimize this by parsing the output in a suitable way.

  • @lionhuang9209
    @lionhuang9209 3 หลายเดือนก่อน +1

    Where can we download the code file?

    • @rabbitmetrics
      @rabbitmetrics  3 หลายเดือนก่อน

      There's a link below the video to the Colab notebook with code and written tutorial including how to generate the ecom tables

  • @SR-zi1pw
    @SR-zi1pw 3 หลายเดือนก่อน

    What happens if he drops the table when hallucinating

    • @MaxwellHay
      @MaxwellHay 3 หลายเดือนก่อน +2

      Read only role

    • @rabbitmetrics
      @rabbitmetrics  2 หลายเดือนก่อน

      As mentioned, make sure to restrict access scope and permission.