RSSAmplifier

Blog

Alexander Junge's website

Recent content on Alexander Junge's website

alexanderjunge.netRSS feed ↗70 posts

Latest posts

Stingray racing and the rising bar for software

This weekend, our five-year-old son really wanted us to make our own racing game and what he wanted was super clear: only stingrays (his favorite pet animal) racing each other, and they should say “oh my days” when they crash. Using a vibe coding tool, we pretty much zero-shot a working game. Amazing that you can just do this in 10min these days! You can see the result above.

Basic async performance testing with FastAPI and Locust

Performance optimization is a crucial aspect of web application development, especially when dealing with concurrent requests. When writing FastAPI applications in Python, you can use the async and await keywords to improve performance in many use-cases by writing asynchronous code. However, most tutorials focus on sprinkling in a bunch of asyncs and awaits and hoping for the best. Between some…

Show me the prompt: PydanticAI

I am a happy user of pydantic and instructor, the latter being a well scoped tool with a well-defined surface area to use pydantic for structured outputs and validation for large language models. This week saw the release of PydanticAI that looks like a nice abstraction to build agents on top of pydantic. I think this personal preference is largely because of my preexisting bias to use pydantic…

After evals, flywheels

Let’s assume you have a few evals for your AI product in place that allow you to get a good idea of how well the underlying (set of) model(s) is doing and attract a few first users. And now what? Start building data flywheels! Flywheels are mechanisms that allow you to leverage the data you have to improve your model and attract more users. They are the key to scaling your AI product and the…

Recommended tutorial on achieving Structured Outputs in DSPy

I am a big fan and active user of instructor to make interactions with inherently probabilistic LMs more structured and reliable in the form of their output. Without approaches like this, making LMs work reliably in certain production settings would be a true nightmare. This is a really cool intro video by Connor Shorten (of Weaviate) to structured outputs in general and specifically using…

Recommended read: Your AI Product Needs Evals by Hamel Husain

I really like this blog post by Hamel Husain entitled ‘Your AI Product Needs Evals’. In particular, what sets this one apart from other posts on the topic is that it is very practical and actionable (by centering the post around a specific case study). It helps that this post is not written by an LLM tool provider that primarily tries to sell their new fancy tool to you and only…

Fine-tuning LMs as a way to move compute back from inference to training

As I was reading this review paper on tool use for language models (LMs) over the Easter holidays, a thought crossed my mind: There is an interesting trend when working with LMs in production to perform more and more computations at inference time. For example, tool-using agents, multiagent systems, elaborate state machines, and ever more complicated RAG systems like CRAG are becoming popular…

The Berkeley Function-Calling Leaderboard

Function-calling (aka tool-use) is essential to enable LLMs to run internet searches, write and execute code, generate images, use a calculator, … whenever that makes sense to solve the current task. The Berkeley Function-Calling Leaderboard gives a good overview of which LLMs perform best on function-calling benchmarks. Here is what the leaderboard looks like currently: Noteworthy A few…

RAG 2.0?

This blog post on “RAG 2.0” by Contextual AI got me thinking. Not sure, if it makes sense for anyone to be “announcing” (or even defining) RAG 2.0 but there are a few tidbits in this post hinting towards a potentially more powerful, general approach to RAG they are working on. The article is light on technical details and heavy on claimed “state-of-the-art”…

Building AI tools for an audience of one

With modern AI tools just being an API call away for most developers, the bottleneck to creating entirely new, powerful experiences is no longer a lack of access to technology but a lack of human creativity, understanding of the problem space, and an inability to translate what is technically possible to user value. As a developer in this space, it is super important to me to build tools just for…

Short: Differential privacy in a RAG setting

Why The usefulness of modern AI systems dramatically increases when the underlying AI models have access to recent, relevant data in addition to the information captured in the models’ internal parameters. This is the core idea behind both in-context learning and Retrieval Augmented Generation. Here is an interesting LlamaIndex blog post looking at a scenario where three parties want to…

Short: RAFT

RAFT: Adapting Language Model to Domain Specific RAG From the Gorilla LLM project, Retrieval Aware Fine-Tuning (RAFT) combines retrieval-augmented generation and fine-tuning to adapt language models to domain-specific knowledge. Blog post: here Paper: here Why Retrieval Augmented Generation (RAG) and fine-tuning are two of the most important concepts in the NLP domain when it comes to exposing…

Major news: I am co-founding amass

Major personal news today: I have joined amass as a co-founder solving challenges every life sciences researcher and R&D organization is facing: How to keep up with scientific knowledge, in all its shapes and sizes, both internally and externally? How to make optimal decisions by synthesizing new insights based on this knowledge? To solve these, amass is creating a scientific memory relying on…

Getting started as a technology team lead: books and resources I recommend

As I briefly mentioned in a previous post, I went from an individual contributor (IC) role to tech & team lead over the last few years. Most technical and team leadership growth comes from learning by doing and experiencing challenging situations for the first time, dealing with them with the help of the people around you, and coming out wiser at the other end. Then you run into the next thing and…

Recommending scientific articles interactively

TL;DR There are too many interesting research papers to read. This article describes an approach to recommend papers using user feedback and pretrained paper embeddings. Check the live app here or see the source code on GitHub. The app in action looks like this (no sound, just a video) - read on if you want to know how it works: Your browser does not support the video tag. Why?

Book review. Hands-On Healthcare Data by Andrew Nguyen

I recently finished reading Andrew Nguyen’s book “Hands-On Healthcare Data” published by O’Reilly in September 2022. What I particularly liked about the book: Clearly illustrating the complexity of healthcare data Performing scientific research, statistical analyses, data integration, or machine learning in a healthcare setting often means reusing data originally collected…

To grow, leave your comfort zone

Photo credit: Suzanne D. Williams on Unsplash When I reflect on the times when I rapidly developed as a person or as a professional, I notice that periods of growth followed a decision to leave a comfortable, current state behind and instead do something new. This new thing often felt challenging, uncomfortable, and scary. I failed more often than when I knew what I was doing. But I think leaving…

TIL: f-string formatting - a cheat sheet

I am a big fan of f-strings in Python. If you are not using them yet, you should! f-strings come with a string formatting syntax that makes it very convenient to create nicely formatted strings. For example, you can introduce padding: >>> v = "test" >>> f"{v:>20}" ' test' Or you can format dates and print weekdays instead: >>> from datetime import datetime >>> print(f"Happy {datetime.now():%A}!")…

GitHub Copilot generating PyTorch code comments: an anecdote

I have used GitHub Copilot, an ML pair programming tool based on OpenAI Codex, for a few months now when working on hobby projects and wanted to share a short anecdote here illustrating its usefulness and where it currently fails. In general, I believe that Copilot saves time while coding and I primarily use it as a “tab completion on steroids”. The core problem is, as with all text…

TIL: saying `yes` the Unix way

Today (well, earlier this week but let’s not be picky here) I learned about the Unix core utility yes. It works like this: $ yes y y y # [ad infinitum until stopped] $ yes no no no no # [ad infinitum until stopped] As you can see, yes either prints y\n until stopped or whatever string you pass it followed by a newline, again continuing until the process is killed.

Keeping sensitive information out of Jupyter notebooks stored in git version control

Jupyter notebooks are very useful to quickly prototype ideas in data science projects because they allow seeing code, the output of that code, and a narrative explaining its logic right next to each other. But when committing said Jupyter notebooks to version control systems like git, code output containing sensitive information (such as passwords, access tokens, or sensitive data) can easily end…

Book tip. Designing Machine Learning Systems by Chip Huyen

I recently finished (and enjoyed) reading Chip Huyen’s book “Designing Machine Learning Systems” published by O’Reilly. I’d recommend this book to anyone looking for an introduction to what it takes to make machine learning (ML) work in the real world, i.e., outside a pure research setting and in real products. Here is what I think about the book: What’s good…

Open source text-to-image diffusion

This is the obligatory post playing with text-to-image diffusion models recently made very popular by tools such as OpenAI’s DALL-E 2 or Google’s Imagen. If you ever want to try this out yourself, I highly recommend starting with this open-source implementation of stable diffusion. Here is an image generated by the prompt: an unsolvable problem, digital art (The black boxes are NSFW…

Comparing Oura personal health data over the years

I have been wearing an Oura ring for a few years now to track my nightly sleep, daily activity, and other health variables. The Oura app works well to track daily, weekly, and monthly differences in these variables but I was lacking a feature to compare my monthly or weekly data over the years. Visualizing monthly heart rate, year-on-year As a proof of concept, I visualized my average sleeping…

Multi-label classification using 🤗 Hugging Face Transformers AutoModelForSequenceClassification

🤗 Hugging Face Transformers AutoModelForSequenceClassification offers a quick way to fine-tune a pre-trained language model for a text classification task. AutoModelForSequenceClassification supports multi-label classification via its problem_type argument: from transformers import AutoModelForSequenceClassification model_ckpt = "distilbert-base-uncased" # etc. num_labels = 10 # etc. model =…

PyScript: looking beyond the hype

PyScript was announced on April 30th 2022 at PyCon US by Peter Wang, CEO of Anaconda Inc., and in an accompanying blog post. The announcement sparked a lot of interest and excitement in the Python community and generated a lot of hype. First off, PyScript is not a JavaScript replacement (and it does not want to be). PyScript instead aims to further democratize the superpower of programming by…

Hosting Machine Learning apps easily and freely via Hugging Face Spaces

Data science and machine learning (ML) projects frequently involve prototyping models as part of ML apps, showing them to potential users to get feedback, and iterating to improve both model as well as problem-solution fit. Tools like Gradio and Streamlit make it easy to develop visually appealing ML apps with a few lines of code. Making these apps available to users is unfortunately not trivial…

One JupyterLab, many projects

Jupyter notebooks edited in JupyterLab are my tool of choice when working with and exploring data in Python. I frequently mature code stored in notebooks to importable .py files and further to stand-alone Python packages. I recently read the “Everything Gets a Package” post where Ethan Rosenthal describes his data science project setup. This led me to rethink how I manage virtual…

Video: Create a GitHub Profile README in a few minutes

GitHub Profile READMEs are a great way to present your programming projects, interests and experience to the world. It only takes a few minutes to get started with your Profile README and this video will show you how:

Python 3.10: Structural pattern matching and other new features for data science

Structural pattern matching (aka the match statement) is a new feature introduced in Python 3.10 which was released on October 4th, 2021. A GitHub repository where I will explore and practice using structural pattern matching and other new features with data science use cases in mind is available here. Below is an example of a match statement used to parse a messy CSV file. Time will tell how much…

Generating fake tokens to find out about security breaches

I recently came across Canarytokens, a service generating trap tokens (URLs, images, PDF, and much more) that notify the owner when used. From their documentation: Canary tokens are a free, quick, painless way to help defenders discover they’ve been breached (by having attackers announce themselves.) The option to generate fake AWS API Keys is very interesting. Adding those to private…

Experimenting with ML-powered search in Amazon Kendra

Amazon Kendra is a managed search service offered by AWS. Using machine learning/natural language processing, Kendra is able to “understand” both search queries and the documents searched to answer questions directly or to perform a keyword-based search. Kendra is fully-managed by AWS which means that, as a developer, I do not need to worry about managing infrastructure, as, for…

Deleting old tweets

It’s good to clean up regularly. I just wrote a little script to delete all my tweets that are older than two years AND have less than three favorites/hearts AND I have not favorited myself. You can find my script on GitHub.

Labeling data in Amazon SageMaker Ground Truth

Acquiring and cleaning data, including reliable labels for supervised learning, determines the fate of every data science project and usually takes up about 80 percent of project time. For an NLP project I am working on (more on that in a later post), I have been looking for a simple tool to label named entities in text. After comparing a few alternatives out there, I decided to use Amazon…

Spotlight: New TaskFlow API in Apache Airflow 2

I recently switched to version 2 of Apache Airflow which was released in December 2020. I am a big fan of the new TaskFlow API and want to highlight it here. The TaskFlow API allows users to write DAGs in a much more efficient way, requiring less boilerplate code. Specifying task dependencies and exchanging data between tasks via XComs is also much easier now. A minimal example of a DAG using the…

Deploying a custom Python machine learning model as an AWS SageMaker endpoint using MLflow

Deploying a trained machine learning model behind a REST API endpoint is an common problem that needs to be solved on the last mile to getting the model into production. The MLflow package provides a nice abstraction layer that makes deployment via AWS SageMaker (or Microsoft Azure ML or Apache Spark UDF) quite easy. Here follows an example that illustrates how a PyTorch-based pre-trained…

%autoreload: reload code before execution in Jupyter

As I keep forgetting the following and keep finding outdated answers/documentation when searching online, I hope this will be useful to others and to future me: Autoreload all imported packages in Jupyter %load_ext autoreload %autoreload 2 Autoreload specific packages foo and bar %load_ext autoreload %autoreload 1 %aimport foo, bar Documentation Link

GitHub Actions: Setting up poetry and running CI

This weekend, I set up my first GitHub Action to run continuous integration using Pytest for one of my repositories. Dependencies and virtual environment managment is done via Poetry. For example, the following file, placed in .github/workflows/python-app.yml of a GitHub repository, does the following: checkout the repository install Python install Poetry install dependencies using Poetry in a…

Simple NER visualization using displaCy

displaCy, a component of the excellent spaCy NLP library makes it super easy to visualize named entity recognition (NER) results from a Jupyter notebook. For example: The full example notebook is available as a GitHub Gist here. Further documentation is available here.

Using a Raspberry Pi as a sound-activated recorder

Using a Raspberry Pi 4 Model B and a Seeed ReSpeaker Mic Array v2.0 connected via USB, I built a simple sound-activated recorder. The Raspberry Pi records one-minute sound snippets at a time and, using a very simple heuristic, detects sound in the snippet. Snippets where no sound was detected are deleted. Snippets where sound was detected are converted to MP3 by a scheduled job and kept. This was…

Deploying fastAPI to AWS Lambda via Amazon API Gateway

I started experimenting with AWS and as a first tiny project I deployed a fastAPI-based REST API to AWS Lambda, a serverless framework. Amazon API Gateway acts as a front-door to the Lambda instance. The architecture roughly looks like this: The deployed API is a simplified version of the REST API described in a previous post. My code is available on GitHub. Using AWS SAM, the deployment works…

Book tip: Inspired by Marty Cagan

I recently read the book ‘Inspired: How to Create Tech Products Customers Love’ by Marty Cagan and can wholeheartedly recommend it to anyone interest in learning more about digital product management. Split into many short chapters, the book covers everything from case stories describing the work of successful product managers (PMs) at big tech companies to developing product roadmaps,…

Building a Vue/Vuetify application to label articles

As described in my last post, I used Apache Airflow to query articles from arxiv.org. I now built a small web application to label articles that I find interesting (upvote) or not interesting (downvote). Using the application, it took me about an hour to label 500+ arxiv.org preprint articles with an up- or downvote. I plan to use these label to recommend new articles of interest in the future.…

Querying arXiv preprints using Airflow

Querying arXiv preprints using Apache Airflow I experimented with Apache Airflow to schedule hourly workflows fetching recent preprint articles from different arXiv categories via the public arXiv.org REST API. These articles are then stored in a PostgreSQL database via a custom-built fastAPI-based REST API. The setup looks like this: The code is fully dockerized and available on GitHub along with…

Sanity checking your git commits

Most projects I am working on enforce specific code styles, minimal requirements for documentation, or other rules every code contribution needs to follow. Git pre-commit hooks are very useful to automatically check that commits fulfill these requirements. This allows all project contributors to focus on the code instead of manually running different code formatters or wasting time in unnecessary…

Starting a new job

On February 1st 2019, I left my position as a postdoctoral researcher at the University of Copenhagen and started working as a data scientist in pharmaceutical R&D at Novo Nordisk A/S. I look forward to contributing to many exciting project and will perhaps write about some of the key differences I perceived when working in academic and industrial reserarch here.

Trying out Docker Compose

Docker containers are well-suited to ship software because they allow a fast, flexible, and efficient deployment in any computing environment - be it on premise, in the cloud, etc. Docker Compose allows users to orchestrate multiple Docker containers that can talk to one another. Docker Compose applications are perfectly suited for providing data science and machine learning infrastructure where…

Packaging a Python library: first steps

A central goal in the development of CoCoScore is to make it as easy as possible for new users to get start with context-aware co-occurrence text mining. So far, I recommended new users to set up a conda virtual environment to install CoCoScore and its dependencies. I now started working on releasing CoCoScore as a library on PyPI. Releasing on PyPI will allow an installation via pip and make it…

CoCoScore preprint available

Our preprint describing CoCoScore was posted on bioRxiv yesterday. CoCoScore is a novel, context-aware co-occurrence scoring scheme for text mining applications. Our method can be used to extract biomedical relations, such as protein-protein interactions, from the scientific literature. CoCoScore unifies previous approaches based on machine learning and statistical co-occurrence counting in one…

Book tip. Machine Learning Yearning by Andrew Ng

I just finished reading Andrew Ng’s new book ‘Machine Learning Yearning’ and would like to recommend it to everyone interested in learning more about managing machine learning projects. Andrew Ng is one of the world’s thought-leaders in the field of machine learning. Many of his lectures and MOOCs are freely available online and they are great resources for hands-on tips…