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.
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"
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 ablation —
experiments/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
- Linguistic gate — experimental prior; defaults to mixed when confidence is low
- Variation — eight mutation strategies
- Selection — objective alignment, clarity, utility, coherence, register fit, simplicity
- Retention — lineage memory and convergence detection
- 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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5a3961936bc46ce9dc23974763453b8723097c3f04b64c9f76a95bbc7cb4974
|
|
| MD5 |
1767cd9449fc80b0a03d332d47f0ce77
|
|
| BLAKE2b-256 |
bedb0cfadeb11d1b3c418d1d86f06e444875884c19a8b819e5c65a85997f2ed5
|
Provenance
The following attestation bundles were made for recursive_intelligence-0.1.5.tar.gz:
Publisher:
publish.yml on russfranky/recursive-intelligence
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
recursive_intelligence-0.1.5.tar.gz -
Subject digest:
b5a3961936bc46ce9dc23974763453b8723097c3f04b64c9f76a95bbc7cb4974 - Sigstore transparency entry: 1826531259
- Sigstore integration time:
-
Permalink:
russfranky/recursive-intelligence@8335e1f8ebdfab867e6da5b1b20f631421c157fc -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/russfranky
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8335e1f8ebdfab867e6da5b1b20f631421c157fc -
Trigger Event:
push
-
Statement type:
File details
Details for the file recursive_intelligence-0.1.5-py3-none-any.whl.
File metadata
- Download URL: recursive_intelligence-0.1.5-py3-none-any.whl
- Upload date:
- Size: 142.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf0c47be3aec2d5d6a0184625bfd4851cc97be3a1693cbd6a6806c4aabdb325a
|
|
| MD5 |
9e6d584bafd046bcf38ee10633a88611
|
|
| BLAKE2b-256 |
ce19409ae4296b528ba72dbf7b689a3ccfd2ae0932c7b62424339cce81377370
|
Provenance
The following attestation bundles were made for recursive_intelligence-0.1.5-py3-none-any.whl:
Publisher:
publish.yml on russfranky/recursive-intelligence
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
recursive_intelligence-0.1.5-py3-none-any.whl -
Subject digest:
cf0c47be3aec2d5d6a0184625bfd4851cc97be3a1693cbd6a6806c4aabdb325a - Sigstore transparency entry: 1826531790
- Sigstore integration time:
-
Permalink:
russfranky/recursive-intelligence@8335e1f8ebdfab867e6da5b1b20f631421c157fc -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/russfranky
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8335e1f8ebdfab867e6da5b1b20f631421c157fc -
Trigger Event:
push
-
Statement type: