Intro

Hello! I’m El Mehdi Salih, an AI / Generative AI Engineer specialized in Retrieval-Augmented Generation (RAG), information retrieval systems, small language models (SLMs) and edge AI. I hold a Master's degree in Intelligent Processing Systems (IPS) at the Faculty of Sciences of Rabat.

I design and build AI-powered applications that combine modern software engineering practices (Spring Boot, Angular, microservices) with local and privacy-preserving AI pipelines that run on modest hardware. My work focuses on transforming research concepts into practical, efficient systems, particularly in document intelligence, adaptive retrieval, and AI-assisted decision support.

Feel free to explore my portfolio to see projects and skills that define my journey!

Projects

DocBot Offline RAG Chatbot

DocBot: Offline Local RAG — Adaptive Context Budgeting & Project Sentinel

Offline PDF chatbot that runs on an 8GB laptop and is the base for two research papers.

−30% latency, 5.9% hallucination rate

  • Python
  • Ollama
  • pgvector
  • TinyBERT
Details

Technologies: Python, LangChain, Ollama (Qwen3-1.7B), PostgreSQL, pgvector, nomic-embed-text, BM25, TinyBERT, Gradio, Docker

Built a fully offline, privacy-preserving PDF chatbot using Retrieval-Augmented Generation, then used it as the base system for two published research projects (first author on both), each targeting a different weakness of small local RAG pipelines. Everything runs on modest hardware (11th-gen Intel i5, 8GB RAM, CPU only):

  • Local RAG Pipeline: Qwen3-1.7B served through Ollama, with nomic-embed-text embeddings and PostgreSQL + pgvector storage, so no data leaves the machine
  • Ingestion & Storage: PDFs chunked at 512 tokens with 64-token overlap, stored in cleanable, session-based indices
  • Real-Time Streaming & Logging: Token-level response streaming via threaded callbacks, with per-query logs (retrieval depth, tokens, latency) exportable to CSV
Research 1 — Adaptive Context Budgeting (ACB), solo research:
  • Problem: A fixed top-k wastes tokens and latency on easy queries. ACB picks the retrieval depth per query instead.
  • Method: Retrieval stops early based on the similarity gap between consecutive chunks and the entropy of the similarity distribution, and is adjusted by query length.
  • Evaluation: Compared with a fixed top-5 baseline on 3 academic PDFs and 30 questions, scored by 3 independent human judges.
  • Result: Latency cut by ~30% (29.5s to 20.6s) and prompt size by ~38% (733 to 454 tokens), with human-judged F1 of 0.748 against 0.811 for the fixed baseline.
Research 2 — Project Sentinel, team research (3 authors):
  • Problem: Small models hallucinate when retrieval returns plausible but irrelevant “distractor” chunks.
  • Semantic Gatekeeper: A fine-tuned TinyBERT cross-encoder scores each (query, chunk) pair for factual utility and discards chunks below the threshold.
  • Early Exit: If no retrieved chunk passes the threshold, the system politely refuses instead of letting the generator answer from unsupported context.
  • Hybrid Retrieval: BM25 keyword search and pgvector dense search run in parallel and are fused with Reciprocal Rank Fusion.
  • Open Artifacts: Built and released a labeled dataset derived from HotpotQA (69k training and 7k validation pairs), plus the fine-tuned model, on Hugging Face.
  • Result: 5.92% hallucination rate at 5.3ms CPU inference latency (ROC-AUC 0.906), at the cost of lower fact recall (60% at the strict threshold).

EGMR Entropy-Guided Matryoshka Retrieval

EGMR: Entropy-Guided Matryoshka Retrieval — Master's Thesis (defended)

Thesis research: routing each biomedical question to a light or a deep retrieval index.

Better retrieval at 30% of the deep-search cost

  • Python
  • FAISS
  • Qdrant
  • RAGAS
Details

Technologies: Python, Ollama (Qwen3-1.7B), nomic-embed-text, FAISS, Qdrant, BM25, RAGAS, MLflow, Podman

Master's thesis research on per-question adaptive retrieval for resource-constrained biomedical RAG. EGMR routes each question between a compact (64-dim) and a full-resolution (768-dim) dense index using a training-free uncertainty signal from a small local model, then stress-tests whether that routing really tracks question difficulty:

  • Dual-Resolution Index: Built from a single Matryoshka embedding pass over 75,919 deduplicated PubMed snippets, served through both FAISS and Qdrant with an in-RAM / on-disk split matching clinic-scale hardware.
  • Margin-Based Routing Gate: A logit-margin uncertainty signal from a no-context draft answer decides, per question, which index to search; calibrated against a declared 30% deep-search compute budget.
  • Full Evaluation: Four generation tiers (zero-shot, oracle, static, routed) over the complete BioASQ Task 14b training set (5,729 questions, 22,916 generation calls), scored with BERTScore and RAGAS using a separate judge model.
  • Diagnostic Audit: Paired Wilcoxon tests, Monte Carlo random-routing controls, bootstrapped AUC and Bonferroni-corrected correlation tests, plus root-cause analysis of five evaluation anomalies.
Key Findings:
  • Significantly better retrieval than an always-shallow baseline (Wilcoxon p<0.0001) at 30% of the deep-search cost.
  • Reported a negative result with equal prominence: the routing signal allocates budget effectively but does not identify which individual questions are hard (AUC ≈ 0.49 against a 0.5 chance baseline).

DocBot Offline RAG Chatbot

Multi-Agent Credit-Analysis Assistant (in progress)

On-premise multi-agent system that helps analysts draft cited, human-validated credit analysis reports.

Alpha stage: ingestion and orchestration layers running

  • Python
  • FastAPI
  • n8n
  • Ollama
Details

Technologies: Python, FastAPI, n8n, Ollama (Qwen3), PyMuPDF, pdfplumber, Streamlit, Docker/Podman Compose. Planned: Qdrant, LangGraph

Ongoing project at a confidential enterprise client (financial services sector): an on-premise multi-agent assistant that answers questions on lending regulations and drafts structured credit-analysis reports, with the human analyst keeping final responsibility. The data is sensitive, so everything must run on the client’s own servers with no cloud APIs. The project is at alpha stage: part of the architecture below is built, part is still planned. Built so far:

  • Document Ingestion Service: A FastAPI microservice that classifies financial PDFs page by page, sending scanned pages to a vision LLM and native pages to a fast text extractor.
  • Workflow Orchestration: n8n workflows that window documents, assemble a knowledge base with a routing index, and dispatch it to specialist agents (legal/governance, financial, market/risk) running on a local reasoning model.
  • Analyst Validation UI: A Streamlit front end to upload document batches and review the extracted text before it reaches the agents.
  • Local, Containerized Stack: Docker Compose deployment with GPU-accelerated local inference, designed around a zero-data-exfiltration constraint.
Planned next:
  • Retrieval Layer: A vector store with hybrid retrieval over regulations and conventions, so agents rely on cited retrieval instead of direct context injection.
  • Agent Graph: A LangGraph-orchestrated Financial Analyst and Compliance agent, plus a Critique agent that must sign off before anything reaches the analyst, followed by a synthesis step.
  • Human-in-the-Loop: A pause step for analyst review, then evaluation on anonymized real dossiers.

GLHF Prosocial Gaming Platform

GLHF: AI-Powered "Loyalty-as-a-Service" for Gaming

Gaming moderation that rewards good behavior instead of only banning bad behavior.

Under 50 ms moderation latency

  • TinyBERT
  • LoRA
  • FAISS
  • Flask
Details

Technologies: Python, TinyBERT, LoRA (PEFT), Qwen/Llama (Ollama), FAISS, LangChain, Flask

Developed a B2B platform designed to combat the "Toxicity Crisis" in competitive gaming. GLHF shifts the moderation paradigm from purely punitive bans to restorative justice and positive reinforcement:

  • Hybrid AI Architecture: Orchestrated a three-layer system combining a high-speed classifier, a contextual RAG engine, and an incentive ledger.
  • Gatekeeper Layer: Fine-tuned TinyBERT with LoRA adapters to achieve <50ms latency for real-time moderation, handling 90% of traffic locally.
  • Contextual RAG Engine: Integrated a Retrieval-Augmented Generation pipeline using FAISS and Ollama to resolve cultural nuances and distinguish "competitive banter" from identity-based hate.
  • Incentive Engine: Built a universal "Honor Profile" that translates prosocial behavior into economic rewards (skins, currency), effectively reducing "smurfing" incentives.
  • Domain Adaptation: Leveraged PEFT to create tiny (~3MB) game-specific adapters (Valorant, LoL) instead of maintaining multiple large-scale models.
Impact & Ethical Focus:
  • Addressed the $29B annual industry loss caused by toxicity by focusing on player retention and community sustainability.
  • Implemented Radical Transparency by providing natural-language explanations for moderation decisions to rebuild player trust.
  • Optimized for low-resource environments, allowing the entire "Judge" model and vector database to run locally without cloud API costs.

Multi-Robot Delivery Coordination

Autonomous Multi-Robot Warehouse Coordination System

Warehouse robots that share tasks, avoid collisions and cover for failed teammates.

Contract Net and auctions benchmarked on 3 traffic levels

  • Python
  • Mesa
  • A*
  • FIPA-ACL
Details

Technologies: Python, Mesa Framework, Pygame, A* Algorithm, Matplotlib, Seaborn, FIPA-ACL

Developed a robust Multi-Agent System (MAS) to simulate and optimize autonomous delivery robots within a warehouse environment. The project focused on comparing coordination strategies for task allocation and collision-free navigation:

  • AEIO Architecture: Structured the system into Coordination, Execution, and Environmental planes for scalable agent logic.
  • Coordination Mechanisms: Implemented and benchmarked Contract Net Protocol (CNP) and Market-Based Auctions against greedy baselines to optimize battery efficiency.
  • Pathfinding & Navigation: Integrated A* Search with Manhattan distance for optimal routing, complemented by reactive collision avoidance.
  • Failure Recovery Logic: Designed a "Rescue Order" system where functional robots autonomously take over tasks from agents with battery failures or faults.
  • Decision Modeling: Built agent logic using Finite State Machines (FSM) to manage transitions between Idle, Pickup, Delivery, and Recovery states.
Key Achievements:
  • Evaluated performance metrics across Low, Medium, and High traffic scenarios to identify optimal agent-to-task ratios.
  • Reduced delivery delays by implementing capacity penalties, ensuring large robots prioritized heavy packages.
  • Visualized system dynamics (battery depletion, message cost, throughput) using real-time Mesa dashboards.

AirDwa Drone Medical Dispatch

AirDwa: Voice-Activated Drone Medical Dispatch

Describe an emergency in Darija and a drone fleet organizes the medical delivery.

Team project, 4 students

  • Whisper
  • Mesa
  • OpenStreetMap
  • Local LLM
Details

Technologies: Python, Mesa, Solara, Whisper (fine-tuned), local LLM, OpenStreetMap, OpenTopography, Streamlit, Gradio, Pygame

Team project (4 students): a multi-agent drone logistics simulation for emergency medical delivery in rural Morocco, where poor road access can turn a medical emergency fatal. A request spoken in Darija triggers a drone fleet that coordinates delivery on its own:

  • Darija Voice Activation: A fine-tuned Whisper ASR model combined with a local LLM extracts medical intent and destination from natural spoken Darija.
  • Real-World Map Generation: Pick a bounding box anywhere in Morocco and the system maps pharmacies, telecom towers and impassable high-altitude terrain from OpenStreetMap and OpenTopography into the simulation grid.
  • Auction-Based Dispatch: Drones bid on missions using a cost function that balances battery, flight distance and payload urgency.
  • Patient-First Failure Recovery: On a critical in-flight failure, the dispatcher abandons the lost payload and immediately orders a fresh drone from the nearest hospital.
  • Infrastructure Reuse: Existing rural telecom towers act as mid-flight charging points for the fleet.

AgriStore Smart Microservices Platform

AgriStore: Smart Agricultural E-commerce Platform

Agricultural online shop with an AI assistant for product advice.

Fully dockerized microservices

  • Spring Boot
  • Angular
  • Docker
  • OpenAI API
Details

Technologies: Spring Boot (microservices), Angular, Docker, OpenAI API, PostgreSQL

Developed a containerized, AI-powered web application for selling agricultural products. Key features:

  • AI Chatbot Assistant: Integrated OpenAI API using RAG techniques to offer product guidance and seasonal recommendations.
  • Smart Search: Implemented ChatGPT-4o Mini-based search engine for intuitive product discovery.
  • DevOps: Fully dockerized microservices for easy deployment and scalability.
Impact: Improved user engagement and streamlined customer support with intelligent automation.

View On GitHub
AgriMar Agricultural Chatbot

AgriMar: AI-Powered Agricultural Assistant

Chatbot giving Moroccan farmers weather, soil and crop advice for their exact location.

+40% response relevance

  • Flask
  • OpenAI API
  • OpenStreetMap
Details

Technologies: Python, Flask, OpenAI API, OpenStreetMap, OpenCage

Developed an intelligent agricultural assistant that combines AI conversation with precise geospatial analysis to empower Moroccan farmers:

  • Smart Chat Interface: Engineered a context-aware chatbot that understands agricultural queries and provides location-specific recommendations
  • Precision Weather System: Implemented dynamic forecasting that analyzes microclimate conditions based on exact GPS coordinates
  • Automated Soil Reports: Designed a system that generates comprehensive soil analysis PDFs with visualized data trends and actionable insights
  • Conversation Memory: Developed a robust chat history system that maintains context across sessions for continuous advisory support
  • Advanced Geomapping: Solved regional data challenges by integrating OpenStreetMap with custom spatial filters for accurate location services
Key Achievements:
  • Boosted response relevance by 40% through advanced prompt engineering techniques
  • Reduced farmers' research time by providing instant, hyper-localized agricultural intelligence
  • Transformed raw data into decision-ready insights through automated visualization and reporting

EcoSentinel Environmental AI Platform

EcoSentinel: Smart Pollution and Carbon Response Orchestrator

Satellite images and citizen reports turned into pollution alerts for local governments.

Refreshed every 6 hours, tested on the Abou Regreg river

  • Flask
  • Angular
  • n8n
  • Sentinel-2
Details

Technologies: Python (Flask), Angular, Tailwind, PostgreSQL, n8n, Hugging Face, GPT-4, Sentinel-2, Docker

Prototype of an AI-powered environmental alert platform for local governments, grounded in a real case study: monitoring the Oued Abou Regreg river (Rabat–Salé) and detecting waste accumulation in Salé Al Jadida with actual satellite data.

  • Satellite Monitoring: Estimates water pollution levels from Sentinel-2 imagery using NDWI, NDMI, SWIR and true-color composites.
  • AI Vision & NLP: Hugging Face vision models classify illegal dumps and pollution; NER and sentiment analysis process citizen reports; GPT-4 summarizes alerts into readable recommendations.
  • Risk Scoring & Citizen Reporting: Incidents are scored low / medium / high urgency, with geo-tagged submission from web and mobile.
  • Automated Orchestration: An n8n workflow runs every 6 hours: it fetches OpenAQ air-quality data and fresh imagery, runs classification and summarization, then updates a live map, emails stakeholders, logs to PostgreSQL and sends SMS/Telegram alerts when thresholds are exceeded.

Citoyens Commun'ITy Ambassador Platform

Citoyens Commun'ITy: Ambassador Management Platform

Dashboard and admin tools for a national network of civic ambassadors.

Built in about 48 hours

  • Flask
  • Chart.js
  • Leaflet
Details

Technologies: Python (Flask), JavaScript, Chart.js, Leaflet, DOCX/XML

Hackathon prototype built in about 48 hours at the Commun'ITy Hackathon (Marrakech, March 2026) for “Les Citoyens”, a national network of civic ambassadors:

  • Ambassador Dashboard & Admin Console: Personal stats, events and messages for ambassadors; KPIs, membership-growth charts (Chart.js) and a regional activity map (Leaflet) for admins.
  • Onboarding & Events: Multi-step ambassador application workflow and event participation requests.
  • Automated Reporting: A Flask endpoint generates official .docx activity reports by injecting data into a Word template through direct zipfile/XML manipulation, with no heavy templating library.

Library Management System

Library Management System – Business Intelligence Project

Library cataloging system with Power BI reporting, in Arabic and French.

20k+ records cleaned and loaded

  • PMB
  • MySQL
  • pandas
  • Power BI
Details

Technologies: PMB, PHP, MySQL, Python (pandas), Power BI

Designed and deployed a library system based on real-world CSV datasets in Arabic and French:

  • Preprocessing: Cleaned and normalized 20k+ multilingual records for integration into PMB.
  • MCD Customization: Simplified and adapted the database schema to essential business needs.
  • Visualization: Generated insights and performance reports using Power BI and Chart.js.
Impact: Enabled efficient library cataloging and inventory tracking across language barriers.

View On GitHub
House Energy Data Mining

House Energy Consumption Analysis – Data Mining

Finding usage patterns and predicting daily consumption in household energy data.

Clustering, association rules and k-NN

  • Scikit-learn
  • Pandas
  • K-means
Details

Technologies: Python, Scikit-learn, Pandas, Matplotlib , Mlextend

Analyzed a large energy dataset to uncover usage patterns and predict consumption:

  • Clustering: Applied K-means to segment homes based on usage behavior.
  • Association Rules: Extracted high-confidence rules for appliance usage timing.
  • Prediction: Implemented k-NN to predict daily energy consumption per household.
Impact: Provided actionable insights into energy saving for households.

View On GitHub

About

I specialize in retrieval and generation systems that stay efficient, reliable, and private under real-world constraints: RAG pipelines, information retrieval, small language models (SLMs), and edge AI that runs on a standard laptop or a clinic-scale machine instead of a GPU cluster. I care about performance optimization, privacy, and system robustness.

My research includes a Master’s thesis on entropy-guided adaptive retrieval (EGMR) and two papers on local RAG, Adaptive Context Budgeting and Project Sentinel, with first authorship on both. On the engineering side, I have built document-ingestion and multi-agent pipelines for a confidential client in the financial sector. I work evaluation-first, with statistical tests and human judges, and I report negative results as prominently as positive ones.

Across academic and engineering projects, I have developed a structured approach that spans problem analysis, algorithmic design, and end-to-end implementation: local RAG pipelines, context optimization, data and microservices architectures, and system evaluation with both quantitative and human-centered metrics.

I value discipline, consistency, and long-term improvement, principles reinforced through regular gym training and weightlifting, which naturally influence how I approach complex engineering problems, iterate on solutions, and deliver reliable systems.