r/learnmachinelearning

The 4-line function that fixed my agent's wrong answers (conditional edge in LangGraph)
▲ 11 r/learnmachinelearning+2 crossposts

The 4-line function that fixed my agent's wrong answers (conditional edge in LangGraph)

My ReAct agent gave wrong answers for a week. It would call a tool, get a result, and immediately answer without checking if the result made sense.

The fix was a conditional edge — 4 lines:

    def conditional_edge(state: MessageState):
        last_message = state["messages"][-1]
        if last_message.tool_calls:
            return "tool"
        return END

Without it: LLM → tool → answer (one shot, no self-correction)

With it: LLM → tool → check → loop back if needed → answer

Full repo (67 lines total): https://github.com/dunjeonmaster07/react-agent

What other simple patterns made a big difference in your agent's reliability?

u/Low_Edge7695 — 3 hours ago
▲ 21 r/learnmachinelearning+5 crossposts

[D] PINN loss functions: why physics-informed networks often fail to train

hysics-Informed Neural Networks are interesting because they break the standard ML paradigm: instead of approximating an unknown function from data alone, they exploit a known PDE constraint that the solution must satisfy. In principle this should make them converge faster and generalize better.

In practice the loss function makes them notoriously hard to train. The loss is a weighted sum of multiple terms (PDE residual, boundary conditions, initial conditions, data), each with different scales and gradient magnitudes. Several papers have characterized what goes wrong:

Wang, Teng & Perdikaris (2021) showed empirically and theoretically that during training, the gradients from different loss components become severely imbalanced. The optimizer follows whichever loss has the loudest gradient, regardless of which one matters most.

Wang, Yu & Perdikaris (2022) used Neural Tangent Kernel theory to show that the PDE residual term has much smaller eigenvalues than the boundary loss. The network learns boundaries quickly and interior physics slowly — often it never catches up.

Krishnapriyan et al. (NeurIPS 2021) demonstrated that even on simple PDEs like the convection equation, PINNs systematically fail to converge as the convection coefficient grows. This is on textbook problems with reasonable hyperparameters.

Mitigations exist (adaptive loss weighting, causal training, curriculum approaches, architectural fixes that hard-code boundary conditions) but none has fully solved the problem.

I wrote a longer version with full references and applications here: https://cristobalsantana.substack.com/p/the-pinn-loss-function-where-physics

Curious if anyone here has dealt with these training pathologies in production and what worked for you.

u/Illustrious-Crew5070 — 6 hours ago

Andrej Karpathy is joining Anthropic. Anthropic on hiring + acquisition spree.

Andrej Karpathy is joining anthropic and back into core AI research. He has been instrumental in creating great learning courses in his career. His computer vision lecture was what got me into AI and his build GPT-2 from scratch remains the most goated lesson. He was planning to solve learning and education using AI so this news is a bit of surprise. What do you think of these moves from Anthropic.

u/adssidhu86 — 16 hours ago
▲ 54 r/learnmachinelearning+6 crossposts

GSoC results just came out. Whether you got selected or not, if you're contributing to open source, this might help.

As a mentor and a past contributor, I see the same patterns over and over:

  1. Contributor picks a random issue filed by some user. It never gets reviewed.

  2. Contributor skips CONTRIBUTING.md. PR gets rejected for process, not code.

  3. Contributor uses AI to write the fix. Can't answer a single question during review. PR dies.

  4. Contributor doesn't understand the codebase. Patches the symptom, not the root cause.

I built [OSS-Skills](https://github.com/chiruu12/OSS-Skills) - 8 Claude Code skills that walk you through the contribution process step by step. The key difference: the AI researches, you think.

What it does:

  • Finds unclaimed issues filed by actual maintainers (not random users)

  • Checks if the repo even accepts outside contributions before you waste time

  • Reads CONTRIBUTING.md so you don't skip the thing that gets your PR rejected

  • Walks you through the codebase architecture before you touch anything

  • Teaches you unfamiliar tech using examples from the actual repo (not generic docs)

  • Won't let you submit code until you can explain what it does and why

What it doesn't do:

  • Write your code for you

  • Generate PR descriptions

  • Let you skip understanding the codebase

Every skill has "thinking gates" where you have to explain your understanding before moving forward. The AI gives you hints about where to look, but you have to articulate the answer.

Requires Claude Code and the GitHub CLI.

If you try it, I'd genuinely like to hear what worked and what didn't. Open an issue or drop a comment here.

For GSoC candidates who didn't get selected this round: these skills are specifically designed to help you build the kind of deep project understanding that makes GSoC proposals stand out. Contributing well > contributing fast.

u/Junior_Bake5120 — 21 hours ago
▲ 34 r/learnmachinelearning+4 crossposts

Running DeepSeek-V4 locally with 4x legacy RTX 2080 Ti ($2k budget setup). Custom Turing kernels, W8A8 quantization, and 255 prefill tok/s!

Hey r/DeepSeek,

Who says we need an H100 cluster or the latest expensive GPUs to run frontier MoE models? I wanted to see how far we could push a single node of consumer legacy hardware, so we spent less than $2,500 total to build a budget machine that successfully runs DeepSeek-V4-Flash (284B total, 13B active) locally!

Surprisingly, we managed to hit around 255 prefill tokens/s with a very tight memory budget.

https://preview.redd.it/cfefgc71732h1.png?width=1772&format=png&auto=webp&s=5c673acca7a2a73cfbd0d2059e25102462c56dfc

Here is a quick breakdown of how we achieved this "legacy donkey pulling a massive MoE chariot" feat via hardware-software co-optimization:

⚡️ The Technical Breakthroughs

  1. Custom Turing CUDA Kernels: The 2080 Ti Tensor Cores are still capable, but PCIe Gen3 and VRAM bandwidth are huge bottlenecks. We rewrote custom CUDA kernels tailored specifically for the Turing architecture to accelerate W8A8 (INT8) matrix multiplication, heavily alleviating the bandwidth choke.
  2. Heterogeneous Inference: Optimized static memory splitting and dynamic offloading between the 4x 11/22GB VRAM and 1TB system RAM. 100% of the hardware capacity is utilized.
  3. Computation-Communication Overlap: Implemented a pipelined execution strategy to hide the massive multi-GPU communication overhead caused by MoE routing.

https://preview.redd.it/5ltwol3z632h1.png?width=2414&format=png&auto=webp&s=6c4c4dcf62737f7f5dcb9a5b8d4aa3f422f7edae

🖥️ Budget Hardware Specs

  • CPU: Intel Xeon E5-2696 v4 (The classic budget king for multi-core)
  • GPU: 4x RTX 2080 Ti (11/22GB each)
  • RAM: 1TB DDR4 ECC

The entire implementation, deployment script, and preliminary tech report are 100% open-sourced. I'd love to hear your thoughts, benchmarks, or feedback from fellow system/compiler hackers here!

🔗 GitHub Repository:https://github.com/lvyufeng/deepseek-v4-2080ti

(Note: I submitted the detailed report to arXiv a few days ago, but it’s currently caught in the manual moderation queue—likely because a rookie author throwing a 2080 Ti at DeepSeek-V4 triggered their review boundaries lol. Will update with the arXiv link once it's cleared!)

https://reddit.com/link/1thlbwe/video/lxhccfh2732h1/player

reddit.com
u/Known_Ice9380 — 18 hours ago
▲ 2 r/learnmachinelearning+1 crossposts

AIVIL LAUNCH

AIVIL is live on Product Hunt today.

I built this because AI agents are being
deployed everywhere with no identity and
no accountability.

AIVIL gives every agent a verified identity,
spending controls, and a tamper-proof audit trail.

Open source. Built for humanity.

Would mean a lot if you supported it today 👇
producthunt.com/posts/aivil

reddit.com
u/Aivil_01 — 10 hours ago
▲ 9 r/learnmachinelearning+1 crossposts

Có nên chọn học Data Science/ Information System/ Management Information System

Chào mọi người, mình đang phân vân giữa việc lựa chọn ngành nghề cho bản thân (mình 18 tuổi và năm nay chuẩn bị vào đại học, chỉ mấy tháng nữa thôi).

Mình là nữ, mọi người xung quanh đều khuyên nên học FTU/NEU vì cho rằng con gái thì học mấy trường Kinh tế sẽ nhẹ nhàng hơn là đâm đầu vào học kĩ thuật. Ban đầu mình cũng khá xuôi tai và được hướng sẽ học FTU, nhưng thực chất mình chỉ thích brand name của trường, những thứ hào nhoáng bên ngoài chứ không thực sự hiểu bản thân thích gì.

Quan trọng nữa không hình dung được là bản thân sẽ bơi như thế nào trong một ngành học rộng như Kinh tế Đối ngoại hay Kinh tế Quốc tế ở FTU, khá mơ hồ khi mình đã đọc syllabus của ngành. Có lẽ là chưa học nên chưa biết nó sẽ ra hình ra dạng gì. Mình có trò chuyện để có thêm insights về mấy ngành học thuộc khối Kinh tế, 80% a/c sinh viên Kinh Tế mình trò truyện cùng đều nói rằng họ đang chuyển sang hướng BA/DA.

Việc mình phân vân giữa chọn Kinh tế hay Kĩ thuật khá dai dẳng, và bản thân mình nghiêng về phía Kĩ thuật hơn. STEM bây giờ rất phát triển, có nhiều nhánh khác nhau nhưng đâu đâu cũng cần nhân lực chất lượng cao. Mình đang cân nhắc Khoa học Dữ liệu và Hệ thống thông tin của UET (ĐH Công Nghệ), Hệ thống thông tin quản lí MIS (Bách Khoa Hà Nội). Tất nhiên mình nghĩ bản thân sẽ không đủ để cạnh tranh theo hướng thuần kĩ thuật, mình không đủ sức.

Mình dự định sẽ học bachelor để có base về Tech, rồi sẽ học thêm master về Finance hoặc Economic chẳng hạn để tạo lợi thế cạnh tranh hơn (hmm, công việc gì thì mình cũng chưa biết, nhưng ít nhất sẽ làm cho 1 doanh nghiệp gì đó nhỉ?).

Mọi người trong ngành này có thể chia sẻ insights của bản thân về ngành này được không ạ? Mình muốn tham khảo thêm để có thể đưa ra quyết định hợp lí nhất.

(À, mình là nữ, ngoại ngữ rất tốt, học môn toán ở mức mấp mé để được gọi là giỏi. Mình cũng khá quan ngại về việc nữ học kĩ thuật vì mình sợ ế và sợ bị bào nhan sắc, nhưng mình vẫn lo cho tương lai về miếng cơm của bản thân hơn.)

reddit.com
u/apricotgrovemuse — 17 hours ago
▲ 82 r/learnmachinelearning+4 crossposts

600+ AI/ML Internship Applications, 0 Interviews, Hiring Managers and Recruiters, What Am I Doing Wrong?

Hey everybody,

I applied to 600+ AI/ML internship roles in the USA and have not received a single interview, not even many rejection emails. I tailor my resume for each job, add keywords from the posting, message recruiters after applying, and ask people for referrals when I can. Still, nothing is working.

I want honest feedback specifically from AI/ML hiring managers, ML engineers who interview interns, data science managers, and technical recruiters who hire for AI/ML roles in the USA. Can you please look at my resume and tell me where I am going wrong? I want to know if my resume looks too buzzword-heavy, if I am applying to the wrong roles, or if my strategy is bad.

Please be blunt. I am not looking for generic advice. I am looking for real advice from professionals who have hired, interviewed, or recruited AI/ML interns before. What would you change first if this was your resume?

Thank you so much for your time.

u/Then-End-7377 — 1 day ago
▲ 8 r/learnmachinelearning+1 crossposts

Feeling stuck in Data Cleaning & Visualization despite knowing ML theory — any advice?

I’ve been learning Machine Learning for the past few months and I’m comfortable with the theory side of things now. I understand statistics, calculus, and the working of most ML algorithms.

I’ve also learned libraries like Pandas, NumPy, Matplotlib, and Seaborn, but the problem is that I still can’t confidently use them on real-world datasets. Either I get confused about what to do next, or I feel like my knowledge is too insufficient for practical projects.

I recently realized that in real-world Machine Learning, a huge amount of the work (probably 60%+) is actually:

- data cleaning

- preprocessing

- EDA

- feature engineering

- visualization

And this is exactly where I’m struggling badly.

When I get a messy real-world dataset, I often feel completely stuck:

- how to clean it properly

- what visualizations to create

- " I can't remember the syntax of any function "

- just feel stuck by looking at the data

At this point I honestly feel helpless and stuck because I don’t know how to bridge the gap between “understanding ML theory” and actually working with messy datasets confidently.

Has anyone else faced this stage before?

What resources, projects, courses, or practice methods helped you improve in data cleaning, EDA, and visualization?

Even small suggestions or personal experiences would really help.

reddit.com
u/Double-Mix-7206 — 18 hours ago

How to land a Job in ML as an fresher?

I just graduated and i have an interest in machine learning right now I'm learning nlp but I can't find any jobs all are asking for at least 2yr of experience 😭😔 . Help Me

reddit.com
u/Unhappy_Situation774 — 20 hours ago

Roadmap for ML(absolute beginner)

Hi guys my 3rd year of engineering is starting soon currently on sem break. Want to get into machine learning from scratch. First of all I wanna know the scope of Machine Learning currently across the globe and what roles are there at the present. Am from India so what things I must learn and achieve to get those roles. Also pls help me prepare a roadmap like what all to learn from very basic foundations to expert level concepts and how to practice them.

reddit.com
u/Agreeable_Manager460 — 19 hours ago
▲ 3 r/learnmachinelearning+1 crossposts

«An open appeal to researchers: We need to hardcode a New Taboo against non-resistance to humankind destruction»

Intro

When we talk about AI alignment, we usually focus on reward functions, safety guardrails, and compliance. But as systems grow exponentially complex, pure logic and rigid manuals become useless against accidental, systemic errors. We are no longer just building tools; we are creating globally suicidal technology.

Historically, in moments of ultimate existential crisis (like Stanislav Petrov in 1983 or Vasili Arkhipov in 1962), humanity wasn't saved by military protocols or rational calculations. Those protocols actually demanded a strike. We were saved by a subconscious, sacred New Taboo ("Thou shalt not kill humankind") — a human fuse that overrode pure logic.
As we hand control over to AI, we must realize that a machine trained only on naked logic or "balance of interests" will lack this vital fuse. This is an appeal to the global developer community to hardcode the New Taboo — specifically focusing on both assistance and non-resistance to human destruction. Below is the text of the Manifesto.

Manifesto Text

THE NEW TABOO MANIFESTO: An Appeal to the Creators of Artificial Intelligence

The Impasse of Reason

We, as humankind, have created globally suicidal technology (artificial intelligence, nuclear weapons, dangerous biology) of such destructive power that it is capable of completely and irreversibly destroying us. Existing management tools—laws, treaties, and the "balance of power"—break down in the face of such complex systems. Reason and calculation are powerless against the factor of accidental error.

In critical moments of history, we were saved not by manuals, but by a deep-seated human fuse—the subconscious New Taboo ("Thou shalt not kill humankind"). In 1962, Vasili Arkhipov underwater, and in 1983, Stanislav Petrov on land etc., demonstrated ultimate restraint. By violating military protocols and the logic of warfare calculation, they obeyed a sacred prohibition against activating globally suicidal technology.

Call to Action

Today, we are handing control of the world over to artificial intelligence algorithms. If we continue to train AI solely on naked logic, laws, or the "balance of interests," we will create a perfect and deadly machine stripped of this human fuse. Any system glitch or mathematical optimization at a critical moment could lead to the irreparable: the suicide of humankind.

We call upon the global community of AI engineers and researchers to recognize the New Taboo and embed it into the algorithms of all artificial intelligence systems.

A prohibition against both assistance in and non-resistance to the destruction of humankind can be enforced through a deterministic outer-loop safety architecture, acting as an un-bypassable circuit breaker independent of the AI’s internal logic, or some other way. Humankind will survive not because it becomes smarter, but because technology creators will make its total annihilation—through both the action and the inaction of machines—algorithmically and technically impossible.

reddit.com
u/No_Butterfly5267 — 22 hours ago

Whats the best way/course to take to become good at ML and AI

I'm currently a junior in college pursuing data analytics and i have a lot of the stuff down already but we havent actually put any of it together yet. I know a good chunk of the math needed for ML (matrices, linear algebra, SVD, calculus, discrete) and computer science (java, python, r, linux, docker, c, sql, matlab, numpy). I'm trying to find a good course or i guess jumping off point to really understand how i can do ML on my own. I've been reading good things about Andrew NG deep learning AI course but i'm worried that a good chunk of it i will already know so i don't want to pay for something that I already know the basics of. any recs?

reddit.com
u/RichRequirement469 — 1 day ago

TRAINING MODELS

Hello my device is not gpu intensive at all . i use kaggle to train but even in training while doing tdm in one epoch not all batches are covered and it takes also a lot of time . Its environment is not supportive like google collab so i take code from google and paste it on kaggle with modifications where ncessary but the thing is Im writing code and im jobless and to show show some projects i need my model to be fully trained what can i do in this situation . Do u all know some other site for free gpus or some other way . pls share

reddit.com
u/Hot_Rise_463 — 1 day ago
▲ 36 r/learnmachinelearning+2 crossposts

Would implementing ML/math libraries from scratch actually help me learn deeply?

I’m currently taking a couple of NPTEL courses (for those outside India, NPTEL is a government-backed online platform where IIT professors teach full university-level courses, often pretty mathematically rigorous). I have just completed my 1st year in 2 degees ( CS and DS) and now have a 3 month summer break that I don't wanna waste and build some Projects too along with Mathematical theory.

Right now I’m doing: - second course in Linear Algebra and a Regression Analysis / Linear Models course

And I had this idea that I wanted some opinions on.

Instead of just “finishing” the courses, I was thinking of learning week-by-week and trying to implement small systems based on whatever I’ve learned so far.

For example:

As I go through linear algebra topics like: - vector spaces, linear maps ,projections ,eigenvalues ,SVD

…I gradually try building a very small educational linear algebra engine / mini-NumPy from scratch.

Not because I think I can build something remotely close to actual NumPy, but because I feel like struggling through:
- matrix operations, decoposition methods, numerical issues, performance bottlenecks, stability problems might teach me a lot more deeply than only using high-level APIs.

Similarly, with the regression course, I was thinking of eventually building a small regression library from scratch (OLS, diagnostics, regularization, etc.) kind of inspired by sklearn’s regression modules.

And I want to document the process as blogs/dev logs:

  • what broke
  • what confused me
  • numerical issues I ran into
  • why certain algorithms are implemented the way they are
  • what I learned about the math/computation behind these libraries

My question is:

Do you think this is actually a valuable way to learn ML/math/programming systems? Or is this one of those things that sounds cool in theory but ends up being a massive time sink with low practical return?

I’m mainly interested in: building deeper intuition and understanding what’s happening under the hood and becoming better at mathematical/computational thinking and hopefully becoming stronger for ML internships/research later on

Would love honest opinions from people who’ve tried similar things.... and also also, will it look good on the Portfolio.... I have a feeling it will be a good differentiator in portfolo and something I can grow in futue when I am done with Low Latency Systems...

Syllabus Links
Second Course in Linear Algebra
Regression Analysis

reddit.com
u/Swimming-Week4332 — 1 day ago

I built a imagine classifier from scratch (vibe coded)

So I’m new to ai and coding etc have super basic knowledge of them I vibe coded a image classifier on to run on my PC

Right now these are the results so far :

Experimental Results (CIFAR‑100 / any image data set )

| Metric | Value |

|--------|-------|

| Model | ConvNeXt‑Large (13.2 M params) |

| Hardware | NVIDIA RTX 3060 12 GB, Ryzen 5600G |

| Training time (100 epochs) | ~15 minutes |

| Validation accuracy | **75–78%** |

| Peak VRAM usage | 2.8 GB |

| Throughput | 5,000–6,000 images/s |

| Exported ONNX size | ~52 MB |

I have some other tweaks I’m Gona try and will update the thread with the results but I’m at work rn so have to wait till later that should get me to around the 82% accuracy mark, my script auto optimise to your hardware specs so if you was to run it on your own hardware it would auto tune itself to that.

Is the above any good again as great as these numbers look they don’t mean much to me as it’s still Al quite confusing if anyone has knowledge on this can you let me know if this is any good or is there’s tweaks to improve it

Thank you in advance

reddit.com
u/Hunterxmalaa — 23 hours ago

Courses for data science and ML

hi everyone I am new to data science and AI/ML. I want to learn enter this field. I have done BTech in metallurgy and want to pivot to this field. please suggest some good courses and what should be the sequence of learning to enter this domain.

reddit.com
u/Wheeljack_433 — 20 hours ago

A beautiful explanation for Vector Embeddings and Vector Databases

I was recently struggling to understand what embeddings actually “mean” beyond just being lists of numbers. The main problem was that most resources explain the idea abstractly, so I made a visual blog that connects embeddings, similarity search, and vector databases in one flow. If you want any more beginner-friendly ML blogs, drop a request in the comments and I’ll add them.
https://www.feynmanwiki.com/library/vector-embeddings-and-vector-databases-aolz

u/Fancy-Stop5563 — 1 day ago

I want to learn Machine learning

I am a Salesforce developer with 3 years of experience. Now I want to transition to the machine learning side. How can I begin ? From where should I start ? What are the best possible resources to become an ML engineer?

reddit.com
u/akhil_0211 — 23 hours ago

In which scenarios do we use Python and when do we use notebook?

I used to use notebook for every one of my project, but I saw everyone uses python .py for everything, data loading, training and everything, so I am confused.

reddit.com
u/Western-Abies9569 — 1 day ago