LLM Student Advisor: RAG-powered Chatbot for MSc Econometrics

(3.12.7) Introduction In this post, I’ll document how I built Metrica, an AI-powered student advisor chatbot for the MSc Econometrics program. The chatbot uses Retrieval-Augmented Generation (RAG) to provide accurate information by combining the power of a large language model (LLM) with reliable source material such as FAQs and terms of study. Metrica is designed to assist students with common queries about the program and provide guidance based on official documentation. ...

July 3, 2024 · 11 min · 2314 words · Martin Christopher Arnold

Interactive digit recognition in tensorflow.js

(pynenv setup with python 3.9.20) The story so far In my previous post about Convolutional Neural Networks (CNNs), I demonstrated how to train a model for handwritten digit recognition. Now, we’ll take this model further by deploying it in a web application using TensorFlow.js. This post guides you through the process of exporting the trained model and implementing it in an Observable notebook where users can draw digits on a canvas for real-time classification. ...

June 18, 2024 · 4 min · 848 words · Martin Christopher Arnold

CNN for digit recognition

(pynenv setup with python 3.9.20) Convolutional Neural Networks (CNNs) are powerful tools in image recognition tasks. A classic problem solved by CNNs is predicting handwritten digits from the MNIST dataset. Here’s how to train a CNN for handwritten digit classification using TensorFlow’s Keras API in Python. Dataset and Preprocessing The MNIST dataset (delivered in tensorflow.keras.datasets) consists of 70,000 grayscale images, each representing a digit (0–9). We first load the TensorFlow library as tf, preprocess the data by reshaping the images into a 28x28 pixel format with 1 channel (grayscale), and normalize pixel values to the range $[0, 1]$. The labels are one-hot encoded for multi-class classification. ...

June 17, 2024 · 5 min · 920 words · Martin Christopher Arnold

Mallows Model Averaging: Python Example

Quick Facts Mallows Model Averaging (MMA) (Hansen 2007) combines predictions from multiple models to minimize the mean squared prediction error (MSE), balancing predictive accuracy against model complexity. Hansen demonstrates that MMA is asymptotically optimal, achieving the lowest possible squared error within a class of discrete model averaging estimators. ...

July 18, 2022 · 8 min · 1666 words · Martin C. Arnold

Understanding and Implementing the Box-Muller Transform in Python

When simulating random variables in statistics or machine learning, we often need samples from a standard normal distribution. However, programming languages that are not focused on statistics often lack a rich suite of random number generators for various distributions. Therefore, it is essential to know how to implement such generators from scratch, typically using uniformly distributed pseudo-random numbers. This is where the Box-Muller Transform comes into play—a clever method to transform two uniform random variables into two independent standard normal random variables. ...

March 15, 2021 · 7 min · 1420 words · Martin Christopher Arnold