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.5.tar.gz (121.4 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.5-py3-none-any.whl (142.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: recursive_intelligence-0.1.5.tar.gz
  • Upload date:
  • Size: 121.4 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.5.tar.gz
Algorithm Hash digest
SHA256 b5a3961936bc46ce9dc23974763453b8723097c3f04b64c9f76a95bbc7cb4974
MD5 1767cd9449fc80b0a03d332d47f0ce77
BLAKE2b-256 bedb0cfadeb11d1b3c418d1d86f06e444875884c19a8b819e5c65a85997f2ed5

See more details on using hashes here.

Provenance

The following attestation bundles were made for recursive_intelligence-0.1.5.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.5-py3-none-any.whl.

File metadata

File hashes

Hashes for recursive_intelligence-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 cf0c47be3aec2d5d6a0184625bfd4851cc97be3a1693cbd6a6806c4aabdb325a
MD5 9e6d584bafd046bcf38ee10633a88611
BLAKE2b-256 ce19409ae4296b528ba72dbf7b689a3ccfd2ae0932c7b62424339cce81377370

See more details on using hashes here.

Provenance

The following attestation bundles were made for recursive_intelligence-0.1.5-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