Tool

Load and Process Data with Lilac

LlamaIndex reader that pulls a cleaned Lilac dataset back into LlamaIndex documents.

Works with llama indexlangchainlilac

74
Spark score
out of 100
Updated 2 days ago
Version 0.14.23
Models

Add to Favorites

Why it matters

Integrate your unstructured data analysis pipeline with LlamaIndex and LangChain. This asset allows you to load data into Lilac for cleaning and enrichment, then bring it back into LlamaIndex for downstream AI applications.

Outcomes

What it gets done

01

Load data from LlamaIndex into Lilac for analysis and cleaning.

02

Enrich and structure unstructured data using Lilac's AI capabilities.

03

Load cleaned and processed data from Lilac back into LlamaIndex Documents.

04

Prepare data for use in LlamaIndex and LangChain applications.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-reader-readers-lilac | bash

Overview

Lilac reader

The Lilac Reader closes the loop between LlamaIndex and Lilac: after cleaning, labeling, or structuring a dataset in Lilac, LilacReader pulls it back into LlamaIndex documents by project directory and dataset name. Use it when you have already cleaned or labeled a dataset in Lilac and need it back as LlamaIndex documents. It requires Lilac already running locally with a project set up.

What it does

The Lilac Reader lets you bring cleaned, enriched data back from Lilac -- an open-source tool for analyzing, enriching, and cleaning unstructured data with AI -- into LlamaIndex documents. The workflow runs both directions: load data into LlamaIndex with any loader (for example ArxivReader), push it into a Lilac dataset for cleaning, labeling, or structuring, then pull the cleaned dataset back into LlamaIndex documents with LilacReader.

When to use - and when NOT to

Use it when you have already cleaned, labeled, or structured a dataset in Lilac and need it back as LlamaIndex documents for indexing or querying. It assumes you already have Lilac running locally with a project directory and dataset set up, so it is not usable without first running Lilac and creating that project.

Inputs and outputs

Install with:

pip install llama-index-readers-papers

pip install llama-index-readers-lilac

Getting data into Lilac (from any LlamaIndex loader, here ArxivReader):

import lilac as ll

from llama_index.readers.papers import ArxivReader

loader = ArxivReader()
documents = loader.load_data(search_query="au:Karpathy")

ll.set_project_dir("./data")

ll.create_dataset(
    config=ll.DatasetConfig(
        namespace="local",
        name="arxiv-karpathy",
        source=ll.LlamaIndexDocsSource(
            documents=documents
        ),
    )
)

ll.start_server(project_dir="./data")

Bringing cleaned data back into LlamaIndex:

from llama_index.core import VectorStoreIndex, download_loader

from llama_index.readers.lilac import LilacReader

loader = LilacReader()
documents = loader.load_data(
    project_dir="~/my_project",
    dataset="local/arxiv-karpathy",
)

index = VectorStoreIndex.from_documents(documents)

index.query("How are ImageNet labels validated?")

LilacReader.load_data takes a project_dir (your local Lilac project directory) and a dataset name (the namespace and name of the dataset within that project).

Who it's for

Developers who use Lilac to clean, structure, or label their data and need the cleaned result back inside a LlamaIndex or LangChain pipeline.

Source README

Lilac reader

pip install llama-index-readers-papers

pip install llama-index-readers-lilac

Lilac is an open-source product that helps you analyze, enrich, and clean unstructured data with AI.

It can be used to analyze, clean, structure, and label data that can be used in downstream LlamaIndex and LangChain applications.

Lilac projects

This assumes you've already run Lilac locally, and have a project directory with a dataset. For more details on Lilac projects, see Lilac Projects

You can use any LlamaIndex loader to load data into Lilac, clean data, and then bring it back into LlamaIndex Documents.

Usage

LlamaIndex => Lilac

See this notebook for getting data into Lilac from LlamaHub.

import lilac as ll

### See: https://llamahub.ai/l/papers-arxiv
from llama_index.readers.papers import ArxivReader

loader = ArxivReader()
documents = loader.load_data(search_query="au:Karpathy")

### Set the project directory for Lilac.
ll.set_project_dir("./data")

### This assumes you already have a lilac project set up.
### If you don't, use ll.init(project_dir='./data')
ll.create_dataset(
    config=ll.DatasetConfig(
        namespace="local",
        name="arxiv-karpathy",
        source=ll.LlamaIndexDocsSource(
            # documents comes from the loader.load_data call in the previous cell.
            documents=documents
        ),
    )
)

### You can start a lilac server with. Once you've cleaned the dataset, you can come back into GPTIndex.
ll.start_server(project_dir="./data")

Lilac => LlamaIndex Documents

from llama_index.core import VectorStoreIndex, download_loader

from llama_index.readers.lilac import LilacReader

loader = LilacReader()
documents = loader.load_data(
    project_dir="~/my_project",
    # The name of your dataset in the project dir.
    dataset="local/arxiv-karpathy",
)

index = VectorStoreIndex.from_documents(documents)

index.query("How are ImageNet labels validated?")

This loader is designed to be used as a way to load data into GPT Index and/or subsequently used in a LangChain Agent.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.