CocoIndex is now open source

CocoIndex is now open source: an engine that combines custom transformation logic with incremental processing for data indexing.

Changelog3 min read
CocoIndex is now open source
Enlarge cover

CocoIndex is now open source

Zoom in to see details.

CocoIndex is now open source

CocoIndex is now open source. It supports custom transformation logic and incremental processing for data indexing.

cocoindexwhere all three overlap
Custom transformation logic
Incremental indexingon data or logic update
Heavy transformation
parsechunkingembeddingknowledge graph triple extraction
CocoIndex is the overlap of all three

CocoIndex is an ETL framework to prepare data for AI applications such as semantic search and retrieval-augmented generation (RAG). It offers a data-driven programming model that simplifies the creation and maintenance of data indexing pipelines, ensuring data freshness and consistency.

Why indexing needs its own engine

Indexing pipelines have a property most ETL tooling doesn’t account for: the output is derived data that has to stay correct as the source keeps changing. The clean way to express that is TargetState = Transform(SourceState). You declare what the index should look like given the current source, and something keeps it in sync. The trouble is that doing the “keeping in sync” by hand is a lot of error-prone bookkeeping. You have to detect what changed and compute the exact delta of inserts, updates, and deletes for the target. You also have to preserve intermediate results so you aren’t paying twice for embeddings or LLM calls, and migrate the target schema when your transformation code evolves. Get any of it wrong and you ship a stale or inconsistent index. These bugs can be difficult to detect.

CocoIndex exists to own that bookkeeping. You write the transformation; the engine diffs each run against the last, skips work whose inputs and code are unchanged (memoization), and applies only the difference to the target.

CocoIndex is now open source under the Apache License 2.0. The core functionality is available to use, modify, and distribute under the license’s terms.

Open source also matters specifically for infrastructure like this. An indexing pipeline sits between your data and your AI applications. Their answers depend on its output. Teams should be able to read the engine that decides what gets reprocessed and what gets cached, extend it with the connectors and transforms their data needs, and run it without a vendor in the critical path. A permissive license makes those commitments durable.

Key features

  • Data flow programming: Build indexing pipelines by composing transformations like building blocks, with built-in state management and observability.
  • Custom logic: Plug in your choice of chunking, embedding, and vector stores. Extend with custom transformations like deduplication and reconciliation.
  • Incremental processing: State management minimizes re-computation by tracking changes. At the time of this release, changes were tracked per file; CocoIndex 1.0 can memoize individual function calls (memo=True), so a changed file re-runs only the memoized calls whose inputs or code changed.
  • Python SDK: Built with a Rust core for performance, exposed through a Python binding.

The Rust-core / Python-binding split is deliberate. The engine’s work (change detection, state tracking, computing deltas, and reconciling target states) is concurrent, long-running, and performance-sensitive, which is the kind of work Rust is suited for. But the people writing indexing logic want to reach for the rest of the AI and data ecosystem: chunkers, embedding models, LLM clients, vector stores. So the heavy lifting stays in Rust while everything you author (sources, transforms, targets) is plain Python. You get the engine’s guarantees without giving up the libraries you already use.

Getting started

  1. Installation: Install the CocoIndex Python library:

    sh
    pip install cocoindex
  2. Set up Postgres with the pgvector extension: Ensure Docker Compose is installed, then start a Postgres database:

    sh
    docker compose -f <(curl -L https://raw.githubusercontent.com/cocoindex-io/cocoindex/refs/heads/main/dev/postgres.yaml) up -d
  3. Define your indexing flow: Create a flow to index your data. For example:

    python
    @cocoindex.flow_def(name="TextEmbedding")
    def text_embedding(flow_builder: cocoindex.FlowBuilder, data_scope: cocoindex.DataScope):
        data_scope["documents"] = flow_builder.add_source(cocoindex.sources.LocalFile(path="markdown_files"))
        doc_embeddings = data_scope.add_collector()
    
        with data_scope["documents"].row() as doc:
            doc["chunks"] = doc["content"].transform(
                cocoindex.functions.SplitRecursively(language="markdown", chunk_size=300, chunk_overlap=100))
    
            with doc["chunks"].row() as chunk:
                chunk["embedding"] = chunk["text"].transform(
                    cocoindex.functions.SentenceTransformerEmbed(model="sentence-transformers/all-MiniLM-L6-v2"))
    
                doc_embeddings.collect(filename=doc["filename"], location=chunk["location"],
                                       text=chunk["text"], embedding=chunk["embedding"])
    
        doc_embeddings.export(
            "doc_embeddings",
            cocoindex.storages.Postgres(),
            primary_key_fields=["filename", "location"],
            vector_indexes=[cocoindex.VectorIndex("embedding", cocoindex.VectorSimilarityMetric.COSINE_SIMILARITY)])

For a detailed walkthrough, refer to our Quickstart Guide.

Community

Since this release, CocoIndex has passed 10,000 GitHub stars and shipped 200+ releases of fixes, connectors, and new capabilities, with many contributions from the community. If you find the project useful, the best way to help is to use it, tell us where it falls short, and contribute back.

We welcome bug reports, feature suggestions, and contributions. Tell us what you build and where CocoIndex needs improvement.

Build fresh context for your agents.

CocoIndex keeps derived data in sync with its sources. Only what changed re-runs.