Skip to main content

With CocoIndex, users declare the transformation, CocoIndex creates & maintains an index, and keeps the derived index up to date based on source update, with minimal computation and changes.

Project description

CocoIndex

Data transformation for AI

GitHub Documentation License PyPI version

PyPI Downloads CI release Link Check prek Discord

cocoindex-io%2Fcocoindex | Trendshift

Ultra performant data transformation framework for AI, with core engine written in Rust. Support incremental processing and data lineage out-of-box. Exceptional developer velocity. Production-ready at day 0.

⭐ Drop a star to help us grow!


CocoIndex Transformation


CocoIndex makes it effortless to transform data with AI, and keep source data and target in sync. Whether you’re building a vector index, creating knowledge graphs for context engineering or performing any custom data transformations — goes beyond SQL.


CocoIndex Features


Exceptional velocity

Just declare transformation in dataflow with ~100 lines of python

# import
data['content'] = flow_builder.add_source(...)

# transform
data['out'] = data['content']
    .transform(...)
    .transform(...)

# collect data
collector.collect(...)

# export to db, vector db, graph db ...
collector.export(...)

CocoIndex follows the idea of Dataflow programming model. Each transformation creates a new field solely based on input fields, without hidden states and value mutation. All data before/after each transformation is observable, with lineage out of the box.

Particularly, developers don't explicitly mutate data by creating, updating and deleting. They just need to define transformation/formula for a set of source data.

Plug-and-Play Building Blocks

Native builtins for different source, targets and transformations. Standardize interface, make it 1-line code switch between different components - as easy as assembling building blocks.

CocoIndex Features

Data Freshness

CocoIndex keep source data and target in sync effortlessly.

Incremental Processing

It has out-of-box support for incremental indexing:

  • minimal recomputation on source or logic change.
  • (re-)processing necessary portions; reuse cache when possible

Quick Start

If you're new to CocoIndex, we recommend checking out

Setup

  1. Install CocoIndex Python library
pip install -U cocoindex
  1. Install Postgres if you don't have one. CocoIndex uses it for incremental processing.

  2. (Optional) Install Claude Code skill for enhanced development experience. Run these commands in Claude Code:

/plugin marketplace add cocoindex-io/cocoindex-claude
/plugin install cocoindex-skills@cocoindex

Define data flow

Follow Quick Start Guide to define your first indexing flow. An example flow looks like:

@cocoindex.flow_def(name="TextEmbedding")
def text_embedding_flow(flow_builder: cocoindex.FlowBuilder, data_scope: cocoindex.DataScope):
    # Add a data source to read files from a directory
    data_scope["documents"] = flow_builder.add_source(cocoindex.sources.LocalFile(path="markdown_files"))

    # Add a collector for data to be exported to the vector index
    doc_embeddings = data_scope.add_collector()

    # Transform data of each document
    with data_scope["documents"].row() as doc:
        # Split the document into chunks, put into `chunks` field
        doc["chunks"] = doc["content"].transform(
            cocoindex.functions.SplitRecursively(),
            language="markdown", chunk_size=2000, chunk_overlap=500)

        # Transform data of each chunk
        with doc["chunks"].row() as chunk:
            # Embed the chunk, put into `embedding` field
            chunk["embedding"] = chunk["text"].transform(
                cocoindex.functions.SentenceTransformerEmbed(
                    model="sentence-transformers/all-MiniLM-L6-v2"))

            # Collect the chunk into the collector.
            doc_embeddings.collect(filename=doc["filename"], location=chunk["location"],
                                   text=chunk["text"], embedding=chunk["embedding"])

    # Export collected data to a vector index.
    doc_embeddings.export(
        "doc_embeddings",
        cocoindex.targets.Postgres(),
        primary_key_fields=["filename", "location"],
        vector_indexes=[
            cocoindex.VectorIndexDef(
                field_name="embedding",
                metric=cocoindex.VectorSimilarityMetric.COSINE_SIMILARITY)])

It defines an index flow like this:

Data Flow

🚀 Examples and demo

Example Description
Text Embedding Index text documents with embeddings for semantic search
Code Embedding Index code embeddings for semantic search
PDF Embedding Parse PDF and index text embeddings for semantic search
PDF Elements Embedding Extract text and images from PDFs; embed text with SentenceTransformers and images with CLIP; store in Qdrant for multimodal search
Manuals LLM Extraction Extract structured information from a manual using LLM
Amazon S3 Embedding Index text documents from Amazon S3
Azure Blob Storage Embedding Index text documents from Azure Blob Storage
Google Drive Text Embedding Index text documents from Google Drive
Meeting Notes to Knowledge Graph Extract structured meeting info from Google Drive and build a knowledge graph
Docs to Knowledge Graph Extract relationships from Markdown documents and build a knowledge graph
Embeddings to Qdrant Index documents in a Qdrant collection for semantic search
Embeddings to LanceDB Index documents in a LanceDB collection for semantic search
FastAPI Server with Docker Run the semantic search server in a Dockerized FastAPI setup
Product Recommendation Build real-time product recommendations with LLM and graph database
Image Search with Vision API Generates detailed captions for images using a vision model, embeds them, enables live-updating semantic search via FastAPI and served on a React frontend
Face Recognition Recognize faces in images and build embedding index
Paper Metadata Index papers in PDF files, and build metadata tables for each paper
Multi Format Indexing Build visual document index from PDFs and images with ColPali for semantic search
Custom Source HackerNews Index HackerNews threads and comments, using CocoIndex Custom Source
Custom Output Files Convert markdown files to HTML files and save them to a local directory, using CocoIndex Custom Targets
Patient intake form extraction Use LLM to extract structured data from patient intake forms with different formats
HackerNews Trending Topics Extract trending topics from HackerNews threads and comments, using CocoIndex Custom Source and LLM
Patient Intake Form Extraction with BAML Extract structured data from patient intake forms using BAML
Patient Intake Form Extraction with DSPy Extract structured data from patient intake forms using DSPy

More coming and stay tuned 👀!

📖 Documentation

For detailed documentation, visit CocoIndex Documentation, including a Quickstart guide.

🤝 Contributing

We love contributions from our community ❤️. For details on contributing or running the project for development, check out our contributing guide.

👥 Community

Welcome with a huge coconut hug 🥥⋆。˚🤗. We are super excited for community contributions of all kinds - whether it's code improvements, documentation updates, issue reports, feature requests, and discussions in our Discord.

Join our community here:

Support us

We are constantly improving, and more features and examples are coming soon. If you love this project, please drop us a star ⭐ at GitHub repo GitHub to stay tuned and help us grow.

License

CocoIndex is Apache 2.0 licensed.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cocoindex-0.3.31.tar.gz (447.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cocoindex-0.3.31-cp314-cp314t-win_amd64.whl (19.5 MB view details)

Uploaded CPython 3.14tWindows x86-64

cocoindex-0.3.31-cp314-cp314t-manylinux_2_28_x86_64.whl (18.9 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.28+ x86-64

cocoindex-0.3.31-cp314-cp314t-manylinux_2_28_aarch64.whl (18.2 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.28+ ARM64

cocoindex-0.3.31-cp314-cp314t-macosx_11_0_arm64.whl (17.7 MB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

cocoindex-0.3.31-cp311-abi3-win_amd64.whl (19.5 MB view details)

Uploaded CPython 3.11+Windows x86-64

cocoindex-0.3.31-cp311-abi3-manylinux_2_28_x86_64.whl (18.9 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ x86-64

cocoindex-0.3.31-cp311-abi3-manylinux_2_28_aarch64.whl (18.2 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

cocoindex-0.3.31-cp311-abi3-macosx_11_0_arm64.whl (17.7 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

cocoindex-0.3.31-cp311-abi3-macosx_10_12_x86_64.whl (18.4 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file cocoindex-0.3.31.tar.gz.

File metadata

  • Download URL: cocoindex-0.3.31.tar.gz
  • Upload date:
  • Size: 447.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.11.5

File hashes

Hashes for cocoindex-0.3.31.tar.gz
Algorithm Hash digest
SHA256 7a0af700d8a1a6a3f5c234dbfe02d01d9694c53d4bd2e907b602154019ba471a
MD5 e24844ade046b27f285fe9123afb0661
BLAKE2b-256 326a4ca7fa8fad6f39c48a643578b79584e102be57a6f17cc76209ca052c434b

See more details on using hashes here.

File details

Details for the file cocoindex-0.3.31-cp314-cp314t-win_amd64.whl.

File metadata

File hashes

Hashes for cocoindex-0.3.31-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 682fe112cae7ac91e3f35f05becb75823202c1ec7dbd489f8cbfd5b54609b4fc
MD5 db00fa01b344937998e674834681317c
BLAKE2b-256 1a8aae62d076cd13470b7742f6e4f0154df11f514a035418968baee4f5bb90da

See more details on using hashes here.

File details

Details for the file cocoindex-0.3.31-cp314-cp314t-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cocoindex-0.3.31-cp314-cp314t-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6cb7adfeb662aacd501d86008849b358ecd3cebfcc30c76ecc3ce872685aba6e
MD5 bf44ac0af6e729ab5e6672f8a7a5c674
BLAKE2b-256 b833ba3699f22a46e46b0cc306d6bf930c7f28e5a30ecf42d8ced8aa3ff30608

See more details on using hashes here.

File details

Details for the file cocoindex-0.3.31-cp314-cp314t-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cocoindex-0.3.31-cp314-cp314t-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b728cfe922979f1d458aeb428f73a1b6fdcc0489f44e410ffc2e606b6878ff32
MD5 0b6300b823e0c728db11ad6c6baf4cda
BLAKE2b-256 6294e0d317c5b0abee36e9428c6644894c3ff97540f882d7faf95f002cdf5786

See more details on using hashes here.

File details

Details for the file cocoindex-0.3.31-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cocoindex-0.3.31-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2d7e33eff2a58445d8bdbb75a6443c4583fd5debd2b9fd1224b3d7ad6d5f22e9
MD5 5bd24e63f5f77d54e5f8d5c3c6c6bfaa
BLAKE2b-256 7aabf1757be6ec9478cd07b9d427515b7037f176f51c5d83059740feedf15e1a

See more details on using hashes here.

File details

Details for the file cocoindex-0.3.31-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for cocoindex-0.3.31-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 80ea937027d429206face0690b46428a44db95fe1070708413008851bd597720
MD5 a655af35e09a145917ee7077b4d29d4d
BLAKE2b-256 70e7bd791dc2ddf45bfb40329b2078560c746d99c27b6a30cf04a1fa7f79502c

See more details on using hashes here.

File details

Details for the file cocoindex-0.3.31-cp311-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cocoindex-0.3.31-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bb3cd664eefb54f419b77564b1fff3d9947523e29104c6ed905018519f9aa6ce
MD5 d80d621c36f9e9b91c86b9c7c24b2972
BLAKE2b-256 71066d88b9c6ab161645309a515bab3dfcf0f6868d6302e891c21ca60e2de801

See more details on using hashes here.

File details

Details for the file cocoindex-0.3.31-cp311-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cocoindex-0.3.31-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 93413c094215ee4a779e9d8ff1aee55c74d0159ba58a15678f142aa9888485cd
MD5 8e630dd7bd386611f8ef8f883f573b5e
BLAKE2b-256 e8a572ce628dbc0c45c6e51d4ba3f4c6b5ba1cfef53210f140065de650cb97c6

See more details on using hashes here.

File details

Details for the file cocoindex-0.3.31-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cocoindex-0.3.31-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 060128652972ad48554b90d90c17c168b64dc1bad9b78f75759d55bdcf467bed
MD5 abd77c3f5d666d43fa5a7cde52138ed1
BLAKE2b-256 eeda195a45aa6fcc0bad5b4ed75702f66f013b660931f9cb8cc210787197b38d

See more details on using hashes here.

File details

Details for the file cocoindex-0.3.31-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for cocoindex-0.3.31-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d34875b9ad105722cfc300cea6ee0cf0bdb8fbaec40904e7534b6b4291170fd8
MD5 98371af0ebee455270ac356da6bb02e7
BLAKE2b-256 485e4d64e9594d4def79ef449c116128f961220fa41438e2eb5a4f2c6b0ef90d

See more details on using hashes here.

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