12 AI Papers That Changed Everything: Explained with Examples

This article has a short video:TikTok

1. Overview

Most of the AI systems you use every day — ChatGPT, Midjourney, Google Search with AI Overview — stand on the shoulders of dozens of research papers. This article walks through 12 of them, explains core ideas in plain language, and illustrates each concept with a short Java code snippet. By the end, you’ll understand why Transformers dominate NLP, why RAG solves hallucination, and why a single prompt instruction like “let’s think step by step” is so powerful.

2. AlexNet (2012) — Deep learning starts “seeing”

Before AlexNet, computer vision relied on manual feature engineering. AlexNet used convolutional neural networks (CNNs) with ReLU activation and dropout, trained on GPUs, and crushed all competitors at ImageNet 2012 with error rates nearly 10 percentage points lower. This was the opening shot of the deep learning era.

public class ConvOutputSizeCalculator {

    public static int outputSize(int inputSize, int kernelSize, int stride, int padding) {
        return (inputSize - kernelSize + 2 * padding) / stride + 1;
    }

    public static void main(String[] args) {
        // AlexNet input image: 227x227, kernel 11x11, stride 4
        int size = outputSize(227, 11, 4, 0);
        System.out.println(size);
    }
}
55

outputSize calculates the feature map size after a conv layer. With input 227×227 and kernel 11×11 stride 4, the output is 55×55×96 — exactly AlexNet’s first layer size. ReLU prevents gradients from “dying” like sigmoid does, so deeper networks can still train.

3. GAN (2014) — Two networks compete to generate images

A Generative Adversarial Network pits two networks against each other: the generator tries to create fake images that fool the discriminator, while the discriminator tries to distinguish real from fake. Both improve with each training round.

public record GanLosses(double discriminatorLoss, double generatorLoss) {}

public class GanLossCalculator {

    public static GanLosses compute(double probReal, double probFake) {
        double dLoss = -(Math.log(probReal) + Math.log(1 - probFake));
        double gLoss = -Math.log(probFake);
        return new GanLosses(dLoss, gLoss);
    }
}

probReal is the probability the discriminator correctly identifies a real image, probFake is the probability it gets fooled by the generator. The discriminator wants probReal → 1 and probFake → 0; the generator wants the opposite. This is a classic zero-sum game.

Note: GANs are notoriously difficult to train — they often suffer from mode collapse (the generator only produces a few types of images). Diffusion models later proved far more stable, so most modern image generation systems (DALL·E, Stable Diffusion) don’t use GANs anymore.

4. Transformer (2017) — “Attention Is All You Need”

Transformers dropped RNNs/LSTMs entirely, replacing them with self-attention: each token directly looks at every other token in the sequence to compute relevance, with no sequential processing needed. This is the foundational architecture of GPT, Claude, Llama, and BERT.

public class ScaledDotProductAttention {

    public static double[] attendFirstToken(double[][] query, double[][] key) {
        int seqLen = key.length;
        int dim = query[0].length;
        double scale = Math.sqrt(dim);
        double[] scores = new double[seqLen];
        for (int j = 0; j < seqLen; j++) {
            double dot = 0;
            for (int k = 0; k < dim; k++) dot += query[0][k] * key[j][k];
            scores[j] = dot / scale;
        }
        return softmax(scores);
    }

    private static double[] softmax(double[] row) {
        double max = Arrays.stream(row).max().orElse(0);
        double sum = 0;
        double[] exps = new double[row.length];
        for (int i = 0; i < row.length; i++) {
            exps[i] = Math.exp(row[i] - max);
            sum += exps[i];
        }
        for (int i = 0; i < exps.length; i++) exps[i] /= sum;
        return exps;
    }
}

The dot / scale line divides the dot product by sqrt(dim) to prevent values from growing too large and saturating the softmax. The softmax output is the attention weights — tokens most relevant to the current token get higher weights, used to mix the value vectors.

5. Scaling Laws (2020) — Loss decreases by a power law

OpenAI discovered: scale up parameters, data, or compute exponentially, and loss decreases along a smooth, predictable power law — no magic, just do it right.

public class ScalingLawEstimator {

    // L(N) = (Nc / N)^alpha — N: billions of parameters, Nc, alpha: empirical constants
    public static double estimateLoss(double paramsBillion, double nc, double alpha) {
        return Math.pow(nc / paramsBillion, alpha);
    }
}

With nc and alpha fixed from empirical data, increasing paramsBillion makes estimateLoss drop, but at a decreasing rate (diminishing returns). This is why AI labs pour hundreds of millions into compute: loss reduction is predictable, not a gamble.

Note: Scaling laws don’t go on forever. Beyond a threshold, reducing loss further requires exponentially more compute — that’s why the field is shifting toward improving data and architecture instead of just “bigger.”

6. GPT-3 (2020) — Scale unlocks new abilities

GPT-3 with 175 billion parameters showed: scale up enough and a model can do few-shot learning — give it a few examples in the prompt and it works, no fine-tuning needed.

<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-openai-spring-boot-starter</artifactId>
    <version>1.0.0</version>
</dependency>
@Service
public class FewShotClassifier {

    private final ChatClient chatClient;

    public FewShotClassifier(ChatClient.Builder builder) {
        this.chatClient = builder.build();
    }

    public String classifySentiment(String review) {
        String prompt = """
                Review: "Great product, fast shipping" -> Positive
                Review: "Defective product, can't use it" -> Negative
                Review: "%s" ->
                """.formatted(review);
        return chatClient.prompt(prompt).call().content();
    }
}

The two examples in the prompt “teach” the model the answer format right in the context — no retraining needed. This is the emergent ability smaller models don’t handle well.

7. InstructGPT & RLHF (2022) — Turn raw LLM into a helpful assistant

Base GPT-3 is great at predicting the next token, but it doesn’t “follow instructions” — it can go off-topic or be harmful. InstructGPT uses Reinforcement Learning from Human Feedback (RLHF): humans rank completions, a reward model is trained on those rankings, then the policy is optimized using that reward model via PPO.

public record Completion(String text, double rewardScore) {}

public class RewardBasedSelector {

    public Completion pickBest(List<Completion> candidates) {
        return candidates.stream()
                .max(Comparator.comparingDouble(Completion::rewardScore))
                .orElseThrow();
    }
}

The code above illustrates the final step: pick the completion with the highest reward according to the reward model. In practice, PPO gradually updates the policy model’s weights so it generates high-scoring answers directly, without needing to rank multiple candidates afterward.

Note: RLHF requires massive amounts of human-labeled preference data, which is expensive and prone to annotator bias. Techniques like DPO (Direct Preference Optimization) emerged later to reduce this cost.

8. ViT (2020) — Images can be “sentences” too

Vision Transformer divides an image into small patches (e.g., 16×16 pixels), flattens each patch into a vector, then treats them like tokens fed into a Transformer encoder — the exact same architecture used for text.

public class PatchEmbeddingCalculator {

    public static int numPatches(int imageSize, int patchSize) {
        int gridSize = imageSize / patchSize;
        return gridSize * gridSize;
    }
}

With a 224×224 image and 16×16 patches, numPatches returns 196 — equivalent to a “sentence” of 196 tokens fed into Transformer. This way, ViT reuses all the proven attention techniques from NLP for vision, and beats CNNs when training data is large enough.

9. DDPM (2020) — Add noise then learn to remove it

Denoising Diffusion Probabilistic Models (DDPMs) form the foundation of all modern diffusion models: a forward process gradually adds Gaussian noise to an image over many steps, a reverse process learns to predict and remove that noise to recreate the original image.

public class ForwardDiffusion {

    public static double[] addNoise(double[] x0, double alphaBarT, Random random) {
        double[] xt = new double[x0.length];
        for (int i = 0; i < x0.length; i++) {
            double noise = random.nextGaussian();
            xt[i] = Math.sqrt(alphaBarT) * x0[i] + Math.sqrt(1 - alphaBarT) * noise;
        }
        return xt;
    }
}

alphaBarT controls the ratio of original image to noise at step t: close to 1 means mostly original, close to 0 means mostly noise. The generative model learns to reverse this — starting from pure noise, it gradually “denoise” to create meaningful images.

10. Latent Diffusion (2021) — Denoise in compressed space

Running diffusion directly on pixels is compute-intensive. Latent Diffusion compresses images to a smaller latent space using an autoencoder, runs the entire denoising process there, then decodes back to pixels — this is how Stable Diffusion works.

public class LatentCompressionCalculator {

    public static long pixelCount(int width, int height, int channels) {
        return (long) width * height * channels;
    }
}
pixelCount(512, 512, 3) = 786_432   // pixel space
pixelCount(64, 64, 4)   = 16_384    // latent space

The ~48x compression ratio makes diffusion run much faster while preserving image quality, because the autoencoder discards most redundant information in pixel space (uniform color regions, small details) during compression.

11. CLIP (2021) — Bridge images and text in one space

CLIP trains contrastive learning on hundreds of millions of (image, caption) pairs: matching pairs get close embeddings, mismatched pairs get far apart. The result is a shared space where you can compare text and images using cosine similarity.

@Service
public class ImageTextMatcher {

    private final EmbeddingModel embeddingModel;

    public ImageTextMatcher(EmbeddingModel embeddingModel) {
        this.embeddingModel = embeddingModel;
    }

    public double similarity(String caption, float[] imageEmbedding) {
        float[] textEmbedding = embeddingModel.embed(caption);
        return cosine(textEmbedding, imageEmbedding);
    }

    private double cosine(float[] a, float[] b) {
        double dot = 0, normA = 0, normB = 0;
        for (int i = 0; i < a.length; i++) {
            dot += a[i] * b[i];
            normA += a[i] * a[i];
            normB += b[i] * b[i];
        }
        return dot / (Math.sqrt(normA) * Math.sqrt(normB));
    }
}

similarity returns close to 1 if the caption matches the image content, close to 0 or negative if unrelated. This is how text-to-image search works for many e-commerce platforms today.

12. Chain-of-Thought (2022) — One prompt unlocks reasoning

Just add a phrase like “let’s think step by step” to your prompt, and large LLMs automatically break down complex problems into smaller steps, significantly reducing arithmetic and logic errors compared to direct answers.

public String solveWithReasoning(ChatClient chatClient, String question) {
    String prompt = """
            Let's think step by step before answering.
            Question: %s
            Reasoning:
            """.formatted(question);
    return chatClient.prompt(prompt).call().content();
}

Asking the model to “reason” before finalizing the answer forces it to generate intermediate tokens as scaffolding — like how humans draft before answering hard questions.

Note: Chain-of-Thought increases the number of tokens generated, raising costs and latency. For simple questions (straight fact lookup), forcing CoT only makes it slower without improving accuracy.

13. RAG (2020) — Retrieve then generate, no more making things up

Retrieval-Augmented Generation (RAG) attaches an LLM to a document retrieval step before generating an answer, reducing hallucinations and enabling answers based on fresh data outside the original training set.

<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-pgvector-store-spring-boot-starter</artifactId>
    <version>1.0.0</version>
</dependency>
@Service
public class DocumentAnsweringService {

    private final VectorStore vectorStore;
    private final ChatClient chatClient;

    public DocumentAnsweringService(VectorStore vectorStore, ChatClient.Builder builder) {
        this.vectorStore = vectorStore;
        this.chatClient = builder.build();
    }

    public String answer(String question) {
        List<Document> relevant = vectorStore.similaritySearch(
                SearchRequest.query(question).withTopK(3));

        String context = relevant.stream()
                .map(Document::getContent)
                .collect(Collectors.joining("\n---\n"));

        String prompt = """
                Based on the following documents, answer the question. If no information is available, say "I don't know."
                Documents:
                %s

                Question: %s
                """.formatted(context, question);

        return chatClient.prompt(prompt).call().content();
    }
}

similaritySearch retrieves the 3 most semantically relevant passages, inserts them into the prompt as context, then has the model answer based on that context rather than relying on fuzzy training-time memories.

class DocumentAnsweringServiceTest {

    @Test
    void shouldReturnUnknownWhenNoRelevantDocument() {
        VectorStore emptyStore = mock(VectorStore.class);
        when(emptyStore.similaritySearch(any())).thenReturn(List.of());

        ChatClient stubClient = mock(ChatClient.class, RETURNS_DEEP_STUBS);
        when(stubClient.prompt(anyString()).call().content()).thenReturn("I don't know");

        ChatClient.Builder builder = mock(ChatClient.Builder.class);
        when(builder.build()).thenReturn(stubClient);

        DocumentAnsweringService service = new DocumentAnsweringService(emptyStore, builder);

        String result = service.answer("When was the company founded?");

        assertThat(result).contains("I don't know");
    }
}

This test ensures that when no relevant documents are found, the answer admits “I don’t know” instead of making something up — the whole point of grounding with RAG.

Note: If your entire document library is just a few dozen pages, dumping it all in the context window is simpler and cheaper than building a full RAG pipeline with a vector store. RAG only makes sense when your data is large or changes frequently.

14. Conclusion

These 12 papers aren’t independent — they build on each other: Transformers underpin GPT-3 and ViT; scaling laws explain why GPT-3 works; RLHF turns GPT-3 into ChatGPT; DDPM is the foundation for Latent Diffusion; CLIP bridges diffusion models and text prompts. Understanding each piece helps you read new papers faster, because most “novel” ideas today are variations or combinations of these foundations.

llmdeep-learningtransformerragai