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

Uploaded Python 3

File details

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

File metadata

  • Download URL: recursive_intelligence-0.1.6.tar.gz
  • Upload date:
  • Size: 121.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.6.tar.gz
Algorithm Hash digest
SHA256 0fe2acfbbf4aca35f48829463871c9034fcd39b07156602965f56c9c18ab756d
MD5 6c0e46a87cd63eeb13b83eef15058dbe
BLAKE2b-256 bb80e39434d6e682be0099c122ae6423a9d0e0420cca30165bee9021c4def90a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for recursive_intelligence-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f89ce55aa03211a6b2f8bbe717bde4e580467c3bc84cdd1be87d6a37d2a7b611
MD5 66fe4892703366b3bc69bcd11d026a77
BLAKE2b-256 e2cdf4c649a2684b57f59822d517565ffac6007094066d7e9ecbb6ef8bf92ce0

See more details on using hashes here.

Provenance

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