RSSAmplifier

Blog

Christopher Samiullah

Christopher Samiullah - Christopher Samiullah

christophergs.comRSS feed ↗45 posts

Latest posts

A Fun PydanticAI Example For Automating Your Life

Disclaimer: I work on Pydantic Logfire but these opinions are my own. Introduction Imagine you want an AI application that periodically fetches some real-world data, analyzes it with an LLM, and saves a neat, validated result without ever worrying about servers. That’s the longing behind this toy Electric Vehicle Charging Growth CLI built on PydanticAI , Typer and scheduled via the GitHub Actions…

ZIRP's End Meets AI - Changing the Rules of Software Work

The end of the Zero Interest Rate Period (ZIRP) and the advent of modern AI have tipped the balance of power in the technology industry back to the employer, and continue to reshape the industry. This post examines the second and third order effects of these major trends. 1. Introduction: A Changing Tech Industry The end of ZIRP After the global financial crisis of 2008/2009, many economies…

Observability for Generative AI

Disclaimer: I work on Pydantic Logfire , but these opinions are my own. Table of Contents Introduction 1. Non-Determinism: Same Roots, Different Scale of Impact 2. Multi-Step Agentic Behavior vs. Single-Pass Predictions 3. Observing Retrieval-Augmented Generation (RAG) 4. Embedding Analysis & Visualization for Drift and Performance 5. Multi-Modal (Video, Image, Audio, and Beyond) 6. Security &…

Scaling AI with Open-Source Models - Leveraging Together AI for Enhanced Applications

Welcome to part 7 of this AI Engineering open-source models tutorial series. Click here to view the full series . Table of Contents Introduction Why Not Host the Model Ourselves? Enter the AI as a Service (AIaaS) Platforms TogetherAI Pros TogetherAI Cons Mini-Project Example with TogetherAI Summary If you’re not familiar with Large Language Model (LLM) basics (e.g. you don’t know what “inference”…

The Technical User's Introduction to LLM Tokenization

This blog post is basically my notes from Andrej Karpathy’s excellent YouTube talk Let’s build the GPT Tokenizer Table of Contents Introduction Why Does Tokenization Matter? Tokenization Details Naive Vocabulary Construction Example: Shakespeare Understanding Tokenization Challenges Interlude - Why Can’t we Just Use the Unicode Codes Points? Byte Pair Encoding (BPE) Algorithm What’s the Difference…

Django SEO: A Sitemap Tutorial For Humans

Table of Contents Introduction Step 1: Install Django’s Sitemaps Framework Step 2: Define Your Models Step 3: Update Your Data Models Step 4: Create Sitemap Classes Step 5: Update URLs with Sitemaps Step 6: Inspect Your Sitemap.xml Step 7: Submit Your Site to Google Search Console Introduction: So You Want to SEO Optimize Your Django Website? This post will show you how to correctly use Python’s…

Production RAG with a Postgres Vector Store and Open-Source Models

Welcome to part 6 of this AI Engineering open-source models tutorial series. Click here to view the full series . Table of Contents Caution: Advanced Material Ahead Retrieval Augmented Generation (RAG) Overview What’s an Index? What’s a Vector Store Index? Why Care About Index Storage? The Basic Index Storage PostgreSQL and pgvector Integrating RAG and Postgres Vector Store in Django (Detailed)…

Leveraging Open Source Models for AI Evaluation with DeepEval

Welcome to part 5 of this AI Engineering with open-source models tutorial series. Click here to view the full series . Post Sections 1. Introduction to AI Evaluation Challenges 2. AI Evaluation Metrics 3. Introducing DeepEval: A Framework for AI Evaluation - Code starts here 4. DeepEval in Action: Evaluating a Simple Language Model 5. Closing Thoughts Introduction to AI Evaluation Challenges Once…

Retrieval Augmented Generation (RAG) with Llama Index and Open-Source Models

Welcome to part 4 of this AI Engineering open-source models tutorial series. Click here to view the full series . Post Sections Skip to section 3 if you just want code 1. What is Retrieval Augmented Generation (RAG) 2. Intro to Llama Index 3. Using Open Source Models with Llama Index - Python Code Starts Here 4. Persisting Embeddings 5. Why Open-Source RAG is a Big Deal What is Retrieval Augmented…

AI Engineering with Open-Source Models - Ultimate Tutorial

In numbers, there’s probably going to be significantly more AI Engineers than there are ML engineers / LLM engineers. One can be quite successful in this role without ever training anything. - Andrej Karpathy This is a work-in-progress ongoing series of tutorials. I will add a new one every week. Subscribe to the blog to receive these updates, as well as a digest of what is happening in the world…

Running Open Source LLMs In Python - A Practical Guide

Welcome to part 3 of this AI Engineering tutorial series. Click here to view the full series . Table of Contents 1. Installation & Setup 2. Selecting and Downloading a Model 3. Using Your Model with llama.cpp Locally 4. Prompt Setup 5. Formatting LLM Output With GBNF Grammar 6. Streaming Responses 7. Multi-model Modals 8. Summary The creation of open source Large Language Models (LLMs) is a huge…

Transcribing Audio mp3 files with Python and OpenAI's Whisper Model

Introduction Whisper, an advanced automatic speech recognition (ASR) system developed by OpenAI, is changing how we transcribe audio files. Offering unparalleled accuracy and versatility, it can handle various languages and audio qualities and is completely open-source with a permissive MIT licence. This makes Whisper not just a technological marvel, but a practical tool for professionals and…

The Technical User's Introduction to Large Language Models (LLMs)

The Technical User’s Introduction to Large Language Models (LLMs) This post is a summary of Andrej Karpathy’s excellent 1 hour talk introducing LLMs Table of Contents 1. What is a Large Language Model? 2. How are Large Language Models Created? 3. Stages of LLM Training 4. Evaluating LLM Performance 5. Exploring the Capabilities of LLMs 6. The Future of Large Language Models and Generative AI What…

The FastAPI Ultimate Tutorial

Introduction Tutorial Series Contents Optional Preamble: FastAPI vs. Flask Beginner Level Difficulty Part 1: Hello World Part 2: URL Path Parameters & Type Hints Part 3: Query Parameters Part 4: Pydantic Schemas & Data Validation Part 5: Basic Error Handling Part 6: Jinja Templates Part 6b: Basic FastAPI App Deployment on Linode Intermediate Level Difficulty Part 7: Setting up a Database with…

FastAPI vs Flask - The Complete Guide

Introduction More and more people are getting onboard the FastAPI train. Why is this? And what is it about this particular web framework that makes it worth switching away from your tried-and-tested Flask APIs? This post compares and discusses code from an example Flask and FastAPI project. The sample project is a JSON web token (JWT) auth API. Here is the full source code . I’m willing to concede…

Python tox - Why You Should Use It and Tutorial

Introduction Most people in tech will have heard the classic “it works on my machine” excuse response, one so classic that it has its own meme: “It” may well work on your machine. But that’s probably not good enough when teammates and build servers need to run your Python code. tox fixes this problem (and quite a few others). In this detailed post I’m going to delve into why tox can save you time…

Monitoring Machine Learning Models in Production

Introduction Once you have deployed your machine learning model to production it rapidly becomes apparent that the work is not over. In many ways the journey is just beginning. How do you know if your models are behaving as you expect them to? What about next week/month/year when the customer (or fraudster) behavior changes and your training data is stale? These are complex challenges, compounded…

First Impressions of Data Science Version Control (DVC)

Introduction I was recently approached by the team developing Data Science Version Control (DVC). What follows are my initial thoughts after giving the system a test for a day. Contents ML System Challenges and DVC A Typical Approach DVC Setup Tracking Data with DVC DVC Pipelines Reproducibility Versioning Incorporating into CI Evaluation Machine Learning System Challenges and DVC Once machine…

Top 10 Software Development Fundamentals for Data Scientists

Introduction Drew Conway famously created this Venn diagram of skills for a data scientist. Now, the “Maths/Statistics” and “Substantive Expertise” sections of this diagram are quite self-explanatory. But what exactly are “hacking skills?” Here, Conway is using “Hacking” in the positive sense of the word , not the criminal sense: For better or worse, data is a commodity traded electronically;…

Deploying Machine Learning Models in Shadow Mode

Introduction The strategies you adopt when deploying software have the potential to save you from expensive and insidious mistakes. This is particularly true for machine learning systems, where detecting subtle data munging, feature engineering or model bugs in production can be very challenging, particularly when the production data inputs are hard to replicate exactly. “Shadow Mode” is one such…

How to Deploy Machine Learning Models

Introduction The deployment of machine learning models is the process for making your models available in production environments, where they can provide predictions to other software systems. It is only once models are deployed to production that they start adding value , making deployment a crucial step. However, there is complexity in the deployment of machine learning models. This post aims to…

Elegant Flask API Development Part 1

Introduction Flask is one of the most popular web (micro)frameworks in the Python ecosystem. In contrast to Django’s “batteries included” approach, Flask is lightweight. This means that its core is simple and extensible, and that many of the design decisions are left to the developer. There are many pros to Flask, and to be clear, I think it is a great tool which I personally enjoy using. However,…

Using Python Concurrent Futures

Python concurrent.futures concurrent futures are described in the docs as: “a high-level interface for asynchronously executing callables”. In this post I’m going to look at: Why you might want to use futures The two key ways to use the futures.Executor map method (via threads or processes) and their pros and cons Some useful sample and benchmarking code If you don’t know the difference between a…

RollTec Write Up

In the summer of 2016 I ran a kickstarter campaign for a wearable for martial artists. It did not succeed. However, I did learn an enormous amount, which I have written up in proper academic journal format. You can download the paper here.

Using Python smtplib and smptd

Introduction This is a basic guide for an area where I wasn’t able to find any particularly great tutorials, perhaps because this stuff is obvious to more experienced developers. Well, it wasn’t to me. OK, to begin: If you want to send an email using Python, you need two things: 1) An SMTP client 2) An SMTP server In most cases, you will connect to a remote SMTP server, such as gmail’s, or perhaps…

Overview of Python Generators Part 1

Introduction Most Python developers know about generators, but don’t really use them very often. They are aware of the yield statement, but if you read their code, it tends not to feature. Let’s do away with this hesitation and take a close look at how to use these powerful Python tools. To begin, let’s clarify some terminology. A generator is a particular type of function which returns an object…

Using Python errno

Python errno Introduction You probably won’t come across errno until you have been using Python for a little while. When you do, it may not be immediately clear why you need it. Here’s a code snippet to view the full range of errors: import errno import os print {i: os.strerror(i) for i in sorted(errno.errorcode)} The docs give the following intro: This module makes available standard errno system…

Using Python copy

Python copy Introduction The background to copy in the docs makes the point: Assignment statements in Python do not copy objects, they create bindings between a target and an object This is a super important Python concept. Instead of variables (in the classic sense), Python has names and bindings. When you do: foo = 1 Then you are binding the name foo to the object 1 . To check that 1 really is…

Using Python glob

Python glob glob is described in the docs as: “Unix style pathname pattern expansion”…So what is that? Basically, anytime your program needs to look for a list of files on the filesystem, and the names of these files match a pattern, then glob will help you get the task done. The glob API The API for using glob is brief, with three main methods: glob.glob(pathname, *, recursive=False) The main…

Using Python unittest.mock

Python unittest.mock As you test your Python code, there will be operations which are slow and painful to test. These are usually bits of code that do things with the filesystem or involve network access. unittest.mock provides a way to mimic these bits of ‘slow’ code, so that your test suite can run fast, or to prevent you from having to write very complex tests. Installation After Python version…

Using Python datetime

Python datetime The datetime module is for manipulating dates and times. It is often used in conjunction with the time and calendar modules. In programming, dealing with dates and times can be difficult. In a Python context, key concepts to note are that we usually deal with two types of date and time objects: “Aware”: knows about political time adjustments (e.g. daylight saving), and therefore…

Using Python setuptools

Python setuptools The setuptools module deals with building and distributing Python packages. Technically, setuptools is not part of the Python standard library. However, the standard library package that is responsible for the same task, distutils , recommends using setuptools for distribution as it has greater functionality. setuptools is complex. This guide focuses purely on the basics to get…

Using urllib.parse in Python

In Python 3, urllib.parse contains lots of functions for doing things with URLs (note that in Python 2, these are not organized in quite the same way): urlparse parse_qs parse_qsl urlunparse urlsplit urlunsplit urljoin urldefrag quote quote_plus quote_from_bytes unquote unquote_plus unquote_to_bytes urlencode What follows is a very brief explanation and usage example of each, to give a flavor of…

Using the Python json Library

Using the Python json Library: A Basic Guide This guide uses Python 3 JSON (JavaScript Object Notation) is everywhere on the internet. It’s a “lightweight data interchange format” which has become one of the most common ways to send information from web applications to web browsers. If you’re doing any work involving calling web APIs, the chances are you are going to come across JSON data. Python…

An Overview of Cross-Site Scripting

Introduction Recently I was asked to explain Cross-Site Scripting (commonly referred to as XSS), and gave an answer with which I was not satisfied. In order to improve my understanding, I’m writing this blog post to summarize exactly: What XSS is Example XSS attacks How to defend against XSS Note that I am not an expert in this area, so make sure you do further fact checking to secure your…

MetaWear Guide Series Part 10

This is part 10 of a multipart series showing you how to get started with the MetaWear platform. View the contents of the series to easily skip forwards or backwards To make our ScannerActivity useful, we need to be able to trigger our MyActivity class (which we built in parts 2-8). We will do this via the mechanism of an Android intent , which is how you start one activity from within a different…

MetaWear Guide Series Part 9

This is part 9 of a multipart series showing you how to get started with the MetaWear platform. View the contents of the series to easily skip forwards or backwards One of the reasons why using the MetaWear sample Android app is a big jump for those new to Android is that it involves multiple activities and especially because it uses fragments which build upon other fragments. This can make some…

MetaWear Guide Series Part 8

This is part 8 of a multipart series showing you how to get started with the MetaWear platform. View the contents of the series to easily skip forwards or backwards For anyone looking to do analysis of the data they are collecting with their board, it is likely that you will want to access the data so you can analyze it using languages/tools like Python, R or Matlab. The easiest way to get started…

MetaWear Guide Series Part 7

This is part 7 of a multipart series showing you how to get started with the MetaWear platform. View the contents of the series to easily skip forwards or backwards In this post we will simultaneously stream data from the accelerometer and gyroscope. This is a typical use case for analysing motion since the combination of data gives a much richer dataset upon which to perform machine learning…

MetaWear Guide Series Part 6

This is part 6 of a multipart series showing you how to get started with the MetaWear platform. View the contents of the series to easily skip forwards or backwards In the previous section we saw how to stream data. Streaming is, for most applications, the way to go. However, it requires an uninterrupted bluetooth connection. If you are using your board in a scenario where the bluetooth connection…

MetaWear Guide Series Part 5

This is part 5 of a multipart series showing you how to get started with the MetaWear platform. View the contents of the series to easily skip forwards or backwards A key concept to grasp with the MetaWear platform is routing . You interact with sensor data from the board by creating routes: Routes are constructed via a Java DSL that enables users to express how they want to process the data…

MetaWear Guide Series Part 4

This is part 4 of a multipart series showing you how to get started with the MetaWear platform. View the contents of the series to easily skip forwards or backwards About Modules Now that we have established a connection to the board, we can begin interacting with modules. Modules are on-board sensors or features supported by the firmware. We do this by calling MetaWearBoard.getModule . Let’s…

MetaWear Guide Series Part 3

This is part 3 of a multipart series showing you how to get started with the MetaWear platform. View the contents of the series to easily skip forwards or backwards Binding the Service For us to interact with the MetaWear board, we need to bind the Bluetooth service in our application and keep a reference to it. This is one of the more confusing parts of working with the MetaWear platform, and…

MetaWear Guide Series Part 2

This is part 2 of a multipart series showing you how to get started with the MetaWear platform. View the contents of the series to easily skip forwards or backwards Prerequisites 1) You will need at least one MetaWear sensor, which you can buy from mbientlab . The code in this series should work for any of the MetaWear platform sensors (with a few small differences depending on the available…

MetaWear Guide Series Part 1

Introduction This is the first in a series of tutorial posts which aim to help you start working with the Metawear platform using the Android API. The series is designed to be followed in order, with the complexity of posts (and the sample project) gradually growing as the series unfolds. Some prior knowledge of programming is required, but I’ve tried to make this as accessible as possible, so no…