LLM Fine-tuning Use Case

Generate Code Documentation

Code needs good documentation—it improves comprehension and enables programmers to collaborate efficiently. However, manual docstring creation is time-consuming and often neglected due to tight deadlines. Learn how to fine-tune an open-source LLM to automatically generate high-quality documentation.

The Predibase Solution

Generate accurate docstrings with LLMs

  • Fine-tune CodeLlama with <6,000 data points to improve the accuracy of docstring generation
  • Instantly deploy and query your fine-tuned LLM on serverless endpoints
  • Save developers hours of time by automating the creation of documentation

Unstructured Text

Sample code
Sample code
Tutorials
Tutorials
Docstrings
Docstrings
FAQs
FAQs
Generate Code Documentation with LLMs

Business Value

Reduce the time and effort of writing docs
Reduce the time and effort of writing docs
Improve code comprehension and collaboration
Improve code comprehension and collaboration
Enable developers to focus on higher value activities
Enable developers to focus on higher value activities

Fine-tune and serve your own LLM for Document generation

Easily and efficiently fine-tune open-source CodeLLama with built-in optimizations such as quantization and LoRA to generate high-quality docstrings. Instantly serve and prompt your fine-tuned LLM with cost-efficient serverless endpoints built on top of open-source LoRAX. Read the full tutorial and follow along with this Colab notebook.

# Kick off the fine-tune job and track the learning curves for your adapter in the Predibase UI
adapter = pb.finetuning.jobs.create(
    config={
        "base_model": "meta-llama/Llama-2-13b",  # specify a HuggingFace LLM to fine-tune
    },
    dataset=my_dataset,  # Upload your dataset to Predibase beforehand.
    repo="my_adapter",
    description='Fine-tune "meta-llama/Llama-2-13b" with my dataset for my task.',
)

# Dynamically load fine-tuned adapter for serverless inference
prompt = """
    Write an appropriate docstring for the following Python function. Return the
    entire function with the in-line docstring.

    ### Function: {raw_code}

    ### Function with docstring:
"""

print(
    client.generate(
        prompt,
        adapter_id="my_task_type_adapter/1",  # Specify adapter/version for inference
        max_new_tokens=1024,
        temperature=0.1,
    ).generated_text
)

Example code in Predibase for illustrative purposes only

Resources to Get Started

Ready to efficiently fine-tune and serve your own LLM?