Machine Learning · Production-shaped portfolio

Abolfazl Ranjbaran
ML that ships, with numbers that survive review.

Nine end-to-end projects — from a Persian retrieval-augmented assistant with hybrid search and streaming, to a GPT whose autograd engine is written in raw NumPy. Every headline number is reproducible from committed code, seeds and golden sets.

9end-to-end projects
320+tests, all in CI
93%measured coverage (gate 90%)
5CI layers incl. CodeQL SAST
2live demos, free-tier hosted
Latest release

Try it right here

The two flagship models run as public Hugging Face Spaces, embedded below — no signup, nothing to install. First load can take a minute: free-tier Spaces sleep and cold-start on demand.

Preparing the live demo…

Free Hugging Face Spaces sleep and restart on demand — usually ready in a minute. If this takes long, open the Space's page to wake it up; the embed switches on automatically as soon as the Space is running.

checking the Space…
If the embed is slow or blocked, open the Space directly: RAG standalone → TinyGPT standalone → REST API live tour →
LIVE

Persian RAG assistant

Hybrid BM25 + dense retrieval with RRF fusion, re-ranking, prompt-injection guardrails and a paraphrase-aware answer cache — answering Persian questions with cited sources.

LIVE

GPT, trained from scratch — in your browser

The unchanged raw-NumPy stack runs in-browser via Pyodide/WASM: a 249k-parameter char-level transformer generating Persian text, no server involved.

API LIVE TOUR

REST API, captured session

A real Swagger UI from a committed OpenAPI snapshot plus verbatim captured responses: health, spam scoring, a cited RAG answer with per-stage timings, an SSE stream and Prometheus output.

Projects

Every project ships as a structured codebase (src/ + tests/), a README with methodology and evaluation numbers that can be re-run — including the unflattering ones.

LLM / RETRIEVAL

Persian RAG assistant rag-farsi-assistant

E5 embeddings + FAISS fused with a from-scratch BM25 via Reciprocal Rank Fusion; bilingual query expansion, exact + semantic answer cache, per-stage traces, RAGAS-style evaluation, Ollama/OpenAI providers and a Streamlit chat UI.

E5 hybrid Hit@1 = 0.967 · MRR = 0.983 · re-rank lifts Hit@1 0.81 → 0.92 on the committed 100-pair golden set (11 fixes, 0 regressions) · 188 tests
FAISSBM25 from scratchRRFFastAPIStreamlitPrometheus
DEEP LEARNING

TinyGPT tiny-gpt-from-scratch

A reverse-mode autograd engine, decoder-only transformer and Adam — all in raw NumPy, no PyTorch/JAX. Every primitive is verified against numerical gradients; Persian char-level training.

249k params, trains in 65 s on CPU (loss 4.89 → 1.22) · grad-check errors ~1e-10 · 32 tests
NumPy onlyautogradtransformerPyodide/WASM
NLP CLASSIFICATION

AI-text detector ai-text-detector

TF-IDF plus stylometric features (sentence-length variation, punctuation habits) with Linear SVM vs Naive Bayes vs Logistic Regression; every number reproduced in a real retraining run.

Accuracy 0.897 · F1 0.899 · ROC-AUC 0.964
scikit-learnTF-IDFstylometry
RECSYS

Recommender system recommender-system

User-based and item-based collaborative filtering plus matrix factorization (ALS + truncated SVD) — all implemented from scratch on MovieLens.

Item-CF RMSE 0.875 · ALS 0.914 · 25 tests
collaborative filteringALSMovieLens
FINANCE / TIME SERIES

Stock movement ML stock-movement-ml

20 technical indicators, walk-forward validation and a leakage-free backtest with costs — with a Plotly dashboard. The honest number stays published on purpose.

+25.45% on 696 out-of-sample days · OOS ROC-AUC 0.53 — reported as-is, because the methodology is the product
walk-forwardleakage-free backtestPlotly
NLP BASELINE

SMS spam classifier sms-spam

TF-IDF (1–2 grams) + Logistic Regression with 5-fold GridSearchCV — the disciplined baseline the bigger projects are measured against.

Accuracy 0.975 · ROC-AUC 0.987
TF-IDFLogistic RegressionGridSearchCV
PLATFORM

One FastAPI layer over all model families serving/

A single serving contract for RAG, spam and stock families: one OpenAPI schema, SSE streaming, per-stage Prometheus metrics, Docker Compose stack for local runs — plus a deployable HF Space with the index and E5 cache pre-baked at build time.

Get started in three commands

No GPU, no API keys, no model downloads needed for the unit tests — the CI runs network-free by design, and so can you.

Clone

The whole portfolio is one repository with a shared Makefile.

git clone https://github.com/Abolfazlrwm/Machine-Learning.git cd Machine-Learning

Run the tests

Every project's suite in one target — RAG, serving, TinyGPT, recsys, NLP projects.

pip install numpy requests pytest pypdf make test

Serve it

The FastAPI layer exposes all model families on one contract, with Swagger at /docs.

pip install -r serving/requirements.txt make api # http://127.0.0.1:8000/docs

Full stack (API + Ollama + Streamlit chat + Prometheus + Grafana): docker compose up — see the deployment guide.

How a query flows

The serving pipeline in one strip — every stage emits timings that land in Prometheus.

user query guardrails hybrid retrieval BM25 ⊕ dense, RRF re-rank cache LLM SSE stream bilingual (fa/en) prompt-injection gate exact TTL + semantic paraphrase layer

Engineering decisions

The load-bearing choices are written down in Engineering Decision Records — context, decision, consequences, with verified numbers only.

Hybrid retrieval with RRFDense misses exact lexemes, sparse misses paraphrases — fused, they beat either alone (Hit@1 0.967).
Embedding contract testA real 768-vs-384 drift incident is now structurally impossible to repeat.
Network-free CI320+ tests run on a deterministic fake embedder + mock LLM — fast, free, reproducible.
Honest numbers or no numbersThe stock project's OOS ROC-AUC 0.53 stays published, with the backtest that produced it.

Read all 11 decision records →

What you can do with it

Serve a Persian RAG product

Point the serving layer at your own corpus, keep the retrieval, guardrails, caching and metrics stack, and deploy with the included Docker Compose or the pre-baked HF Space image.

Teach and learn ML internals

TinyGPT's autograd engine and the from-scratch BM25/ALS implementations are deliberately readable and gradient-check-tested — a worked reference, not a black box.

Borrow the engineering discipline

Network-free CI, contract tests for model artifacts, tag-gated releases with changelog-extracted notes, ADRs: copy the patterns into your own project regardless of stack.

FAQ

Do I need a GPU, API keys or model downloads to run this?
No. The unit suites (320+ tests) run network-free on a deterministic fake embedder and a scripted mock LLM — that's how CI stays fast and reproducible. Real providers (Ollama, OpenAI) are optional: configure them with environment variables, documented in serving/.env.example.
Why is the stock predictor's ROC-AUC only 0.53? Isn't that bad?
Yes — and that's why it's published. Daily stock direction is close to unpredictable; the project's value is the leakage-free walk-forward backtest with transaction costs that proves it honestly, instead of a cherry-picked backtest that "predicts" 0.9 AUC. See the methodology page.
What exactly is a "fake embedder" and why would you test with one?
A deterministic stand-in that maps text to fixed vectors, so retrieval tests assert structure (ranking, caching, guardrails) without downloading gigabytes of model weights or getting flaky with floating-point drift. The real model's behaviour is pinned separately by contract tests — one of which exists because a real 768-vs-384 dimension drift incident happened and had to become impossible. See ADR-003.
Is the content Persian-only?
The flagship assistant is Persian-first (normalisation, tokenisation, bilingual query expansion Persian↔English, RTL UI), but the pipeline, docs and API are English-readable, and the guardrails are bilingual by design.
How do I cite this work?
The repository ships a CITATION.cff; GitHub renders it under "Cite this repository". Current version: see the releases.
Can I use this in my own project?
Yes — MIT license. Attribution appreciated, not required. If you reuse the serving contract or the test strategy, the ADRs explain the trade-offs you're inheriting.