coreason-optimizer
Project description
coreason-optimizer
Automated Prompt Engineering / LLM Compilation / DSPy Integration for CoReason-AI
coreason-optimizer is the "Compiler" for the CoReason Agentic Platform. It automates prompt engineering by treating prompts as trainable weights, optimizing them against ground-truth datasets to maximize performance metrics.
Installation
pip install coreason-optimizer
Features
- Automated Optimization: Rewrites instructions and selects examples to maximize a score, not human intuition.
- Model-Specific Compilation: Generates optimized prompts specifically tuned for target models (e.g., GPT-4, Claude 3.5).
- Continuous Learning: Re-runs optimization on recent logs to patch prompts against data drift.
- Mutate-Evaluate Loop: Systematic cycle of drafting, evaluating, diagnosing, mutating, and selecting prompts.
- Strategies: Includes BootstrapFewShot (mining successful traces) and MIPRO (Multi-prompt Instruction PRoposal Optimizer).
- Integration: Works seamlessly with
coreason-construct,coreason-archive, andcoreason-assay.
For full product requirements, see docs/product_requirements.md.
Usage
Here is how to initialize and use the library to compile an agent:
from coreason_optimizer import OptimizerConfig, PromptOptimizer
from coreason_optimizer.core.interfaces import Construct
from coreason_optimizer.data import Dataset
# 1. Configuration
config = OptimizerConfig(
target_model="gpt-4o",
metric="exact_match",
max_rounds=10
)
# 2. Load Data
dataset = Dataset.from_csv("data/gold_set.csv")
train_set, val_set = dataset.split(test_size=0.2)
# 3. Load Agent (Construct)
# In a real scenario, this would be imported from your agent code
# from src.agents.analyst import analyst_agent
class MockAgent(Construct):
inputs = ["question"]
outputs = ["answer"]
system_prompt = "You are a helpful assistant."
agent = MockAgent()
# 4. Compile
optimizer = PromptOptimizer(config=config)
optimized_manifest = optimizer.compile(
agent=agent,
trainset=train_set,
valset=val_set
)
print(f"Optimization complete. New Score: {optimized_manifest.performance_metric}")
print(f"Optimized Instruction: {optimized_manifest.optimized_instruction}")
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file coreason_optimizer-0.2.1.tar.gz.
File metadata
- Download URL: coreason_optimizer-0.2.1.tar.gz
- Upload date:
- Size: 25.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c53db14e5c51987684384bfeeec953eb1569d311272a99926e3085a7bc21a0d
|
|
| MD5 |
e87b482cbff02e3588d5c942340c2073
|
|
| BLAKE2b-256 |
33565b5a8588f0213647d0546f39dd66f5967d6191623fed6e8fc1ae03359164
|
Provenance
The following attestation bundles were made for coreason_optimizer-0.2.1.tar.gz:
Publisher:
publish.yml on CoReason-AI/coreason-optimizer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coreason_optimizer-0.2.1.tar.gz -
Subject digest:
1c53db14e5c51987684384bfeeec953eb1569d311272a99926e3085a7bc21a0d - Sigstore transparency entry: 869338412
- Sigstore integration time:
-
Permalink:
CoReason-AI/coreason-optimizer@bf8903c21058c440d797ab6933684a307a7f1155 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/CoReason-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bf8903c21058c440d797ab6933684a307a7f1155 -
Trigger Event:
release
-
Statement type:
File details
Details for the file coreason_optimizer-0.2.1-py3-none-any.whl.
File metadata
- Download URL: coreason_optimizer-0.2.1-py3-none-any.whl
- Upload date:
- Size: 38.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
253885a10afd628b535ace7692841b65c585e465068cd9117226dd785a51c143
|
|
| MD5 |
a0c534b558be17ddc03ccb2fca8099f7
|
|
| BLAKE2b-256 |
b4807c0b2d9333aaa1ffcc9e4181e5ff75973040ccef729efc4c365ec756b9cc
|
Provenance
The following attestation bundles were made for coreason_optimizer-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on CoReason-AI/coreason-optimizer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coreason_optimizer-0.2.1-py3-none-any.whl -
Subject digest:
253885a10afd628b535ace7692841b65c585e465068cd9117226dd785a51c143 - Sigstore transparency entry: 869338413
- Sigstore integration time:
-
Permalink:
CoReason-AI/coreason-optimizer@bf8903c21058c440d797ab6933684a307a7f1155 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/CoReason-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bf8903c21058c440d797ab6933684a307a7f1155 -
Trigger Event:
release
-
Statement type: