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 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 for RAG, creating knowledge graphs, 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.

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
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
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
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 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

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.2.1.tar.gz (26.2 MB view details)

Uploaded Source

Built Distributions

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

cocoindex-0.2.1-pp311-pypy311_pp73-manylinux_2_28_aarch64.whl (16.0 MB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

cocoindex-0.2.1-cp313-cp313t-manylinux_2_28_aarch64.whl (16.0 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.28+ ARM64

cocoindex-0.2.1-cp313-cp313-win_amd64.whl (15.9 MB view details)

Uploaded CPython 3.13Windows x86-64

cocoindex-0.2.1-cp313-cp313-manylinux_2_28_x86_64.whl (16.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

cocoindex-0.2.1-cp313-cp313-manylinux_2_28_aarch64.whl (16.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

cocoindex-0.2.1-cp313-cp313-macosx_11_0_arm64.whl (15.8 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

cocoindex-0.2.1-cp313-cp313-macosx_10_12_x86_64.whl (16.4 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

cocoindex-0.2.1-cp312-cp312-win_amd64.whl (15.9 MB view details)

Uploaded CPython 3.12Windows x86-64

cocoindex-0.2.1-cp312-cp312-manylinux_2_28_x86_64.whl (16.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

cocoindex-0.2.1-cp312-cp312-manylinux_2_28_aarch64.whl (16.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

cocoindex-0.2.1-cp312-cp312-macosx_11_0_arm64.whl (15.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

cocoindex-0.2.1-cp312-cp312-macosx_10_12_x86_64.whl (16.4 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

cocoindex-0.2.1-cp311-cp311-win_amd64.whl (15.9 MB view details)

Uploaded CPython 3.11Windows x86-64

cocoindex-0.2.1-cp311-cp311-manylinux_2_28_x86_64.whl (16.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

cocoindex-0.2.1-cp311-cp311-manylinux_2_28_aarch64.whl (16.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

cocoindex-0.2.1-cp311-cp311-macosx_11_0_arm64.whl (15.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

cocoindex-0.2.1-cp311-cp311-macosx_10_12_x86_64.whl (16.4 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: cocoindex-0.2.1.tar.gz
  • Upload date:
  • Size: 26.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.9.4

File hashes

Hashes for cocoindex-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3adec73ccd9ba9e1939317653e1462dd1e97c0b774c6d0f0a1d6913b5aa10aec
MD5 2ff66975648f10ec30bcbd88f113ba08
BLAKE2b-256 c1ff8178ae2068548a4cd63944dfa6ec3c3cd67aa5b156726baa5dd34c6410ad

See more details on using hashes here.

File details

Details for the file cocoindex-0.2.1-pp311-pypy311_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cocoindex-0.2.1-pp311-pypy311_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a6fdac1c75e9bdfdc69bbb9928a325eddd4cad31b545573ceb2ccde9a9707d34
MD5 7870bb6a8cfeda996d8f9b6eb08675a1
BLAKE2b-256 4bcf3f5ffe8923430f93024e3bfb9a6f958525f6b76ecaf0f0c2d36f89b8ed92

See more details on using hashes here.

File details

Details for the file cocoindex-0.2.1-cp313-cp313t-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cocoindex-0.2.1-cp313-cp313t-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fe915f3c3bb2c6696fad53425ff44f8df54a3eaf7d7a2565750ed4a15aececca
MD5 a38171170c5b5c35710c66ca6afeb6f6
BLAKE2b-256 517137cc7f2e9631474e83aeddf071e049db6b1a249fc9d732fc8e6690114072

See more details on using hashes here.

File details

Details for the file cocoindex-0.2.1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for cocoindex-0.2.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c562cdb503ab21373493b5f9022db927750f6cc95c2777e0f4d1518d99be777d
MD5 90e1b408198d25fb4da6415db157055c
BLAKE2b-256 d5c47560c1c95d502d3660e75cb270dce5bbcb3e981d9453b8975367cce4ae98

See more details on using hashes here.

File details

Details for the file cocoindex-0.2.1-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cocoindex-0.2.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 58835a037ab5f1017c4b414ffa0f31359fff57f2d9770aeb3c5ea8f6825a0749
MD5 d3d4d78769f656ed91d8610352a36672
BLAKE2b-256 9a01657b64fac82ba8cfea52ac1a11eff9eff9fa0c61e926aaec3e00e79b9ae7

See more details on using hashes here.

File details

Details for the file cocoindex-0.2.1-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cocoindex-0.2.1-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 816a63a3b95d78c50c0868eec4bce545bad4bf9cb542a94c11b28d1275ca856d
MD5 c4c81f548dfe4d0a69976114b0baa547
BLAKE2b-256 9201e0ba2219b478c98639c4e9419be7aa064b47629e4576285d29d4f5685b6d

See more details on using hashes here.

File details

Details for the file cocoindex-0.2.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cocoindex-0.2.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0f6e1dabf0dc299c553bb8cca6c60990d60dad320922df736cebe0869fd24665
MD5 ec680a4f93691c252e89e490ef0a2e13
BLAKE2b-256 8c673bddcb31b20bec6ae7bec9edacb5b683e1d6bd7302f8a6a852be86d968f1

See more details on using hashes here.

File details

Details for the file cocoindex-0.2.1-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for cocoindex-0.2.1-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1c5c8dd903be5125bfd3e883d581d19506efb94442a6f37fc4faabea867d5da6
MD5 a936b6b8b91ee8bc65c6b6328e36b136
BLAKE2b-256 a96d7380ce6fb91c8ebd435f1aa8526b53218408b18a1972cc01d3462ec92cbc

See more details on using hashes here.

File details

Details for the file cocoindex-0.2.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for cocoindex-0.2.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8671a77be7687d3f077941971d070b0ee080a6359e567eebcfc820101007727d
MD5 175060fc5a81cbe35434d8d9c6edceac
BLAKE2b-256 be84a030670168149a5264f8efcf0bfddfd2d168d42265e0536a6f85a06d001b

See more details on using hashes here.

File details

Details for the file cocoindex-0.2.1-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cocoindex-0.2.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 09b144f1abe7d9ca53423579d925f8ab1cb445c0fc396d8c6f049b11feb48a59
MD5 25e007f6bf1ee2f05aad6b47701887df
BLAKE2b-256 fb9e56d4e827cc1db127c3a3a0ea7608148c4eedd29aa07254d61757827273a3

See more details on using hashes here.

File details

Details for the file cocoindex-0.2.1-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cocoindex-0.2.1-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 62fd2bc9d9ea931945ff65d0785ee11bf6d4ff203c0cf402eb39872f0e6374fc
MD5 9ff3cf4049ed8ffc08c19886ce778760
BLAKE2b-256 522859c498a6f38d8df167758c897bac4cc3170063ed2bd810ebf68d74723702

See more details on using hashes here.

File details

Details for the file cocoindex-0.2.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cocoindex-0.2.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 08a987ad26dceeab2e21e208bfc2ac634684a3f02a89c4358dc6b9bc981d2577
MD5 1cba5770235a25c654eced8d590ea274
BLAKE2b-256 6d3935dbd9855be50187c7a6850119a4d95fbe6959722a7949fe47d371a6ac5e

See more details on using hashes here.

File details

Details for the file cocoindex-0.2.1-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for cocoindex-0.2.1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a142104d5f43ef867b5ff33f51258655a4bb5575ac323619687df85501562235
MD5 7d20a3c1345fb968029106d041808bd6
BLAKE2b-256 6e72b129845a4a3f7edfdb473befd88bbd50b22b9f24b48c5c4f44de67873f34

See more details on using hashes here.

File details

Details for the file cocoindex-0.2.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for cocoindex-0.2.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c2609baf01f56108793681e9d88ece8689d54474ce29ed55bb8c5e5d1a44894b
MD5 e71e6c168b741e0a3920bcc450dbfd40
BLAKE2b-256 2e818499a07827ff0b796d3060d5a6031260434d244486cfc1cddc091ff8febb

See more details on using hashes here.

File details

Details for the file cocoindex-0.2.1-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cocoindex-0.2.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 792f2b0e343e544464beef4768449754ce39bf56244a01cffa42a2a1f506aeb6
MD5 4d37cb302236290beae7dbe789182572
BLAKE2b-256 1cdcd03834a4369f8b721ffd667cb2da2a61c4eeb564e052794a3812a53498c1

See more details on using hashes here.

File details

Details for the file cocoindex-0.2.1-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cocoindex-0.2.1-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 226c0d4ca5e6718b905e7a2083856a9dbb660137cbdbc5250f6dd4a2457587c6
MD5 d74c8a2bc34351e8df13b84d6bb8a635
BLAKE2b-256 0acf8691d9649abaf4264694fb348d277361f0acedc8dcf7746fddcd29cbdf6a

See more details on using hashes here.

File details

Details for the file cocoindex-0.2.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cocoindex-0.2.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ae2fe31f760ba848eb7eb726683f6c8731ffd3a788ae04520083aafc78a66fc0
MD5 8dc125998779cf3c53de1f03b46a34b7
BLAKE2b-256 de8af8fd1d4151cc1356329510ec362b2dc653f5d7970c7a4e978bed4efabc69

See more details on using hashes here.

File details

Details for the file cocoindex-0.2.1-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for cocoindex-0.2.1-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1999685d05f18c60d58c8a2a91cf59bac049caec87df1473a571b9524cca013e
MD5 a4c89a248d338cea5c819421d49e0134
BLAKE2b-256 2f167cb287a593fd93b189dd4fb4813d0b7597a6e449b68025977e30bd3b5a2f

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