Live data from Hacker News

DSPy: Framework for programming with foundation models

github.com

31–40 of 56 posts

Re: DSPy: Framework for programming with foundation models

#31

This is really cool! It took me a bit to understand what this thing is for so allow me to summarize: For simple LLM tasks, don't bother using this tool. It won't do much for you. If you have a more complicated task (eg. knowledge database lookups, chain of thought reasoning, multi-hop lookups...) then DSPy offers 2 things: a clean class-based representation of your workflow, and a way to *solve* for the best prompt s…

I really want to understand that second part! I think that's the part I haven't been able to get my head around yet.

Re: DSPy: Framework for programming with foundation models

#32
post #31

This is really cool! It took me a bit to understand what this thing is for so allow me to summarize: For simple LLM tasks, don't bother using this tool. It won't do much for you. If you have a more complicated task (eg. knowledge database lookups, chain of thought reasoning, multi-hop lookups...) then DSPy offers 2 things: a clean class-based representation of your workflow, and a way to *solve* for the best prompt s…

I really want to understand that second part! I think that's the part I haven't been able to get my head around yet.

Here's the key idea.

You give DSPy (1) your free-form code with declarative calls to LMs, (2) a few inputs [labels optional], and (3) some validation metric [e.g., sanity checks].

It simulates your code on the inputs. When there's an LM call, it will make one or more simple zero-shot calls that respect your declarative signature. Think of this like a more general form of "function calling" if you will. It's just trying out things to see what passes your validation logic, but it's a highly-constrained search process.

The constraints enforced by the signature (per LM call) and the validation metric allow the compiler [with some metaprogramming tricks] to gather "good" and "bad" examples of execution for every step in which your code calls an LM. Even if you have no labels for it, because you're just exploring different pipelines. (Who has time to label each step?)

For now, we throw away the bad examples. The good examples become potential demonstrations. The compiler can now do an optimization process to find the best combination of these automatically bootstrapped demonstrations in the prompts. Maybe the best on average, maybe (in principle) the predicted best for a specific input. There's no magic here, it's just optimizing your metric.

The same bootstrapping logic lends itself (with more internal metaprogramming tricks, which you don't need to worry about) to finetuning models for your LM calls, instead of prompting.

In practice, this works really well because even tiny LMs can do powerful things when they see a few well-selected examples.

Re: DSPy: Framework for programming with foundation models

#33
post #9

Earlier quoted context omitted.

I agree with you on all of those points - but my conclusion is different: those are the reasons it's so important to me that the prompts are not abstracted away from me! I'm working with Llama 2 a bunch at the moment and much of the challenge is learning how to prompt it differently from how I prompt GPT-4. I'm not yet convinced that an abstraction will solve that problem for me.

this is one of the reasons why Langchain sucks. People seem to underestimate and overlook the importance of prompts.

> People seem to underestimate and overlook the importance of prompts.

We do this to each other as well. Being able to communicate clear, concise, and complete requests will produce better results with both humans and LLMs. What is interesting is that we can experiment with prompts against machines at a scale we cannot with other people. I'd really like to see more work towards leveraging this feature to improve our human interactions, kind of like empathy training in VR

Re: DSPy: Framework for programming with foundation models

#34

This is really cool! It took me a bit to understand what this thing is for so allow me to summarize: For simple LLM tasks, don't bother using this tool. It won't do much for you. If you have a more complicated task (eg. knowledge database lookups, chain of thought reasoning, multi-hop lookups...) then DSPy offers 2 things: a clean class-based representation of your workflow, and a way to *solve* for the best prompt s…

Did you actually try it and find it useful or are you just speculating?

I was not particularly impressed by the tutorial notebook. I’m not sure I believe that automatic prompt generation is nearly as easy as it sounds.

What task did you try it on?

Re: DSPy: Framework for programming with foundation models

#35
post #16
post #11

Earlier quoted context omitted.

@simonw it sounds like we'd agree that: 1] when prototyping, it's useful to not have to tweak each prompt by hand as long as you can inspect them easily 2] when the system design is "final", it's important to be able to tweak any prompts or finetunes with full flexibility But we may or may not agree on: 3] automatic optimization can basically make #2 above only very rarely needed --- Anyway, the entire DSPy project h…

It sounds fascinating! Is there anything one could read to figure out more about how this is being done (From reading the docs by the "Teleprompter"s right)?

Posted an answer here: https://news.ycombinator.com/item?id=37420175

Re: DSPy: Framework for programming with foundation models

#36

This is really cool! It took me a bit to understand what this thing is for so allow me to summarize: For simple LLM tasks, don't bother using this tool. It won't do much for you. If you have a more complicated task (eg. knowledge database lookups, chain of thought reasoning, multi-hop lookups...) then DSPy offers 2 things: a clean class-based representation of your workflow, and a way to *solve* for the best prompt s…

Did you actually try it and find it useful or are you just speculating? I was not particularly impressed by the tutorial notebook. I’m not sure I believe that automatic prompt generation is nearly as easy as it sounds. What task did you try it on?

What did you find underwhelming if I may ask?

It shows you how it takes some ~25 Pythonic lines of code to make GPT-3.5 retrieval accuracy go from the 26-36% range to 60%.

Not a bad deal when you apply it to your own problem?

Re: DSPy: Framework for programming with foundation models

#37
post #36

Earlier quoted context omitted.

Did you actually try it and find it useful or are you just speculating? I was not particularly impressed by the tutorial notebook. I’m not sure I believe that automatic prompt generation is nearly as easy as it sounds. What task did you try it on?

What did you find underwhelming if I may ask? It shows you how it takes some ~25 Pythonic lines of code to make GPT-3.5 retrieval accuracy go from the 26-36% range to 60%. Not a bad deal when you apply it to your own problem?

The examples appear to knowledge retrieval and factoids only.

The concept appears to be large scale chain of thought and automatic prompt generate and fine tuning… but there don’t appear to be actual examples of this.

Re: DSPy: Framework for programming with foundation models

#38
post #36

Earlier quoted context omitted.

What did you find underwhelming if I may ask? It shows you how it takes some ~25 Pythonic lines of code to make GPT-3.5 retrieval accuracy go from the 26-36% range to 60%. Not a bad deal when you apply it to your own problem?

The examples appear to knowledge retrieval and factoids only. The concept appears to be large scale chain of thought and automatic prompt generate and fine tuning… but there don’t appear to be actual examples of this.

Ah okay makes sense, yeah we'll release more examples.

This is just an intro to the key concepts/modules.

Re: DSPy: Framework for programming with foundation models

#39
post #38

Earlier quoted context omitted.

The examples appear to knowledge retrieval and factoids only. The concept appears to be large scale chain of thought and automatic prompt generate and fine tuning… but there don’t appear to be actual examples of this.

Ah okay makes sense, yeah we'll release more examples. This is just an intro to the key concepts/modules.

The problem is, there is a big song and dance about string template prompts.

…but, carefully crafted string templates would be a) simpler and b) arguably better with existing solutions for this task, because it’s a trivial task and you can hand massage your string template prompts for that.

So, the narrative really doesn’t make sense, unless you’re doing something hard, but the example just shows doing something easy in a very complicated way.

I get it, maybe you can scale this up better… but you’re really not showing it off well.

Re: DSPy: Framework for programming with foundation models

#40
post #38

Earlier quoted context omitted.

The examples appear to knowledge retrieval and factoids only. The concept appears to be large scale chain of thought and automatic prompt generate and fine tuning… but there don’t appear to be actual examples of this.

Ah okay makes sense, yeah we'll release more examples. This is just an intro to the key concepts/modules.

[deleted]
Post reply on HN