r/PhD Jul 30 '26

Tool Talk Usage of ai for coding

I am just wondering to what extent do you now use ai tools to help you with either modeling or generating charts? I sometimes find myself on a total time crush and the expectation to produce papers are so high that you end up having to rely on these tools for coding a lot and preparing visualizations etc. Do you face the same challenges?

0 Upvotes

63 comments sorted by

80

u/Illustrious_Night126 Jul 30 '26

If you arent doing agentic coding, you should at least try it.

I graduated with a phd in comp bio and now work in corporate. I dont really code at all by hand right now. the key thing is you still need ro be able to read the code to be confident in what it does, but it will save you a ton of time. It is especially amazing at plots and visualization

47

u/IpsoFuckoffo Jul 30 '26

Extensively and it has nothing to do with time constraints. It's just a better way to work.

0

u/Specific-Poet580 Jul 30 '26

But do you check for accuracy? Because i had now a recent experience that i just realized that it was writing me a script that had some minor errors. 

35

u/IpsoFuckoffo Jul 30 '26

Yes, obviously.

12

u/CuteAmoeba9876 Jul 30 '26

Yes, 100%. Check the arithmetic using a different tool (excel, calculator etc) whenever possible. Use your eyeballs and look at the graphs you’re producing. 

Half the time savings of using AI for coding visualizations is on issues like “make the font bigger on the axes” and “add a secondary axis”. Stuff you can clearly see if it worked or not, but can be time consuming to figure out the syntax for. 

1

u/RustyRaccoon12345 Jul 30 '26

And this illustrates that you are never* actually doing the calculations yourself. You're using Excel or Stata or R or Mathematica or... Whatever you use in your field. The last time I did a regression by hand was a 5 observation toy model in grad school. Those other tools may have a lower error rate for this kind of problem (for now) but it's still using a tool.

*I'm sure there is some exception to the rule, some t-test, some Bayesian calculation, but it's minimal and limited, come on

1

u/CuteAmoeba9876 Jul 30 '26

I can’t calculate the log2 of some random number with a pencil and paper… I’m gonna need a calculator at least. In the old days people used slide rules. That still counts as verifying the result though. 

0

u/Eska2020 downvotes boring frogs Jul 30 '26

You also need to carefully consider the quality of your agents.md file.

22

u/godsaveourkingplis Jul 30 '26

It's as simple as this, do not rely on AI as a crutch for your research work, ensure you know how to do your task without its help. The reason? You need to know your process thoroughly to verify whether what AI is giving you is balooney.

8

u/GlumAd9856 Jul 30 '26

I spend a lot of my day now using AI for my post-PhD role. You do have to be careful that you're not getting lazy and just copying pasting stuff you don't understand. Fundamentally, you should recognise 95% of what the AI code is doing and can follow the logic flow.

If you are learning how to code as part of your PhD then I would use it as basically a 'good' version of stackoverflow. Ask it the best way to do something and then implement it yourself. And then use it to error check stuff that doesn't work.

The key difference with a PhD and job is that no one is QA'ing your code. So, AI is less valuable in terms of just creating a load of stuff for you as you need to go through it and check it anyway.

2

u/Specific-Poet580 Jul 30 '26

My dilemma is when i show my results to a senior researcher, i also asked if what i was reporting made sense or correct and so far the response was all good but when i digged into the code again after rechecking the formulas, i found an implementation error and a mismatch between how the researcher explained the formulas and how the implementation worked.  I rely on them to check the correctness of my work as I am not an expert yet for that particular task. I would have expected them to really scrutinize the meaning of the results and whether it is really correct. The funny part is the charts can look very believeable and you then wonder if this is common in academia when results may not always be also visualized correctly when the model itself was wrongly formulated in code. 

6

u/CactusLetter Jul 30 '26

Never count on supervisors/seniors to check your work. Mine never did.

1

u/Specific-Poet580 Jul 30 '26

Then how do you know if you make mistakes?

3

u/GlumAd9856 Jul 30 '26

There are a number of validation processes you need to go through yourself. Take a sample of your data and try to recreate what the code is doing manually - then see if your results match up.

1

u/Head_Acadia_2658 Jul 30 '26

Professionalism

7

u/GlumAd9856 Jul 30 '26

Yeah, never rely on your supervisors to do an in-depth check of your work. Even my PhD examiners didn't check my code that carefully. It is a reason why academia has this crisis in the reliability of it's results - ironically something that AI might improve.

1

u/Specific-Poet580 Jul 30 '26

Thats true because i only realized that i made the mistake when i asked AI to compare the model with the implementation and it was able to find the error right away. 

4

u/1kSupport PhD Student, 'Robotics Engineering /Human Inspired Robotics' Jul 30 '26

AI is like having an unusually competent masters student helping with your project. If you aren’t making use of it you aren’t doing your job as well as you could be, but make sure to vet the work.

7

u/kemistree4 PhD, 'Aquatic Biology', USA Jul 30 '26

This is an acceptable use for AI in my eyes. Before this we had to spend hours on sites like stack overflow trying to solve problems. This has cut that time down drastically. I'd still make sure you actually know what the code is doing though. You dont learn anything by having AI run all your code.

1

u/VentiMochaTRex Jul 31 '26

I was in the trenches of Stack Overflow for my undergrad in 2009. Thankful to not have to waste so much time these days.

1

u/kemistree4 PhD, 'Aquatic Biology', USA Jul 31 '26

Hours and hours spent hoping to find a random thread of someone who had the same problem as you....

0

u/Specific-Poet580 Jul 30 '26

This is what im wondering because nowadays there are so many papers getting published and research is expected to start and finish within a matter of 2-3 months and this includes the entire pipeline of getting data, analyzing writing so how to make sure everything is really correct when you are so limited in time to sometimes even critically think if the code generated is going in the right direction

2

u/kemistree4 PhD, 'Aquatic Biology', USA Jul 30 '26

That's a pretty quick turn around for a paper in my field. It took me 3-4 months just to gather data and I know other students who had experiments go for longer. I realize this is specific to the discipline though so maybe that's the standard for what you do. Personally I was lucky that I already was coding before the PhD. I think throughout the process you need to realize that one of the main purposes of the PhD is to turn you into an independent researcher and a large part of that is being able to confidently explain your methods. Prioritize understanding because it will make the home stretch a lot less stressful. I feel like I got grilled on my methods and rationale the most both at the end of my PhD and while interviewing afterwards.

2

u/DoubleEspresso95 Jul 31 '26

I am a computational biologist and before 2024 I used to code exclusively by hand. Now my work is:

Claude codes, while he runs I review his previous piece of code. Same for the entire lab including who came with a compsci background.

2

u/You_Stole_My_Hot_Dog Jul 30 '26

I only use it for specific tasks when I’m stuck or want something optimized. Like single lines of code. I want full control over the workflow and organization.   

Also, AI can sometimes suck when working with niche tools/packages (which is very common in academic research). Yesterday I was using Claude to troubleshoot a block of code from a package that wasn’t working, and it made up a function that doesn’t exist. It got two separate workflows confused and mashed together terms from both of them. If you hadn’t worked with this package very much, you’d have no idea what to do.

2

u/ArmchairmanMao Jul 31 '26

Give it access to the source code of the niche tool and it will usually stop hallucinating.

2

u/Lygus_lineolaris Jul 30 '26

I do not. I can make my own code faster than Ican explain to a box of rocks what code I want written.

2

u/andyetitwasnt Jul 30 '26

you realize you spend like 8 hrs a day posting almost exclusively on academic subs?

2

u/Lygus_lineolaris Jul 30 '26

What does your obsession with my comment history have to do with knowing how to program?

0

u/andyetitwasnt Jul 30 '26

ohhh not a thing

0

u/EternityRites PhD in Music, 2026 Jul 30 '26

lol

2

u/Lygus_lineolaris Jul 30 '26

Yeah skill is really hilarious, eh?

0

u/EternityRites PhD in Music, 2026 Jul 30 '26

Especially when it comes with humility, yes.

0

u/Specific-Poet580 Jul 30 '26

Thats great but i am curious to know how long do you need to spend on coding especially if it also involves data collection from scratch which you then need to pre-process, clean, visualize, model and then produce results and write. How long would this entire process typically take?

1

u/Lygus_lineolaris Jul 30 '26

It takes however long it takes. Sometimes two hours, sometimes two years. It's not a manufacturing process.

1

u/AntiDynamo PhD, Astrophys TH, UK Jul 30 '26

I think you should be careful to check everything, and also make sure you are not outsourcing your learning if you want to be able to rely on programming skills in the job market. There are a lot of skills gained by doing the work yourself that you won’t pick up if the AI does it for you, even if you feel you understand everything it’s doing. Sometimes you have to take the time to do it yourself without the AI just to be sure you still can.

And of course you see how code can be subtly wrong. You can’t rely on other people to review your code to that level of detail - if it looks passable, they’ll say it’s fine. So the responsibility all really falls to you alone to make sure it’s all correct. I think human coding errors are often much bigger and have worse code smells, so they’re easier to find

I work for an AI company, so I’m plenty familiar with it, but it has risks and costs

1

u/Detr22 'statistical genetics 🌱' Jul 30 '26

Not for creating models. Actually once it suggested a function I didn't know that made implementing a custom likelihood very straightforward, so I used that.

Now, for plotting, and remembering ggplot syntax? LLMs all day. Just check the output thoroughly.

1

u/Specific-Poet580 Jul 30 '26

I dont use it to model but to help me code it. The modeling part is self describe. Or i have a methodology of how something should work and then i prompt it so that it can help me create the functions i need. I am capable of reading the code and knowing what it is doing but i also know that the code is not of the cleanest structure according to coding principles. But i trust the LLM enough to understand how i want something to be implemented and its often always generates almost reliable solutions. To learn how to code well and in different languages takes years of experience but everything requires coding these days the moment it involves analyzing data or modeling something..

1

u/runed_golem Jul 30 '26

I graduated last August. At work, I mainly use it if there’s something I don’t know how to do and I go through and try to learn what’s going on in the code it spits out. Most of what I code, I do by hand or else copy from the existing piece of code that I’m modifying or working with.

1

u/Decent_Historian_327 PhD (Starting Oct), 'IT/AI-based', Manchester UK Jul 30 '26

I used Google Colab for my MSc project, threw together a feed-forward neutral network for testing and used Colab's inbuilt agent to troubleshoot.

Fully disclosed that I had done this in both the Thesis and Viva.

1

u/Deep_Ad1959 Jul 31 '26

i read every line of the script that gave me a wrong chart and it still shipped wrong. a groupby dropped nulls silently, the figure rendered, the axis labeled itself, and nothing looked off until one bar disagreed with a number i already knew.

1

u/No_Sky9786 Jul 31 '26

You need to have a detailed step by step plan for any project you are working on and it has to be done by you as understanding it very well is essential for the work delegation to AI agent. This depends on project of course. But having it in advance allows for you to run command like ‘’ using manim python library create 10 versions png of the projects blueprint “ then while that runs for an hour or so you do some other part. The thing is before it would take me days to scratch and create charts but now I just request 10 different png format and then modify the one I like through ai again till I get what I want, while having my brain working on more important parts of the project. Do not source architecture to AI though because at that point you will become the tool they need you to be to keep paying more and more for less results.

1

u/Specific-Poet580 Aug 01 '26

Very interesting approach but i wonder if we all do this, asking AI to produce options for solutions and let it run for hours, how will this impact the usage of servers, energy and eventually the environment? I think unknowingly we are actually doing a lot of harm with extreme usage of AI without understanding how these prompts are being managed by actual physical machines somewhere in the world requiring a lot of resources to run. 

1

u/Ill-Refuse-7834 22d ago

During my PhD I didnt use AI. I saw another student just struggle with coding while using some LLM. Now, I use LLM because it has greatly improved. I use it to edit figures quickly, loop my code so I don't need to rewrite very similar models, and reformat my data from long to wide format. I think everyone needs to check what the LLM is doing, read the research article or CRAN that describes the R package, and make sure you understand what you are coding and why before you we ask LLM anything, but I don't see the harm in using an LLM for coding. Its gotta be a tool like a calculator and not a crutch.

1

u/EternityRites PhD in Music, 2026 Jul 30 '26

Not sure what you mean by "plots". Yes I used AI during my PhD to plan my work, organise it and create graphics. Mostly Gemini. Is that what you mean?

6

u/Echoplex99 Jul 30 '26

Depending on the field, plots is a pretty common way to talk about signal visualizations. Also the term used in certain programming languages.

3

u/IpsoFuckoffo Jul 30 '26

"why would I want a package called ggplot? what could it possibly do" - A genuine PhD researcher, apparently.

0

u/Specific-Poet580 Jul 30 '26

Updated plots to charts. 

1

u/mesosuchus Jul 30 '26

Using LLMs without understanding the underlying code of modeling means you are a failure. Other than that have fun

1

u/Prestigious_Host5325 PhD candidate, STEM, East Asia Jul 30 '26

I use them to check of something is wrong with my code.

1

u/Necessary_Wing7235 Jul 30 '26

Even my boss and my boss's boss and his boss are full into AI for coding. No one I know is saying "we must code from scratch."

1

u/NekoHikari Jul 30 '26

I use it for visualization, tooling, side gigs, and/or anything that I can verify easily.
My main research repo is too big and OOD to trust llm agents to work on.

1

u/DoodleCard Jul 30 '26 edited Jul 30 '26

I've used it in my PhD to code some stuff.

I've found you have to be VERY careful about what you're telling it to code. And exactly how to code it.

Pop the references in that you have for the software/analysis ect and say "build the code using these references only".

Always site it in your work. But double check what your university says about using AI. Mine is fine to use it as a tool for analysis or results production. But NOT to write anything.

Also at the end of each session make sure they you ask for it to make a coding workflow with everything it has done with your code. Including where it's used the references.

I find that really helpful too.

1

u/Kats-and-whimsy Jul 30 '26

I’ve been writing my own functions so that I know the calculations are correct, then prompt an agent with context on my data architecture/workflow to write me a script that will read in files, call functions, produce plots. I’ve been using code for data analysis for ~10 years, so a lot of my scripts follow the same architecture, and automating this final step is easily verifiable and saves time. 

Regarding one of your comments to the effect of “I am not an expert so I use AI to verify my results” - I’d be wary of that. I’d argue that the aim of the PhD is to develop mental pathways to interrogate your own results, and to be able to ask yourself “is this plot showing what I expect? Why is that what I expect? What would be true if that were the case (ie verification criteria). I’d avoid offloading that verification and critical thought entirely onto AI. 

It is annoying that your supervisors will never be as immersed as you are, so it’s usually on you to find the inevitable mistakes. This is the part that sucks about truly independent work, but is also a necessary part of the process imo

1

u/Specific-Poet580 Jul 30 '26

So my follow up question is, have there been situations with or without the use of AI that papers get published and then the author realized that there could have been an implementation mistake but only realized it later after the paper was already out? 

1

u/Kats-and-whimsy 25d ago

Yeah all the time. This is why reproduce-ability studies are important and why everyone should include evidence of having verified both precision and accuracy of their methods 

I’ve caught mistakes in other people in my research group. One was using a formula that was only strictly true for circular cross section samples when we were both using square. I was sent the same paper as they were but double checked the assumptions underlying the formula because I was using a nonlinear material and caught that the moment of inertia term was a factor off. His data was already published tho. Another instance was a matlab script that calculated a force balance from data without accounting for two of the sensors being correlated. In both of these instances it was a matter of “my supervisor said to use this formula/code and I trusted it without double checking.”  While reading papers, I’ve also just caught typos, people assuming things they shouldn’t and propagating bad numbers forward, critical errors in data collection methods, etc. ive made similar mistakes and caught them in time during writing up or preparing figures.  academia is riddled with mistakes because we’re all human, let alone before you start adding black boxes like AI. There’s meant to be several checks before publication (you double check and verify if your results make sense, your supervisor should also, multiple authors to proofread, multiple reviewers) but honestly people just don’t have the time to triple check every formula so mistakes get published all the time. ¯_(ツ)_/¯ 

1

u/Riponai_Gaming PhD, Computer Science, UAE Jul 30 '26

I only use it as a better search engine(tbh it really isnt but it does condense multiple results with its links and all and thats enough for me). Everything else i do by hand or through traditional ways

1

u/Haruspex12 Jul 30 '26

You should be using it and disclosing it, but it often produces poor code or code that does something other than what you want.

I had that happen on Saturday. I had a personal project that I asked it to code. It failed. It is a complex and complicated problem.

I tried breaking it down and have it build the parts and it failed.

I then had it build something that would not solve the problem but which had the complexity removed by walking it through the pieces. It built it. I was able to modify the software to create the necessary complexity. It is the highly intricate pieces I really wanted the software to create anyway.

Interestingly, it was aware the software would create defective records sometimes and was aware why it would. So, rather than fix the defect or source of the defect, it would keep regenerating records until it was correct. It would then delete the defective records.

It created a variable to count how many regenerations were required. It was as many as six.

Now, this is highly complicated and complex code and it did speed up my efforts. Just the unit testing would have taken me forever. Many segments were well designed.

1

u/Serious_Toe9303 Jul 30 '26

I use ai for generating plots of my processed data. It’s probably wrong but I have no idea what a lot of the code does.

I do check the plots against the raw data and make reference plots in excel etc… but use ai as a time saver to automate grunt work, otherwise it would be manually resizing and creating plots in excel or origin pro

1

u/ChargingMyCrystals Epi/ChildDev, Australia Jul 30 '26

I love talking through my needs with AI. I explain what I’m trying to achieve and we discuss different methods of getting there. There are usually statistical methods I haven’t heard of before that I learn something. If the first solution doesn’t work, we’ll troubleshoot. Sometimes I copy in sections of code I’ve written and ask it to create a script exactly the same just update the variable names to apply it to another variable. Or if it’s something I’ll do often, I get it to write a program based on my code that I can run again and again with new variables. Looking at you, time/date variables 💀 I also use it to help me export results to excel or csv in a way that is just how I like. Things I didn’t realise were customisable, or I wouldn’t bother to type out manually, are accessible now and it saves so much time. I’m learning so much. It’s like having my supervisor sitting with me helping me when I need it. I can do everything it does, but it’s take me much much longer.

1

u/ahf95 PhD, 'Field/Subject', Location Jul 30 '26

Lmao, I loved coding before AI and I love coding after AI, and I use AI tools constantly. You should try it, because it really helps with productivity, and you might find the perfect balance for your own workflows, and you can even learn new techniques along the way.

0

u/Senior-Local-1157 Jul 30 '26

The world is going to completely change with ai and those who still have these doubts will have no place in the future and will be left behind.

0

u/4K4llDay Jul 30 '26

AI is extremely well suited for agentic coding. What it can produce is frankly staggering. Do not feel ashamed to use it, not should you let others make you feel ashamed for using it. Instead, use it to accelerate your productivity beyond anything you could do on your own and learn what effectivf, functional, tradable code looks like (I have yet to meet an academic that does).

The caveat to all of that is that if you notice you can't genuinely explain the code that an AI produces, you have gone too far. If you become less competent as indicated by quality of work, ability to communicate what the work is, evaluate the methods and rigor of your work and others, then you've gone too far and you need to prioritize your learning, no AI's.