Open to AI, ML and data roles · Lisbon or remote

I build AI systems, and measure whether they work.

AI / ML engineer in Lisbon with five years of freelance work behind me: a RAG application for lawyers used by paid customers, reinforcement learning that raised a Swiss farm's profits by 30%, and my own products, from GPU transcription pipelines to a live exam-practice app.

  • 5+ yrs

    freelancing for clients in Germany, Switzerland and China, since July 2021

  • 59.7 → 89.3%

    top-8 retrieval accuracy in BJJ AI, raised by evaluating every change

  • +30%

    profit for a Swiss farm from a reinforcement learning policy

  • ≈9,560

    exam questions live on uruj.app, each checked by a second model

01 Selected work

Things I've built and shipped

Client work first, then my own projects. Each one says what the problem was, what I built, and what happened, with the numbers I actually measured.

01 / Freelance

Client work · Legal-tech startup, Pakistan

ProblemLawyers wanted to ask questions over legal documents that were full of client names and case details, which could not go to a third-party model as they were.

What I built

  • A retrieval-augmented generation application over the documents, using embeddings and vector representations.
  • PII redaction before any text reached the OpenAI API: regular expressions plus named entity recognition models found client names and masked them.
  • LangSmith tracing for observability, and access control so only paid users could use it.

Stack

  • Python
  • OpenAI API
  • Embeddings
  • NER
  • LangSmith

OutcomeShipped to production with paid users. I was on call for the live system.

02 / Oct 2026

BJJ AI

Personal project · Built with AI-assisted programming (Claude Code)

ProblemFinding the exact moment a technique is explained in my own library of Brazilian Jiu-Jitsu instructionals meant scrubbing through hours of video.

Right chapter in top 8

What I built

  • A speech-to-text pipeline on rented GPUs with faster-whisper: sharded, resumable, deduplicated, with a jargon prompt so terms like "ashi garami" come out right.
  • Hybrid search (keywords plus local embeddings, rank fusion) with LLM re-ranking. Every answer cites course, volume and timestamp, and clicking a citation plays that moment.
  • A knowledge graph of positions and techniques extracted with the Claude Batch API, and an AI coach that runs a tool loop over 8 read-only tools.
  • Self-hosted LLM tracing of cost, latency and tokens per call. Thumbs-down answers feed the evaluation set; an LLM judge was checked for position and length bias before I trusted it.

Stack

  • Python
  • Claude API
  • faster-whisper
  • bge-small
  • SQLite
  • RunPod
  • ffmpeg
  • JavaScript

OutcomeOn an evaluation set of 200+ questions, the right chapter in the top 8 went from 59.7% to 89.3% and MRR from 0.32 to 0.75. LLM query rewriting dropped it to 79.1%, so I left it out. About 1 cent per question; 173 tests.

Private, because the transcripts come from paid courses.

03 / Oct – Nov 2026

Uruj

My own product · Built with AI-assisted programming (Claude Code)

ProblemO and A Level students in Pakistan practise Cambridge past papers from thick printed books, with no instant marking and no way to practise by topic.

Visit uruj.app

What I built

  • A Claude pipeline that pulls each question out of past-paper PDFs (by script where the PDF has text, Claude vision where it does not), matches it to the mark scheme and tags its syllabus topic.
  • Multi-model verification: one model reads, a different model checks against the original page, and disagreements are hidden rather than resolved automatically.
  • A phone-first React app on Supabase and Cloudflare Workers, with accounts, row-level security and usage limits.

Stack

  • Python
  • Claude API + vision
  • React
  • TypeScript
  • Supabase
  • PostgreSQL
  • Cloudflare Workers

OutcomeLive with about 9,560 questions across 10 subjects. Total Claude spend about $76, with a spend limit on every batch. About 1,250 automated tests.

More work

Reinforcement learning researchOpen source

Intrinsically motivated agents

What behaviour emerges when agents get no reward from the task at all?

  • Agents in a grid world rewarded only for exploring and reducing uncertainty, with a heavy box that moves only when two agents push together.
  • Python
  • Reinforcement learning

A study of the behaviour that emerges over training. Code is public.

Code on GitHub
Personal project · AI-assisted programmingNov 2026

Linkage

A robotics textbook (Modern Robotics) whose mechanisms you can only look at, never move.

  • An AI tutor that cites the printed page, with prompt caching and the cost shown before expensive calls.
  • Claude turns a figure into a mechanism as structured JSON; the app checks it and animates it in Three.js with forward and inverse kinematics written from scratch.
  • JavaScript
  • Node.js
  • Three.js
  • Claude API

Built in two days, with 284 automated tests.

Client work2021 – now

Freelance ML & data science

Clients with data and a decision to make.

  • A reinforcement learning policy, trained in a custom simulation, for a Swiss farm.
  • Machine failure prediction from a client’s raw machine logs.
  • A multimodal system that writes a product’s title, description and price from its images.
  • COVID modelling with ARIMA, dating-app match prediction, email-marketing and voice AI automations.
  • scikit-learn
  • PyTorch
  • Stable Baselines
  • pandas
  • Flask
  • Docker

The farm’s profits rose 30%. Models deployed with Flask and Docker.

Built from scratch, to understand them

  • Bitcoin
  • TCP
  • A page table and its algorithms
  • Camera calibration
  • Classic ML models, before deep learning
  • Robot kinematics

02 Experience

Five years with clients, and time teaching RL

Freelancing since July 2021 for private clients and through Upwork and Fiverr, alongside research and teaching in reinforcement learning.

  1. Jul 2021 – Present

    Freelance engineer: ML, reinforcement learning and LLM applications

    Private clients, Upwork and Fiverr · Clients in Germany, Switzerland and China

    • Shipped systems to production with paid users, including the RAG application for lawyers and reinforcement learning systems, and was on call for them.
    • Gathered requirements, set expectations and explained results to non-technical clients; ran several projects in parallel.
    • Led a small team, coordinated other freelancers, reviewed code and mentored around 50 junior engineers.
  2. Sep 2025 – Jan 2026

    Teaching Assistant, Reinforcement Learning

    Information Technology University · Lahore, Pakistan

    • Designed programming assignments and ran code reviews and debugging sessions for students.
  3. Jul 2023 – early 2024

    Research Assistant, Reinforcement Learning

    Lahore University of Management Sciences (LUMS) · Lahore, Pakistan

    • Six months of reinforcement learning research, and teaching assistant for the RL course from September to December 2023.
  4. 2023

    BSc Computer Science

    Lahore University of Management Sciences (LUMS) · Lahore, Pakistan

03 Skills

Tools I use day to day

Strong maths underneath: probability, statistics, linear algebra and calculus. I use Claude Code, Codex, Copilot and Cursor every day, and write tests for what I ship.

AI & LLMs

  • RAG
  • Embeddings & hybrid search
  • Re-ranking
  • Retrieval evaluation (recall, MRR)
  • LLM-as-judge
  • Agents & tool use
  • LLM tracing (LangSmith, self-hosted)
  • Claude & OpenAI APIs
  • Whisper
  • PII redaction

Machine learning

  • PyTorch
  • TensorFlow
  • scikit-learn
  • XGBoost
  • Reinforcement learning
  • Stable Baselines
  • OpenAI Gym
  • Mesa

Data science

  • pandas
  • NumPy
  • SQL
  • Power BI
  • Hypothesis testing
  • A/B testing
  • Causal inference
  • Time series (ARIMA)

Engineering

  • Python
  • TypeScript
  • JavaScript
  • C / C++
  • React
  • Flask
  • Docker
  • Azure
  • Supabase
  • CI/CD
  • pytest
  • Git
  • Linux
  • Cloud GPUs

04 About

Hands-on, and happy to explain it

Portrait of Mahen Mughal, wearing glasses and a dark blazer

I'm an engineer who builds things myself, from the data pipeline to the screen, and then checks them against real numbers.

My base is maths: I competed in maths competitions at school and university and won some of them, then took a computer science degree at LUMS. I wrote ML models from scratch before deep learning took over, and went deep on reinforcement learning: Sutton and Barto's book, research at LUMS, teaching an RL course at a university and assisting on one twice. Since then I've moved into LLMs, retrieval and speech recognition.

Clients have trusted me with live systems, and I've been the one on call when they broke. I've mentored around 50 junior engineers and I like explaining hard things simply. Outside work I train Brazilian Jiu-Jitsu, which is where BJJ AI came from.

Languages
English (C1), Urdu, Punjabi, Hindi; Portuguese (A1)
Location
Lisbon, Portugal
Reading
Sutton & Barto, Prince's Understanding Deep Learning

05 Contact

Hiring for an AI or ML role? Let's talk.

I'm looking for AI engineer, ML engineer, data scientist, forward deployed, software, RL or QA engineering roles, on-site in Lisbon or remote. Email is the fastest way to reach me.