Skip to main content

Sycamore is an LLM-powered semantic data preparation system for building search applications.

Project description

SycamoreLogoFinal.svg

PyPI PyPI - Python Version Slack Docs License

Sycamore is a semantic data preparation system that makes it easy to transform and enrich your unstructured data and prepare it for search applications. It introduces a novel set-based abstraction that makes processing a large document collection as easy as reading a single document, and it comes with a scalable distributed runtime that makes it easy to go from prototype to production.

Features

  • Support for a variety of unstructured document formats, starting with PDF and HTML. More formats coming soon!
  • LLM-enabled entity extraction to automatically pull out semantically meaningful information from your documents with just a few examples.
  • Built-in data structures and transforms to make it easy to process large document collections. Sycamore is built around a data structure called the DocSet that represents a collection of unstructured documents, and supports transforms for chunking, manipulating, and augmenting these documents.
  • Easily embed your data using a variety of popular embedding models. Sycamore will automatically batch records and leverage GPUs where appropriate.
  • Scale your processing workloads from your laptop to the cloud without changing your application code. Sycamore is built on Ray, a distributed compute framework that can scale to hundreds of nodes.

Demo

Hosted on Loom

Resources

Installation

Sycamore currently runs on Python 3.9+ for Linux and Mac OS. To install, run

pip install sycamore-ai

For certain PDF processing operations, you also need to install poppler, which you can do with the OS-native package manager of your choice. For example, the command for Homebrew on Mac OS is

brew install poppler

Getting Started

The following shows a simple Sycamore script to read a collection of PDFs, partition them, compute vector embeddings, and load them into a local OpenSearch cluster. This script currently expects that you configured OpenSearch locally as described in the OpenSearch Docker documentation. You should adjust based on your setup.

See our documentation for lots more information and examples.

# Import and initialize the Sycamore library.
import sycamore
from sycamore.transforms.partition import UnstructuredPdfPartitioner
from sycamore.transforms.embed import SentenceTransformerEmbedder

context = sycamore.init()

# Read a collection of PDF documents into a DocSet.
doc_set = context.read.binary(paths=["/path/to/pdfs/"], binary_format="pdf")

# Segment the pdfs using the Unstructured partitioner.
partitioned_doc_set = doc_set.partition(partitioner=UnstructuredPdfPartitioner())

# Compute vector embeddings for the individual components of each document.
embedder=SentenceTransformerEmbedder(batch_size=100, model_name="sentence-transformers/all-MiniLM-L6-v2")
embedded_doc_set = partitioned_doc_set.explode() \
                                      .embed(embedder)

# Write the embedded documents to a local OpenSearch index.
os_client_args = {
    "hosts": [{"host": "localhost", "port": 9200}],
    "use_ssl":True,
    "verify_certs":False,
    "http_auth":("admin", "admin")
}
embedded_doc_set.write.opensearch(os_client_args=os_client_args, index_name="my_index_name")

Contributing

Check out our Contributing Guide for more information about how to contribute to Sycamore and set up your environment for development.

Project details


Download files

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

Source Distribution

sycamore_ai-0.1.7.tar.gz (11.0 MB view hashes)

Uploaded Source

Built Distribution

sycamore_ai-0.1.7-py3-none-any.whl (11.0 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page