LLM的RAG技术全流程解析

📅 发布时间:2026/7/30 20:40:55
LLM的RAG技术全流程解析
llm 的 rag 技术全流程案例目录llm 的 rag 技术全流程案例1. 组装知识:`domain_knowledge.py` 的 `knowledge_for`2. 变成 prompt 文本:`llm_sections._knowledge_block`3. 塞进 prompt 并**指示 LLM 怎么用**(最关键)串起来的完整调用链"知识怎么被使用"分两件事:先把知识组装出来,再在 prompt 里指示 LLM 怎么用它。代码分别在这几处。1. 组装知识:domain_knowledge.py的knowledge_for按业务域分类,挑出该类适用的知识条目再合并(profile 自定义条目优先):cls = classify(business_domain) merged: List[str] = [] for item in (extra or []): s = str(item).strip() if s and s not in merged: merged.append(s) if cls == "software": base = list(SOFTWARE_KB) else: base = list(GENERAL_3DP) + list(_CLASS_KB.get(cls, [])) for item in base: if item not in merged: merged.append(item)