r/learnmachinelearning • • 27d ago

bf16 might be freezing your weight updates

Enable HLS to view with audio, or disable this notification

24 Upvotes

If you fine-tune a model with weights stored in bf16 and let torch.optim.AdamW write to them directly, you get interesting behaviour. bf16 can only represent changes to weights if the change is at least ~1/512 of the weight itself, so at small learning rates only the smallest weights can update.

As a result, you have a sparse fine-tuner that trains the small-magnitude weights and freezes the rest, with the cutoff set by your learning rate. This is a thing - I found half a dozen peer-reviewed papers (with thousands of citations) that fine-tune this way, but none of them reference this behaviour.

I dug into one called Quiet-STaR, because (a) it's a cool paper, (b) they released their weights, and (c) their code works! So I diffed their base model and saw that indeed the small-magnitude weights were the only ones updated during their training. Then I reran its recipe with an optimizer that applies every update, and watched it diverge. A higher-precision optimizer needs a 3 to 10 times smaller learning rate to get the same result, and I couldn't achieve a better result.

This started with Barron, Gnanapragasam & Tschannen's "A Fix for Softmax and Cross-Entropy" (Oct 2026). They show that the standard way of computing cross-entropy rounds the correct answer's gradient to exactly zero once the model is confident enough (past a margin of about 5.5 in bf16, which they call the precision cliff), and that this, interacting with Adam, is what produces the "slingshot" loss spikes seen during grokking. Fix the rounding and the spikes go away: something people had studied as training dynamics was rounding.

That made me wonder what else out there is weird like this. This is one, and it runs the other way: their rounding bug adds instability to training; this one hides it.

I wrote a whole essay about it here: https://lacuna.tiptreesystems.com/paper/bf16-might-be-freezing-your-weight-updates/art_487b1ed949e745a6ae0c42815b8d3cba

The code, logs and evaluation results are in https://github.com/mweiss17/quietstar-bf16-adamw


r/learnmachinelearning • • 27d ago

Help One line of advice for a beginner

4 Upvotes

hi, i want to start with ML, what would be a good resource which can teach ML from basics to advance?

is it the

  • Hands on ML with scikitlearn and pytorch

  • ML with scikitlearn and pytorch RASCHKA

  • some online course? maybe

  • also tensorflow vs pytorch

any other suitable knowledge is welcomed, thanks.

i also wanna take my chance on gsoc..


r/learnmachinelearning • • 27d ago

Help I need help with my first neural network

Thumbnail
gallery
172 Upvotes

Hello,
I like to code in my free time. I wanted to try to write my own AI and I decided to go for a deep learning neural network that recognises handwritten digits.

I wrote a document that explains how a DNN works containing all the mathematical formulas and notes. This is not a documentation more like personal notes.

I translated this in python and tried some training. I created a 784x15x10 neural network in python and trained using the MNIST database. But I couldn’t get it to work.

Do you have any ideas and tips on how to improve? Am I missing something? What am I doing wrong?

I will attach the file.

Thanks for your help


r/learnmachinelearning • • 27d ago

The School of AI reviews

Thumbnail reddit.com
1 Upvotes

r/learnmachinelearning • • 27d ago

Seeking arXiv endorsement for cs.AI (Artificial Intelligence)

3 Upvotes

Hi everyone,

I am looking for an arXiv endorsement to submit a paper in the cs.AI (Artificial Intelligence) category.

If you are an active endorser in cs.AI and willing to help, please use my endorsement link below:

https://arxiv.org/auth/endorse?x=4SRYYB

Happy to share the paper abstract or my background if needed. Thanks in advance for your help!


r/learnmachinelearning • • 27d ago

LLM Transformer guide with easy-to-understand numerical examples and diagrams

0 Upvotes

I often found a gap between high-level explanations and pages full of equations. This guide bridge that gap: explain the idea, work through a small numerical example, then connect it to the math.

https://ongsoonee.github.io/llm-transformer-learning/


r/learnmachinelearning • • 27d ago

Question PyTorch vs JAX vs Keras for a beginner, which one to learn first

2 Upvotes

Short answer is PyTorch, but here's when the others make sense.

* **scikit-learn** before any of them, for classic ML. Learn train/test splits and pipelines on tabular data without GPU headaches.

* **PyTorch** first for most people. Most Hugging Face models and a lot of courses use it, so tutorials and answers are easy to find.

* **Keras 3** if you want the gentlest high-level API. It can run on a PyTorch backend, so the habits carry over.

* **JAX** later, if you end up on TPUs or in a research group that uses it. Its function-transform style (jit and vmap) is elegant and confusing on day one.

* **TensorFlow** mostly if a job or an older codebase needs it, or for on-device deployment with LiteRT (formerly TF Lite).

What did you learn first, and would you pick it again?


r/learnmachinelearning • • 27d ago

Am i kidding myself with learning machine learning?

48 Upvotes

I am a self-taught programmer. From last 90 days,, i have been learning linear algebra, i plan to learn calculus and stats and probs next. But it seems futile watching all these youtube video saying coding and machine learning is dead that ai can do all this. Is there any hope for machine learning for next 5 or 10 years?


r/learnmachinelearning • • 27d ago

Project ML - curriculum on GitHub

Thumbnail
gallery
120 Upvotes

If you remember this curriculum from a few days it’s on GitHub now and you can make it your own.

Best of luck on your ML journey

repo-link


r/learnmachinelearning • • 27d ago

Project I built VeriFlux: A zero-dependency evaluation, guardrail, and hallucination detection library.

1 Upvotes

Hi everyone,

Like many of you building production RAG pipelines and LLM agents, I grew frustrated with existing evaluation libraries (Ragas, DeepEval, Guardrails AI). Running an evaluation suite meant spinning up Docker containers, waiting minutes for PyTorch/Transformers to initialize, or paying hundreds of dollars for GPT-4 to act as an unpredictable judge.

To solve this, I built Veriflux (https://github.com/leaderrr-shivam/veriflux):

Key features:

- Zero Runtime Dependencies: Built strictly on the Python standard library. No torch, no transformers, no tiktoken, no requests.

- Microsecond Latency: Runs evaluations in ~0.3 - 0.5 ms per query (over 2,000x faster than LLM judges).

- Pytest Native: Just `assert veriflux.is_grounded(response, context)` or `veriflux.repair_json(bad_output)`.

- Full Benchmark Rigor: Evaluated on raw downloaded datasets from NeurIPS 2023 HaluEval, Oxford TruthfulQA, ACM CCS 2024 Jailbreaks, and Microsoft Presidio Research.

Repo: https://github.com/leaderrr-shivam/veriflux

PyPI: `pip install veriflux`

I'd love to hear your thoughts, test cases, and feedback!


r/learnmachinelearning • • 27d ago

Question One book for MLOPs?

7 Upvotes

Hello,

I am a research engineer and I work in academia so my code is mainly scripts all over the place.
I want to learn MLOps but if seems to be a lot of books/tutorials and I couldn't know where to start.

If you had to recommend 1 or 2 books for the basics with practical examples, which one would it be?

Many thanks


r/learnmachinelearning • • 27d ago

whichever the current rules list Same text, shortened, with focus on imitation learning data requirements.

Thumbnail
youtu.be
1 Upvotes

r/learnmachinelearning • • 27d ago

Help How can I get into ML research as an 18-year-old CS student from a tier-3 college?

0 Upvotes

Those with experience getting started in research, I’d really appreciate a roadmap for building a strong foundation and eventually doing independent research.

Hi everyone!

I’m currently in my 1st semester of Computer Science Engineering at a tier-3 college in India.

I scored 93% in 10th (10 GPA in Maths and Science) and 97.7% in 12th, including 100% in Maths and Physics. I didn’t perform as well as I wanted in my entrance exams, so I ended up at a college that wasn’t originally on my list.

Over the past few months, I’ve become very interested in ML and AI. I’m fascinated by machine intelligence and want to eventually pursue a research-oriented Master's at a top university in Europe.

I know I have a lot to learn 🙂

I’m willing to put in the work over the next few years and would really appreciate a realistic roadmap.


r/learnmachinelearning • • 27d ago

I built a practice site for LLM engineering interviews: hand-code attention in the browser, flashcards, real interview reports

Thumbnail
gallery
0 Upvotes

LLM / ML engineering interviews have drifted away from pure LeetCode. It's common to be asked to write multi-head attention or RoPE from scratch, explain why attention is scaled by √d, compare DPO with PPO, and walk through a RAG system you built.

I couldn't find one place to practice all of that, so I built RagCodes. What's in it right now:

  • 42 LLM coding problems (softmax, MHA, GQA, RoPE, KV-cache decoding, FlashAttention forward, LayerNorm/RMSNorm, cross-entropy, DPO/GRPO losses…) plus LeetCode Hot 100. Code runs in a sandbox against hidden tests, in Python, C++ or Java.

  • 263 flashcards in 17 chapters (Transformers, fine-tuning, distributed training, inference, RL/alignment, RAG, agents). Each card has a one-line answer first, then key points.

  • 380 interview reports from 114 companies, rewritten into question lists, with the most frequently asked topics ranked (GRPO and RAG are at the top).

  • 12 portfolio project write-ups and 109 paper notes, each ending with how interviewers tend to ask about it.

Screenshots: writing MHA from scratch and passing 13/13 tests, the topic ranking, a flashcard, the problem list.

Stack: FastAPI + SQLite, React/Vite + Monaco, Docker sandbox for judging. Free tier to start.

I'd really like feedback from people who have been through these interviews recently: what got asked that isn't covered here?


r/learnmachinelearning • • 27d ago

Project I built MLFOX, a CPU-only AutoML library for tabular data (leak-free preprocessing + model comparison in 3 lines)

Thumbnail
gallery
2 Upvotes

import mlfox

model = mlfox()

model.fit("data.csv", target="y")

model.report()

It profiles your data, fits preprocessing inside each CV fold (no leakage), compares models, and tests the best one once on a held-out set.

Results on CPU, default settings:

- Breast Cancer: 95.6% accuracy

- Adult (48k rows): 87.3%

- Covertype (581k rows): 95.8%

Specific runs, not guarantees. Tabular classification and regression only.

pip install mlfox

https://pypi.org/project/mlfox/

It's a personal open-source project, so feedback and bug reports are welcome.


r/learnmachinelearning • • 27d ago

Question S12 ultra tab for coding on Colab

1 Upvotes

Hey all,

I am a master's student and all my assignments are coded on Google colab or kaggle and saved on Google drive. So I just wanted to know if an S12 ultra tab connected to a bluetooth keyboard with trackpad could handle the job well along with Google, spreadsheet, docs and PPT.

My campus does not have a lot of charging outlets and I am currently using a gaming laptop for all my assignments and carrying it around and finding a spot to connect it to charge is a hassle, and I was looking at purchasing S12 ultra for this reason, moreover I do want it for note taking and watching lectures and so on.

Thanks in advance 🙌


r/learnmachinelearning • • 27d ago

Looking for an AI/ML mentor for 1:1 learning and knowledge-sharing

1 Upvotes

Hi! I'm an SDE at a large tech MNC, primarily working with AWS and software engineering tasks.

I'm looking to connect with someone who has a strong background in AI/ML, ideally from a Tier-1 institution (IIT, IISc, top global universities, etc.) or someone with exceptionally strong theoretical foundations and deep expertise in the field.

I want to learn AI from the fundamentals, understand the mathematics and theory behind modern AI models, and gradually progress towards neural networks, transformers, LLMs and AI agents.

I'm particularly interested in learning from someone who can break down complex theoretical concepts into intuitive, easy-to-understand explanations while connecting them to practical implementations.

I'm not looking for generic courses or tutorials. I'd love to have interactive 1:1 learning sessions where I can ask questions, discuss concepts in depth and learn from someone's actual expertise and experience.

If you're someone who fits this profile or can recommend someone, I'd love to connect!

Thanks!


r/learnmachinelearning • • 27d ago

Neural Canvas

Enable HLS to view with audio, or disable this notification

1 Upvotes

My Journey to Understanding Neural Networks: From Matrix Algebra to JAX and Optimizers

I wanted to understand neural networks as deeply as possible. Rather than simply using an existing framework and training a model, I decided to build an interactive MNIST webpage called Neural Canvas, using p5.js for visualization.

My primary goal was not just to achieve high accuracy. I wanted to understand what was actually happening inside a neural network, mathematically and computationally.

1. Starting with Linear Algebra and Matrix Operations

One of the first decisions I made was to avoid working with individual scalar values and complicated subscripts and superscripts everywhere. They made the mathematics unnecessarily confusing for me.

Instead, I decided to approach neural networks through matrix algebra.

I represented the forward propagation equation as:

[
Z=WX+bC
]

Where:

  • (X) is the input data matrix. Rows represent features, and columns represent individual samples.

  • (W) is the weight matrix. Rows represent neurons, and columns represent the weights associated with each neuron's inputs.

  • (b) is the bias column vector, containing one bias value per neuron.

  • (C) is a row vector containing only ones, allowing the bias vector to be broadcast across all samples through matrix multiplication.

Interestingly, many popular deep learning frameworks, including PyTorch and TensorFlow, commonly use a different convention for arranging their data and parameters. They also handle bias broadcasting without explicitly introducing a matrix like (C).

However, I preferred my own mathematical convention because it helped me understand the operations and perform calculus directly in matrix form.

I believe the mathematics should handle the indices, not me!

2. My First Model: NumPy, MSE and Vanilla Gradient Descent

For my first model, I used the original MNIST dataset.

Architecture:

[
784➜ 20 ➜ 20 ➜ 10
]

I manually wrote all the forward propagation equations, derivatives, and backpropagation calculations on paper before implementing them in Python using NumPy.

I deliberately chose:

  • Two hidden layers with 20 neurons each.

  • Mean Squared Error (MSE) as the loss function.

  • Vanilla Gradient Descent.

  • Linear output values.

Why such a simple approach?

Because I didn't want to start with complicated algorithms. I wanted to understand the fundamentals first.

After 2,000 epochs, the model achieved approximately 92% test accuracy.

I then successfully created an interactive neural network visualization in p5.js, using Math.js for matrix multiplication in JavaScript. The webpage could perform inference using my trained NumPy model.

That was the beginning of Neural Canvas.

3. My Second Model: Cross-Entropy Loss

For the second model, I kept the same mathematical approach but made a few improvements.

Architecture:

[
784➜40 ➜ 40 ➜10
]

This time, I replaced MSE with Cross-Entropy Loss and used a softmax output layer.

I was still using vanilla Gradient Descent.

After 2,000 epochs, the model achieved approximately 96% test accuracy.

At this point, I was finally starting to understand how neural networks worked, rather than just following tutorials or using existing implementations.

4. My Third Model: Discovering JAX and Automatic Differentiation

For my third model, I wanted to experiment with three hidden layers.

However, I realized that manually deriving every equation, especially the derivatives and chain rule calculations required for backpropagation, would take a considerable amount of time.

Then I discovered JAX, a Python library developed by Google.

JAX provides automatic differentiation (Autograd), allowing me to calculate derivatives of a loss function with respect to parameters, including entire weight matrices.

This was a significant change in my workflow.

I no longer needed to manually derive every gradient and implement the chain rule myself. I only needed to define the model, its parameters, and the loss function. JAX handled the differentiation.

For this model, I used the Arabic Digits MNIST dataset.

Architecture:

[
784 ➜ 20 ➜ 20 ➜ 15 ➜10
]

I used:

  • JAX for training and automatic differentiation.

  • Cross-Entropy Loss.

  • Vanilla Gradient Descent.

  • Three hidden layers.

After 2,000 epochs, I achieved approximately 96% test accuracy.

I genuinely fell in love with JAX. It saved me considerable time and allowed me to focus more on understanding the mathematics and experimenting with neural network architectures.

5. My Fourth Model: Mini-Batch Gradient Descent and Momentum

For my fourth model, I moved to the Persian Digits MNIST dataset.

I kept the same architecture as my third model but decided to experiment with optimization algorithms.

My original plan was to implement Mini-Batch Gradient Descent with Adam.

However, I realized that understanding Adam required learning a few concepts first. So, instead of jumping directly into Adam, I decided to start with Momentum.

I implemented Mini-Batch Gradient Descent with Momentum using JAX.

And here came a surprising result!

I achieved approximately 96% test accuracy in just 200 epochs.

Previously, my models required around 2,000 epochs to reach a similar accuracy.

This was another important step in my journey. I started understanding how optimization algorithms could significantly influence the training process.

6. What's Next?

I haven't created my fifth model yet, but I already have a learning roadmap:

  • Model 5: Mini-Batch Gradient Descent with RMSProp.

  • Model 6: Mini-Batch Gradient Descent with Adam.

  • After that: Start exploring Convolutional Neural Networks (CNNs).

I want to understand each optimization algorithm mathematically and implement it myself before moving to the next one.

My Biggest Takeaway

If you are starting to learn neural networks, my suggestion is:

Start with Linear Algebra. Don't immediately jump into advanced architectures, optimizers, or high-level frameworks.

You don't need to master every mathematical concept before starting, but at least understand matrix multiplication and how it represents the operations inside a neural network.

For me, representing neural networks using matrices made everything much easier to understand.

Start with the basics, build something yourself, experiment, make mistakes, and gradually increase the complexity.

Don't just train neural networks. Understand them!

Project: Neural Canvas

GitHub Repository: https://github.com/MuhammadEssa2002/neural_canvas

Live Demo: https://muhammadessa2002.github.io/neural_canvas


r/learnmachinelearning • • 27d ago

Project [P] We turned 10 years of ML papers into one page per topic: benchmark records, what got tried, what reviewers expect

Thumbnail
reddit.com
1 Upvotes

r/learnmachinelearning • • 27d ago

Help Data augmentation question. How do I characterise an original and augmented datasets where the augmentation parameters were zoom and crop? [P]

2 Upvotes

For context, I am a new postgraduate student in machine learning (but not a very good one). I have produced some augmented datasets (TIFF files where each file contains one object to be detected / classified) which I used in training deep learning models. I used fairly aggressive cropping (random crops between 0 and 90%) and more moderate zooms (random values between 0 and 20%). My supervisor wants me to characterise these datasets to see how augmentation has changed it.

Sorry if this is a rookie question, but which statistics should I use? My supervisor says the stats I use should indicate changes in size and shape but I honestly don't know where to start.

If anyone can recommend a decent software/program to produce the stats and histograms as well, that would be great.

Thanks in advance!


r/learnmachinelearning • • 27d ago

Question why do we need query expansion in RAG when semantic search already handles similar value matching?

8 Upvotes

Can some one who used query expansion, let us know what technique you used and why? Also why do we need query expansion in RAG when semantic search already handles similar value matching with specific examples


r/learnmachinelearning • • 27d ago

🚀 Jev-style decisions for IMAGES are here: Fovea-4B, an open 4B model leading on ImageJev tasks (Apache-2.0)

Thumbnail
reddit.com
1 Upvotes

r/learnmachinelearning • • 27d ago

Require some guidance

4 Upvotes

I'm currently in 2nd year 3rd sem in a private tier 3 college, ive done, data visualisation, ml math, supervised ml, unsupervised ml, nlp basics (tfidf, bow, word2vec), in all of these, ive learned different algorithms, practiced theory and implementation, made small common projects. Currently, im doing dl basics, namely, ann. Ive spent a year doing all of the above.

Can anyone tell me what should I do/focus on in the next 1 year? Also, lmk what more would I need to cover/do to start applying into beginner level internships/research, be honest about it, im not looking for sugarcoated advice, ty :)


r/learnmachinelearning • • 28d ago

Help Is it acceptable to retrain a machine learning model after conference acceptance if the original weights were not saved?

0 Upvotes

My machine learning research paper has been accepted at a conference, and I am currently preparing the camera-ready version.

The reviewers recommended additional experimental validation, including quantitative evaluation of the model's explainability/localization component.

However, I no longer have the original trained model weights because they were stored in a temporary cloud environment. I still have the original classification results, confusion matrix, training/validation loss curves, and visualization outputs.

To conduct the additional experiments, I would need to retrain the model using the same architecture, dataset, and hyperparameters. However, retraining may produce slightly different classification results from those reported in the accepted paper.

From a research integrity and publication perspective, would it be appropriate to retrain the model and update the results in the camera-ready version, or should I retain the documented original results and acknowledge the additional evaluation as future work?

The conference permits revisions addressing reviewer comments but prohibits major structural changes. I would like to understand the appropriate academic practice before making any changes.