Mahdi Shamsi

Senior AI/ML Engineer & Researcher

Summary

AI/ML engineer and scientist (Ph.D., Electrical and Computer Engineering) with 9+ years of experience taking machine learning systems from research to production. I ship production LLM systems for enterprise analytics: AI agent platforms, multi-agent workflows, retrieval-augmented generation (RAG) and fine-tuned LLMs self-hosted on vLLM. I led the design of a company-wide LLM cost control plane. My research covers self-supervised representation learning, deep generative models (VAEs, diffusion, flow matching) and time series modeling, with 14 peer-reviewed publications.

Experience

PeriGen

Jul 2025 – Present

AI Researcher

  • Technical lead and sole developer for self-supervised representation learning on intrapartum fetal heart rate (FHR) and uterine activity (UA). Kept research code to production standards over 846 commits in 15 months, with 5,785 automated tests and a PyTorch Lightning multi-GPU DDP framework with MLflow tracking.
  • Designed the Transfer Entropy Bottleneck (TEB), a causal variational Transformer (4.26M parameters). It measures directed UA-to-FHR coupling as the KL divergence between a UA-aware posterior and an FHR-only prior, and lag cross-attention splits the coupling by contraction delay.
  • Showed that the TEB, trained on healthy births only, still separates neonatal brain injury (HIE) from healthy recordings in 10 of 11 half-hour windows before delivery, on 1,959 held-out recordings (Cliff’s up to 0.36, ). First author, CinC 2026.
  • Established a pre-registered evaluation framework of 27 analyses with automatic PASS/FAIL verdicts, recording-level bootstrap confidence intervals and Holm-corrected tests over 6.45M forecast anchors. Its null controls showed that of the raw coupling signal came from source-availability timing alone.
  • Developed a leakage-safe outcome classifier on 6,308 labour recordings (256,866 segments), with patient-disjoint 10-fold cross-validation on 8 GPUs, 14 coded leakage guards and a 12-criterion verification gate.
  • Designed a strictly causal scattering-transform front end that cuts future-sample filter energy to exactly 0 and keeps a 0.94–0.95 median correlation with two-sided features. The batched GPU PyTorch port runs at 4.5 ms per 22-minute segment, faster than NumPy, within relative error.
  • Built generative and predictive pretraining variants: flow-matching and score-based diffusion latent priors, contrastive predictive coding, and a JEPA with a causal convolutional Transformer encoder. Benchmarked RSSM, Transformer and Mamba models for long-horizon probabilistic forecasting at matched compute.
  • Built an explainable AI and mechanistic interpretability toolkit (PyTorch, TypeScript) with activation patching, activation steering, Integrated Gradients and logit lens. It scales to billion-parameter LLMs through NNsight.

Independent AI Consultant

Feb 2024 – Present

Part-time · Toronto, ON

Quinn AI · Vancouver, BC

Jun 2025 – Present

  • Architected a production AI agent platform for KPI analytics over 8,000+ KPIs per organization. Its LLM tool-use orchestrator runs multi-step workflows (KPI queries, SQL, research, memory, document generation) with parallel tool execution, streaming and multi-provider routing across Anthropic Claude, OpenAI, Gemini and self-hosted Llama. It halved per-KPI prompt payloads (80 to 40 tokens).
  • Built a multi-agent system on Google Agent Development Kit (ADK). A master agent extracts intents in parallel and coordinates 7+ specialized agents for search, research, SQL generation, data retrieval, reporting and auditing over SugarCRM, QuickBooks, NetSuite and HubSpot.
  • Shipped a production RAG system over 11+ document formats with three execution modes (fast, thorough, agentic): hybrid semantic and keyword search with rank fusion, self-hosted cross-encoder reranking and end-to-end tracing. Index-aware pre-filtering cut large-organization query latency by 50–70%.
  • Built a multi-tenant, LLM-augmented knowledge graph that unifies KPIs, goals, data lineage and decisions, with dual-model adversarial judging, what-if simulation and human-in-the-loop questions. It raised audited KPI classification accuracy from 21% to 79% in staging.
  • Fine-tuned Llama 8B and 70B with LoRA and QLoRA (Hugging Face PEFT, 4-bit bitsandbytes, multi-GPU) for KPI analysis, summarization and intent extraction, to match premium-model quality at a fraction of the cost.
  • Built the self-hosted LLM inference stack on vLLM: PagedAttention, continuous batching, chunked prefill and tensor-parallel multi-GPU sharding behind an OpenAI-compatible endpoint. Benchmarked AWQ, GPTQ, FP8 and INT8 quantization for latency, throughput and accuracy.
  • Delivered a unified KPI data tool with one core and three interfaces (CLI, Python API, MCP server), which exposes 16+ Model Context Protocol tools for navigation, data retrieval, time series, discovery and data-quality checks.
  • Productionized a time series forecasting platform that exposes 13 statistical, machine learning and foundation models (TimeGPT, Chronos-2, TimesFM) as 40+ MCP tools, with walk-forward backtesting, four uncertainty quantification methods, ensembling, hierarchical reconciliation and scenario analysis.
  • Led the design of a company-wide LLM cost control plane: task-aware routing, per-organization cost attribution, runtime model switching, and self-hosted Gemma and Llama on AWS. A baseline analysis found that two premium models drove of OpenAI spend on 3% of requests, and it projected a 30–40% cut in LLM spend.

GlobVision · Montreal, QC

Aug 2024 – Dec 2024

  • Built a deep residual-learning model (WaveNet-style dilated gated TCN plus a bidirectional RNN, FiLM-conditioned) that corrects 7-day SGP4 orbit propagation errors. A heteroscedastic loss gives calibrated per-axis uncertainty.
  • Built an end-to-end satellite maneuver detection pipeline on two-line element (TLE) data: 200+ physics-informed features, focal and cost-sensitive losses, a decision-threshold optimizer and a new probability-weighted gradient localization algorithm for maneuver epochs. It runs live-data inference with an alerting state machine.

Ample Insight · Toronto, ON

Feb 2024 – Jun 2024

  • Owned delivery of an LLM-powered data quality platform: an eight-agent workflow (OpenAI Agents SDK) over a Neo4j test catalog that automates profiling, risk assessment, test selection and self-correcting code generation.
  • Replaced a monolithic prompt with a four-stage chain-of-thought pipeline (profile, risks, map, analyze) behind an adapter for hosted and local LLM backends, with schema-enforced outputs, retries, caching and cost tracking.
  • Built an autonomous agent-driven experimentation framework with metric verification, a commit-before-verify loop, noise-robust keep-or-discard decisions, stuck detection and crash recovery for unattended overnight runs.

McGill University

Jun 2023 – Jun 2025

Postdoctoral Researcher · Montreal, QC

  • Improved HIE early detection with UCSF and Kaiser Permanente (CinC 2024, 2025). Generative pretraining plus deep classifiers raised sensitivity by more than 20% and specificity by more than 10%, validated with clinical decision rules, operating-point threshold search, cross-validation and subgroup ROC analysis.
  • Benchmarked nine time series classifier architectures behind a common interface (selective state space, dilated causal convolutional-recurrent, Inception-style, Transformer) for controlled ablations at fixed training budgets.
  • Engineered distributed training on up to 7 GPUs (DDP) with parallel 10-fold cross-validation (latent caching, length-aware batching, validated configurations, MLflow tracking), which cut training time by more than 90%.

Toronto Metropolitan University · SIP Lab

Jan 2019 – May 2023

Research Assistant (Ph.D.) · Toronto, ON

  • Developed efficient hyperparameter selection methods that replace grid search with a single training run, and a clustering validation index that tunes clustering algorithms without convexity assumptions (Artificial Intelligence, 2026).
  • Built an unsupervised graph neural network (GNN) for community detection with centrality-weighted clustering and topological priors, and an adaptive graph signal processing method that auto-tunes GCN kernel sizes.

Skills

LLMs & agents
  • Anthropic, OpenAI & Gemini SDKs
  • OpenAI Agents SDK
  • Google ADK
  • LangChain
  • LangGraph
  • MCP
  • RAG
  • Hybrid search
  • Cross-encoder reranking
  • pgvector
  • LoRA / QLoRA / PEFT
LLM inference
  • vLLM
  • Continuous batching
  • Tensor parallelism
  • AWQ
  • GPTQ
  • FP8
  • INT8
Machine learning
  • PyTorch
  • PyTorch Lightning
  • TensorFlow
  • scikit-learn
  • Hugging Face Transformers
  • PyTorch Geometric
  • VAEs
  • Diffusion
  • Flow matching
  • CPC
  • JEPA
  • Transformers
  • Mamba
  • GNNs
  • Forecasting
  • Uncertainty quantification
MLOps & infrastructure
  • DDP
  • FSDP
  • Docker
  • FastAPI
  • Git
  • CI/CD
  • MLflow
  • AWS
  • GCP
Data
  • PostgreSQL
  • MongoDB
  • Neo4j
  • Apache Spark
  • SQLAlchemy
  • NumPy
  • SciPy
  • Pandas
  • NetworkX
  • Matplotlib
  • Plotly
Explainable AI
  • Mechanistic interpretability
  • Activation patching
  • Integrated Gradients
  • Logit lens
  • NNsight
Languages
  • Python
  • SQL
  • TypeScript
  • C++
  • Julia
  • MATLAB

Education

Toronto Metropolitan University

2023

Ph.D., Electrical and Computer Engineering · Toronto, ON

Thesis: Stochastic-Based Hyperparameter Selection and Learnability Analysis in Supervised and Unsupervised Learning.

University of Tabriz

M.Sc., Electrical Engineering · Tabriz, Iran

Publications and service

  • 14 peer-reviewed papers, 10 as first author.
  • Peer reviewer:Artificial Intelligence Review (Springer); Data Mining and Knowledge Discovery (Springer); Signal, Image and Video Processing (Springer); IEEE ICASSP; IEEE EMBC.
All publications