Dayward AIWeChat Mini Program
RAG in 14 Days: From Retrieval to Trustworthy Answers
Week 1 · D7🔒 LockedAbout 5 hours

Week One Capstone: Assembling Six Days of Parts Into a One-Command Question-Answering Service, and a Retrospective

Assemble the previous six days — parsing, chunking, indexing, retrieval, assembly, generation — into a real service: one ingestion command, one question-answering endpoint, one configuration guide, all started with a single Docker command, then look back at the reasoning behind each decision this week and the technical debt left behind.

Today's goals 0/3

Sign in to tick these off and save your progress.

Today's Goals

  1. Split the ingestion and query pipelines into clear module boundaries, and explain why each module can be swapped independently
  2. Bring the service up along with its database with one command, and run the full path from feeding in documents to getting a cited answer
  3. List three pieces of technical debt left from this week, and say which day of week two each one gets paid off

No new theory today. Six days built six parts one at a time, and today assembles them into a machine that can open for business, then looks back at whether each of this week's decisions still holds. Come back and tick off the three goals.

Plain-Language Walkthrough

Six trades have signed off and the library is not open yet

All week we borrowed the library as a metaphor: the corpus is the collection, chunking is cutting books into entries, the index is the card catalog, retrieval is finding books by the catalog, and a citation is a reference at the end of a paper. As of today all six trades have finished their work — the books are in, the entries are cut, the catalog exists in both keyword and vector form, and the rules for finding books and attributing sources are settled.

But the library is not open, because nobody can walk in. Every lab of the first six days was a script that ran and exited: you typed one command, looked at the output, and closed it. Nobody uses a knowledge base that way in the real world; they want an address, somewhere to drop documents, and the ability to ask at any time.

Between six scripts and one service lies not a volume of code but boundaries. Inside a script everything may call everything, since it all disappears after one run; a service cannot. A service runs long, gets modified by others, and has half its parts swapped in week two without being rebuilt. So today's only real decision is how many pieces this machine cuts into and where the cuts go.

The criterion for a cut is not similar code volume and not grouping by function but this sentence:

Whichever layer is most likely to be replaced wholesale is where the cut goes.

Walk this week by that standard and the three cuts are clear: an embedding model changes several times a year, and one change voids every vector in the store and forces a full recomputation; storage may move from PostgreSQL to a dedicated vector store, and either way both pipelines must speak through it; and the chunking strategy still gets tuned repeatedly in week two.

The first cut lands on embedding. The interface is D2's signature with not one word changed:

embed.ts
// The course-wide vectorization interface: this signature for all 14 days, never renamed
export type Embedder = (
  texts: string[],
  opts?: { dimensions?: number }
) => Promise<number[][]>
 
export interface EmbeddingBackend {
  name: string // written into chunk_embeddings.model, to tell whether stored vectors came from the current model
  dimensions: number
  embed: Embedder
}
 
export function createEmbedder(cfg) {
  // Three backends, one signature: offline hash, a local open model, an API.
  // Code above never knows which one it got
  if (useMock) return { name: `mock-hash-${dims}`, dimensions: dims, embed: hashBackend }
  return { name: `${cfg.model}-${dims}`, dimensions: dims, embed: openaiBackend }
}

Note that this abstraction's reason is not the platitude that programming to an interface is good practice but something very concrete: a model change genuinely happens once a year, and each time you want to edit one configuration entry and run one rebuild rather than hunting call sites across the repository. The cost is equally concrete — one more layer of indirection and one more hop while debugging. Whether it is worth it depends on whether that event will actually happen. Do not abstract what will not happen; that is over-design.

Sign in and link WeChat to read

Sign in, then link your WeChat mini program account on the account page. Linked accounts share one free article per day. Unlock additional articles with rewarded videos in the mini program.

Mini program QR code

Scan in WeChat to open Dayward AI. Open the same course and chapter, choose the rewarded video, then refresh this page after completion.

Interview questions

  • How would you draw the module boundaries of a RAG system, and which layer most needs to be swappable? Why?你会怎么划分一个检索增强生成系统的模块边界?其中哪一层最应该做成可替换的,为什么?
    Common in ChinaCommon overseasBasic#architecture#modularity#embeddings

    🔒 Unlock this chapter to see the answer keys.

  • What should the ingestion path and the query path share, and what concretely goes wrong when you over-share?摄取链路和查询链路应该共享哪些代码?强行复用会带来什么具体问题?
    Common in ChinaCommon overseasIntermediate#architecture#ingestion#retrieval

    🔒 Unlock this chapter to see the answer keys.

  • What three checks would you run before shipping a retrieval QA service, and why those three?一个检索问答服务上线前你会做哪三项检查?为什么偏偏是这三项?
    Common in ChinaCommon overseasIntermediate#production-readiness#citations#refusal

    🔒 Unlock this chapter to see the answer keys.

  • What is the biggest risk in the RAG service you just assembled, and how would you prove that judgment?你刚拼出来的这个检索问答系统,现在最大的风险在哪里?你打算怎么证明这个判断?
    Common in ChinaCommon overseasDeep dive#evaluation#risk-assessment#retrospective

    🔒 Unlock this chapter to see the answer keys.

Comments