惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy & Cybersecurity Law Blog
SecWiki News
SecWiki News
T
Troy Hunt's Blog
Y
Y Combinator Blog
V
V2EX
美团技术团队
Last Week in AI
Last Week in AI
S
Security @ Cisco Blogs
IT之家
IT之家
博客园_首页
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
阮一峰的网络日志
阮一峰的网络日志
AI
AI
罗磊的独立博客
人人都是产品经理
人人都是产品经理
H
Hacker News: Front Page
N
News and Events Feed by Topic
P
Privacy International News Feed
V2EX - 技术
V2EX - 技术
Recent Commits to openclaw:main
Recent Commits to openclaw:main
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
GbyAI
GbyAI
L
LINUX DO - 热门话题
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Azure Blog
Microsoft Azure Blog
Martin Fowler
Martin Fowler
月光博客
月光博客
WordPress大学
WordPress大学
Latest news
Latest news
Google DeepMind News
Google DeepMind News
S
Schneier on Security
N
Netflix TechBlog - Medium
腾讯CDC
T
Tailwind CSS Blog
TaoSecurity Blog
TaoSecurity Blog
S
Secure Thoughts
L
LINUX DO - 最新话题
Project Zero
Project Zero
Cyberwarzone
Cyberwarzone
D
DataBreaches.Net
Webroot Blog
Webroot Blog
B
Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
H
Help Net Security
L
LangChain Blog
A
Arctic Wolf
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Part 3 — Vector Retrieval in Domain-Specific Terminology Scenarios: From Model Selection to Dual Validation
James Lee · 2026-06-18 · via DEV Community

This article covers the third layer of the full-stack architecture: the Hybrid Retrieval Layer. Core engineering challenge: general-purpose embedding models drift on domain-specific terminology, and single-path vector retrieval cannot distinguish fine-grained semantic differences.

📦 Source code: production-rag-engineeringesg/services/embedding_service.py, esg/services/search_service.py


0. The Pain Point

Part 1 built the knowledge base. Part 2 handled chunking. The first version of the system used text-embedding-ada-002 for retrieval — OpenAI's most mainstream embedding model at the time.

The results:

  • Recall rate: 82% — 18% of relevant content simply wasn't found
  • False positive rate: 12% — querying "Scope 1 emission intensity" returned "Scope 3 emissions"
  • "Low-carbon" and "zero-carbon" were close together in vector space — the system couldn't tell them apart

The first instinct was to tune the similarity threshold: drop from 0.85 to 0.75? To 0.65?

After a full round of testing, recall went up — but false positives went up in lockstep. Lower threshold = cast a wider net = pull in more irrelevant content.

This wasn't a threshold problem. It was a model problem.

More precisely: it was a semantic drift problem caused by a general-purpose model operating on specialized domain text. ada-002's training corpus is predominantly general text. ESG domain terminology is poorly encoded in its vector space — related terms end up far apart, unrelated terms end up close together.

This problem isn't unique to ESG. Legal statutes, medical diagnostics, financial compliance — any domain with dense specialized terminology will hit the same semantic drift when using a general-purpose embedding model.


1. What Retrieval Needs to Solve

Vector retrieval in domain-specific scenarios has three core tensions:

Tension 1: General-purpose models drift on specialized terminology

"Carbon footprint" and "carbon accounting" have similar meanings in general text, but in ESG compliance they refer to different things — the former is product lifecycle emissions, the latter is a data measurement methodology. They are not interchangeable. General-purpose models can't distinguish this fine-grained difference.

Tension 2: High similarity score ≠ semantic relevance

Vector similarity measures "distance in vector space," not "business semantic relevance." "Energy consumption" and "spill incidents" may be close in a general vector space (both are environment-related), but they map to completely different compliance clauses.

Tension 3: Single-path vector retrieval can't distinguish fine-grained variants of the same concept

GRI has three emission scopes: Scope 1, Scope 2, and Scope 3. In vector space, all three are close together. Single-path retrieval easily returns Scope 3 content when querying for Scope 1.

The solution isn't a single fix — it's three progressive layers: model selection → semantic drift mitigation → dual validation.


2. Embedding Model Selection: Not "Pick the Most Expensive"

Test methodology:

We sampled 200 ESG domain terms as queries — covering Environmental, Social, and Governance categories, including long-form terms like "Scope 1 emission intensity calculation" and short terms like "carbon intensity." We ran each query against the GRI knowledge base, manually annotated ground truth, and compared Top-3 recall accuracy across four models.

Four-model comparison:

Model Recall Rate Cost per item Deployment Elimination reason
text-embedding-3-large 91% $0.0001 API ✅ Final selection
text-embedding-ada-002 85% $0.00006 API Unstable long-text encoding; Scope term confusion
BGE-M3 82% $0 (local) Self-hosted Limited ESG training data; poor fine-grained term distinction
Tongyi Qianwen Embedding 83% Low API Acceptable Chinese ESG terms; poor cross-language consistency

Why not BGE-M3 (self-hosted)?

The intuition is that self-hosting is cheaper — but when you run the full cost calculation:

Dimension text-embedding-3-large BGE-M3 self-hosted
Monthly API / server cost ~$8/mo (100K items, batch discount) ~$50/mo (GPU instance)
Development adaptation cost 0 (out of the box) 2 weeks (domain adaptation + fine-tuning)
Recall rate 91% 82%
Long-text encoding stability Stable Noticeable drift on long terms

Self-hosting costs 6x more per month, requires 2 weeks of adaptation work, and delivers 9% lower recall.

This isn't "expensive = better." It's model selection based on a clear ROI calculation.

How is data security handled?

Text is desensitized before upload — regex identifies and replaces sensitive information (company names, revenue figures, client data). Only ESG terminology and report fragments are uploaded, with no corporate identity information. We also signed OpenAI's Data Processing Agreement, satisfying compliance requirements.


3. Semantic Drift Mitigation: Disambiguate Before Retrieval

Switching to a better model improved recall from 82% to 91% — but false positive rate remained at 12%.

Root cause analysis: Even with 3-large, fine-grained ESG term distinction is still insufficient. "Low-carbon" and "zero-carbon" have similarity 0.85. "Scope 1 emission intensity" and "Scope 3 emissions" have similarity 0.78. The model treats them as semantically close — but in business terms they are completely different.

The solution is a three-layer augmentation strategy that layers domain knowledge on top of the model:

Layer 1: Domain term dictionary (500+ entries)

The dictionary maps professional terms, abbreviations, and synonyms:

ESG_TERM_DICT = {
    "Scope 1": {
        "definition": "Direct GHG emissions from sources owned or controlled by the organization",
        "synonyms": ["direct emissions", "direct carbon emissions", "Scope 1 emissions"],
        "domain": "Environmental",
        "distinct_from": ["Scope 2", "Scope 3"]  # explicit disambiguation
    },
    "low-carbon": {
        "definition": "Reduced carbon emissions, but emissions still exist",
        "distinct_from": ["zero-carbon", "net-zero emissions"],  # key: explicitly not zero-carbon
        "domain": "Environmental"
    },
    # 500+ entries...
}

Dictionary data sourced from three layers:

  1. GRI official standard documents → 200+ core terms extracted
  2. 10 industry ESG reports → 300+ commonly used terms extracted
  3. ESG domain experts → synonyms and fine-grained disambiguation relationships annotated

Layer 2: Domain hints embedded in prompt

At encoding time, dictionary information is embedded in the prompt to give the model precise semantic context:

def build_embedding_prompt(text: str, term: str = None) -> str:
    base_prompt = f"Encode text: {text}"

    if term and term in ESG_TERM_DICT:
        term_info = ESG_TERM_DICT[term]
        domain_hint = f"""
Domain context:
- {term} is an ESG {term_info['domain']} domain term
- Definition: {term_info['definition']}
- Synonyms: {', '.join(term_info.get('synonyms', []))}
- Distinct from: {', '.join(term_info.get('distinct_from', []))}
"""
        return base_prompt + domain_hint

    return base_prompt

Layer 3: Post-retrieval reranking

After retrieving Top 5 candidates, the term dictionary is used to rerank results — chunks containing standard synonyms get a score boost; chunks containing terms in the "distinct_from" relationship get downweighted:

def rerank_results(query_term: str, results: list) -> list:
    for result in results:
        # Contains standard synonym → boost score
        if any(syn in result["text"] for syn in
               ESG_TERM_DICT.get(query_term, {}).get("synonyms", [])):
            result["rerank_score"] += 0.1

        # Contains "distinct_from" term → penalize score
        if any(dt in result["text"] for dt in
               ESG_TERM_DICT.get(query_term, {}).get("distinct_from", [])):
            result["rerank_score"] -= 0.15

    return sorted(results, key=lambda x: x["rerank_score"], reverse=True)

Two real incident cases:

Case 1: Low-carbon vs. zero-carbon

  • Problem: querying "low-carbon" returned zero-carbon content with similarity 0.85
  • Root cause: model treats both as "reducing carbon emissions" — semantically close
  • Fix: dictionary explicitly marks distinct_from relationship; prompt emphasizes "low-carbon ≠ zero-carbon"
  • Result: similarity dropped from 0.85 to 0.65; retrieval now distinguishes them precisely

Case 2: Scope 1 emission intensity vs. Scope 3 emissions

  • Problem: querying "Scope 1 emission intensity" returned Scope 3 content with similarity 0.78
  • Root cause: model treats Scope 1 and Scope 3 as both "emissions-related" — close in vector space
  • Fix: dictionary gives each Scope its own precise definition and mutual distinct_from relationships
  • Result: similarity dropped from 0.78 to 0.55; Scope confusion false positive rate < 1%

Three-layer augmentation results: false positive rate 12% → 3%, term matching accuracy 82% → 90%.


4. Dual Validation: A High Score on One Path Isn't Enough

After semantic drift mitigation, one problem remained: high vector similarity, but business semantics are unrelated.

Typical case: querying for GRI 306 waste management clauses returned a report chunk about "spill incident handling" with similarity 0.82. In vector space, the two are genuinely close (both are environmental incident-related) — but "waste management" and "spill incidents" are completely different compliance clauses.

The fundamental limitation of single-path vector retrieval: vector similarity is a statistical measure of "text distance in vector space" — not a business measure of "semantic relevance."

The solution is dual validation: keyword hard match + vector similarity — both must pass to count as a hit.

def dual_verify(query: dict, candidate_chunk: dict) -> bool:
    # Condition 1: vector similarity threshold met
    vector_match = candidate_chunk["similarity_score"] >= 0.7

    # Condition 2: keyword hard match (core keywords from the queried clause must appear)
    required_keywords = query.get("required_keywords", [])
    keyword_match = sum(
        1 for kw in required_keywords
        if kw in candidate_chunk["text"]
    ) >= max(1, len(required_keywords) // 2)  # at least half the keywords must match

    return vector_match and keyword_match

Three-layer false positive filter (complete flow):

Layer 1 — Keyword hard match (millisecond-level)
  When querying for GRI 305 (greenhouse gas emissions),
  retrieved chunks must contain at least 2 of:
  ["Scope 1", "Scope 2", "emissions volume", "calculation method"]
  → Filters out chunks like "spill incidents" that score high but fail keyword match
  → Eliminates ~60% of obvious false positives

Layer 2 — LLM semantic cross-validation (< 1s)
  For chunks passing Layer 1, ask the LLM:
  "Does this content actually answer the disclosure points required by the clause?"
  → Filters out chunks that "mention emissions but lack calculation method and data source"
  → Eliminates ~30% of remaining semantically irrelevant chunks

Layer 3 — Manual spot-check calibration (monthly)
  Monthly spot-check of 100 retrieval results, manually judged for false positives
  If false positive rate > 5%, trigger keyword library update or threshold adjustment
  → Continuous calibration to prevent system degradation as business evolves

Dual validation results: accuracy 70% → 94%, false positive rate 15% → 3%.


5. Vector Store Selection and Parameter Tuning

Why Milvus?

Three options compared:

Option Performance Multi-condition filtering Ecosystem Elimination reason
Milvus Million-scale vectors at 50ms ✅ Single query handles it Mature Python SDK ✅ Final selection
Pinecone Comparable performance ⚠️ Weak filtering capability Good Multi-condition filtering requires multiple queries — high cost
FAISS Strong performance ❌ Not supported Average Pure vector library, no metadata filtering support

Milvus's core advantage: multi-condition filtering in a single query:

search_params = {
    "metric_type": "COSINE",
    "params": {"nprobe": 20}
}

# Single query filters simultaneously: similarity + word count + model version
results = collection.search(
    data=[query_vector],
    anns_field="embedding",
    param=search_params,
    limit=3,  # top_k=3
    expr="char_count >= 20 and embedding_model == 'text-embedding-3-large'",
    output_fields=["chunk_id", "page_range", "similarity_score"]
)

The three retrieval parameters:

Parameter Value Design rationale
top_k 3 Retrieve 3 candidates for LLM judgment — more introduces noise, fewer risks missing content
Similarity threshold 0.7 Calibrated against 500 reports — 0.7 is the balance point between recall and false positives
nprobe 20 IVF_FLAT search scope — at nlist=128, nprobe=20 balances accuracy and speed

Real incident: concurrency above 10 caused latency to spike from 50ms to 200ms

Early after launch, when concurrent queries exceeded 10, latency jumped from 50ms to 200ms with occasional timeouts.

Diagnosis:

  1. Checked Milvus server resources — CPU and memory were not saturated. Not a resource bottleneck.
  2. Checked index parameters — nprobe=10 gave too narrow a search scope; queue backlog built up under concurrency.
  3. Checked caching — high-frequency queries (e.g., "GRI 305-1 carbon emissions") were re-executing full searches every time.

Two-step fix:

# Fix 1: increase nprobe for better stability under concurrency
search_params = {"params": {"nprobe": 20}}  # increased from 10 to 20

# Fix 2: cache high-frequency query results (Redis, TTL=1 hour)
import redis
cache = redis.Redis()

def cached_search(query_vector: list, query_key: str) -> list:
    cached = cache.get(query_key)
    if cached:
        return json.loads(cached)

    results = milvus_search(query_vector)
    cache.setex(query_key, 3600, json.dumps(results))  # cache for 1 hour
    return results

Result: latency dropped from 200ms to 80ms, cache hit rate 70%, stable support for 10+ concurrent queries.


6. Cost Control

Once model selection was finalized, cost control relied on two mechanisms:

Mechanism 1: Batch processing for volume discount

OpenAI Embedding API supports batch submission — 100 items per batch reduces per-item cost by 20%:

def batch_embed(texts: list[str], batch_size: int = 100) -> list:
    all_embeddings = []
    for i in range(0, len(texts), batch_size):
        batch = texts[i:i + batch_size]
        response = client.embeddings.create(
            model="text-embedding-3-large",
            input=batch  # batch submission
        )
        all_embeddings.extend([item.embedding for item in response.data])
    return all_embeddings

Mechanism 2: Cache embeddings for high-frequency terms

The GRI clause library is relatively static — vectors for 300+ clauses don't need to be regenerated on every request. Pre-compute and cache them at startup, saving 30% of API calls:

# Preload GRI clause vectors at startup
def preload_gri_embeddings():
    clauses = get_all_gri_clauses()  # ~300 clauses
    embeddings = batch_embed([c["text"] for c in clauses])

    for clause, embedding in zip(clauses, embeddings):
        cache.set(
            f"gri_embedding:{clause['disclosure_id']}",
            json.dumps(embedding),
            ex=86400  # 24-hour cache
        )

Final cost comparison:

Option Monthly cost Recall rate Miss rate
ada-002 (original) ~$6/mo 85% 12%
3-large (unoptimized) ~$10/mo 91% 5%
3-large (batch + cache optimized) ~$8/mo 91% 5%
BGE-M3 self-hosted ~$50/mo 82% 15%

3-large optimized costs only $2/month more than ada-002 — with 6% better recall and 7% lower miss rate.


7. Wrapping Up: The Retrieval Decision Tree

When facing a new retrieval scenario, two questions determine the approach:

Q1: Does the data contain domain-specific terminology?
  ├─ Yes (legal / medical / financial / ESG or other specialized domains)
  │   → General-purpose models will drift
  │   → Required: domain term dictionary + prompt domain hints + post-retrieval reranking
  │   → Go to Q2
  └─ No (general text)
      → General-purpose embedding model + single-path vector retrieval is sufficient

Q2: Does the query require fine-grained semantic distinction?
  ├─ Yes (e.g., Scope 1 vs. Scope 3, low-carbon vs. zero-carbon)
  │   → Single-path vector retrieval is not enough
  │   → Required: dual validation (keyword hard match + vector similarity)
  │   → Add three-layer false positive filter (keywords → LLM cross-validation → manual spot-check)
  └─ No (coarse-grained semantic distinction is sufficient)
      → Single-path vector retrieval + similarity threshold is sufficient

Transferability of this retrieval approach:

  • Domain term dictionary → swap in legal / medical / financial terminology; the logic is identical
  • Prompt domain hints → applicable to any specialized domain; just replace the dictionary content
  • Dual validation → applicable to any scenario requiring high-precision recall; swap in the keyword library for your business domain

Source Code

All implementations referenced in this article are available here:

👉 github.com/muzinan123/production-rag-engineering

Relevant files for this part:

  • esg/services/embedding_service.py — multi-provider embedding + batch write + 4-layer metadata
  • esg/services/search_service.py — Milvus vector retrieval, top_k + threshold dual-parameter filtering

Next up: Retrieval is solid. Relevant content is being surfaced. But a high semantic similarity score does not equal a correct business conclusion. Similarity 0.88 — but the company only disclosed total emissions volume, with no calculation method and no data source. Does that satisfy GRI 305-1? Between "retrieved content" and "a quantifiable, auditable conclusion," there are three gaps. → Part 4 — Judgment Engine