Complete DSPy Tutorial - Master LLM Prompt Programming in 8 amazing examples!

Поделиться
HTML-код
  • Опубликовано: 25 ноя 2024

Комментарии • 73

  • @avb_fj
    @avb_fj  2 месяца назад +2

    If you found DSPy useful, check out this TextGrad tutorial: ruclips.net/video/6pyYc8Upl-0/видео.html.
    TextGrad is another awesome LLM Prompt Optimization library that also tries to reduce prompt engineering in favor of a more programmatic approach.

  • @fojo_reviews
    @fojo_reviews 3 месяца назад +19

    I kinda feel guilty that I am seeing such content without paying anything! This is gold...Thank you!

    • @avb_fj
      @avb_fj  3 месяца назад

      Thanks!

    • @caseyhoward8261
      @caseyhoward8261 3 месяца назад +1

      You could always donate to his channel 😉

    • @zes7215
      @zes7215 Месяц назад

      wrr

  • @JimMendenhall
    @JimMendenhall 3 месяца назад +8

    This is the only video or resource I've seen on DSPy that makes ANY sense. Great job!

  • @spookymv
    @spookymv 3 месяца назад +7

    Thanks to you, my friend, I learned what I haven't understood for days. I insistently want to learn dspy, but I didn't understand it.
    Thanks a lot.

    • @avb_fj
      @avb_fj  3 месяца назад +1

      Glad to hear that! Your insistence has paid off! Good luck with your DSPy journey!

    • @gaims1
      @gaims1 2 месяца назад

      Same here, learnt what I couldn't from my other attempts

  • @AyanKhan-dc3eu
    @AyanKhan-dc3eu 3 месяца назад +1

    When this module came out the docs were very confusing. thank you for such a great explanation

  • @erfanrezaei7791
    @erfanrezaei7791 14 дней назад

    Very good and clear explanation, thanks buddy👌

  • @trashchenkov
    @trashchenkov 3 месяца назад +1

    thanks for the video! It will be great to see how to use DSPy for agents.

  • @arirajuh
    @arirajuh 2 месяца назад

    Thank you for sharing step by step tutorial, i tried dspy with local Ollama, with Llama 3.1, the Chain of thought provided an different answer, i have shared the result, [ I don't know anything about football.]
    Reasoning: Let's think step by step in order to answer this question. First, we need to identify the team that won the World Cup in 2014. The winner of the tournament was Germany. Next, we should find out who scored the final goal for Germany. It was Mario Götze who scored the winning goal against Argentina. To determine who provided the assist, we can look at the details of the game and see that Toni Kroos made a long pass to André Schürrle, who then crossed the ball to Götze.

    • @avb_fj
      @avb_fj  2 месяца назад

      Yes the results will vary depending on the underlying LLM and the specific instructions as well.

  • @jeffrey5602
    @jeffrey5602 3 месяца назад +1

    As a German I enjoyed the chosen example a lot 😄

    • @avb_fj
      @avb_fj  3 месяца назад

      😂

  • @MrMoonsilver
    @MrMoonsilver 3 месяца назад +1

    Yes boss! Subscribed! Great video and very much untapped territory, the only well made tutorial for dspy!

    • @avb_fj
      @avb_fj  3 месяца назад

      Thanks!

  • @thareejanp3933
    @thareejanp3933 2 месяца назад

    Wonderful content and Presentation loved the way you explained . Keep it up

  • @mazsorosh
    @mazsorosh 2 месяца назад

    I love the contents and presentations in this video! Keep it up!💙

    • @avb_fj
      @avb_fj  2 месяца назад

      😇

  • @shoaibsh2872
    @shoaibsh2872 3 месяца назад +1

    Great video man, also loved the one piece T-shirt ;)

    • @avb_fj
      @avb_fj  3 месяца назад

      Thanks for noticing!

  • @GagandeepBhattacharya22
    @GagandeepBhattacharya22 2 месяца назад

    I love the content & found it really useful. Thank You!
    I have only 1 suggestion for you, "ZOOM IN" the code section as it's really difficult to see the code.

    • @avb_fj
      @avb_fj  2 месяца назад

      Thanks for the suggestion! Will keep it in mind next time.

  • @krlospatrick
    @krlospatrick 3 месяца назад

    Thanks for sharing this amazing tutorial

  • @tedhand6237
    @tedhand6237 8 дней назад

    I've been impressed with the ability of LLMs to summarize academic research but also getting really frustrated with the limits and hallucinations. I wonder if programming my own LLM is the answer.

  • @security_threat
    @security_threat 14 дней назад

    Thanks!

  • @vaioslaschos
    @vaioslaschos 2 месяца назад

    Really nice content. I liked and subscribed :-). Is there something that can be done easily with DSPy that cant be done with langchain?

  • @ashadqureshi4412
    @ashadqureshi4412 3 месяца назад +1

    Thanks man!!!

  • @ritikatanwar3013
    @ritikatanwar3013 17 дней назад

    Thank you for making this video. This has been a great hands-on experience learning DSPy..
    What are your thoughts on this - For building AI Agents or having more robust prompt programming, what other framework can be used?

    • @avb_fj
      @avb_fj  13 дней назад +1

      My current go-to framework is definitely DSPy, although they do have their fair share of issues (like no async programming support, continuous changes, etc). There are a bunch of frameworks that try to do prompt tuning - I have played around with TextGrad, which uses feedback loops to improve LLM generated content/prompts. Many people swear by Langchain, although I personally haven't used it much. Langfuse is a good tool for maintaining prompts, and tracking usage/sessions etc - unnecessary for small scale apps. I have also used litellm, which is a good solution for load-balancing if you are using multiple different LLM providers in your application.
      It might sound funny but the most useful framework I have used for prompting is good old function composition in Python with some Jinja2 templating. :)

  • @zappist751
    @zappist751 2 месяца назад

    GOAT

  • @daniloMgiomo
    @daniloMgiomo 3 месяца назад

    Awesome content, u can please try some text-grad? The Stanford guys release a paper about this in July

    • @avb_fj
      @avb_fj  3 месяца назад

      Thanks for the suggestion! Sounds like a good idea for a future video.

  • @shinigamiryuk4183
    @shinigamiryuk4183 2 месяца назад

    Pretty Nice explanation

    • @avb_fj
      @avb_fj  2 месяца назад

      Nice username 🍎

  • @haralc6196
    @haralc6196 3 месяца назад

    Thanks!

  • @vineetsuvarna8185
    @vineetsuvarna8185 3 месяца назад

    Awsome ! Please can you share the collab link of the examples shown in video

  • @prashlovessamosa
    @prashlovessamosa 3 месяца назад +1

    Excellent 👌

  • @lakshaynz
    @lakshaynz 3 месяца назад

    Thank you:)

  • @aillminsimplelanguage
    @aillminsimplelanguage 2 месяца назад

    Great video! Can you also please share the notebook with this code. This would help us in doing hands-on ourselves. Thanks!

    • @avb_fj
      @avb_fj  2 месяца назад

      Thanks! As mentioned in the video, currently all the code produced in the channel is for Patreon/Channel members.

  • @boaz9798
    @boaz9798 3 месяца назад +1

    Excellent video. Thank you. Can I grab the resulting prompt? I know it is supposedly a new paradigm which abstracts it away, but some may still want to revert back to using a simple prompt in prod. post optimization

    • @avb_fj
      @avb_fj  3 месяца назад

      Yes you can use the inspect_history() function as shown in the video (around 4:30) to check out all the previous prompts ran by a module.

  • @VedantiSaxena
    @VedantiSaxena 2 месяца назад +1

    Hi! I am trying to use the LLM (Mistral-Nemo) for sentiment analysis. The issue I'm facing is that for the same input text, it returns different responses. Sometimes it identifies the sentiment as positive, and other times as negative. I have set the temperature to 0, but this hasn’t resolved the problem. Can using DsPy help solve this inconsistency, or is there another solution?
    Also , great video with precise and crisp explanation ! kuddos 👏

    • @avb_fj
      @avb_fj  2 месяца назад

      That’s indeed strange. Setting the temp to zero and keeping the entire prompt same generally return the same output coz the LLM chooses next tokens greedily. When I say “entire prompt” it includes the prompt as well as the input question. I don’t know the implementation details in Mistral Nemo, but if they still sample tokens with t=0 during decoding then I’m afraid we can’t do much to make it deterministic. Again, I am not aware. You may want to test with other LLMs once.
      DSPy might help, you could try it. Note that DSPy by default caches the results of past prompts in the session, basically reusing the cached outputs when the same prompt is re-ran. This means to test the consistency correctly, you must first set the caching off. (Control F “cache” here: dspy-docs.vercel.app/docs/faqs)

    • @VedantiSaxena
      @VedantiSaxena 2 месяца назад

      @@avb_fj I guess , trying Dspy through Fewshot might help with the consistent result . Thank you so much though!

  • @Anonymous-lw1zy
    @Anonymous-lw1zy 3 месяца назад +2

    Great video.
    However , dspy seems to be very fragile; it breaks easily.
    e.g. at 11:00 you ask ""What is the capital of the birth state of the person who provided the assist for Mario Gotze's in the football World Cup finals in 2014?"" and it answers 'Mainz', which you said is correct.
    But if I make the question slightly different by adding "goal" after "Gotze's", so the question is now ""What is the capital of the birth state of the person who provided the assist for Mario Gotze's goal in the football World Cup finals in 2014?"", it answers "Research".

    • @avb_fj
      @avb_fj  3 месяца назад +1

      In general it’s the underlying LLM that could be “fragile”. Remember that DSPy is just converting your program into a prompt and sending to the LLM. The LLM generates the answer which depends on input prompts and temperature settings. Either way, as long as the concepts make sense, don’t worry about replicating the test cases shown in the video!

    • @RazorCXTechnologies
      @RazorCXTechnologies 3 месяца назад +1

      @@avb_fj I tested your exact code with and without the "goal". It responded correctly for both prompts using a local Ollama model: gemma2:27b. DSPy seems to work well with local models that are >20B parameters. Smaller local models especially Mistral-Nemo:12b work in some cases but tend to fail with multi-step (ChainOfThought) modules.

  • @ProgrammerRajaa
    @ProgrammerRajaa 3 месяца назад

    Greate explanation.
    can i have link for the Notebook that you have show on the video

    • @avb_fj
      @avb_fj  3 месяца назад

      As I mentioned in the video and on the description, the code is currently members/patrons only.

  • @haralc
    @haralc 3 месяца назад

    I just tried it. However it failed on the first try of the "basic" stuff. With GPT4, the BasicQA keep returning "Question: .. Answer: ..." , but I only need the answer itself, not the whole "Quesion: ... Answer: ..." .... So, which part I don't have to worry about the prompting part?

  • @artmusic6937
    @artmusic6937 3 месяца назад

    if the 60m parameter model does 50% accuracy, how can you improve this without using a bigger model? Because if you use a bigger model, then it actually just memorizes the data better. So it is basically overfitting, isn't it?

  • @Anonymous-lw1zy
    @Anonymous-lw1zy 3 месяца назад

    Also at 12:42 I am getting:
    answer='Mario Götze' confidence=0.9
    not Andre Schurrle
    I quadruple-checked that my code is the same as yours.

  • @Karan-Tak
    @Karan-Tak Месяц назад

    Can we get Optimized Prompt using DSPy as we get using TextGrad? If yes How can we do it?

    • @avb_fj
      @avb_fj  Месяц назад

      I believe so. It's on my bucket list of things to try out one day. Look into this page: dspy-docs.vercel.app/docs/building-blocks/optimizers
      and look for COPRO and MIPROV2 optimizers.

  • @JeevaPadmanaban
    @JeevaPadmanaban 3 месяца назад

    i have a question can i use any other models other than openai? im running my own models in deepinfra.

    • @avb_fj
      @avb_fj  3 месяца назад +1

      Haven't tested this myself, but I assume that you can call deepinfra models using OpenAI apis by changing the base_url parameter.
      deepinfra.com/docs/openai_api

    • @JeevaPadmanaban
      @JeevaPadmanaban 3 месяца назад

      @@avb_fj Thanks man ✨

    • @JeevaPadmanaban
      @JeevaPadmanaban 3 месяца назад

      @@avb_fj also another doubt can i use another vector db's like astra db into rag
      Thanks.

    • @avb_fj
      @avb_fj  3 месяца назад +1

      @@JeevaPadmanaban check out the supported ones here:
      dspy-docs.vercel.app/docs/category/retrieval-model-clients

  • @leeharrold98
    @leeharrold98 Месяц назад

    Champ

  • @AbhijeetSingh-lf3uu
    @AbhijeetSingh-lf3uu 2 месяца назад

    you didn't show us the goal :(

    • @avb_fj
      @avb_fj  2 месяца назад

      Haha so I had a 5-second clip before, but FIFA copyrighted it so had to remove it.

    • @AbhijeetSingh-lf3uu
      @AbhijeetSingh-lf3uu 2 месяца назад

      @@avb_fj ah no worries, but thanks so much for teaching us I really appreciate it.

  • @xtema1624
    @xtema1624 3 месяца назад

    Plz share the colab in this video, not dspy example.

  • @haralc
    @haralc 3 месяца назад

    Btw, I'm not a football fan, and although you mentioned in the note that it is okay .... no, it's really not ... even when I watched this video a few times, who did what still doesn't register in my brain...

    • @avb_fj
      @avb_fj  3 месяца назад

      Fair criticism. I regretted using these examples soon after shooting the video. Future tutorials won’t have examples like these.

  • @h3xkore
    @h3xkore 3 месяца назад

    was hoping to make the prompts autonomized. i feel like you still need to understand prompting well before you can use this :(

  • @orthodox_gentleman
    @orthodox_gentleman 3 месяца назад

    You do realize that GPT 3.5 Turbo was deprecated aka it no longer exists.

    • @avb_fj
      @avb_fj  3 месяца назад +1

      Thanks for your comment. The DSPy documentation and official tutorial still uses it (links below), and it worked out for the examples I was going for in the tutorial. Whether the particular LM is deprecated or not is not important at all. You can replace it with whichever model you prefer… the concepts remain the same.
      dspy-docs.vercel.app/docs/tutorials/rag
      github.com/stanfordnlp/dspy/blob/main/intro.ipynb