About The Project
Swiftide is a data indexing, processing and query library, tailored for Retrieval Augmented Generation (RAG). When building applications with large language models (LLM), these LLMs need access to external resources. Data needs to be transformed, enriched, split up, embedded, and persisted. Queries can then be augmented by retrieving the indexed data and generating an answer. It is build in Rust, using parallel, asynchronous streams and is blazingly fast.
With Swiftide, you can build your AI application from idea to production in a few lines of code.
While working with other Python-based tooling, frustrations arose around performance, stability, and ease of use. Thus, Swiftide was born. Indexing performance went from tens of minutes to a few seconds.
Part of the bosun.ai project. An upcoming platform for autonomous code improvement.
We <3 feedback: project ideas, suggestions, and complaints are very welcome. Feel free to open an issue.
[!CAUTION] Swiftide is under heavy development and can have breaking changes while we work towards 1.0. Documentation here might fall short of all features, and despite our efforts be slightly outdated. Expect bugs. We recommend to always keep an eye on our github and api documentation. If you found an issue or have any kind of feedback we'd love to hear from you in an issue.
Latest updates on our blog :fire:
- Release - Swiftide 0.7 (2024-07-12)
- Building a code question answering pipeline (2024-07-13)
- Release - Swiftide 0.6 (2024-07-12)
- Release - Swiftide 0.5 (2024-07-1)
Example
.filter_cached
.then_chunk
.then
.then
.then_in_batch
.then_store_with
.run
.await?;
from_loader
You can find more examples in /examples
Vision
Our goal is to create a fast, extendable platform for data indexing and querying to further the development of automated LLM applications, with an easy-to-use and easy-to-extend api.
Features
- Fast streaming indexing pipeline with async, parallel processing
- Experimental query pipeline
- Integrations with OpenAI, Groq, Redis, Qdrant, FastEmbed, and Treesitter
- A variety of loaders, transformers, semantic chunkers, embedders, and more
- Bring your own transformers by extending straightforward traits or use a closure
- Splitting and merging pipelines
- Jinja-like templating for prompts
- Store into multiple backends
tracing
supported for logging and tracing, see /examples and thetracing
crate for more information.
In detail
Feature | Details |
---|---|
Supported Large Language Model providers | OpenAI (and Azure) - All models and embeddings AWS Bedrock - Anthropic and Titan Groq - All models |
Loading data | Files Scraping Other pipelines and streams |
Transformers and metadata generation | Generate Question and answerers for both text and code (Hyde) Summaries, titles and queries via an LLM Extract definitions and references with tree-sitter |
Splitting and chunking | Markdown Code (with tree-sitter) |
Storage | Qdrant Redis |
Getting Started
Prerequisites
Make sure you have the rust toolchain installed. rustup Is the recommended approach.
To use OpenAI, an API key is required. Note that by default async_openai
uses the OPENAI_API_KEY
environment variables.
Other integrations will need to be installed accordingly.
Installation
-
Set up a new Rust project
-
Add swiftide
-
Enable the features of integrations you would like to use in your
Cargo.toml
-
Write a pipeline (see our examples and documentation)
Usage and concepts
Before building your stream, you need to enable and configure any integrations required. See /examples.
A stream starts with a Loader that emits Nodes. For instance, with the Fileloader each file is a Node.
You can then slice and dice, augment, and filter nodes. Each different kind of step in the pipeline requires different traits. This enables extension.
Nodes have a path, chunk and metadata. Currently metadata is copied over when chunking and always embedded when using the OpenAIEmbed transformer.
- from_loader
(impl Loader)
starting point of the stream, creates and emits Nodes - filter_cached
(impl NodeCache)
filters cached nodes - then
(impl Transformer)
transforms the node and puts it on the stream - then_in_batch
(impl BatchTransformer)
transforms multiple nodes and puts them on the stream - then_chunk
(impl ChunkerTransformer)
transforms a single node and emits multiple nodes - then_store_with
(impl Storage)
stores the nodes in a storage backend, this can be chained
Additionally, several generic transformers are implemented. They take implementers of SimplePrompt
and EmbedModel
to do their things.
[!NOTE] No integrations are enabled by default as some are code heavy. Either cherry-pick the integrations you need or use the "all" feature flag.
[!WARNING] Due to the performance, chunking before adding metadata gives rate limit errors on OpenAI very fast, especially with faster models like 3.5-turbo. Be aware.
For more examples, please refer to /examples and the Documentation
Roadmap
See the open issues for a full list of proposed features (and known issues).
Contributing
Swiftide is in a very early stage and we are aware that we lack features for the wider community. Contributions are very welcome. :tada:
If you have a great idea, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
If you just want to contribute (bless you!), see our issues.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'feat: Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
See CONTRIBUTING for more
License
Distributed under the MIT License. See LICENSE
for more information.