Autodoc: Toolkit for auto-generating codebase documentation using LLMs
github.com
github.com
It doesn't matter how good your LLM is, the information simply isn't there for it to know the information it needs to document. You're never going to get a comment out of this that says "This interface is meant to be backwards compatible with the interface Bob once wrote on a napkin in the pub on a particularly quiet friday afternoon when he decided to reinvent Kafka".
Sure it would, if you asked. But then, it could be 100% wrong while giving you a very confident answer.
Autodoc won't substitute the need for engineers to document their work, but I believe specially in legacy cosebases that it could help with maintenance of an otherwise helpless codebase.
I give non specific explanations about what I'm writing, the template and the target audience. It's sped up my documentation time significantly. I can create high quality documents in hours, instead of days.
Main impression - it does hallucinate like crazy. I asked "How does authorization of HTTP request work?" and it started spitting explanation of how user bcrypt hash is stored in SQlite database and token is stored in Redis cache. There are no signs of SQLite or Redis whatsover on this project.
In other query it started confidently explaining how `getTeam` and `createTeam` functions work. There are no such entity or a word "team" in the entire codebase. To add to the insult, it said that this whole team handling logic is stored in `/assets/sbadmin2/scss/_mixins.scss`.
Other time it offered extremely detailed explanation of some business-logic related question, linking to a lot of existing files from the project, but that was completely off.
Sometimes it offered meaningful explanations, but was ignoring the question. Like I ask to explain relation between two entities and it started showing how to display that entity in a HTML template.
But I guess it's just a question of time when tools like this become a daily assistant. Seems invaluable for the newcomers to the codebase.
To be clear, I don't know the answer.
https://github.com/context-labs/autodoc/blob/83f03a3cee62d6e...
> You are acting as a code documentation expert for a project called ${projectName}. Below is the code from a file located at \`${filePath}\`. Write a detailed technical explanation of what this code does. Focus on the high-level purpose of the code and how it may be used in the larger project. Include code examples where appropriate. Keep you response between 100 and 300 words. DO NOT RETURN MORE THAN 300 WORDS. Output should be in markdown format. Do not say "this file is a part of the ${projectName} project". Do not just list the methods and classes in this file. Code: ${fileContents} Response:
The only part that surprises me is `Output should be in markdown format`. Usually being that vague results in weird variation in output; I'd have expected a formatted example in the prompt for GPT to copy.
I'll probably get used to it over time, as I get a deeper sense of how it works, and how it differs from real persons. ATM the distinction is blurred.
Self spamming your own code base with comments that are either obvious, misleading or wrong was previously unfathomable to me.
Most people think I’m unrealistically pessimistic.
Well done.
It mostly only need the function and the type definitions (typescript) and it is usually very good at writing them and it does save me time.
https://www.reddit.com/r/ProgrammerHumor/comments/4ktp12/my_...
My “Well done” was not meant sarcastically!
An LLM may not fully comprehend the code like the original author, but it can offer a different perspective that may be valuable. The only argument I've seen against LLMs is that it may encourage laziness, but this is a flawed argument similar to those made against the printing press, which was said to make people illiterate.
As a reader of the docs: does it require discipline to refer back to the code when needed. Yes, but this is no different from the discipline required to write documentation in the first place. But with a key difference, the discipline is shifted from author to reader.
2. Everyone can see the same thing
3. It can be utilized for search
4. You can do both
Perhaps most importantly
5. It can be reviewed
Autogenerating function documentation seems like such a low bar by comparison. It's like taking limited creativity and applying it with high powered tools.
Literally like asking for a faster horse.
Tell me how WebKit generates tiles for rasterizing a document tree. Show me specifically where it takes virtualized rendering commands and translates them into port specific graphics calls.
Show me the specific binary format and where it is written for Unreal Engine 5 .umaps so that I can understand the embedded information for working between different types of software or porting to different engines.
Some codebases are so large that it literally doesn't matter if individual functions are documented when you have to build a mental model of several layers of abstraction to understand how something works.
We're not there yet with Autodoc; there is still tons of work to do.
If you have't tried the demo, give it a shot. You might be surprised.
In the future, the training sets will contain more and more automatically generated stuff I believe will not be curated well, leading to a spiral of ever declining quality.
Would be interesting to analyze it over the next years, maybe even anlyzing the past ones, with these AI detection tools.
Companies like openai will keep injecting human-generated feedback into the training set.
A lot of the value is already in the RLHF today. See openai technical report.
It would be really cool if we could take code + docs, feed it into an LLM and get a determination of whether the code matches what's in the docs. It could also be a good way to evaluate the correctness of the generated docs from the linked tool (assuming it works).
I am afraid no one will come talk to you when that happens.
In the meantime I'd prefer not to be subjected to served-from-a-can, machine-generated content in the code I'm trying to grok.
It would be hell to lose trust to api docs due to those risks.
Documentation of unknown quality is useless noise.
People don't understand the unfathomable amount of garbage that's going to be generated in light of all these models. Doesn't matter how accurate they are, the lack of understanding for that remainder percent of inaccuracy is going to cause false confidence and cause errors to compound like mad.
You can view the prompts used for generating docs here[1] and the prompts used for answering questions here[2]
[1]https://github.com/context-labs/autodoc/blob/master/src/cli/... [2https://github.com/context-labs/autodoc/blob/master/src/cli/...]
You can do it yourself and make pull request back to the BuildKit codebase :)
If it gets merged everyone who uses BuiltKit would have access.
The thing I’m wondering about is the cost. How much would it cost to run this on the entire WordPress source, for example?
I think people who dismiss this kind of tool because it can hallucinate stuff are off topic.
The AI will get better and better, but more importantly we will evolve and learn to work with this kind of tool.