LLM Temperature, Top-P, and Top-K Explained, With Python Simulations
Build temperature, top-p, top-k, and min-p sampling from scratch in Python. Interactive code, probability visuals, and a per-task cheat sheet.
137 tutorials tagged Python on Machine Learning Plus, newest first. Most of them belong to the Gen AI category.
Build temperature, top-p, top-k, and min-p sampling from scratch in Python. Interactive code, probability visuals, and a per-task cheat sheet.
Learn to use the OpenAI API in Python. Master chat completions, streaming responses, error handling, retries, and async calls with runnable examples.
Build a working BPE tokenizer in Python step by step. Learn how LLMs split text into tokens, implement byte pair encoding, and count tokens with...
Master Polars with 101 hands-on exercises and solutions, covering DataFrames, groupby, joins, window functions, lazy eval, and more.
Learn LLM structured output in Python with 3 methods: OpenAI JSON schema, Claude tool extraction, and Instructor. Build a type-safe invoice parser...
Build a resilient LLM client in Python with retry, fallback chains, circuit breakers, and rate limiting, pure Python, runnable code, no SDKs needed.
Learn OpenAI function calling in Python with 3 working tools. Build the tool-use loop, handle parallel calls, and design schemas using raw HTTP...
Master the OpenAI Batch API in Python: build a reusable pipeline for 10,000+ prompts at 50% cost with JSONL formatting, progress polling, and error...
Master the OpenAI API in Python with raw HTTP requests. Learn chat completions, streaming, parameters, error handling, retries, and cost tracking...
Learn to run LLMs locally with Ollama. Install Llama, Mistral, and DeepSeek, use the OpenAI-compatible Python API, and build a local-to-cloud...
Learn multimodal AI in Python with GPT-4o, Claude, and Gemini vision APIs. Build image classification, chart analysis, receipt OCR, and audio...
Build a multi-provider LLM router in Python with cost-based routing, latency tracking, and automatic fallbacks across Groq, Together AI, and...
Stream LLM tokens from OpenAI, Claude, and Gemini in Python using SSE and async generators. Includes FastAPI server, backpressure handling, and...
Master LLM temperature, top-k, and top-p with interactive Python simulations. Runnable code, exercises, and a sampling playground to build real...
Build a Python benchmarking harness to compare GPT-4o, Claude, Gemini, and Llama on quality, latency, and cost with LLM-as-judge and radar charts.
Build an LLM evaluation pipeline in Python with LLM-as-judge scoring, rubric design, A/B testing, and regression alerts. Runnable code examples...
Learn to call OpenAI, Claude, and Gemini APIs from Python in 15 minutes. Includes code examples, error handling, streaming, and a unified wrapper.
Build a Python benchmark harness comparing Groq, Fireworks, Together AI, and Replicate on latency, throughput, and cost with runnable code.
Master Hugging Face inference in 20 minutes. Run LLMs locally with Pipeline API or serverless via HTTP, with Python examples you can copy and run.
Build a multimodal document analyzer with the Google Gemini API in Python. Analyze images, PDFs, and text with structured JSON output, using raw HTTP...
Learn how LLM context windows work, count tokens with tiktoken, estimate API costs, and build a Python token budget manager that allocates context...
Build a working BPE tokenizer in Python, learn how text becomes tokens, and use tiktoken to count tokens and estimate LLM API costs across providers.
Master the Claude API with raw HTTP, messages, streaming, tool use, extended thinking, and prompt caching with runnable Python code examples.
Add real-time streaming to your LangGraph agents, pick the right stream mode, show tokens as they arrive, and build chat UIs that feel instant.
Learn to build a ReAct agent from scratch in LangGraph with this hands-on guide, wire the think-act-observe loop, add tools, and debug agent cycles.
Build a RAG agent in LangGraph that routes questions, grades documents, detects hallucinations, and rewrites queries when results are poor. Full code...
Step-by-step guide to building a LangGraph SQL agent that turns plain English into SQL, runs queries, retries on errors, and explains results clearly.
Build a multi-agent research pipeline in LangGraph with planner, researcher, writer, and reviewer agents that turn any topic into a polished report.
Build a full-stack AI app from scratch with FastAPI and LangGraph, streaming responses, saved chats, API key auth, and a live chat frontend in one...
Build a LangGraph agent that reads PDFs, images, and text, cross-checks facts across sources, and writes a clean JSON report, with full code...
Learn to build a LangGraph pipeline that scrapes websites on its own, pulls structured data, handles pagination and errors, and writes analytical...
Deploy LangGraph agents as scalable APIs with LangGraph Server, step-by-step guide covering SDK setup, streaming, background runs, and cloud hosting.
Save and resume LangGraph agent state with checkpointers so your conversations survive crashes, restarts, and long breaks between sessions.
Build multi-agent AI systems in LangGraph using supervisor, swarm, and network patterns, with full code for each and a guide to choosing the right...
Learn how to run LangGraph branches in parallel using the Send API and map-reduce pattern to process multiple items at once and merge results cleanly.
Complete your LangGraph installation setup in minutes, then build and run your first StateGraph that calls an LLM and returns a response.
Master LangGraph cycles and recursion limits, stop runaway agents, handle GraphRecursionError, and build clean exit strategies for your loops.
Build LangGraph workflows that branch at runtime using conditional edges and routing functions. Route by LLM output, user input, or custom logic with...
Step-by-step guide to building a LangGraph agent that writes Python code, runs it safely, checks the output, and self-corrects until it works.
Start using the OpenAI API Python SDK today. Build your first LLM-powered app with runnable code for chat completions, streaming, and token...
Learn how LLMs work step by step. Build an inference simulator in Python, tokenize, embed, compute attention, sample, and decode with runnable code...
Python exercises to practice as a beginner. These are devised as mini tasks that you might need to apply when programming with Python.
Using Cython, you can speed up existing Python code by an order of 100x or more. This is possible because Cython converts some of the Python code to...
Lets see how to convert Python to Cython inside Jupyter Notebooks?
At its core, KL (Kullback-Leibler) Divergence is a statistical measure that quantifies the dissimilarity between two probability distributions.
The Probe method is a highly intuitive approach to feature selection. The idea is to introduce a random feature to the dataset and train a machine...
Cook’s distance is a measure computed to measure the influence exerted by each observation on the trained model. It is measured by building a...
Z score, also called as standard score, is used to scale the features in a dataset. It can also be used to detect outliers.
Z score is one of the most important concepts in statistics. It is also called __standard score__. Typically it is used to scale the features for...
Outliers are those specific data points that differ significantly from others. Let's understand how to identify them using IQR and Boxplots.
One of the most common tasks when working with DataFrames is selecting specific columns. In this blog post, we will explore different ways to select...
PySpark library allows you to leverage Spark's parallel processing capabilities and fault tolerance, enabling you to process large datasets...
OpenCV (Open Source Computer Vision Library) is an open-source computer vision and machine learning software library. OpenCV-Python is a Python...
Web scraping is the technique of extracting data from a specific website or web page. Let's understand how to use Scrapy for web scraping of Reddit...
Pip is a widely used package manager for Python, allowing you to install and manage Python packages easily. In this blog post, we'll explore various...
Adding Python to the PATH environment variable in Windows allows you to run Python commands from any directory within the command prompt
Adaboost is one of the earliest implementations of the boosting algorithm. It forms the base of other boosting algorithms.
Numpy.random.randint is used to get random integers from low to high values. The low value is included while the high value is excluded while...
The numpy.random.uniform() function is used to create an array with random samples from a uniform probability distribution of given low and high...
The numpy.sort() function in python is used to sort the array along a specified axis.
numpy.median function is used to calculate the median of an array along a specific axis or multiple axes
Python is the most popular programming language used for AI and machine learning. Let’s see how to setup python environment for ML using anaconda.
The train-test split technique is a way of evaluating the performance of machine learning models
The size of the data you can load and train in your local computer is typically limited by the memory in your computer. Let's see how to deal with...
Granger Causality test is a statistical test that is used to determine if a given time series and it's lags is helpful in explaining the value of...
Any Python files is a Module in Python. A python package is a collection of such modules along with a `__init__.py` file. Let's understand how to...
Iterable in Python is any object that can be looped over. In order for an iterable to be looped over, an iterable needs to be converted to an...
Generators in python provide an efficient way of generating numbers or objects as and when needed, without having to store all the values in memory...
Decorators in python allow you to dynamically change the functionality of another function, without altering it's code.
Object oriented programming is an effective way of writing code. Classes represent meaningful entities which defines its own behaviour (via methods)...
The numpy.random.rand() function is used to generate random float values from a uniform distribution over [0,1). These values can be extracted as a...
Simulated annealing algorithm is a global search optimization algorithm that is inspired by the annealing technique in metallurgy. Understand the...
Partial correlation is used to find the correlation between two variables with the effect of other influencing variables being controlled.
Chi-square test is used to determine whether there is a statistically significant difference between the observed frequency and the expected...
The numpy.reshape() is used to reshape a numpy array without changing the data in the array. Read on to know all about reshaping numpy arrays.
Use the pandas.DataFrame.sample() method from pandas library to randomly select rows from a Dataframe
How to iterate over rows in a pandas dataframe using diffferent methods like loc(),iloc(),iterrows(), iteritems etc, with practical examples
pandas.head() function is used to access the first n rows of a dataframe or series. It returns a smaller version of the caller object with the first...
The pandas.DataFrame.duplicated() method is used to find duplicate rows in a DataFrame. It returns a boolean which tells whether a row is duplicate...
The pandas describe function is used to get a descriptive statistics like mean, median, min-max values of different data columns.
Pandas Series is a 1-dimensional array like object which can hold data of any type. You can create a pandas series from a dictionary by passing the...
You can manipulate the data using regular expressions (Regex). This article explains different ways of using pandas replace function with regex
This article guides you on different methods to plot a histogram in a pandas dataframe along with various features available.
You can create quick line plot on a pandas dataframe in python to understand the relationship between features. Learn how with practical examples.
Explains different ways pandas read_csv function can be used to read csv files into pandas dataframe, along with examples
This article walks you through the different ways through which you can create a pandas datetime series along with it's features.
This article explains how to add new column in an existing pandas dataframe using list, dictionary, insert, assign and so on with examples
This article introduces pandas groupby method, and explains different ways of using it along with practical code examples.
Learn about pandas index and how to use it to access rows, how to define custom row labels and more with practical examples
Using ARIMA model, you can forecast a time series using the series past values. In this post, we build an optimal ARIMA model from scratch and extend...
You can convert a pandas series to list using the tolist() or typecasting method. This article explains both with practical examples.
The pandas dropna function allows you to drop rows & columns that contain missing values. You can drop rows that have certain columns missing
Pandas iloc is a method for integer-based indexing, which is used for selecting specific rows and subsetting pandas DataFrames and Series. The...
Vaex Python is an alternative to the Pandas library that take less time to do computations on huge data using Out of Core Dataframe. It has fast...
To drop a single column or multiple columns from pandas dataframe in Python, you can use `df.drop` and other different methods.
Matplotlib is the most popular Python library to plot beautiful graphs. Grasp fundamental plotting through reproducible examples.
Modin is a python library that can be used to handle large datasets using parallelisation. The syntax is similar to pandas and its astounding...
Learn how to use Dask to handle large datasets in Python using parallel computing. Covers Dask DataFrames, delayed execution, and integration with...
Gradient boosting works by building weak prediction models sequentially where each model tries to predict the error left over by the previous model.
Natural language processing (NLP) is the technique by which computers understand the human language. NLP allows you to do text classification...
Portfolio optimization in finance is the process of creating a portfolio of assets, which maximizes return and minimizes risk.
Global Interpreter Lock (GIL) in python restricts multithreading. This post walks you behind the neccesity of GIL and how it it works.
Learn how Python lambda functions work, when to use them, and how they differ from regular functions. Includes practical examples with map, filter...
tf.function is a decorator function provided by Tensorflow 2.0 that converts regular python code to a callable Tensorflow graph function, which is...
Adding yield keyword to a function will make the function return a generator object that can be iterated upon.
Compare the deep learning frameworks: Tensorflow vs Pytorch. We will go into the details behind how TensorFlow 1.x, TensorFlow 2.0 and PyTorch...
Python Profilers, like cProfile helps to find which part of the program or code takes more time to run. This article will walk you through the...
Learn how to create line plots in Matplotlib to visualize trends. Covers multiple lines, secondary axes, time series plots, styling, and highlighting...
Learn how to create scatter plots in Python to visualize relationships between variables. Covers color groups, linear fits, bubble plots, and Seaborn...
Learn how to send HTTP requests in Python using the Requests library. Covers GET, POST, PUT, DELETE methods, headers, parameters, and response...
A comprehensive guide to Matplotlib Pyplot, Python's core plotting interface. Learn to create line, scatter, bar, pie, histogram, and box plots with...
Learn how to create and interpret boxplots in Python. Understand quartiles, detect outliers, and summarize distributions using Matplotlib and Seaborn.
Learn how to create bar plots in Python using Matplotlib and Seaborn. Covers simple, grouped, stacked, and horizontal bar charts with customization...
The KPSS test checks whether a series is stationary around a deterministic trend. Like the ADF test it is widely used, but it differs in function and...
Augmented Dickey Fuller test (ADF Test) is a common statistical test used to test whether a given Time series is stationary or not. It is one of the...
Python datatable is the newest package for data manipulation and analysis in Python. It carries the spirit of R's `data.table` with similar syntax...
Learn Vector Autoregression (VAR) for multivariate time series forecasting. Covers the intuition, math, model training, diagnostics, and forecasting...
Mahalanobis distance is an effective multivariate distance metric that measures the distance between a point and a distribution. It is an extremely...
datetime is the standard module for working with dates in python. It provides 4 main objects for date and time operations: datetime, date, time and...
Understand PCA, the math, concept, and Python implementation. Learn how Principal Component Analysis reduces dimensions while preserving maximum...
The logging module lets you track events while your code runs, so you can find what caused a crash from the logs. This post is a simple, clear guide...
Matplotlib histogram is used to visualize the frequency distribution of numeric array. In this article, we explore practical techniques like...
This tutorial explains matplotlib's way of making python plot, like scatterplots, bar charts and customize th components like figure, subplots...
In this post, we follow a structured approach to build gensim's topic model and explore multiple strategies to visualize results using matplotlib...
A compilation of the Top 50 matplotlib plots most useful in data analysis and visualization. This list helps you to choose what visualization to show...
List comprehensions is a pythonic way of expressing a 'For Loop' that appends to a list in a single line of code. It is an intuitive, easy-to-read...
A python @property decorator lets a method to be accessed as an attribute instead of as a method with a '()'. Today, you will gain an understanding...
Understand how the Naive Bayes algorithm works with a step-by-step example. Covers Bayes Theorem, Laplace correction, Gaussian Naive Bayes, and full...
Parallel processing is when the task is executed simultaneously in multiple processors. In this tutorial, you'll understand the procedure to...
Lemmatization is the process of converting a word to its base form. Python has nice implementations through the NLTK, TextBlob, Pattern, spaCy and...
Master pandas with 101 hands-on exercises across 3 difficulty levels. Practice data manipulation, filtering, grouping, and more to sharpen your...
Python's Scikit Learn provides a convenient interface for topic modeling using algorithms like Latent Dirichlet allocation(LDA), LSI and Non-Negative...
Topic Modeling is a technique to understand and extract the hidden topics from large volumes of text. Latent Dirichlet Allocation(LDA) is an...
pdb, short for python debugger is a standard built-in module used to debug python code interactively. You can set breakpoints, see variable values...
This is part 2 of the mega numpy tutorial. In this part, I go into the details of the advanced features of numpy arrays that are essential for data...
This is part 1 of the numpy tutorial covering all the core aspects of performing data manipulation and analysis with numpy's ndarrays. Numpy is the...
Regular expressions, also called regex, is a syntax or rather a language to search, extract and manipulate specific string patterns from a larger...