---
title: "Discussion on \"Dependency Injection and Interface Segregation in a Python RAG Retriever\" | Hashnode"
description: "Discussion on \"Dependency Injection and Interface Segregation in a Python RAG Retriever\". LangGraph from Scratch, Phase 6: building the embedder, the vector store and the retriever as three separate pieces."
url: "https://hashnode.com/posts/dependency-injection-and-interface-segregation-in-a-python-rag-retriever/6ac0732fa00dc4c15f7313bd"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Dependency Injection and Interface Segregation in a Python RAG Retriever](https://thearchitectsmind.hashnode.dev/dependency-injection-and-interface-segregation-in-a-python-rag-retriever?utm_source=hashnode&utm_medium=feed)

LangGraph from Scratch, Phase 6: building the embedder, the vector store and the retriever as three separate pieces.

Oct 3 · 21 min read · thearchitectsmind.hashnode.dev  
Read the article

-   [#design-patterns](https://hashnode.com/tag/design-patterns)
-   [#rag](https://hashnode.com/tag/rag)
-   [#llm](https://hashnode.com/tag/llm)
-   [#python](https://hashnode.com/tag/python)

## Written by

[Jairam](https://hashnode.com/@jairamish)

@jairamish

  
[View profile](https://hashnode.com/@jairamish)

Surfing the Ai Wave

## Responses 1

Markdown supported · ⌘↵ to post

[Ahmet Özel](https://hashnode.com/@ahmetozel)

[Oct 4](https://hashnode.com/posts/dependency-injection-and-interface-segregation-in-a-python-rag-retriever/6ac0732fa00dc4c15f7313bd/comment/6ac29407cf078b4675ddcc51)

The same-length fake/Qwen comparison is the strongest part of the constructor argument: a plausible score can hide an incompatible coordinate system. If this store later becomes persistent, I would carry an embedding specification with it, including the model revision, dimensions, and query/document preprocessing, and validate that specification when opening the stored collection.

Handing the store one embedder prevents two local construction sites from disagreeing, but it cannot by itself detect an existing collection created under another configuration. A focused test could reopen a collection with a different model specification of the same dimension and require a clear failure before any search runs. That extends the invariant without enlarging the retriever's interface.
