File size: 19,260 Bytes
55a76a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
��Express Analytics  |  Intern Take-Home Assignment



EXPRESS ANALYTICS

AI/ML Engineer Intern



TAKE-HOME ASSIGNMENT

RAG-Based Technical Documentation Assistant



Build a Retrieval-Augmented Generation system with a self-corrective LangGraph workflow



Role: AI/ML Engineer - Intern



Duration: 2 days



Submission: GitHub Repository + README



Stack: Python, LangGraph, FastAPI



Please read the entire document before starting.



Overview



Build a RAG-powered technical documentation assistant that can answer questions about a set of

technical documents (e.g., Python library docs, API references, or framework guides). The system should

use a LangGraph workflow with retrieval, document grading, and answer generation nodes. It should be

served via a simple FastAPI application.



This assignment evaluates your ability to build a RAG pipeline, work with LangGraph�s graph-based

workflows. There is no single correct architecture � we want to see how you think.



Scenario



You are provided with a small corpus of technical documentation (3�5 documents, such as pages from a

Python library�s official docs, README files, or API references). A user submits a natural language

question, and your system should retrieve the most relevant chunks, verify their relevance, generate an

answer with citations, and handle cases where the retrieved context is insufficient.



You may choose the corpus yourself � for example, you could use documentation from LangChain,

FastAPI, Pydantic, or any other technical project you find interesting. Provide the documents (or URLs to

fetch them) in your repository.



System Architecture



LangGraph Workflow



Your system should be implemented as a LangGraph StateGraph with the following nodes. You may add

additional nodes if you see fit.



Node 1: Query Analysis



Takes the user�s raw question and prepares it for retrieval. This node should:



�  Rewrite or expand the query to improve retrieval quality (e.g., add synonyms, clarify ambiguity)



CONFIDENTIAL Page 1



Express Analytics  |  Intern Take-Home Assignment



�  Optionally classify the query type (conceptual, how-to, troubleshooting, API reference) to guide



downstream processing



Node 2: Retrieval



Searches the vector store for relevant document chunks. This node should:



�  Use a vector store (e.g., ChromaDB, FAISS) to perform similarity search

�  Return the top-k most relevant chunks along with their source metadata



Node 3: Document Grading



Evaluates whether the retrieved documents are actually relevant to the question. This is the

self-corrective component of the pipeline. The node should:



�  Use an LLM to grade each retrieved chunk as �relevant� or �irrelevant�

�



If all documents are irrelevant, route to a fallback path (e.g., rewrite the query and re-retrieve, or

return an �I don�t know� response)

If some documents are relevant, filter out the irrelevant ones and proceed



�



Node 4: Generation



Generates the final answer using the relevant documents as context. This node should:



�  Use an LLM to generate a clear, accurate answer grounded in the retrieved context

�



Include citations or references to the source documents in the response



Conditional Edges (Routing Logic)



Your graph should include at least one conditional edge that routes based on the document grading

outcome:



�

�



If relevant documents are found ? proceed to Generation

If no relevant documents are found ? rewrite query and re-retrieve (with a retry limit).



Think carefully about your state schema. What data flows between nodes? How do you track the

number of retries? This is a core evaluation criterion.



Document Ingestion Pipeline



Before the workflow can run, you need to ingest and index your technical documents. Your ingestion

pipeline should:



1.  Load documents from files (Markdown, text, or HTML) or fetch them from URLs

2.  Split documents into chunks using an appropriate strategy (consider chunk size, overlap, and



how technical content should be split)



3.  Generate embeddings for each chunk using an embedding model (e.g., OpenAI embeddings,



sentence-transformers, or any other provider)



4.  Store the embeddings in a vector store (ChromaDB or FAISS recommended for simplicity)



The ingestion can be a standalone script or run as part of application startup. Document your chunking

strategy and explain why you chose it.



CONFIDENTIAL Page 2



Express Analytics  |  Intern Take-Home Assignment



API Requirements



Serve the system via FastAPI. At minimum, your API should support the following endpoints:



Method



Endpoint



Purpose



Notes



POST



POST



GET



/query



/ingest



Submit a question



Returns answer with sources



Ingest new documents



Accepts file uploads or URLs



/documents



List indexed documents



Shows what�s in the corpus



POST



/feedback



Submit feedback on an

answer



Thumbs up/down + optional

comment



You may add additional endpoints as you see fit. Consider error handling, input validation, and meaningful

HTTP status codes.



Bonus (Optional)



These are not required but will strengthen your submission if you have time:



�  Hallucination check: Add a node that verifies the generated answer is actually supported by the



retrieved context (inspired by Self-RAG)



�  Web search fallback: If the vector store has no relevant results, fall back to a web search (e.g.,



using Tavily, Serper or Exa) before generating the answer



�  Conversation memory: Support follow-up questions by maintaining chat history within a session

�  Simple UI: A minimal Streamlit or Gradio frontend for interactive Q&A



Deliverables



�  A GitHub repository (public or private � invite us if private) containing all source code

�  A README.md with: project overview, architecture diagram or description, setup instructions



(environment, API keys, dependencies), how to run the application, example API requests and

responses, and a section on design decisions and tradeoffs



�  A working FastAPI application that can be run locally

�  The document corpus you used (or a script to fetch it)

�  A brief write-up (can be in the README) explaining: your thought process and reasoning behind

the architecture and the components of your workflow, what you would improve with more time,

any assumptions you made, and your chunking/embedding strategy choices



CONFIDENTIAL Page 3



Express Analytics  |  Intern Take-Home Assignment



LangGraph Cookbooks & References



The following official and community resources will help you understand the patterns needed for this

assignment. We strongly recommend reviewing these before you start coding.



Official LangGraph Tutorials



�  Agentic RAG Tutorial � Build a custom RAG agent with LangGraph (retrieval, grading, query



rewriting)

https://docs.langchain.com/oss/python/langgraph/agentic-rag



�  Adaptive RAG Tutorial � Combines query routing with self-corrective RAG (closest to this



assignment�s architecture)

https://langchain-ai.github.io/langgraph/tutorials/rag/langgraph_adaptive_rag/



�  Corrective RAG (CRAG) Notebook � Document grading and query rewriting patterns from the



CRAG paper

https://github.com/langchain-ai/langgraph/blob/main/examples/rag/langgraph_crag.ipynb



�  Self-RAG Blog Post � Overview of self-reflective RAG concepts and LangGraph



implementation

https://blog.langchain.com/agentic-rag-with-langgraph/



Community Tutorials



�  LangChain Open Tutorial � Adaptive RAG � Step-by-step walkthrough with groundedness



checking and web search modules

https://langchain-opentutorial.gitbook.io/langchain-opentutorial/17-langgraph/02-structures/06-langgraph-age

ntic-rag



�  FutureSmart AI � LangGraph RAG Agent Tutorial � Covers basics to multi-agent RAG, good



for understanding the progression

https://blog.futuresmart.ai/langgraph-rag-agent-tutorial-basics-to-advanced-multi-agent-ai-chatbot



Reference: Tools & APIs You Can Use



Below are some tools and APIs that may be useful. You are not limited to these � use whatever you think

is appropriate.



LLM Providers (pick one)



Provider



OpenAI



Anthropic



Groq



Notes



Free Tier



GPT-4o-mini recommended for

cost efficiency



Pay-as-you-go (low cost for this

project)



Claude 3.5 Sonnet / Haiku



Pay-as-you-go



Very fast inference, Llama & Mixtral

models



Generous free tier



Google Gemini



Gemini Flash for fast, cheap

inference



Free tier available



CONFIDENTIAL Page 4



Express Analytics  |  Intern Take-Home Assignment



Vector Stores



Tool



Notes



Free Tier



ChromaDB



FAISS



Simple, runs locally, great for

prototyping



Free, open source



Facebook�s similarity search, very

fast



Free, open source



Web Search (for bonus fallback)



API



Purpose



Free Tier



Tavily (tavily.com)



AI-optimized web search



1,000 searches/month free



Serper (serper.dev)



Google Search results via API



2,500 free queries on signup



Important Notes



�  You may use any LLM provider for the pipeline (OpenAI, Anthropic, Groq, Google, etc.)

�  Focus on getting the core RAG pipeline right before attempting bonus features

�



If you run into time constraints, prioritize the LangGraph workflow + document grading logic over

additional features



�  We value clear thinking and honest documentation of tradeoffs over feature completeness

�  Don�t hesitate to ask clarifying questions before starting



Good luck! We look forward to reviewing your work.



CONFIDENTIAL Page 5