Machine Learning Mastery
AI news source. Articles are auto-selected and adapted by Hamidun News editors.
Latest publications

A Python Prompt Test in Under 150 Lines Catches Edits That Silently Break AI Answers
A walkthrough of building a Python harness under 150 lines that flags, after every prompt edit, which assistant answers have stopped working.

Why model.generate() Isn't a Service Yet: A Mini LLM Engine with a 4-Request Queue
A single model.generate() call is not enough for a service. You need a queue, KV-cache memory accounting, cancellation, and metrics. A Machine Learning Mastery walkthrough of a Python mini-engine recommends vLLM.

How to Write an MCP Client with Python SDK 2.0 and Let Claude Call Tools
A step-by-step tutorial: an MCP client built on Python SDK 2.0 connects a local weather server over stdio and lets Claude call its tools. Old v1 code no longer works.

Qwen2.5-7B Checked Its Own Work in Three Roles and Caught an Error, but Slowed Down 6.3x
One 7B model on Colab played author, critic and judge in turn and fixed an answer from 50 to 90, but took 16.67 s instead of 2.63 s and used 7.8x more tokens.

Microsoft BitNet on a Laptop CPU Delivers 34 Tokens per Second at 0.4 GB of Memory
Microsoft's BitNet stores its weights as just three values and runs on a regular CPU with no GPU. We look at how to run it and where it is stronger or weaker than 4-bit Qwen.

A Simple 500-Text Test: BGE Small Separated Topics 1.7 Times More Cleanly Than MiniLM
A guide to embeddings: how the models differ, how much memory a million vectors takes, and how to compare two models on your own texts with a short Python script.

Local AI Agent in Python: Qwen3 4B and Ollama Search Your Files Without an API Key
A step-by-step breakdown of building a Python assistant for a project folder on Qwen3 4B and Ollama. The model weighs about 2.5 GB, runs locally, and needs no API key.

A vLLM Request with n=4 Uses Roughly Four Times the KV Cache for Its Outputs
According to a Machine Learning Mastery breakdown, vLLM with n=4 runs four responses at once and holds roughly four times the KV cache, while top-k and top-p barely save any compute.

TabPFN-3.5 Tops the TabArena Leaderboard, but Boosting Wins on Very Large Tables
The pretrained tabular model TabPFN-3.5 ranks first on TabArena for small and medium datasets, but it is capped at 1 million rows and needs a GPU. Here is what to choose in 2026.

Operator Fusion and FlashAttention: Keeping GPUs from Idling While They Wait for Memory
Language model inference on a GPU is often slowed not by math but by memory traffic and launching many small operations. Operator fusion, FlashAttention, and CUDA Graphs address this.

LLM Compression Without Quantization: Pruning Cuts MLP Width from 8192 to 2048 Channels
Quantization isn't the only way to cut inference costs: pruning and distillation shrink the model itself. In a teaching example, an MLP block is compressed from 8192 to 2048 channels, a 4x reduction.

How to Serve a Local Llama 3 Classifier via FastAPI Without Paid Clouds
Scikit-LLM turns a local Llama 3 into a regular classifier with fit and predict, and FastAPI serves it over HTTP, with no paid cloud API and no fine-tuning.

How to Compress an LLM to 8 Bits End to End: SmoothQuant and FP8 Against Outliers
Quantizing LLM weights to 8 bits is straightforward, but activations are harder because they change with every request. We break down W8A8, SmoothQuant and FP8, and how to run them through LLM Compressor and vLLM.

Quantization Makes INT8 LLM Weights Half the Size of FP16: A TorchAO Guide
Every token an LLM generates requires rereading all of its weights from memory. Here's how 8-bit integers (INT8) halve that footprint and what to check before you deploy.

Graph-RAG: Database Beats Wiki and PDFs — 44% Fewer Hallucinations on Average
How to build Graph-RAG from a live database, wiki and PDFs with strict priorities: on conflict, the assistant trusts the database. IDC estimates graph context cuts hallucinations by 44%.

Schema Passed, Invoice Total Off by 10x: How to Validate LLM Structured Output
Pydantic accepted the model's response, the schema matched, and yet EUR 1,250 on the invoice turned into 125. Here is how to catch such errors: validation against the source, bounded retries, and constrained decoding.

How to Lock Down AI Agent Code: subprocess, Docker and microVM — Three Levels of Protection
An agent that writes and runs code is only as safe as the place where that code runs. We break down three levels of isolation, from subprocess to Firecracker, and the price of each.

How Much Memory a Model Will Eat: How GQA, Sliding Windows, and MLA Change the KV-Cache
Two models with the same parameter count can need very different amounts of inference memory. Here is how the KV-cache works and how to estimate how many requests your GPU can handle.

Groq processed five reviews in 2 seconds, Ollama in 81: what the test leaves out
Where should you classify reviews: on your own computer or through an API? A tutorial test found a nearly 40-fold difference, but compared different models. Here is what is worth checking on your own data.

Unsloth Turns Qwen3.5-4B Into a 10-Intent Classifier on a Single T4
When a model needs to choose the next action rather than produce an eloquent response, generation becomes unnecessary. Unsloth proposes training Qwen3.5-4B to identify a user's intent and return a confidence score.

16-bit formats halve model weight memory without changing the architecture
The same AI model can take up 28 GB or 14 GB—the number format makes all the difference. But blindly switching to fewer bits can slow the model down and degrade its responses.

Google's DiffusionGemma writes text in blocks of 256 tokens at once, rather than one at a time
Google has released an experimental open model that does not type word by word, but instead “develops” an entire paragraph out of noise. Here is how to run it and how it differs from conventional LLMs.

pgvector vs Qdrant: a benchmark on 100 000 vectors with 1536 dimensions
Machine Learning Mastery offers a reproducible pgvector vs Qdrant test: identical HNSW, 1536 dimensions, 100 thousand vectors, p50/p95/p99 and QPS on an ordinary laptop.

Your Own LLM Test Harness in Python: 4 Modules and About 60 Lines of Code
How to build a custom LLM test harness with 20–50 real prompts, async runs, two kinds of judges, and a log that lets you rescore results without new API calls.

Machine Learning Mastery shows how to build RAG on scikit-learn without a vector database
Machine Learning Mastery walks through a lightweight end-to-end RAG pipeline: open-model embeddings, vector search in scikit-learn, and answer generation from retrieved context.

Unsloth and Llama 3: How to Teach a Model to Call APIs Reliably via JSON
Machine Learning Mastery walks through fine-tuning Llama 3 for strict JSON tool calling with Unsloth: a general-purpose model breaks API schemas, and LoRA helps fix that.

How to Build a Browser AI Agent in Python: A Step-by-Step Guide from Machine Learning Mastery
Machine Learning Mastery has published a guide to building Python agents that control a browser: they open sites, click and fill in forms without an official API.

Transformers.js and Embeddings: Semantic Search Without Server Infrastructure
Machine Learning Mastery shows how to replace keyword search with semantic search using Transformers.js, a browser library that builds vector embeddings on the client with no server API.

Agentic AI Pipeline: 7 Components That Separate Production from a Demo
Machine Learning Mastery has published a guide to seven architectural components that set a production agentic AI system apart from an ordinary demo script.

How AI Agents Manage the Context Window on Long-Running Tasks: Five Strategies
Machine Learning Mastery breaks down five practical context-window strategies for AI agents that run for hours and hit a model's token limit.