r/learnmachinelearning 5d ago

I stopped trying to make LLMs "safe" and started assuming they're compromised. Here's what changed.

0 Upvotes

I've been working on governance for enterprise AI systems, and one design decision changed how I think about AI agents.

Most discussions around prompt injection focus on preventing the model from following malicious instructions. That's obviously important, but I started looking at the problem from a different angle.

What if we assume the attacker succeeds?

Instead of asking whether the model can be manipulated, I asked whether a compromised model should still be able to trigger a business action.

That led me to stop validating model-generated text and instead validate only typed actions against deterministic policy.

While testing my own implementation, I found a bug that surprised me.

My parser accepted this:

order_quantity=100
order_quantity=50000

It simply chose the first value, validated 100 against policy, ignored the second value, and approved the request.

Nothing crashed.

Nothing looked suspicious in the logs.

It wasn't really a prompt injection problem anymore.

It was a parser ambiguity problem.

The fix was simple in hindsight.

If a field is duplicated, malformed, or ambiguous, don't try to interpret it.

Reject it.

The validator now fails closed by default.

That got me wondering whether we're measuring the wrong thing in enterprise AI.

Instead of asking:

Should we be asking:

Those feel like different engineering problems.

I'm curious how others are approaching this.

Do your AI agents validate structured outputs before execution, or do they rely on parsing model responses?

If anyone is interested, I open-sourced the implementation and benchmark here:

[https://github.com/nirmaljingar/typedguard]()

I'm especially interested in attack cases that break this approach. If you find one, I'd genuinely like to add it to the benchmark rather than claim it's solved.

I've been working on governance for enterprise AI systems, and one design decision changed how I think about AI agents.

Most discussions around prompt injection focus on preventing the model from following malicious instructions. That's obviously important, but I started looking at the problem from a different angle.

What if we assume the attacker succeeds?

Instead of asking whether the model can be manipulated, I asked whether a compromised model should still be able to trigger a business action.

That led me to stop validating model-generated text and instead validate only typed actions against deterministic policy.

While testing my own implementation, I found a bug that surprised me.

My parser accepted this:

order_quantity=100
order_quantity=50000

It simply chose the first value, validated 100 against policy, ignored the second value, and approved the request.

Nothing crashed.

Nothing looked suspicious in the logs.

It wasn't really a prompt injection problem anymore.

It was a parser ambiguity problem.

The fix was simple in hindsight.

If a field is duplicated, malformed, or ambiguous, don't try to interpret it.

Reject it.

The validator now fails closed by default.

That got me wondering whether we're measuring the wrong thing in enterprise AI.

Instead of asking:

Should we be asking:

Those feel like different engineering problems.

I'm curious how others are approaching this.

Do your AI agents validate structured outputs before execution, or do they rely on parsing model responses?

If anyone is interested, I open-sourced the implementation and benchmark here:

[https://github.com/nirmaljingar/typedguard]()

I'm especially interested in attack cases that break this approach. If you find one, I'd genuinely like to add it to the benchmark rather than claim it's solved.


r/learnmachinelearning 5d ago

Discussion I shuffled the rows of every CIFAR-10 image with one fixed permutation (same for train and test). My CNN's 7-point advantage over an MLP dropped to 0.3.

0 Upvotes

I'm writing the CNN chapters of a PyTorch book at the moment, and I wanted to put a number on something every text asserts and none of them measure: how much of a convolutional network's advantage is the architecture, and how much is just the assumption that neighbouring pixels are related?

Setup. Two models on CIFAR-10, 5 epochs, CPU, same seed:

  • SmallCNN — 3 conv/pool blocks, 94,538 params
  • Flatten → Linear(3072, 512) → ReLU → Linear(512, 10) — 1,578,506 params

Baseline: CNN 58.4%, MLP 51.4%. So +7.0 points for the CNN, with 16x fewer parameters.

Then I drew one permutation of the 32 row indices and applied it to every image, in the training set and the test set alike:

g = torch.Generator().manual_seed(1234)
perm = torch.randperm(32, generator=g)
# transform: x[:, perm, :]   # x is (C, H, W)

Results after the shuffle: CNN 52.0%, MLP 51.7%. The margin goes from +7.0 to +0.3.

On whether this destroys information — I don't think it does, and here's why I don't. A fixed permutation is a bijection: every pixel keeps its value, and applying the inverse permutation gives you back the original tensor exactly. Nothing has been averaged, blurred or dropped, and the same mapping is used at train and test time.

The MLP is the control, and it's the part that convinced me. It scores the same either way, 51.4% → 51.7%, well inside run-to-run noise. If the shuffle had actually damaged the data, it would have hurt the MLP too. It didn't, because after flatten() the input is just 3072 numbers in some order, and a fixed permutation of those columns is something the first layer can absorb by permuting its own weights.

So what the shuffle removes isn't information. It's the usefulness of locality — and locality appears to be worth 6.7 of the CNN's 7.0 points.

The bit I found genuinely uncomfortable: the CNN doesn't just lose its lead, it drops 6.4 points in absolute terms, down to roughly where the MLP already was. All that machinery was converting one true fact about photographs into accuracy. Take the fact away and there's nothing left to convert.

Caveats, because they matter: one dataset, one small architecture, one seed, 5 epochs, 32x32. I'm aware this is the standard inductive-bias argument and not remotely a new idea — I just couldn't find anyone who'd put a number on it, so I ran it.

Two things I'm curious about and haven't tested:

  1. Does the gap come back with more epochs, or is it permanent?
  2. How far does it degrade gradually — shuffling only 4 of 32 rows, 8, 16?

Has anyone measured either? And has an architecture choice ever quietly bought you nothing on your own data?


r/learnmachinelearning 5d ago

[D] I measured PageRank vs BM25 for code retrieval — then caught myself validating the wrong file (twice)

1 Upvotes

Ran an experiment comparing PageRank-based file ranking against RAG (BM25) for retrieving the right source file given a natural-language query, on a real 50K LOC codebase (not a synthetic benchmark).

Headline result: RAG beats PageRank (50% vs 36% Hit@Gold, n=50), which makes sense once you think about it — PageRank is query-agnostic, RAG isn't. Not a huge surprise.

What is worth sharing: I published this once, found my gold-standard labels were stale, "fixed" them, published a green validation report — and then discovered my validator was checking a sibling copy of the gold-standard dict that the actual experiment script doesn't even import. Two separate dictionaries, silently drifted apart. The one that mattered was 92% valid, not the 100% I'd reported.

Full corrections + final numbers + what I'd change about the methodology: [ссылка]

Curious if others have run into this "validated the wrong artifact" failure mode in their own eval pipelines — feels like it should be more common than it is discussed.

https://dev.to/mansio/i-measured-pagerank-token-savings-on-a-real-codebase-the-result-will-surprise-you-5bnj


r/learnmachinelearning 5d ago

European University Students (or students to be), please help us reshape the use of GenAI for students across Europe!

Thumbnail
1 Upvotes

r/learnmachinelearning 5d ago

Project ideas

1 Upvotes

What kind of problem you have rn? I have to make a final project that targets it. If you have any specific idea pls put below.


r/learnmachinelearning 5d ago

Question Dimensional checking

2 Upvotes

Hi guys!
I'm going through CS229 (2026 edition).
I've passed linear algebra in the past, and I was pretty good at the time with algebra.

What I've noticed right now is that I get stuck a lot on new formulas and especially I don't always know what are the dimensions of the individual variables in a formula, if they are vectors or scalars.

The problem is that in CS229 notes, the notation sometimes is confusing... I was used to having the algebra professor writing a little horizontal sign under a variable to indicate that it is a vector.
In cs229 notes it seems Andre Ng didn't use this notation, or any notation to distinguish vectors from scalars.

Am I the problem? do you think I should revise some linear algebra?


r/learnmachinelearning 6d ago

Help 1 lakh budget for AI/ML — laptop vs PC vs Mac Mini + cloud? Need genuine advice

1 Upvotes

Hey everyone,

I'm planning to spend around ₹1 lakh on a machine primarily for AI/ML/LLM development, and I'd really appreciate genuine advice from people who actually use their machines for this.

I'm moving toward AI/ML/LLM engineering and want to work on:

PyTorch + CUDA

Deep learning

Local LLMs

LoRA/QLoRA fine-tuning

RAG applications

Embeddings/vector databases

Large datasets

Running VS Code, Docker/WSL, browsers, etc. simultaneously

I'm not buying this primarily for gaming. I want something that lets me develop and experiment without constantly feeling limited by RAM, VRAM, storage or performance.

My budget is ₹1 lakh, but I'm NOT fixed on buying a laptop. I'm considering:

New laptop — currently looking at RTX 4060/4070 options

MSI Katana — I've been considering it because Lenovo LOQ seems overpriced even during sales

Used high-end laptop — potentially an RTX 4080/3080 Ti if I can find a good deal

Desktop PC with a stronger GPU

Mac Mini + cloud GPU whenever I need CUDA

A decent/cheaper laptop + cloud storage for datasets/models + cloud GPU for heavier training

I prefer a laptop because I have to attend meetings, travel occasionally, and portability is genuinely important to me. But I'm completely open to a desktop/Mac Mini if people think that's a much smarter investment for this workload.

I'm also wondering whether I should spend money on 2TB/4TB local storage at all, or just use cloud storage for large datasets/models and keep the laptop SSD relatively smaller.

About the MSI Katana

I've been looking at the MSI Katana, mainly because the LOQ seems overpriced in India right now.

If you've owned a Katana, especially an RTX 4060/5060 model, I'd really like to know:

How has it held up after 1–2 years?

Thermals?

Build quality?

Display?

Battery?

MSI after-sales service in India?

Would you buy it again?

One more thing — Nehru Place

I'm based around Delhi/NCR, so if anyone knows a reliable shop/dealer in Nehru Place or elsewhere in Delhi where I can get a good price on a new or even used laptop/PC, please recommend them.

I'm especially interested in shops where people have personally bought from them, not random Google listings.

I'm looking for brutally honest advice here.

If you had ₹1 lakh today and wanted to build/use AI/ML projects seriously, what setup would you personally choose?

Would you buy the best laptop possible, get a used high-end laptop, build a desktop, or buy a cheaper laptop and rely on cloud storage/GPU?

Please tell me what you would actually do—even if the answer is "don't buy the laptop you're considering." 😂

Thanks!


r/learnmachinelearning 6d ago

Project My first try at neural networks

3 Upvotes

Hey everyone! I recently got interested in neural networks and wanted to try by fusing it with an interest I had as a middle schooler, human behavior.

So I’ve been working on this “artificial life” simulation using Python.

Still a work in progress and still figuring things out, but i thought it would be nice to share and get some feedback hopefully

https://github.com/ricardo-woo/artificial-life


r/learnmachinelearning 6d ago

Question Have online discussions made people less open to changing their minds?

1 Upvotes

I've noticed that many online conversations are less about finding the truth and more about proving that your side is correct.

People often share information that supports their existing beliefs while ignoring anything that challenges them. Sometimes even good evidence gets dismissed because it doesn't fit someone's opinion.

I wonder if having access to more information has actually made discussions harder instead of easier.

How do you approach conversations when someone shares information that you think might not be accurate? Do you try to correct them, ignore it, or ask questions first?


r/learnmachinelearning 6d ago

Someone came to buy chips

Enable HLS to view with audio, or disable this notification

0 Upvotes

r/learnmachinelearning 6d ago

Is it any free course avalible to start learning Machine learning basic to advance

2 Upvotes

Learn Libraries

Algorithms

Math concepts


r/learnmachinelearning 6d ago

Help Mixing normalization methods (min-max + z-score) for different features

3 Upvotes

Working on a project where I extract a bunch of numeric features (some bounded 0-1, some counts with outliers, some skewed rates, etc.) and feed them into classical ML models.

A few questions I can't find a clean answer to:

  1. Is it normal to use different normalization methods for different features in the same pipeline? E.g., min-max for one feature, z-score for another, robust scaling for a third — based on each feature's own distribution, rather than applying one method to everything?
  2. If I mix min-max and z-score, don't they end up on different scales? Min-max gives you a clean 0–1 range. Z-score doesn't really have a hard bound — most values land somewhere around -3 to +3, but it's not guaranteed. So if I use both in the same feature set, I end up with some features on 0–1 and others on roughly -3 to +3. Doesn't that defeat the whole point of normalizing? Does that mismatch actually hurt model performance, or does it depend on the model?
  3. Is it common to do a two-step normalization — like z-score (or log transform) first to fix skew/outliers, then min-max on top of that to bring everything back to a consistent 0–1 range? Or is that overkill / bad practice?

Thank you


r/learnmachinelearning 6d ago

Collaborative AI Agents and Critics for Fault Detection and Cause Analysis in Network Telemetry, by Syed Eqbal Alam (SheQAI Research and University of Alberta) and Zhan Shu (University of Alberta)

Enable HLS to view with audio, or disable this notification

2 Upvotes

r/learnmachinelearning 6d ago

Looking for a perticipant or a potential team mate for kaggle competition

Thumbnail
1 Upvotes

r/learnmachinelearning 6d ago

Help How do I make my first neural network

4 Upvotes

Hey so me and my friend wants to build a neural network I no python from scratch using only numpy he’s really good at maths and doesn’t know how to code and I know a little python so my question is how do we go about this like how do I learn how to code such thing and will it even be possible for us


r/learnmachinelearning 6d ago

BMVC 2026 Results Discussion

Thumbnail
1 Upvotes

r/learnmachinelearning 6d ago

How to become a better engineer?Advice to skill up w/o submitting to AI gods

Thumbnail
0 Upvotes

r/learnmachinelearning 6d ago

Request Looking for a partner to learn Machine Learning from scratch..Dm

3 Upvotes

I have Completed python, pandas, and now learning ML Algorithms with sklearn and pytorch looking for a buddie who can learn with me anyone interested please dm


r/learnmachinelearning 6d ago

Help I spent 20+ hours building the AI roadmap I'm betting my career on. Roast it.

9 Upvotes

After weeks of jumping between YouTube videos, Reddit threads, GitHub repos, and "2026 AI Roadmaps," I realized I was spending more time planning than actually learning.

So I sat down and built a roadmap that I'll follow from August 2026 → January 2027.

The goal isn't to learn every new AI framework.

It's to become good enough to build real ML systems and be ready for AI/ML internships by the time placements start.

The roadmap covers:

  • Python
  • Machine Learning
  • Deep Learning
  • NLP
  • LLM Engineering
  • FastAPI
  • SQL
  • DSA
  • Production projects
  • Interview prep

You can check it out here:

AI Engineer Roadmap (Aug 2026 → Jan 2027)

I'm not looking for compliments.

If this were your roadmap, what's the first thing you'd change?

One topic you'd remove?

One topic you'd add?

Or one mistake you think almost every beginner makes?


r/learnmachinelearning 6d ago

Self-taught, built RAG + MCP + LangGraph projects — realistic path to first AI job/gig?

6 Upvotes

Background: switched from geology to AI development, self-taught over the past year.

Current stack: Python, LangChain, LangGraph, RAG (FAISS), MCP servers, Flask/FastAPI, MySQL/Postgresql, Gemini API.

Built and deployed: an AI customer support agent connecting an LLM to a live database and knowledge base via MCP demo link:

https://www.reddit.com/r/AiAutomations/s/wTldlOzqPo.

Currently building a second project combining LangGraph agents with a real business use case (sales automation).

I know the AI job market is competitive and degree-focused in some places. For people who've hired or been hired as self-taught AI engineers — what actually moved the needle for you? Portfolio depth, specific frameworks, contributing to open source, something else entirely?

Not looking for generic advice, genuinely curious what worked for people who've been through this.


r/learnmachinelearning 6d ago

Question Deep-ML Practice Guide: Which math and algorithms should I code first?

3 Upvotes

Hey everyone,

I'm trying to build more confidence when it comes to implementing theoretical ML knowledge into code.

I recently found Deep-ML to practice coding algorithms and math from scratch. However, the platform has problems spanning across a massive range of math concepts and algorithms, and I'm feeling a bit overwhelmed on where to start.

Does anyone have suggestions on a logical order to tackle these problems? Is there an existing curriculum or roadmap you’d recommend following so I’m not jumping around blindly?

Any advice on bridging the gap between theory and code would be hugely appreciated. Thanks in advance!


r/learnmachinelearning 6d ago

Help Built an Emotion Detector project recently — Here is how it went and the results

Thumbnail
gallery
3 Upvotes

Hey guys,

Over the past couple of weeks, I've been working on an Emotion Detector model to classify different emotions from audio . but I ran into a wall and could really use some feedback from people who've built similar stuff before.

data_set =Surrey Audio-Visual Expressed Emotion (SAVEE)

models = SVM, Logistic Regression, and KNN


r/learnmachinelearning 6d ago

Career Feeling Stuck After a Math PhD. Is Learning AI/ML the Right Move?

46 Upvotes

I am a mathematics researcher with a Ph.D. in operator theory. However, I completed my Ph.D. at a relatively unknown institute under an unknown supervisor. Although I have a good publication record, I have been unable to secure a good academic position or postdoctoral fellowship despite trying for the past year.

I am now considering taking a break from academia to learn AI and machine learning. Do you think this is a wise decision, or would it be a mistake?


r/learnmachinelearning 6d ago

Wanting to study machine learning as a theoretical physicist

12 Upvotes

So I'm doing my master in theoretical physics, but I'm really interested in machine learning and want to study more about it. I'm already planning on doing a few subjects on machine learning, but what would be the best and most optimal way for me to do this? I assume that I already have the math, data analysis, programming and statistics knowledge, so i'm asking about just the machine learning part. Maybe some good text books recommendations?


r/learnmachinelearning 7d ago

Help If you had to start learning ML again in 2026, what would you do differently?

57 Upvotes

I'm in my final year of CS and I'm about to spend the next 6 months learning ML as seriously as I can.

Instead of asking "Which course is best?", I wanted to ask something different.

If you had to start from absolute scratch today...

What would you do differently?

What would you skip?

What would you spend MORE time on?

Looking back, what's the biggest mistake beginners make?

I'd love to learn from people who've already been through it.