Deep Lake Documentation
repository·main·Indexed 27 days ago
https://github.com/activeloopai/deeplakeA specialized database for AI designed to store, manage, and search large-scale datasets including embeddings, text, images, audio, and video. It serves as a vector store for LLM applications and a high-performance data loader for deep learning model training. Key features include multi-cloud support, native compression, lazy indexing, and integrations with LangChain and LlamaIndex. The ecosystem also includes pg_deeplake, a PostgreSQL extension providing vector similarity, full-text, and hybrid search capabilities.
What's inside Deep Lake
- OpenJPEG is an open-source JPEG 2000 codec written in C. It is officially recognized by ISO/IEC and ITU-T as a JPEG 2000 Reference Software. The library is released under the BSD 2-clause "Simplified" License, allowing for use and modification in commercial applications provided the copyright is retained in the sources or binaries documentation.
Overview of Deep Lake features
mainDeep Lake is a database optimized for AI, designed for storing and searching data plus vectors for LLM applications, and managing datasets for deep learning model training.
Key features include:
- Multi-Cloud Support: Upload, download, and stream datasets to/from S3, Azure, GCP, Activeloop cloud, local storage, or in-memory storage (including S3-compatible storage like MinIO).
- Native Compression & Lazy Indexing: Store media (images, audio, video) in native compression with NumPy-like lazy indexing for efficient memory usage.
- Deep Learning Dataloaders: Built-in dataloaders for PyTorch and TensorFlow with automatic dataset shuffling.
- Integrations: Native support for LangChain, LlamaIndex, Weights & Biases, MMDetection, and MMSegmentation.
- Instant Visualization: Support for visualizing datasets with bounding boxes, masks, and annotations via the Deep Lake App.
Understand Deep Lake Column Classes
mainDeep Lake uses different column classes depending on the required access level (read-write vs. read-only) and whether you are interacting with the data itself or the schema definition.
Class Description ColumnFull read-write access to column data. ColumnViewRead-only access to column data. ColumnDefinitionSchema definition for columns with modification capabilities (e.g., renaming/dropping). ColumnDefinitionViewRead-only schema definition for columns. Compare Deep Lake with other Vector Stores
mainDeep Lake is a serverless Vector Store that can be deployed locally, in-memory, or on your own cloud. Unlike traditional Vector Databases (like ChromaDB, Pinecone, or Weaviate), Deep Lake allows you to store raw unstructured data (images, videos, text) alongside embeddings, supports native version control, and provides in-browser data visualization. All computations run client-side, making it suitable for lightweight production applications.Choose the appropriate Deep Lake Dataset class
mainDeep Lake provides three dataset classes depending on your required access level:
Dataset: Full read-write access. Use this for creating, modifying, appending, or deleting data and managing branches/tags.ReadOnlyDataset: Read-only access. Use this to prevent accidental modifications while still accessing all data, metadata, and version history. It is returned bydeeplake.open_read_only().DatasetView: A lightweight, read-only view of query results. It is optimized for ML framework integration (PyTorch/TensorFlow) and returned by.query()or tag operations.
Compare Deep Lake with Data Management Tools
mainDeep Lake provides several advantages over traditional data management and storage formats:
- vs DVC: Deep Lake uses chunked compressed arrays for rapid streaming to ML models and is a Python package with an API, whereas DVC is primarily a CLI tool operating on traditional file structures.
- vs MosaicML MDS: Deep Lake uses a columnar storage format (MDS is row-wise) and offers more flexible compression (chunk-level and sample-level) and native version control/visualization.
- vs TensorFlow Datasets (TFDS): Deep Lake is compatible with both PyTorch and TensorFlow and supports streaming directly from the cloud, whereas TFDS is TensorFlow-only and requires local downloads.
- vs Zarr: Deep Lake is optimized for ML use cases (e.g., storing images as jpeg/png or video as mp4) and provides built-in version control, streaming, and ML framework connectivity, whereas Zarr is a general-purpose chunked array storage.
Deep Lake Core API Components
mainThe Deep Lake Python API is organized into several core components for managing multi-modal AI data:
- Dataset Classes: Manage data storage and access using
Dataset,ReadOnlyDataset, andDatasetView. - Column Classes: Interact with data columns using
ColumnandColumnView. - Types: Define data using basic numeric types or ML-optimized types.
- Schemas: Use pre-built schema templates for common data structures.
- Query Language: Use TQL (Deep Lake Query Language) for data operations.
- Metadata: Manage metadata at both the dataset and column levels.
- Version Control: Utilize versioning, history, branches, and tags for dataset management.
- Dataset Classes: Manage data storage and access using
Install MMDetection and dependencies for Deep Lake integration
mainTo use Deep Lake with MMDetection, you must install specific versions of PyTorch and MMCV, and then install MMDetection from the
dev-2.xbranch, as the Deep Lake integration currently supports MMDetection 2.x.python -m pip install torch==1.12.0+cu116 torchvision==0.13.0+cu116 -f https://download.pytorch.org/whl/torch_stable.html python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu116/torch1.12.0/index.html git clone -b dev-2.x https://github.com/open-mmlab/mmdetection.git cd mmdetection python3 -m pip install -e .python -m pip install torch==1.12.0+cu116 torchvision==0.13.0+cu116 -f https://download.pytorch.org/whl/torch_stable.html python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu116/torch1.12.0/index.html git clone -b dev-2.x https://github.com/open-mmlab/mmdetection.git cd mmdetection python3 -m pip install -e .Create or open a Deep Lake Dataset
mainYou can create a new dataset or open an existing one using the following methods:
deeplake.create(path): Creates a new dataset at the specified path.deeplake.open(path): Opens an existing dataset with full read-write access.deeplake.open_read_only(path): Opens an existing dataset with read-only access.deeplake.exists(path): Checks if a dataset exists at the given path.
Implement Vector Similarity Search with OpenAI Embeddings
mainTo perform similarity searches, you can use proprietary models (like OpenAI's
text-embedding-3-large) or open-source models from the MTEB leaderboard. You must generate numerical embeddings for your text data and store them in a Deep Lake column with anEmbeddingtype. This allows for cosine similarity comparisons during queries.import openai import os # Set your API key os.environ["OPENAI_API_KEY"] = "your_api_key" def embedding_function(texts, model="text-embedding-3-large"): if isinstance(texts, str): texts = [texts] texts = [t.replace("\n", " ") for t in texts] return [data.embedding for data in openai.embeddings.create(input = texts, model=model).data]Install ColPali engine and accelerate
mainTo use ColPali for end-to-end neural multi-modal search, install the required dependencies via pip:
!pip install colpali-engine accelerateSelect the Right Data Types for Efficiency
mainUse specialized Deep Lake types instead of generic arrays to enable efficient compression, storage, and searching:
deeplake.types.Image(): Enables efficient image compression/decompression.deeplake.types.Video(): Supports H264 compression.deeplake.types.Mesh(): Supports STL and PLY formats.deeplake.types.Text(): Enables efficient text search and indexing.deeplake.types.Embedding(): Optimized for vector similarity search.deeplake.types.Link(): Use this for images already in cloud storage to avoid data duplication by passing the URL instead of the raw bytes.