Skip to content

Commit 78a5891

Browse files
authored
Merge pull request #164 from cooktheryan/framework
framework to be used by RAG for pipeline
2 parents ad293d2 + cd22a8a commit 78a5891

File tree

2 files changed

+126
-0
lines changed

2 files changed

+126
-0
lines changed

.spellcheck-en-custom.txt

+26
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Please keep this file sorted:
33
Abhishek
44
ADR
5+
agentic
56
Akash
67
AMDGPU
78
Anil
@@ -37,6 +38,8 @@ CWD
3738
Cynefin
3839
dataset
3940
datasets
41+
dateutil
42+
DBs
4043
DCO
4144
Dependabot
4245
dev
@@ -74,8 +77,11 @@ Guang
7477
hacky
7578
hardcode
7679
hardcoded
80+
Hema
7781
hipBLAS
82+
HyDE
7883
ilab
84+
Ilya
7985
impactful
8086
Inferencing
8187
init
@@ -85,16 +91,22 @@ io
8591
ISA
8692
init
8793
iters
94+
itertools
8895
Jie
8996
JIT
97+
jinja
9098
JSON
9199
Jupyter
92100
KAGGLE
93101
Kaggle
94102
Kaggle's
95103
Kai
104+
Kolchinsky
96105
Kubernetes
97106
Kumar
107+
Langchain
108+
langchain
109+
Langgraph
98110
lignment
99111
LLM
100112
llms
@@ -106,6 +118,7 @@ md
106118
Mergify
107119
Merlinite
108120
merlinite
121+
Milvus
109122
mimimum
110123
Miniforge
111124
Mixtral
@@ -117,14 +130,19 @@ modularize
117130
modularized
118131
Murdock
119132
Nakamura
133+
natively
134+
networkx
120135
num
136+
numpy
121137
NVidia
122138
Nvidia
123139
OCI
124140
Ollama
125141
ollama
126142
onboarding
127143
OpenStax
144+
openai
145+
OpenAI
128146
optimizers
129147
orchestrator
130148
ots
@@ -141,18 +159,22 @@ PNG
141159
POC
142160
Podman
143161
podman
162+
posthog
144163
postprocessing
145164
pre
146165
preprint
147166
preprocessing
148167
prereqs
149168
productize
169+
productized
150170
PR's
171+
PSFL
151172
Pydantic
152173
pyenv
153174
PyPI
154175
pyproject
155176
PyTorch
177+
pyyaml
156178
qlora
157179
qna
158180
quantized
@@ -188,6 +210,7 @@ specifiying
188210
src
189211
Srivastava
190212
Standup
213+
Staar
191214
subcommand
192215
subcommands
193216
subdirectory
@@ -204,6 +227,7 @@ th
204227
tl
205228
TODO
206229
tox
230+
tqdm
207231
traigers
208232
triager
209233
Triagers
@@ -217,7 +241,9 @@ USM
217241
UUID
218242
UUIDs
219243
UX
244+
vectordbs
220245
venv
246+
Veeradhi
221247
Vishnoi
222248
vllm
223249
watsonx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# RAG will use Haystack
2+
3+
| Created | Dec 4, 2024 |
4+
| -------- | -------- |
5+
| Authors | Ryan Cook, Ilya Kolchinsky, Hema Veeradhi |
6+
| Replaces | N/A |
7+
| Replaced by | N/A |
8+
9+
## What
10+
11+
This ADR defines the decision on the framework used to support the RAG pipeline for InstructLab. The Red Hat Emerging Technologies team is pushing for the adoption of Haystack to be used for the framework of the RAG offering. Haystack will handle the data ingestion and retrieval processes for this to be productized RAG solution.
12+
13+
NOTE: Speaking with Peter Staar on Dec 3, 2025 [the Docling team](https://github.com/DS4SD/docling) is aware of the efforts to potentially use Haystack and are already looking into adding the functionality for [support of Haystack](https://github.com/DS4SD/docling-haystack).
14+
15+
## Why
16+
17+
Multiple options for frameworks currently exist. During our initial analysis, the following options were the only ones to satisfy the basic requirements in terms of functionality, reliability and open-source availability:
18+
19+
- [Haystack](https://haystack.deepset.ai/)
20+
- [Langchain/Langgraph](https://www.langchain.com/)
21+
- [LlamaIndex](https://www.llamaindex.ai/)
22+
- [RAGFlow](https://ragflow.io/)
23+
24+
All of the above offer a variation of a modular pipeline architecture, where users can chain together components (like retrievers, readers, and generators) to process data in different stages.
25+
26+
Out of those, we propose to use Haystack for the following reasons:
27+
28+
1. **Focus on RAG.** Haystack is a framework specifically targeting RAG use cases and sophisticated RAG indexing and retrieval pipelines. While Langchain and LlamaIndex shine in their own areas, the former is a generalist framework and the latter has a different focus, namely building custom indices over data. Haystack provides functionality that is strongly tailored for RAG and includes a comprehensive library of out-of-the-box solutions for advanced RAG scenarios. As a result, many essential or soon-to-be-essential RAG capabilities can be implemented in a few lines in Haystack but require considerable work to be supported over Langchain or LlamaIndex. Some examples include hybrid retrieval, iterative RAG, HyDE, combining multiple ingestion sources, custom data preprocessing and metadata augmentation. As the decision discussed in this document involves only the RAG component of Instructlab, we believe that choosing the best RAG framework, as opposed to the best general LLM serving framework, would be more strategically correct.
29+
30+
2. **Maturity and stability.** Haystack is the most mature, established and stable product among the considered alternatives. It has been around for more time overall (since 2017) and accumulated more mileage. Haystack has an active, sizable and steadily growing community.
31+
32+
3. **Extensive vendor support.** Haystack natively supports all currently popular vector DBs and provides dedicated backends for incorporating them into its pipelines. Additionally, Haystack supports multiple models and model providers out-of-the-box.
33+
34+
4. **Enterprise-level performance.** Haystack is designed for production-grade scalability, supporting distributed systems and high-throughput applications. Moreover, and in contrast to the alternatives (of which only LlamaIndex showcases similar performance and scalability), Haystack is specifically optimized for efficient search and retrieval in the RAG setting.
35+
36+
5. **Ease of use and documentation.** Being strictly focused on RAG as opposed to taking a generalist approach, the learning curve of Haystack is less steep than that of Langchain. At the same time, Haystack offers extensive documentation and tutorials which are more well-organized and easy to use than those of LlamaIndex.
37+
38+
6. **Architecture.** Extending the previous point, Haystack can be seen as a middle ground between Langchain and LlamaIndex, sharing their benefits while only partially inheriting their drawbacks. Like the former, Haystack enables building custom flows and pipelines. Unlike Langchain though, Haystack does not try to be too abstract and general, strictly focusing on RAG and document search instead. As a result, Haystack is more straightforward to use, especially for users looking to implement custom and highly non-standard scenarios. On the other hand, like LlamaIndex, Haystack's performance is optimized towards data retrieval and indexing, but it offers a higher degree of flexibility and better interfaces for custom use cases.
39+
40+
7. **Actively maintained open source project under permissive license.** Haystack is very [actively](https://github.com/deepset-ai/haystack/pulse/monthly) [maintained](https://github.com/deepset-ai/haystack/issues?q=is%3Aissue+is%3Aclosed) and [supported](https://github.com/deepset-ai/haystack/discussions). [Tagged versions](https://github.com/deepset-ai/haystack/releases) are released on a regular basis and [trusted publishing automation](https://github.com/deepset-ai/haystack/actions/workflows/pypi_release.yml) is used. Haystack is licensed under Apache 2.0, and all of its dependencies (jinja2, lazy-imports, more-itertools, networkx, numpy, openai, pandas, posthog, python-dateutil, pyyaml, requests, tenacity, tqdm, typing-extensions) are licensed under Apache, MIT, BSD or PSFL.
41+
42+
8. **Published to PyPI via Trusted Publishing.**
43+
See [trusted-publishers](https://docs.pypi.org/trusted-publishers/) for more information on trusted publishing. Haystack satisfies the requirements for trusted publishing with this [Github Actions workflow](https://github.com/deepset-ai/haystack/actions/workflows/pypi_release.yml).
44+
45+
## Goals
46+
47+
- The primary goal here is to provide a framework optimized for RAG specifically and that the decision isn't focused on optimizing the choice on the best agentic pattern solution. However, Haystack can potentially implement many [agentic patterns](https://docs.haystack.deepset.ai/v1.22/docs/agent). Since Haystack provides the functionality [to build arbitrarily complex pipelines](https://docs.haystack.deepset.ai/docs/pipelines), it is possible to extend our RAG architecture to introduce nodes for tools, reasoning and agentic actions.
48+
49+
## Non-goals
50+
51+
- What can we ignore when making this decision?
52+
53+
## Decision
54+
55+
Upon acceptance of this integration our next step is to include additional ADRs for the subsequent components required for the RAG pipeline. Next up will be decisions on Milvus and containerized/non-containerized offerings of that solution.
56+
57+
Upon denial of this integration the team will need to go back and evaluate alternative technologies and ensure they meet the needs of the project goal and ensure they meet the larger project plan goals of a configurable RAG pipeline.
58+
59+
## How
60+
61+
A downstream should be generated of the [https://github.com/deepset-ai/haystack](https://github.com/deepset-ai/haystack) project.
62+
63+
## Alternatives
64+
65+
- Langchain/Langgraph
66+
- A generalist framework (as opposed to a RAG-focused solution)
67+
- Complicated as compared to the alternatives, steep learning curve
68+
- Lower performance in large-scale production environments than LlamaIndex and Haystack
69+
70+
- LlamaIndex
71+
- Limited flexibility and customization options as compared to the alternatives
72+
- Limited out-of-the-box support for building complex, multi-component pipelines as compared to Langchain and Haystack
73+
- Documentation is less well-maintained and more difficult to use as compared to the alternatives
74+
75+
- RAGFlow
76+
- Limited support for many of the mainstream vector DB providers
77+
- Limited scalability as compared to the alternatives
78+
79+
- Do not use a framework; write everything directly in Python or some other programming language
80+
- This would take longer to get started.
81+
- This would make it a lot more work to add more vector DBs since we'd need to add additional code for each vector DB we want to support. We would hide that work behind an abstraction layer the same way the frameworks do, but it is work to build and maintain the abstraction layer, and the frameworks do that for us (and have put a lot of time and effort into doing it well).
82+
- This would make it harder to bring in advanced functionality that the frameworks already provide. For example, Haystack provides support for RAG self-correction loops which we might want some day.
83+
- This might make it easier to bring in advanced functionality that the frameworks do not already provide. Frameworks provide an abstraction layer that is generally useful when you want to do things that the framework developers support but often counterproductive when you want to do things that the frameworks do not support. For example, if there is a call to the framework that collapses multiple atomic steps into a single function call, that generally makes it harder to insert your own logic in between those atomic steps.
84+
85+
## Risks
86+
87+
Future versions of Haystack can potentially introduce new dependencies, that could be:
88+
89+
1. Distributed under a non-permissive license (or not open source at all)
90+
2. Not regularly and/or properly maintained
91+
92+
If such a situation arises, the following actions can be taken on our end:
93+
94+
1. Pin to the old version that doesn't have that dependency. That's often OK for a while, but eventually we're likely to run into updates that we need (e.g., critical fixes, compatibility with new vectordbs, etc.).
95+
2. Fork the project to avoid the problematic dependencies.
96+
3. Move off of Haystack completely.
97+
98+
## References
99+
100+
- [https://github.com/deepset-ai/haystack](https://github.com/deepset-ai/haystack)

0 commit comments

Comments
 (0)