AI and Deep Learning Community Question

Can DSPy be used with non-OpenAI models like Anthropic or local LLMs?

Posted on 2025-03-12 • In AI and Deep Learning • By Steven Grant

I love the concept of DSPy, but my company is moving away from OpenAI due to data privacy concerns. Does the framework play well with Anthropic Claude or local deployments via vLLM? I want to make sure my "compiled" prompts aren't just optimized for one specific provider's quirks.

3 Answers 11,551 Views

All answers to this question 3 Answers

Rachel Foster Answered on 2025-04-20
Answered

This is actually where DSPy shines the most. Because the prompts are generated by the compiler rather than being hard-coded by you, the framework is naturally model-agnostic. You can define your program logic once and then compile it for Claude 3.5 Sonnet, and then re-compile it for a local Llama 3 instance. The compiler will pick different few-shot examples and different phrasing that work best for each specific model's architecture. We are currently running a hybrid setup where we use DSPy to optimize our local models to perform nearly as well as the top-tier cloud models for our specific summarization tasks.

Jeffrey Reed Answered on 2025-04-25
Answered

When you re-compile for a smaller local model in DSPy, do you find that the instructions become much longer to compensate for the lower reasoning capability?

Kevin Parker Commented on 2025-04-28
Commented

Often, yes! The optimizer might realize that the smaller model needs more explicit, step-by-step guidance or more diverse examples to reach the same conclusion. That’s the beauty of DSPy—it does that tedious trial-and-error for you. You just provide the metric and the data, and the framework figures out the best way to talk to that specific model.

Melissa Gardner Answered on 2025-05-05
Answered

It works great with vLLM for high-throughput serving. The separation of the "program" from the "parameters" makes it easy to swap backends in seconds.

Rachel Foster Commented on 2025-05-07
Commented

That flexibility is key for enterprise. Not being locked into one API vendor gives you so much more leverage when it comes to cost and privacy.

Write a Comment

Your email address will not be published. Required fields are marked (*)

Join the LearnersEra Community

Ask questions, share knowledge and learn from professionals across technology, project management and certification topics.

Change Country and Nearest City

Select your country and nearest city to see courses available in your region.