Skip to content

Commit 00e00bd

Browse files
authored
ADR: Chat Module Architecutre
Signed-off-by: Anastas Stoyanovsky <[email protected]>
1 parent e12aeea commit 00e00bd

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

docs/adr-chat-module-architecture.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# InstructLab Chat Module Architecture
2+
3+
## Context
4+
5+
InstructLab recently gained the ability of [retrieval augmented generation (RAG) for chat](https://github.com/instructlab/instructlab/pull/2886). The initial implementation is the simplest possible, inserting retrieved document chunks in the chat session history before submitting the user query to the target model. This is done by adding a retriever instance into the chat class which is called by submitting the user query as-is to the vector store as a search query to retrieve those chunks.
6+
7+
Tuning retrieval systems requires significant expertise and testing, and there are many techniques that may be needed specifically and only for that use case. For example, query reformulation or agentic approaches may be necessary to achieve reliable retrieval quality while being redundant and expensive in a non-retrieval scenario.
8+
9+
Having a single code path that conditionally executes various strategies based on a mixture of configuration, application state, and user input can quickly become difficult to maintain, debug, and even understand. That chat module in InstructLab would benefit from a principled approach; that is, to be purposefully architected before becoming a [big ball of mud](http://www.laputan.org/mud/?ref=blog.codinghorror.com).
10+
11+
## Decision
12+
13+
The InstructLab chat module will adopt a [strategy pattern](https://en.wikipedia.org/wiki/Strategy_pattern).
14+
15+
## Status
16+
17+
Accepted
18+
19+
## Consequences
20+
21+
* A refactor to the chat module will be necessary before additional feature work.
22+
* Encapsulation of different sets of logic as distinct pattern should decrease the risk of regression in one area when implementing another.
23+
* Division of responsibility will be clear from the code and project structure.
24+
* Testing different chat strategies will become simpler, with a smaller total testing surface.
25+
* Development velocity of RAG-specific improvements should be higher.
26+
* Code review will become simpler.
27+
* Risk of unsustainable maintenance overhead should be decreased.

0 commit comments

Comments
 (0)