DSRs  by krypticmouse

High-performance Rust framework for building Language Model applications

Created 9 months ago
264 stars

Top 96.6% on SourcePulse

GitHubView on GitHub
Project Summary

DSRs (DSPy Rust) is a high-performance, ground-up rewrite of the DSPy framework in Rust, designed for building robust, efficient, and reliable Language Model (LM)-powered applications. It targets developers seeking a more performant and memory-safe foundation for their LLM projects, leveraging Rust's advanced features.

How It Works

DSRs utilizes Rust's strong type system, memory safety guarantees, and concurrency primitives to achieve superior performance and reliability compared to Python-based frameworks. Its architecture is modular, featuring core abstractions for LMs, Modules, and Signatures, alongside dedicated components for LM provider adapters, data structures, built-in predictors, an evaluation framework, and optimization tools. Signatures define clear input/output specifications, while Modules enable composable pipeline construction, and Predictors offer pre-built LM interaction patterns.

Quick Start & Requirements

  • Installation: Add dspy-rs to your Cargo.toml or use cargo add dsrs --package dspy-rs.
  • Prerequisites: Rust toolchain (version 1.70+ recommended). OpenAI API key is automatically read from the OPENAI_API_KEY environment variable for default configurations. Local models (e.g., vLLM, Ollama) require separate setup.
  • Links: Documentation, API Reference, Examples, Issues, Discord.

Highlighted Details

  • Advanced Optimizers: Includes COPRO (iterative prompt refinement), MIPROv2 (LLM-guided prompt generation), and GEPA (evolutionary search with textual feedback) for optimizing LM interactions.
  • Typed Data Loading: DataLoader provides typed loaders that ingest data directly into Example<S> structures, enforcing schema correctness.
  • Composable Modules: Supports building complex pipelines using Rust's module system and derive macros like facet::Facet.
  • Tracing System: Captures module dataflow as a Directed Acyclic Graph (DAG) for inspection, replay, and modification.
  • Chain of Thought (CoT) Reasoning: Built-in support for CoT patterns, automatically adding a reasoning field to predictions.

Maintenance & Community

DSRs is under active development with a stabilizing API. Contributions are welcomed via a dedicated Contributing Guide. Community support is available on Discord.

Licensing & Compatibility

This project is licensed under the Apache License 2.0, which is permissive for commercial use and integration into closed-source projects.

Limitations & Caveats

DSRs is currently in a Beta Release. While the API is stabilizing, users should anticipate potential breaking changes as development continues.

Health Check
Last Commit

3 days ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
2
Star History
19 stars in the last 30 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Georgios Konstantopoulos Georgios Konstantopoulos(CTO, General Partner at Paradigm), and
1 more.

rig by 0xPlaygrounds

1.2%
7k
Rust library for building LLM-powered applications
Created 1 year ago
Updated 1 day ago
Feedback? Help us improve.