Abstract
This paper introduces an open-source framework designed to automate the generation of GitHub README files using Large Language Models (LLMs). By combining Retrieval-Augmented Generation (RAG) with a fine-tuning pipeline (QLoRA), the authors provide a cost-effective alternative to expensive proprietary APIs. The system allows developers to generate and customize documentation using local or open-source models like Llama-2 and Gemma, democratizing access to high-quality documentation tools.
Introduction
Writing high-quality documentation is a notorious bottleneck in software development. While LLMs like GPT-4 are excellent at summarizing code, existing documentation tools often rely exclusively on OpenAI’s APIs. For large repositories, this can result in substantial financial costs. Furthermore, most current tools are "one-size-fits-all"—they do not allow developers to fine-tune models on their specific coding styles or domain-specific requirements.
The developer community needs a tool that is not only automated but also "free" (via open-source models) and "customizable" (via user-led fine-tuning). This work introduces readme-ready, a software package designed to bridge this gap by providing a flexible, developer-centric documentation pipeline.
Methodology
The proposed system utilizes a two-pronged approach combining efficient retrieval with specialized generation.
Retrieval-Augmented Generation (RAG)
To handle large codebases that exceed an LLM's context window, the tool indexes the repository using a depth-first traversal. Code is chunked into 1,000-token segments and converted into 768-dimensional embeddings using the all-mpnet-base-v2 encoder. These are stored in an in-memory vector store. When a user asks a question (e.g., "How do I install this?"), the system uses the HNSW (Hierarchical Navigable Small World) algorithm to find the four most relevant code chunks to provide as context to the LLM.
Fine-Tuning with QLoRA
To allow for customization without requiring massive compute resources, the authors implemented QLoRA (Quantized Low-Rank Adaptation). They specifically fine-tuned a 4-bit quantized version of Llama-2-7B. This allows the model to adapt to the specific structure of README files while running on relatively modest hardware, such as a single NVIDIA V100. The system uses LangChain templates to structure developer-focused queries, ensuring the output follows standard Markdown documentation practices (Description, Requirements, Installation, etc.).
Dataset and Training
A custom dataset was curated by scraping approximately 200 popular Python-based repositories from GitHub. Pairs of headings (questions) and the text beneath them (answers) were extracted using regex and Markdown signatures. For each pair, the RAG pipeline identified the corresponding source code "context." The final dataset consists of (Question, Context, Answer) triplets. For the fine-tuning experiment, a subset of 190 README files was used for training and 10 for evaluation.
Key Insights and Results
The tool was evaluated using BLEU (n-gram overlap) and BERT (semantic similarity) scores across five major repositories, including allennlp and spleeter.
Semantic Accuracy vs. Exact Match
Semantic scores remained consistently high, averaging around 0.85. This suggests that even when the exact wording differed from the original README, the technical meaning and accuracy were largely preserved. However, BLEU scores ranged from 15 to 32, indicating that while the generated text is understandable, it often requires manual editing to match human-written standards.
The Impact of Fine-Tuning
Interestingly, fine-tuning on the small dataset often led to a decrease in BLEU scores. For instance, the score for the allennlp repository dropped from 32.09 to 16.38.
The authors attribute this decline to the limited size of the training set (190 files) and the constraints of heavy 4-bit quantization, which can introduce noise that degrades performance in low-data regimes. This highlights a critical trade-off: while quantization makes fine-tuning accessible, it requires larger, more diverse datasets to overcome the associated noise.
Conclusion and Future Work
This work demonstrates the feasibility of using open-source LLMs and RAG for automated code documentation. A major takeaway is that the quality of documentation depends heavily on the "comprehensiveness of the code context" retrieved; if the retrieval algorithm fails, the LLM cannot generate accurate docs regardless of its power. Future work will focus on expanding the dataset to multiple programming languages and integrating the tool directly into IDEs as a plugin to further support developer workflows.
Summary updated