Dense embeddings did not make lexical retrieval obsolete: every serious RAG system still runs BM25 or TF-IDF alongside them, because exact tokens like error codes and product SKUs are where embeddings quietly fail.
Implement tfidf(documents) taking a list of strings and returning (matrix, vocabulary):
vocabulary is the sorted list of unique terms across all documentsmatrix has shape (n_documents, n_terms) with cell [i, j] = tf × idfDefinitions to use exactly:
tf(t, d) = count of t in d divided by the total token count of didf(t) = log(N / df(t)) where N is the document count and df(t) the number of documents containing tA term appearing in every document gets idf = log(1) = 0 and contributes nothing. That is the property that makes the whole thing work.
Build the architecture on a canvas: place the components, configure them, connect them into a data flow, and write a short reason for each one. The AI reviewer grades your design against a rubric written specifically for this problem.
Minimum 5 components · needs a wide desktop screen