After studying this material, you should be able to:
Before touching any technology, you must clearly understand what problem exists.
SIDE 1: The Ticket Graveyard SIDE 2: The Messy Knowledge Base
βββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββ
Thousands of resolved tickets VS Knowledge base exists but is:
each month, each containing: β’ Full of duplicate articles
β’ A symptom β’ Stale/outdated content
β’ A root cause β’ Inconsistent quality
β’ A working fix β’ Hard to search effectively
Result: Knowledge is TRAPPED Result: Knowledge is UNUSABLE
Think of it like a library where new books are locked in the basement (tickets), while the public shelves (knowledge base) are filled with outdated, duplicate copies of the same book.
Key insight: The resolutions already exist. The problem is access and organization, not missing information.
KnowledgeForge has two subsystems that feed each other in a closed loop.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CLOSED LOOP β
β β
β Incident Tickets β
β β β
β βΌ β
β ββββββββββββββββ vectors ββββββββββββββββββββ β
β β GENERATION βββββββββββββββββ CURATION β β
β β β β β β
β β Tickets β βββnew articlesββΊβ Classify β β
β β Articles β β Deduplicate β β
β ββββββββββββββββ β Score Quality β β
β β Improve Content β β
β ββββββββββ¬ββββββββββ β
β β β
β βΌ β
β Knowledge Manager β
β Reviews & Approves β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Stage | What Happens |
|---|---|
| 1. Ingestion | Ticket clusters arrive as JSON in S3 |
| 2. Generation | AI writes draft articles from ticket clusters |
| 3. Classification | Articles are sorted by type |
| 4. Curation | Deduplication β Quality Scoring β Improvement |
| 5. Review | Knowledge manager approves before publishing |
Step 3.1: Input arrives
Resolved Tickets (grouped by theme)
β
βΌ
JSON file in S3
(per customer, per theme)
Contains:
β’ Keywords
β’ Article scope
β’ Sample ticket descriptions
β’ Work notes from engineers
Step 3.2: The queue and compute layer
New S3 file
β
βΌ
Amazon SQS Queue βββ event notification
β
βΌ
Amazon ECS + AWS Fargate container
(polls queue, processes up to 5 themes at once)
Why ECS + Fargate here?
| Requirement | Why Fargate Fits |
|---|---|
| Work takes several minutes per theme | Long-running containers (not short Lambda functions) |
| Workload arrives in bursts | Scales task count up/down based on queue depth |
| Team wants to focus on logic, not servers | Serverless containers β no EC2 management |
Step 3.3: RAG Grounding (Critical Concept)
Before writing anything, the system asks: "What already exists on this topic?"
Theme arrives
β
βΌ
Query S3 Vectors index
"Find 5 most similar existing articles"
β
βΌ
Pass those articles as CONTEXT to the AI model
β
βΌ
AI generates new article GROUNDED in existing content
Why this matters: Without grounding, the AI might invent procedures or use inconsistent terminology. With grounding, new articles match the style and accuracy of proven content.
Step 3.4: What gets generated
For each ticket cluster/theme, the model produces two documents:
The system uses response streaming β it assembles the document as tokens arrive rather than waiting for the complete response. This reduces perceived latency on long documents.
Curation handles all articles β both newly generated ones and existing knowledge base articles.
Article enters curation
β
βΌ
βββββββββββββββββββββ
β 1. CLASSIFY β What type of article is this?
ββββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββββ
β 2. DEDUPLICATE β Does this already exist?
ββββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββββ
β 3. SCORE QUALITY β How good is this article?
ββββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββββ
β 4. IMPROVE β If score is low, rewrite it
ββββββββββ¬βββββββββββ
β
βΌ
Published to ServiceNow
for knowledge manager review
This is one of the most elegant patterns in the system.
Article A: "Restart the network adapter to fix connectivity"
Article B: "To resolve connection issues, reboot the NIC"
Article C: "Network problems? Cycling the adapter usually works"
Keyword match: These look DIFFERENT
Meaning match: These are the SAME article
Step 5.1: Every article gets converted to a vector
Article text
β
βΌ
Amazon Titan Text Embeddings V2
β
βΌ
1,024-dimension vector
(a list of 1,024 numbers representing the article's MEANING)
β
βΌ
Stored in Amazon S3 Vectors index (per customer)
Step 5.2: New article is compared against existing vectors
New article β embed β query S3 Vectors index
β
βΌ
Find top-5 nearest vectors
β
βΌ
Cosine distance < 0.05?
(similarity > 95%?)
β β
YES NO
β β
DUPLICATE UNIQUE
β
βΌ
Keep NEWER article,
retire OLDER one
Distance 0.0 = Identical articles
Distance 0.05 = 95%+ similar = DUPLICATE (flagged)
Distance 0.10 = Related but different = NOT duplicate
Distance 1.0 = Completely unrelated
Tuning insight: Too loose (0.10) β false duplicates flagged. Too tight (0.01) β reworded copies missed. The team sampled flagged pairs and adjusted until behavior was correct.
| Factor | S3 Vectors | Standalone Vector DB |
|---|---|---|
| Infrastructure | None (uses existing S3) | New service to manage |
| Cost model | Per query + per GB | Per running node (always-on cost) |
| Integration | Already in S3 ecosystem | Requires new connections |
| Scale | Grows with your content | May need resizing |
Bonus: The same index serves double duty β it's used for RAG grounding in Generation AND for duplicate detection in Curation.
Curation processes tens of thousands of articles across many customers. You need:
EventBridge (daily schedule)
β
βΌ
Lambda: Find customers with new/changed articles
β
βΌ
Group into batches β SQS FIFO Queue
β
βΌ
Dispatcher: Pull one batch β Start Step Functions execution
β
βΌ
βββββββββββββββββββββββββββββββββββββββββ
β STEP FUNCTIONS STATE MACHINE β
β β
β PHASE 1: Distributed Map β
β βββββββββββββββββββββββββββββββββββ β
β β For each article (concurrent): β β
β β β’ Classify type β β
β β β’ Deduplicate (sequential) β β
β βββββββββββββββββββββββββββββββββββ β
β β
β PHASE 2: Distributed Map β
β βββββββββββββββββββββββββββββββββββ β
β β For each article (concurrent): β β
β β β’ Score quality β β
β β β’ Improve if below threshold β β
β βββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββ
Decision 1: STANDARD vs EXPRESS mode
| Mode | Max Duration | Execution History | Use When |
|---|---|---|---|
| EXPRESS | 5 minutes | Limited | Short, high-volume tasks |
| STANDARD | 1 year | Full history | Long AI calls + debugging |
KnowledgeForge uses STANDARD because Bedrock calls can exceed 5 minutes.
Decision 2: S3 pointer instead of inline state
β WRONG approach:
State machine carries full article HTML in its state
β Hits 256 KB limit immediately with large articles
β
CORRECT approach:
State machine carries only: { "s3_location": "bucket/article123.json" }
β Workers read directly from S3
β State payload stays tiny regardless of article size
Decision 3: FIFO Queue for ordering
Customer A articles: [A1, A2, A3, A4, A5] β processed in order
Customer B articles: [B1, B2, B3, B4, B5] β processed in order
(parallel to Customer A)
Using customer ID as the message group key ensures:
Each article is scored across 10 weighted dimensions (highest to lowest weight):
Dimension Weight
βββββββββββββββββββββββββββββββββββββ
Technical accuracy ββββββββ (highest)
Completeness βββββββ
Clarity ββββββ
Structure/formatting βββββ
Step-by-step instructions ββββ
Troubleshooting coverage βββ
Prerequisites listed ββ
Examples included ββ
Links/references β
Metadata quality β (lowest)
βββββββββββββββββββββββββββββββββββββ
Weighted total = Quality Score (0-100)
Article scored
β
βΌ
Score β₯ threshold?
β β
YES NO
β β
Keep as-is Send for AI improvement
β
βΌ
Score AGAIN after improvement
β
βΌ
New score > Original score?
β β
YES NO
β β
Keep new Keep original
version (don't make it worse!)
Critical safety check: The before-and-after scoring ensures the pipeline never silently degrades content quality.
This solves a subtle but important problem: AI models tend to corrupt image URLs and hyperlinks when rewriting prose.
BEFORE improvement:
"See <img src='https://cdn.example.com/diagram.png'> for reference.
Visit <a href='https://docs.example.com/fix'>this guide</a>."
STEP 1 - Replace with tokens:
"See [IMG_1] for reference. Visit [LINK_1]."
(Store: IMG_1 = original img tag, LINK_1 = original link)
STEP 2 - AI improves prose:
"Refer to [IMG_1] for a visual overview.
Consult [LINK_1] for detailed instructions."
STEP 3 - Restore originals:
"Refer to <img src='https://cdn.example.com/diagram.png'> for a visual overview.
Consult <a href='https://docs.example.com/fix'>this guide</a> for detailed instructions."
The AI never sees raw URLs, so it cannot break them.
Running tens of thousands of AI model calls concurrently requires careful engineering.
Control 1: Rate Limiting
βββββββββββββββββββββββββ
Limit concurrent Bedrock calls per batch
β Prevents hitting API quotas
β Keeps costs predictable
Control 2: Guardrail Fallback
ββββββββββββββββββββββββββββββ
If guardrail API throttles:
β Process article WITHOUT guardrail
β Log a WARNING
β Continue (don't fail the whole batch)
Why: Keeps pipeline healthy during load spikes
Control 3: Token Budget Retry
ββββββββββββββββββββββββββββββ
If response is cut off (hit token limit):
β Detect "stopped at token limit" signal
β Retry with DOUBLE the token budget
β Up to model's maximum ceiling
Why: Long articles need more tokens; short articles pay nothing extra
Mechanism 1: Tolerated Failure Percentage
ββββββββββββββββββββββββββββββββββββββββββ
A few bad articles in a batch?
β Continue processing the rest
β Don't abort the entire batch
Mechanism 2: Dead-Letter Queue (DLQ)
ββββββββββββββββββββββββββββββββββββββ
Repeatedly failing articles?
β Move to DLQ for investigation
β Don't block other articles
β Don't stall the entire run
The system serves multiple customers on shared infrastructure. Isolation is non-negotiable.
Customer A Customer B
ββββββββββββββββββββββββββ ββββββββββββββββββββββββββ
S3 Vectors index (A only) S3 Vectors index (B only)
Custom prompts for A Custom prompts for B
Encryption key (A only) Encryption key (B only)
SQS FIFO message group A SQS FIFO message group B
β Shared pool approach:
One index for all customers
β Customer A's articles could appear in Customer B's results
β Data leakage risk
β One customer's bad data affects others
β
Per-customer approach:
Duplicate check runs against THIS customer's index only
Content improvement uses THIS customer's prompts only
Data encrypted under THIS customer's key only
β Complete isolation by design
Onboarding new customers: No code changes needed. The system discovers customers from a data catalog at runtime. Adding a customer = provisioning their resources only.
These are the transferable patterns you can apply to your own pipelines:
| Lesson | Pattern | Benefit |
|---|---|---|
| 1. Reuse your vector index | Same index for RAG grounding AND duplicate detection | Solves two problems with one infrastructure component |
| 2. Pass pointers, not payloads | S3 location through Step Functions, not article content | Eliminates state-size failures at scale |
| 3. Score before AND after improvement | Quality check brackets the AI call | Safe to run automatically without degrading content |
| 4. Degrade gracefully under throttling | Guardrail throttle = warning, not failure | Pipeline stays healthy through load spikes |
Test your understanding with these questions:
Why does KnowledgeForge use ECS+Fargate for generation but Step Functions for curation?
Explain why cosine distance of 0.05 was chosen for duplicate detection. What happens if you set it to 0.20?
Trace the path of a single article from ticket cluster to published knowledge base article through all five stages.
Why is the media placeholder pattern necessary during content improvement?
What would happen if the system used a shared S3 Vectors index for all customers instead of per-customer indexes?
ITSM Tickets (resolved, clustered by theme)
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β GENERATION (ECS + Fargate) β
β RAG grounding β Claude Sonnet β KB Article + RCA β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β new articles
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CURATION (Step Functions) β
β β
β Classify β Deduplicate β Score β Improve β
β (S3 Vectors) (10 (Claude + β
β cosine dist) dims) placeholders) β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β vectors stored back
βΌ
S3 Vectors Index (per customer)
β
βΌ (also feeds back to Generation)
Knowledge Manager Review (ServiceNow)
β
βΌ
β
Published Knowledge Base Article