PHPackages                             neuron-core/raptor-retrieval - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. neuron-core/raptor-retrieval

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

neuron-core/raptor-retrieval
============================

Recursive Abstractive Processing for Tree-Organized Retrieval

3.0.0(2mo ago)93.0k↓41.2%4[1 issues](https://github.com/neuron-core/raptor-retrieval/issues)[1 PRs](https://github.com/neuron-core/raptor-retrieval/pulls)MITPHPPHP ^8.1

Since Sep 12Pushed 2mo agoCompare

[ Source](https://github.com/neuron-core/raptor-retrieval)[ Packagist](https://packagist.org/packages/neuron-core/raptor-retrieval)[ RSS](/packages/neuron-core-raptor-retrieval/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (6)Versions (9)Used By (0)

Recursive Abstractive Processing for Tree-Organized Retrieval
=============================================================

[](#recursive-abstractive-processing-for-tree-organized-retrieval)

This module implements the RAPTOR retrieval strategy for the [Neuron PHP AI framework](https://neuron-ai.dev).

The Problem with Traditional Retrieval
--------------------------------------

[](#the-problem-with-traditional-retrieval)

Most retrieval-augmented models work by breaking down documents into small chunks and retrieving only the most relevant ones. However, this approach has some limitations:

- **Loss of Context**: Retrieving only small, isolated chunks may miss the bigger picture, especially for documents with long contexts.
- **Difficulty in Multi-Step Reasoning**: Some questions require information from multiple sections of a document.

**Use RAPTOR when:**

- Users ask open-ended questions that require comprehensive coverage
- Your domain involves complex topics where context matters as much as facts
- You need to handle queries about themes, trends, or relationships across documents

**Stick with traditional RAG when:**

- Users primarily need quick, specific fact retrieval
- Processing speed and token efficiency are critical constraints

Check out the example in the [examples](./examples/raptor.php) folder.

Requirements
------------

[](#requirements)

- PHP: ^8.1
- Neuron: ^2.0

Install RAPTOR retrieval
------------------------

[](#install-raptor-retrieval)

Install the latest version of the package:

```
composer require neuron-core/raptor-retreival

```

How to use RAPTOR in your agent
-------------------------------

[](#how-to-use-raptor-in-your-agent)

Or use the RAPTOR component directly into the agent. RAPTOR needs a vector store, an embedding provider and uses an LLM to perform the summarization:

```
use NeuronAI\RAG\Retrieval\RetrievalInterface;
use NeuronCore\RaptorRetrieval\RaptorRetrieval;

class WorkoutTipsAgent extends RAG
{
    protected function retrieval(): RetrievalInterface
    {
        return new RaptorRetrieval(
            $this->resolveVectorStore(),
            $this->resolveEmbeddingsProvider(),
            $this->resolveProvider(), // Used for summarization
        );
    }

    protected function embeddings(): EmbeddingsProviderInterface
    {
        return new ...
    }

    protected function vectorStore(): VectorStoreInterface
    {
        return new ...
    }
}
```

Clustering strategy
-------------------

[](#clustering-strategy)

RAPTOR algorithm uses a clustering strategy to group the retrieved documents into clusters. Choose based on your content characteristics:

### Similarity Clustering (default)

[](#similarity-clustering-default)

Groups documents with clear thematic boundaries. Best for already well-organized content with distinct topics.

**Use Similarity Clustering when:**

- You have heterogeneous content with clear topic boundaries
- Your documents have distinct themes that don't overlap much
- Performance is important (faster processing)

```
use NeuronAI\RAG\Retrieval\RetrievalInterface;
use NeuronCore\RaptorRetrieval\RaptorRetrieval;
use NeuronCore\RaptorRetrieval\Clustering\SimilarityClustering;

class WorkoutTipsAgent extends RAG
{
    protected function retrieval(): RetrievalInterface
    {
        return new RaptorRetrieval(
            $this->resolveVectorStore(),
            $this->resolveEmbeddingsProvider(),
            $this->resolveProvider(), // Used for summarization
            new SimilarityClustering()
        );
    }

    protected function embeddings(): EmbeddingsProviderInterface
    {
        return new ...
    }

    protected function vectorStore(): VectorStoreInterface
    {
        return new ...
    }
}
```

### Gaussian Mixture Clustering

[](#gaussian-mixture-clustering)

Handles overlapping topics where documents may belong to multiple themes simultaneously. Useful for research papers, news articles, or any content where topics naturally blend together rather than having sharp boundaries.

**Use GMM when:**

- Documents may relate to multiple topics simultaneously
- You want the algorithm to discover the "natural" number of clusters in your data
- You're dealing with research papers, news, or complex content where multiple topics blend

```
use NeuronAI\RAG\Retrieval\RetrievalInterface;
use NeuronCore\RaptorRetrieval\RaptorRetrieval;
use NeuronCore\RaptorRetrieval\Clustering\GaussianMixtureClustering;

class WorkoutTipsAgent extends RAG
{
    protected function retrieval(): RetrievalInterface
    {
        return new RaptorRetrieval(
            $this->resolveVectorStore(),
            $this->resolveEmbeddingsProvider(),
            $this->resolveProvider(), // Used for summarization
            new GaussianMixtureClustering()
        );
    }

    protected function embeddings(): EmbeddingsProviderInterface
    {
        return new ...
    }

    protected function vectorStore(): VectorStoreInterface
    {
        return new ...
    }
}
```

What is Neuron?
---------------

[](#what-is-neuron)

Neuron is a PHP framework for creating and orchestrating AI Agents. It allows you to integrate AI entities in your existing PHP applications with a powerful and flexible architecture. We provide tools for the entire agentic application development lifecycle, from LLM interfaces, to data loading, to multi-agent orchestration, to monitoring and debugging. In addition, we provide tutorials and other educational content to help you get started using AI Agents in your projects.

**[Go to the official documentation](https://docs.neuron-ai.dev/)**

[**Video Tutorial**](https://www.youtube.com/watch?v=oSA1bP_j41w)

[![Neuron & Inspector](./docs/youtube.png)](https://www.youtube.com/watch?v=oSA1bP_j41w)

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance82

Actively maintained with recent releases

Popularity30

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~23 days

Recently: every ~37 days

Total

8

Last Release

82d ago

Major Versions

1.0.3 → 2.0.02025-10-21

2.x-dev → 3.0.02026-02-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/320345fbe48c7cff2b3a25992c8207e959ae7817fb2fb97bb176dc6e559aacf5?d=identicon)[valerione](/maintainers/valerione)

---

Top Contributors

[![ilvalerione](https://avatars.githubusercontent.com/u/13559278?v=4)](https://github.com/ilvalerione "ilvalerione (23 commits)")

---

Tags

agentagentic-aiagentic-workflowaiai-agentai-agentsai-frameworkembeddingllmphpragrag-chatbotrag-pipelinevector-databasevector-search

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/neuron-core-raptor-retrieval/health.svg)

```
[![Health](https://phpackages.com/badges/neuron-core-raptor-retrieval/health.svg)](https://phpackages.com/packages/neuron-core-raptor-retrieval)
```

###  Alternatives

[saikiran/geohash

Geohash Algorithm to encode geographic coordinates to a string of letters and digits

44456.6k3](/packages/saikiran-geohash)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
