A developer coding with StableCode from Stability AI in a collaborative environment.

StableCode Tutorial: Getting Started with Stability AI's Coding Assistant

What is StableCode from Stability AI?

StableCode is the latest offering from Stability AI, designed to enhance the coding experience for developers at all levels. This innovative generative AI product serves as a powerful tool for both experienced programmers seeking efficiency and newcomers aiming to strengthen their coding skills.

Base Model of StableCode

The foundation of StableCode is a comprehensive model that underwent initial training on a wide range of programming languages, sourced from the stack-dataset (v1.2) from BigCode. To refine its capabilities, the base model was further trained using popular languages such as:

  • Python
  • Go
  • Java
  • JavaScript
  • C
  • Markdown
  • C++

This training involved a substantial dataset, comprising a staggering 560 billion tokens of code. This robust foundation equips StableCode with a deep understanding of various programming languages and structures.

Instruction Model

The instruction model of StableCode has been meticulously fine-tuned for specific use cases, focusing on solving intricate programming challenges. By exposing it to around 120,000 pairs of code instructions and corresponding responses in Alpaca format, this model provides intelligent solutions for complex coding tasks.

Long-Context Window Model

StableCode introduces an advanced long-context window model that excels at generating single and multi-line autocomplete suggestions. Compared to previous open models with limited context windows, this new model can handle significantly more code at once—approximately 2 to 4 times more. This extended context window is particularly beneficial for developers eager to expand their coding expertise and take on larger coding challenges.

Getting Started with StableCode

This tutorial will guide you through the process of using StableCode to generate code completion and see how different models work. You will learn how to use StableCode in both Google Colab and the Hugging Face Inference API to run StableCode even without a powerful GPU.

Implementation in Google Colab

  1. Setting Up the Project: Create a new Notebook in Google Colab named StableCode Tutorial.
  2. Install Required Packages: Set Runtime to Python 3 and Hardware accelerator to GPU. Install the necessary NLP and machine learning packages.
  3. StableCode - Base Model: Add a new code cell to run the Base Model, define a function to run the model, and input your prompt for completion.
  4. StableCode - Instruction Model: Switch to the Instruction Model by changing the model name in your code and repeat the process.
  5. StableCode - Long Context Window Model: Change to the Long Context Window Model and follow the same steps.

Implementation with Hugging Face Inference API

  1. Create an account in Hugging Face: Register or log in to Hugging Face.
  2. Create a New Token: Generate a token from your profile to use the Hugging Face Inference API.
  3. Run StableCode: Access the StableCode model page, copy the deployment snippet for Inference API, and you are ready to go.

Conclusion

Thank you for following this tutorial on using StableCode. If you have any questions or need further assistance, feel free to reach out on LinkedIn or Twitter. Your feedback is welcome!

Back to blog

Leave a comment