Skip to main content

Recursive prompt improvement — VSR loop with linguistic gate (ri-engine CLI)

Project description

Recursive Intelligence Engine

Open-source recursive prompt improvement — Variation → Selection → Retention (VSR), with an experimental linguistic gate.

CI License: MIT Python 3.10+ PyPI

Give a seed prompt and a goal. The engine runs an offline VSR loop (no API key by default), resolves register leanings (plain, latinate, mixed, …), and returns an improved prompt.

pip install recursive-intelligence
ri-engine improve \
  --seed "You are a helper." \
  --goal "When this works, the AI will produce a structured answer with measurable success criteria"

Open in GitHub Codespaces Open In Colab


Overview

Package recursive-intelligence
CLI ri-engine
Python API from ri_engine import improve
Default provider Mock (deterministic, offline)
License MIT

Research inspiration: Raymond Uzwyshyn Ph.D. — agentic AI, recursion, and selection environments. See CREDITS.md and docs/research_and_citations.md.


Features

  • VSR loop — generate variants, score fitness, retain winners, repeat until convergence
  • Linguistic gate (experimental) — weighted register prior; ablation modes via CLI
  • Baseline comparison — VSR output vs one-shot finalize; returns simpler result when VSR does not win
  • Objective alignment scoring — rubric weights goal fit over structural bloat
  • Template fixtures — optional benchmark configs; primary path is --seed + --goal
  • Local ablationexperiments/run_gate_ablation.py (no API key)

Installation

pip install recursive-intelligence

# Optional real LLM backends:
pip install "recursive-intelligence[all]"

From source:

git clone https://github.com/russfranky/recursive-intelligence.git
cd recursive-intelligence
pip install -e ".[all]"

Requirements: Python 3.10+


Quick start

CLI

ri-engine improve \
  --seed "You are a helper." \
  --goal "When this works, the AI will resolve the task in one pass"

Python

from ri_engine import improve

result = improve(
    seed_prompt="You are a helper.",
    objective="When this works, the AI will produce a structured answer.",
)
print(result.improved_prompt)
print(result.fitness)

Research flags

ri-engine improve --seed "…" --goal "…" --linguistic-gate auto   # default
ri-engine improve --seed "…" --goal "…" --linguistic-gate off
ri-engine improve --seed "…" --goal "…" --leaning plain
ri-engine improve --seed "…" --goal "…" --diagnostics

Full walkthrough: docs/getting_started.md


How it works

Linguistic Gate → [Macro Priors] → [Membrane] → Variation → Selection → Retention → repeat
                                                      ↓
                                            Baseline vs VSR pick
  1. Linguistic gate — experimental prior; defaults to mixed when confidence is low
  2. Variation — eight mutation strategies
  3. Selection — objective alignment, clarity, utility, coherence, register fit, simplicity
  4. Retention — lineage memory and convergence detection
  5. Baseline check — compare against one-shot finalize_prompt()

Architecture details: docs/technical_reference.md


Project structure

recursive-intelligence/
├── src/ri_engine/          # Core library and CLI
├── tests/                  # Pytest suite
├── docs/                   # Documentation index → docs/README.md
├── config/                 # Templates, use cases, registries → config/README.md
├── experiments/            # Local ablation scripts → experiments/README.md
├── examples/               # Sample scripts
├── prompts/                # VSR operator prompts (bundled into package)
├── CONTRIBUTING.md         # Contribution guidelines
├── CREDITS.md              # Attribution
├── CITATION.cff            # Machine-readable citation
└── CHANGELOG.md            # Release history

Documentation

Document Description
docs/README.md Documentation hub
getting_started.md Install and first run
technical_reference.md Architecture and API
research_and_citations.md Related work and BibTeX
publication.md Scope, limitations, release notes
cloud_development.md Codespaces and Colab

Scope and limitations

Mock mode (default) is a deterministic offline test of the recursive improvement process. It measures structural prompt quality using local heuristics (prompt_rubric.py). It does not prove that the resulting prompt will improve downstream LLM task performance.

Use --provider openai or --provider anthropic with appropriate API keys for semantic rewriting. Evaluate task outcomes separately.

Persistent macro trait registry is off by default (--use-persistent-macro-registry to enable).


Optional providers

export OPENAI_API_KEY=sk-...
ri-engine improve --seed prompt.txt --goal "…" --provider openai

Contributing

Contributions welcome. Please read CONTRIBUTING.md and CODE_OF_CONDUCT.md.

pytest tests/ -q

Report security issues per SECURITY.md.


Citation

See CITATION.cff and docs/research_and_citations.md.


Changelog

See CHANGELOG.md.

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

recursive_intelligence-0.1.7.tar.gz (122.5 kB view details)

Uploaded Source

Built Distribution

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

recursive_intelligence-0.1.7-py3-none-any.whl (143.3 kB view details)

Uploaded Python 3

File details

Details for the file recursive_intelligence-0.1.7.tar.gz.

File metadata

  • Download URL: recursive_intelligence-0.1.7.tar.gz
  • Upload date:
  • Size: 122.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for recursive_intelligence-0.1.7.tar.gz
Algorithm Hash digest
SHA256 aac979ff690cc6e6d7d2307180f36df87a738ab7db79b05da0fc10353844c58e
MD5 cd1cc93f37ed3b887c6e9a3e9d7ad2f5
BLAKE2b-256 054a789b78f26044e2908eedc45461b8b45f3d3e0c3d49dc8b712ec3d0ba3675

See more details on using hashes here.

Provenance

The following attestation bundles were made for recursive_intelligence-0.1.7.tar.gz:

Publisher: publish.yml on russfranky/recursive-intelligence

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file recursive_intelligence-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for recursive_intelligence-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f2f65dbd3fe2af249ec1cbaeea391ca11284ff7573877cc571bd4dcbab614f09
MD5 9dbbbc7a324a4b91ad8e41195d388e6f
BLAKE2b-256 bd3e340d8a502a695f2f02cd368d14854453da386a3accce32cf881f725bee6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for recursive_intelligence-0.1.7-py3-none-any.whl:

Publisher: publish.yml on russfranky/recursive-intelligence

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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