๐Ÿง 

CORTEX

The Corporate Brain โ€” @neo for a 20-Person Team

AI assistant for a 20-person corporate team. Ask any question about 20GB+ of project documents โ€” Word, Excel, PDF, PowerPoint, source code. Answers via Microsoft Teams and Web UI. Gets smarter over time through The Enrich.

A Real Question

"@neo what do you mean by F1 DRS?" โ€” from question to answer, with The Enrich

๐Ÿ’ฌ MS TEAMS Team Member "@neo what do you mean by F1 DRS?" Corporate ยท 20 users ๐Ÿง  CORTEX search + classify semantic ChromaDB 349K chunks ยท 384-dim ๐Ÿ” click keyword SQLite FTS5 cortex.db ยท full text GPT-4.1 chunks โ†’ answer ~2s response ๐Ÿ˜ Answer #1 "DRS is related to aerodynamic systems and rear wings..." garbled ยท no real detail didn't answer the question weak โ†’ logged ๐Ÿ”บ TRINITY (Opus 4.6) The Enrich โ€” Deep Research ๐Ÿ“„ Reads F1 Technical Regulations 2026 (80 pages) ๐Ÿ“Š DRS Zone specifications (every circuit) ๐Ÿ“ฝ๏ธ Active Aero slides (DRS-2026 changes) Writes deep explanation โ†’ uploads to DB ๐Ÿ’Ž enriched โ†’ ChromaDB โ†’ FTS5 same question next day ๐Ÿง  CORTEX ChromaDB + FTS5 ๐Ÿ’Ž enriched doc โ†’ #1 scored 1.2ร— higher GPT-4.1 enriched input ๐ŸŽฏ Answer #1 (fixed) "DRS = Drag Reduction System. Rear wing flap opens on straights within 1s of car ahead. +12 km/h. DRS-2026: eliminated, replaced by active aero (full car)" detailed ยท accurate ยท useful Same GPT-4.1 ยท Same question ยท Trinity enriched the source โ†’ great answer ๐Ÿ“ Source: 20GB+ docs from network share โ€” Word, Excel, PDF, PPT, Java, Python, shell scripts

Everything Inside Cortex

Cortex is the sun โ€” Smart RAG pipeline components radiate out

๐Ÿง  CORTEX INDEXING document parsing ๐Ÿ“„ Word โ€” python-docx ๐Ÿ“Š Excel โ€” openpyxl ๐Ÿ“‹ PDF โ€” pdfplumber ๐Ÿ“ฝ๏ธ PPT โ€” python-pptx ๐Ÿ–ผ๏ธ OCR โ€” pytesseract SMART RAG 4-layer pipeline D๏ธ Entity/Alias Expand C๏ธ Query Planner/Router A๏ธ Structured Lookup B๏ธ Retry Pass if low AI MODELS LLM + embeddings ๐Ÿข GPT-4.1 (primary) ๐Ÿฆ™ Ollama (fallback) โšก Groq (fallback 2) ๐Ÿ”ค fastembed 384-dim THE ENRICH knowledge deepening ๐Ÿ“ Opus writes deep docs ๐Ÿ” Reads question_log ๐Ÿ“Š Finds weak topics โœ๏ธ Writes enrichments โšก click โ€” before & after INTERFACES how users access ๐ŸŒ Web UI โ€” :5050 ๐Ÿ’ฌ MS Teams (Graph API) ๐Ÿ“ฑ Mobile-friendly ๐Ÿ‘ฅ 20-person team DATA document sources ๐Ÿ“ Account A โ€” 6,351 files ๐Ÿ“ Account B โ€” 1,611 files ๐Ÿ“ System docs โ€” 28 files ๐Ÿ’พ 20GB+ on network share STORAGE databases ๐Ÿ—ƒ๏ธ cortex.db (SQLite) ๐Ÿ”ฎ ChromaDB vectors ๐Ÿ“Š 319K struct records ๐Ÿ” 74 entity aliases

The Enrich โ€” How Cortex Gets Smarter

Weak answer โ†’ Trinity reads source docs โ†’ writes deep explanation โ†’ next time the answer is great

STEP 1 ๐Ÿ’ฌ "@neo what do you mean by F1 DRS?" team member asks STEP 2 ๐Ÿ˜ Thin Answer "DRS is related to aerodynamic systems..." fragmented ยท incomplete STEP 3 ๐Ÿ“ Logged question_log table "asked 4ร— โ€” weak" "ENRICH ON" STEP 4 โ€” TRINITY (Opus 4.6) ๐Ÿ”บ Deep Research Reads FULL source docs โ€” not just chunks HLD ยท design doc ยท architecture PPT Writes a complete, flowing explanation like a senior engineer teaching a new joiner STEP 5 ๐Ÿ’Ž Enriched Doc saved to cortex.db scored HIGHER than raw chunks (1.2ร— boost) STEP 6 โ€” NEXT TIME ๐ŸŽฏ Great Answer "DRS = Drag Reduction System. Rear wing flap opens on straights, +12 km/h. Eliminated in 2026..." โ†บ every ENRICH run makes Cortex smarter โ€” 20 enrichments written so far

Tech Stack

LLMCorporate AI Framework GPT-4.1 (~2s)
Embeddingsfastembed bge-small-en-v1.5 (384-dim)
Vector DBChromaDB โ€” 349K chunks
MetadataSQLite cortex.db + FTS5
Web UIFlask โ€” port 5050
TeamsMicrosoft Graph API polling
Parsingpython-docx, openpyxl, pdfplumber, pptx, OCR
Documents20GB+ from corporate network share
Cost~$5/day AI Framework budget
โœ•
๐Ÿง  The Enrich โ€” Before & After
โŒ BEFORE ENRICH
๐Ÿ’ฌ MS Teams โ€” Team Member asks
@neo what do you mean by F1 DRS?
๐Ÿ’ฌ MS Teams โ€” @neo replies
"DRS is related to aerodynamic systems and rear wings. It is mentioned in the racing regulations document..."

๐Ÿ˜ Thin. Vague. Useless.
GPT-4.1 only got random chunks โ€” a table header from a spreadsheet, half a sentence from a rules PDF. Not enough context to give a real answer.
โšก ENRICH RUNS
๐Ÿ“ Step 1 โ€” Spot the weakness
Cortex logs every question. Trinity scans the log and sees:
"F1 DRS โ€” asked 4 times, answer always thin"
๐Ÿ”บ Step 2 โ€” Trinity deep-reads the source
Trinity (Opus 4.6) doesn't just read chunks โ€” she reads the full documents:

๐Ÿ“„ F1_Technical_Regulations_2026.pdf โ€” all 80 pages
๐Ÿ“Š DRS_Zone_Specifications.xlsx โ€” every circuit
๐Ÿ“ฝ๏ธ Active_Aero_2026_Changes.pptx โ€” slide by slide

Then writes a complete, flowing explanation โ€” like a senior engineer would explain to a new joiner.
๐Ÿ’Ž Step 3 โ€” Load into ChromaDB + FTS
The enriched explanation is:

โ†’ Chunked into proper sections
โ†’ Embedded as vectors into ChromaDB (384-dim)
โ†’ Indexed as keywords into SQLite FTS5
โ†’ Scored 1.2ร— higher than raw document chunks

Next time someone searches, enriched content surfaces FIRST.
โœ… AFTER ENRICH
๐Ÿ’ฌ MS Teams โ€” Same question, next day
@neo what do you mean by F1 DRS?
๐Ÿ’ฌ MS Teams โ€” @neo replies
"DRS stands for Drag Reduction System โ€” a movable rear wing flap introduced in 2011 to promote overtaking. When a driver is within 1 second of the car ahead at a DRS detection point, they can open the flap on the following straight, reducing drag by ~20% and gaining up to 12 km/h. Each circuit has 1-3 DRS zones. Under the 2026 regulations (DRS-2026), the traditional DRS flap is eliminated entirely โ€” replaced by full active aerodynamics across the whole car, allowing continuous drag/downforce adjustment."

๐ŸŽฏ Detailed. Confident. Actually useful.
Same GPT-4.1 model. Same question. But now it has enriched source material to work with โ€” that's the difference.
โ†บ Every ENRICH run makes Cortex smarter ยท 20 enrichments written so far ยท Not retraining the AI โ€” giving it better source material
โœ•
๐Ÿ”ฎ ChromaDB โ€” Vector Search (Semantic)
What it does
ChromaDB stores 349,000 text chunks from 20GB of documents โ€” but not as plain text. Each chunk is converted into a 384-dimension number vector (an "embedding").

These vectors capture meaning, not words. So when you search, it finds chunks that are about the same thing โ€” even if they use completely different words.
The question: "@neo what do you mean by F1 DRS?"
ChromaDB searches 349K chunks for meaning. No doc says "F1 DRS" directly โ€” but these are the closest matches:

๐Ÿ“„ "The automobile engine burns fuel at 15,000 RPM..." 0.71
๐Ÿ“„ "Aerodynamic wind tunnel testing for racing..." 0.65
๐Ÿ“„ "Vehicle maintenance procedures..." 0.58

These are related to racing but none actually explain DRS. GPT-4.1 stitches them together and gets:

๐Ÿ˜ Answer #1: "DRS is related to aerodynamic systems and rear wings..."

Garbled. Didn't answer the question.
โšก Trinity enriches โ†’ uploads back to ChromaDB
๐Ÿ”ฎ Same question AFTER Enrich โ€” new scores
Trinity wrote a deep explanation and loaded it into ChromaDB. Now:

๐Ÿ’Ž "DRS = Drag Reduction System, rear wing flap, +12 km/h, eliminated 2026..." 0.94
๐Ÿ“„ "The automobile engine burns fuel at 15,000 RPM..." 0.71
๐Ÿ“„ "Aerodynamic wind tunnel testing..." 0.65

The enriched doc is now #1 at 0.94. GPT gets the perfect source and gives:

๐ŸŽฏ Answer #1 (fixed): "DRS = Drag Reduction System. Rear wing flap opens on straights, +12 km/h. Eliminated in 2026..."
Model: bge-small-en-v1.5 ยท 384 dimensions ยท ONNX runtime ยท runs locally (no cloud API)
โœ•
๐Ÿ” SQLite FTS5 โ€” Keyword Search
What it does
FTS5 is Full-Text Search โ€” the old-school way. It indexes every word in every document and finds exact matches.

Fast, precise, and catches things that semantic search misses โ€” like part numbers, regulation codes, driver names, and technical specs.
Example: "DRS-2026" โ€” only keywords work here
You search: "DRS-2026" (the drag reduction system regulation code)

๐Ÿ“„ "...DRS-2026 eliminates the rear wing flap..." โœ“ exact hit
๐Ÿ“„ "...under DRS-2026, active aero replaces..." โœ“ exact hit
๐Ÿ“„ "...overtaking strategy and slipstream..." โœ— no match

Semantic search would miss "DRS-2026" entirely โ€” it doesn't understand regulation codes. FTS5 finds it instantly.
Why BOTH are needed (Hybrid Search)
ChromaDB = "what does the question mean?" (F1 DRS โ†’ aerodynamic systems โœ“)
FTS5 = "what exact words appear?" (DRS-2026 โ†’ exact hit โœ“)

Cortex runs both searches in parallel, merges results, and sends the best chunks to GPT-4.1. This is called Hybrid Search โ€” you get the best of both worlds.

Also includes enriched docs (Trinity-written deep explanations) scored higher than raw chunks.