Skip to main content

Learning algorithms for production language model programs

Project description

Apropos

Learning algorithms for production language model programs.

Spinning Up - Usage

Get started by running pip install apropos-ai

Hello World

To get started with simple bootstrapped fewshot random search on the Hendryks Math benchmark, run:

python examples/hello_world.py

Custom Dataset + Prompt

To get started with a custom dataset and/or language model program, if your program happens to be a single-prompt program, we have a simple demo here

Simply replace

messages_examples, gold_outputs, custom_math_metric = (
      get_hendryks_messages_and_gold_outputs()
)

with your own data (in the form of system/user prompt pairs and possibly gold outputs) and a metric of your choosing. Then, run away!

Nota Bene: the logic involved in converting this data to the appropriate DAG / benchmark is very new and experimental, please file an issue if you run into any trouble.

Spinning Up - Dev

1. UV

uv venv apropos-dev source apropos-dev/bin/activate

1. Pyenv

/bash
pyenv install 3.11.0
pyenv virtualenv 3.11.0 apropos-dev
pyenv activate apropos-dev

2. Poetry

/bash
curl -sSL https://install.python-poetry.org | python3 -
poetry install

Usage

If you use the following idea(s):

  • Optimizing over variations of specific substrings within a prompt

please cite this repo and forthcoming paper when released

If you use the MIPROv2 optimizer in your academic work, please cite the following paper:

@misc{opsahlong2024optimizinginstructionsdemonstrationsmultistage,
      title={Optimizing Instructions and Demonstrations for Multi-Stage Language Model Programs}, 
      author={Krista Opsahl-Ong and Michael J Ryan and Josh Purtell and David Broman and Christopher Potts and Matei Zaharia and Omar Khattab},
      year={2024},
      eprint={2406.11695},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2406.11695}, 
}

Moreover, if you find the notion of learning from bootstrapped demonstrations useful, or have used algorithms such as the breadth-first random search optimizer, consider citing the following paper

@misc{khattab2023dspycompilingdeclarativelanguage,
      title={DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines}, 
      author={Omar Khattab and Arnav Singhvi and Paridhi Maheshwari and Zhiyuan Zhang and Keshav Santhanam and Sri Vardhamanan and Saiful Haq and Ashutosh Sharma and Thomas T. Joshi and Hanna Moazam and Heather Miller and Matei Zaharia and Christopher Potts},
      year={2023},
      eprint={2310.03714},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2310.03714}, 
}

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apropos_ai-0.1.8.tar.gz (2.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apropos_ai-0.1.8-py3-none-any.whl (2.5 MB view details)

Uploaded Python 3

File details

Details for the file apropos_ai-0.1.8.tar.gz.

File metadata

  • Download URL: apropos_ai-0.1.8.tar.gz
  • Upload date:
  • Size: 2.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for apropos_ai-0.1.8.tar.gz
Algorithm Hash digest
SHA256 c90db5e2820d248c0d69948ea37fbc1f573b99ce3fd367c7dd5f1b5faf79d1f8
MD5 14ec8e512da943d6a11a2f9bbaf22848
BLAKE2b-256 8636b9ffc3ae605be89789b4b498084591ca53483f71d1e81a536259c3fd88e5

See more details on using hashes here.

File details

Details for the file apropos_ai-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: apropos_ai-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for apropos_ai-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 44977b99b65503b943552422938f59630d9669c42d67e85e5af0475046020293
MD5 16a47c9342c1b21d43508e55e85d3690
BLAKE2b-256 4fbf052d6106749ef2b38d7b9c8391051bc8c9c2680af3ee7c7dbf98a1bb9f61

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page