Skip to content

Repository files navigation

AI WorkFlow POC

This Proof of Concept (POC) demonstrates an AI-powered Model Risk Management (MRM) workflow that automatically identifies whether a quantitative method qualifies as a "model" based on regulatory guidelines

Start PostgreSQL

docker run --name mrm-postgres
-e POSTGRES_USER=mrm_user
-e POSTGRES_PASSWORD=mrm_pass
-e POSTGRES_DB=mrm_db
-p 5432:5432
-d postgres:16

Pull PostgreSQL image

docker pull postgres:14

Run PostgreSQL container

docker run -d
--name mrm_postgres
-e POSTGRES_USER=mrm_user
-e POSTGRES_PASSWORD=mrm_pass
-e POSTGRES_DB=mrm_db
-p 5432:5432
postgres:14

Verify container is running

docker ps | grep mrm_postgres

Connect to PostgreSQL inside container

docker exec -it mrm_post gres psql -U mrm_user -d mrm_db

AI Techniques & LLM Stack

LLM & Framework Stack

ComponentTechnologyVersionPurpose
LLM ModelOpenAI GPT-4o-minigpt-4o-mini-2024-07-18Core reasoning, rule assessment, decision synthesis
FrameworkLangGraphlatestStateful multi-step workflow with conditional routing
Output ParsingLangChain + PydanticlatestStructured, type-safe LLM responses
API ClientOpenAI Python SDK>=1.0.0LLM API communication

AI Techniques Used

TechniqueImplementationBenefit
Structured Prompt EngineeringCustom prompts with explicit output schemas (SectionCollection, RuleSet, RuleAssessment, FinalDecision)Ensures LLM returns predictable, validated JSON
State Machine WorkflowLangGraph StateGraph with conditional edgesManages complex decision flow with clear branching logic
Multi-step Chain-of-ThoughtDocument → Sections → Rules → Assessment → DecisionBreaks complex classification into manageable steps
Clarification Loop with GuardrailsMax 2 rounds, counter in state, automatic escalationPrevents infinite loops, ensures bounded execution
Context Window OptimizationOnly relevant sections passed per rule assessmentReduces token usage, improves accuracy
Few-shot LearningGuidelines contain examples of GOOD/BAD descriptionsImproves classification accuracy without fine-tuning
Selective Re-evaluationOnly affected rules re-assessed after clarificationReduces API calls by 60-70% in clarification rounds
File-based CachingGenerated rules cached to cached_rules.jsonEliminates redundant LLM calls (80% cost reduction)
Structured Output ValidationPydantic models with field validation (confidence 0-1, literals)Prevents hallucinated values, ensures data quality

About

Created an AI - Workflow using LangChain & LangGraph for a model identification process

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages