Model or dataset
bbruceyuan/AI-Interview-Code avatar
bbruceyuan/AI-Interview-Code

AI-Interview-Code: Handwritten AI Algorithm Exercises for Technical Interviews

LLM大模型(重点)以及搜广推等 AI 算法中手写的面试题,(非 LeetCode),比如 Self-Attention, AUC等,一般比 LeetCode 更考察一个人的综合能力,又更贴近业务和基础知识一点

615 stars30 forksJupyter NotebookApache-2.0

At a glance

What is it?
AI-Interview-Code is a Jupyter Notebook repository of handwritten AI and LLM algorithm exercises that cover Self-Attention, Group Query Attention, Transformer Decoder, AUC, KMeans, LayerNorm, and other topics that appear in ML engineering interviews but not on LeetCode. Each exercise includes a difficulty rating, a knowledge-point label, and links to written and video explanations.
Who is it for?
AI-Interview-Code is useful for ML engineers preparing for roles at companies where interviewers test hands-on coding of model components rather than standard data structures. The exercises are written to be worked through alongside the author's blog and video explanations, not as standalone puzzles.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 150 days ago.
What is it written in?
Mainly Jupyter Notebook, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What the Repository Covers and Who It Is For

AI-Interview-Code collects Jupyter Notebooks for ML algorithm interview exercises focused on the components that appear in large language model and recommendation system interviews. The repository description names the target audience directly: engineers preparing for roles requiring knowledge of LLMs and algorithms from search, advertising, and recommendation systems.

The exercises are not LeetCode-style problems. The README makes the distinction explicit: these are more representative of actual ML engineering interviews, testing a candidate's ability to write working implementations of model components from scratch under time pressure. A candidate who can write a BFS traversal but cannot implement Self-Attention from memory will not pass the category of interview this repository addresses.

The homepage points to yuanchaofa.com/hands-on-code, where the author maintains written explanations. The repository itself is the code companion to that site and to the author's Bilibili and YouTube video series.

Repository Structure and How to Use It

The repository contains a src/ directory alongside the README and LICENSE. The top-level layout is minimal: .gitignore, LICENSE, README.md, and src/. All notebooks live inside src/.

The README presents exercises in a table with five columns: title, difficulty (star ratings from two to five stars), knowledge point, a link to a written explanation, and a link to a video explanation. The difficulty ratings give a rough sense of preparation investment: LayerNorm and Softmax are two stars, Self-Attention and AUC are three stars, Group Query Attention and Transformer Decoder are three to four stars, and KMeans, linear regression, and BPE tokenizer implementations are five stars.

To use the repository, clone it and open the notebooks in Jupyter:

bash
git clone https://github.com/bbruceyuan/AI-Interview-Code.git

The README does not specify a Python version or a requirements file. The primary dependency is a Jupyter environment with PyTorch or NumPy available, consistent with the kinds of implementations covered.

The intended workflow is to read the written explanation or watch the video for a topic, then work through the corresponding notebook. The author notes in the README that blog content typically appears there first before the repository is updated.

Covered Topics: Attention Mechanisms and Transformer Components

The attention mechanism section is the most developed part of the repository. The README lists three exercises in this category:

Self-Attention (three stars, attention mechanism knowledge point) has a written guide titled 'Four levels of writing Self-Attention' and both Bilibili and YouTube video links. This is one of the foundational exercises; interviewers at LLM-focused companies commonly ask candidates to implement scaled dot-product attention from scratch.

Multi-Head Self-Attention (three stars) extends the single-head implementation. The guide covers the full interview-ready implementation with annotation.

Group Query Attention (three stars) covers the progression from Multi-Head Attention through Multi-Query Attention to Group Query Attention. The README title reads 'Handwriting large model components: Group Query Attention, from MHA to MQA to GQA.' This exercise is relevant because GQA is used in production models such as Llama 3 and Mistral to reduce KV cache memory.

The Transformer Decoder exercise (four stars) covers a causal language model decoder. At four stars it is the most complex single-component exercise in the repository. The knowledge point label is 'Transformer architecture.'

There is also an exercise for computing LLM decoder parameter counts (three stars, video only) and one for estimating training and inference memory usage (four stars, written explanation only).

Other ML Algorithm Exercises

Beyond attention and transformer components, the repository covers algorithms from the machine learning evaluation and classical ML categories.

AUC (two stars) is listed as a handwritten implementation exercise. AUC and ROC computation from scratch is a common warm-up question in algorithm rounds at companies that rank content or ads, where the metric is used to evaluate ranking models. The README marks the written explanation as TODO, so the coverage here is code only.

KMeans (five stars) and linear regression (five stars) are listed as the two hardest exercises in the repository. Both are marked with written and video explanations as TODO, indicating the notebook code is available but the accompanying explanations have not been written yet.

BPE tokenizer (five stars) covers byte pair encoding, the subword segmentation algorithm used by GPT-family and many other models. Implementing BPE from scratch tests understanding of the vocabulary construction process, not just its output.

LayerNorm and BatchNorm (both two stars) and Softmax (two stars) are the lightest exercises. LayerNorm appears in every transformer; being able to implement it in ten lines under pressure is a basic expectation at ML engineering interviews.

LoRA (five stars) appears in a separate section labeled 'Usually not tested.' The README explains its purpose is to deepen understanding rather than to prepare for interviews. A written guide and Bilibili link are provided.

Limitations: Incomplete Coverage and Maintenance

Several exercises in the repository table have written or video explanations marked as TODO. KMeans, linear regression, AUC's written guide, and BPE's explanations are in this state. A candidate relying on those exercises for interview preparation gets the notebook code but none of the conceptual framing.

The repository does not cover model training components beyond memory estimation: no optimizer implementations (Adam, AdamW), no gradient checkpointing, no mixed precision training. Candidates preparing for roles that test training code as well as inference code will need additional resources.

The last push was on 2026-05-04, roughly five months before this writing. The repository is not archived. Given that the ML interview landscape changes as new model architectures become more prevalent in production, a five-month gap is not critical for foundational topics like Self-Attention and LayerNorm, but it does mean recently introduced architectures are unlikely to appear.

The alternative for systematic ML interview preparation is a combination of the Deep Learning Interviews book and Papers With Code's implementation repository, both of which cover overlapping ground with more complete explanations but less focus on the specific pattern of writing components under interview conditions.

Related Author Resources and License

The README lists several related resources from the same author. ApeCode.ai is an AI coding learning platform (Chinese language). ApeRouter is an LLM API routing service. The technical blog at yuanchaofa.com and bruceyuan.com carries most of the written content. Video explanations are on Bilibili and YouTube.

The repository is licensed under Apache-2.0. This permits use, modification, and redistribution with attribution. The Apache-2.0 license includes an explicit patent grant, which is relevant if the implementations are used as the basis for commercial tooling.

Editorial conclusion

AI-Interview-Code is useful for ML engineers preparing for roles at companies where interviewers test hands-on coding of model components rather than standard data structures. The exercises are written to be worked through alongside the author's blog and video explanations, not as standalone puzzles. The last push was on 2026-05-04, so candidates should verify that the covered topics still match current interview patterns at their target companies before spending time on them. The LoRA exercise is explicitly marked as unlikely to appear in interviews; its purpose is to build conceptual depth, not interview readiness.

Frequently asked questions

What algorithms does AI-Interview-Code cover?

The repository covers Self-Attention, Multi-Head Self-Attention, Group Query Attention, Transformer Decoder, LLM parameter counting, memory usage estimation, AUC, KMeans, linear regression, BPE tokenizer, LayerNorm, BatchNorm, Softmax, and LoRA. Each exercise comes as a Jupyter Notebook with difficulty ratings and links to written and video explanations where available.

How does AI-Interview-Code differ from LeetCode?

The README states these exercises are not LeetCode-style. They test the ability to implement ML model components such as Self-Attention, Group Query Attention, and BPE tokenizer from scratch. LeetCode focuses on data structures and algorithms; AI-Interview-Code focuses on model architecture knowledge and hands-on implementation of LLM components.

Does AI-Interview-Code include video explanations?

Yes. The README table links each exercise to Bilibili and YouTube videos where available. Some exercises such as KMeans and BPE tokenizer are marked with video links as TODO, meaning the notebook code is present but the video has not been published.

Official sources

  1. bbruceyuan/AI-Interview-Code on GitHub
  2. Issues
  3. License: Apache-2.0
  4. Project website
  5. README
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/bbruceyuan-ai-interview-code.svg)](https://hysenlabs.com/projects/bbruceyuan-ai-interview-code)