Skip to main content

An optimizer for genAI workflows

Project description

Cognify logo

Cognify: The Automated Gen-AI Workflow Optimizer

Building high-quality, cost-effective generative-AI (gen-AI) applications is challenging due to the absence of systematic methods for tuning, testing, and optimizing them. We introduce Cognify, a tool that automatically enhances generation quality and reduces costs for gen-AI workflows, including those written with LangChain, DSPy, and annotated Python. Built on a novel foundation of hierarchical, workflow-level optimization, Cognify improves gen-AI workflow generation quality by up to 48% and reduces their execution cost by up to 9 times. Read more about Cognify here.

Installation

Cognify is available as a Python package and can be installed as

pip install cognify-ai

Or install from the source:

git clone https://github.com/GenseeAI/cognify
cd cognify
pip install -e .

Getting Started

You can use Cognify with our simple CLI:

cognify optimize /your/gen/ai/workflow.py   

where workflow.py is your workflow source code. Cognify currently supports unmodified LangChain and DSPy workflow source code. You can also port your existing workflow written directly on Python or develop new Python-based workflows with our simple workflow interface.

Cognify automatically searches for a config.py in the same folder as the workflow. You can also specify this file explicitly by:

cognify optimize /your/gen/ai/workflow.py -c /your/gen/ai/custom_config.py

Within the config.py, you should define the following:

  • Sample Dataset: Cognify relies on training data to evaluate and improve its workflow optimization. You should provide a data loader that loads your training dataset in the form of input-output pairs. Read more about how to load your data.
  • Evaluator: Cognify expects you to provide an evaluator for judging the final workflow generation's quality. To help you get started, Cognify provides several common evaluator implementations such as the F1 score. Find out more about workflow evaluator.
  • Optimization Configurations and Model Set Selection: Optionally, you can configure your optimization process in various ways. For example, you can choose between light, medium, or heavy search over the optimization space. We also provide a few domain-specific optimization configurations. You can also define the set of models you want Cognify to explore. If no configurations or models are provided, Cognify uses a default set of values. Read more about optimization configurations and model selections.

With these parameters, Cognify optimizes your workflow by iteratively experimenting with various combinations of tuning methods (we call them “cogs”) applied across workflow components and assessing the effectiveness of these combinations based on the quality of the final output using the user-provided sample dataset and evaluator. This process continues until Cognify hits the user-specified maximum iteration numbers (in cognify.py).

The result of this process is a set of optimized workflow versions with different quality-cost combinations on the Pareto frontier among all the iterations. You can inspect the optimizations applied in these output files You can evaluate these optimized versions with a test dataset:

cognify evaluate /your/gen/ai/workflow/optimization/output/path

You can also continue running Cognify with more iterations from these outputs using the -r or --resume flag:

cognify optimize /your/gen/ai/workflow.py -r

Follow our quickstart or read our full documentation to learn more.

Project details


Download files

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

Source Distribution

cognify_ai-0.1.0.tar.gz (99.1 kB view details)

Uploaded Source

Built Distribution

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

cognify_ai-0.1.0-py3-none-any.whl (123.1 kB view details)

Uploaded Python 3

File details

Details for the file cognify_ai-0.1.0.tar.gz.

File metadata

  • Download URL: cognify_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 99.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for cognify_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 04fc9f5ec598690a5e8e6469086a779a6d324d74247a74070e92e1510e5d95ba
MD5 8bcd4a4e017213ffae5f71a18583d771
BLAKE2b-256 ecda91d5787eb7fdf9f4149caeeaad015c4214f0f3c8753436830088299e96c1

See more details on using hashes here.

File details

Details for the file cognify_ai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cognify_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 123.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for cognify_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1c2c718d37df25d1d796a73479b87676143cf1ae57c72c080b62583e47856705
MD5 0e54c5d79d2a7570c80d60e62f049d0c
BLAKE2b-256 7bb9c2d1dd936793a532f7db80671871ecbabc37f69c431188f356c1c3f43a94

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