StarCoder: The Top Coding Assistant and Steps to Deploy It on E2E Cloud
Surya Haridass
AI/ML Solutions @KGiSL | Innovating Business Efficiency with Intelligent Automation
What Is an AI Copilot?
Code LLMs, famously known as AI Copilots, enable developers to write code more efficiently by providing suggestions for code completion, writing high-quality maintainable code, providing automatic code explanations, and more. Developers are now empowered to code and generate solutions to problems using natural language. These AI systems allow interaction with the IDE and developing software solutions to be done in a much more natural way.
What Is Starcoder?
StarCoder is a Large Language Model released by BigCoden aimed to act as an AI copilot for developers. It aims to do multiple chores like acting as a technical assistant, auto-completing code, making code modifications, and explaining code snippets through natural language. The base model is called StarCoderBase and StarCoder is a result of fine-tuning it on 35 billion Python tokens.
StarCoder and Its Capabilities
StarCoder is a part of the BigCode project. It is a joint effort of ServiceNow and Hugging Face. BigCode is an effort to build open-source AI tools around code generation. As a result, StarCoder has been made available under an OpenRAIL license for usage by the community.?
The model was trained across 86 programming languages through permissively licensed data from GitHub. All the languages ranked within the top 50 for the most popular languages have been included. All of these languages had an individual dataset size of more than 500 MB leading to a total training of 1 trillion tokens for the final model. The data included GitHub commits, issues (enabling it to act as a technical assistant), and notebooks (Jupyter). The final model is on the smaller side with 15 billion parameters trained on 1 trillion tokens. StarCoderBase was then fine-tuned on 35 billion Python tokens for 2 epochs. The final dataset used to train the entire model has a total size of 815 GB.
StarCoder has been made open source under the OpenRAIL license. The license allows open access, use, and distribution of licensed material like AI artifacts for which it is primarily designed. The license promotes ‘Open’ and ‘Responsible’ use of the product which holds it. As for StarCoder, it is allowed to be used, modified, distributed, and made derivatives under some conditions/restrictions enforced by its license such as:
Steps to Deploy and Use StarCoder Locally
Here we will be discussing setting up StarCoder on a TIR notebook environment on E2E Cloud.
# Install transformers library
!pip install transformers
# Install huggingface_hub
!pip install --upgrade huggingface_hub
2. Login to Hugging Face with your access token.
from huggingface_hub import login
login()
领英推荐
3. Obtain permission to use the model from here.
4. Import the libraries and download the model from Hugging Face.
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
checkpoint = "bigcode/starcoder"
device = "cuda" # for GPU usage or "cpu" for CPU usage
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
# to save memory consider using fp16 or bf16 by specifying torch_dtype=torch.float16 for example
model = AutoModelForCausalLM.from_pretrained(checkpoint, torch_dtype=torch.float16).to(device)
5. Run the model through a custom input as an argument to the tokenizer.encode()
inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to(device)
outputs = model.generate(inputs)
# clean_up_tokenization_spaces=False prevents a tokenizer edge case which can result in spaces being removed around punctuation
print(tokenizer.decode(outputs[0], clean_up_tokenization_spaces=False))
Benefits of Using StarCoder vs Proprietary AI Copilots
Proprietary AI copilots such as GitHub Copilot are designed to work with specific IDEs (Integrated Development Environment) even if they provide support to many languages. This is due to their closed-source nature and thereby the lack of flexibility on how they can be used and where they can be integrated. Proprietary copilots can also be kept under a paywall when the company pleases it and thereby access/usage can be disrupted under various unfavourable conditions. Changes and modifications that suit the particular user/benefit users would be less negotiable unlike in an open-source project like StarCoder. StarCoder and its open-source nature allow it to be freely accessed and used by individuals and organizations alike, freely integrated into their IDEs and other software, updates, and changes all monitored and kept in favor of the growth of the entire community.
How Enterprises Can Leverage StarCoder to Power Their Programmers and R&D
How Was StarCoder Trained and How Expensive Can It Get?
The StarCoderBase model was trained on 512 Nvidia A100 80 GB GPUs distributed across 64 nodes. With various parallelization and other optimizations during training, the base model took a total of 24 days of training and a power usage of 280W per GPU. The fine-tuning of the model in the same set-up to produce StarCoder took 3.5% of the original training time under the same hardware conditions. Again, StarCoder is a fine-tuned Python version of the base model trained for 2 epochs on the original data’s Python subset.
The final power consumption estimate for the training is 89671.68 kWh. The total time it took to train the GPU was 24 days. The cheapest rate of renting an A100 80GB GPU from E2E Cloud for an hour is approximately $3.39. We need a total of 512 such GPUs giving a cost of $1735.68/hour. Our total training time was 576 hours. A rough estimate of the final cost for just training StarCoderBase would be $999K. Now fine-tuning adds around 3.5% of the original training time. This gives a total final cost of $1.03 million. All this is a rough estimate by factoring in purely the E2E Cloud GPU rental costs.?
How Beneficial Is Such a Tool for an Enterprise?
Code LLMs enable people from all backgrounds to write higher-quality code and, thereby, develop no-code/low-code applications. This greatly enhances what can be done through a given amount of knowledge and skill – enabling access to technology in much wider hands.?
Enterprises can use these LLMs to help their developers write high-quality code all the time, which is very important for the maintenance of a lot of mission-critical applications. Efforts spent on refactoring low-quality code can be used elsewhere, thereby saving massively on cost. This can also help relatively early developers to easily learn and implement good quality maintainable systems, which makes the entire process more worthwhile.
The usage of Code LLMs like StarCoder is useful for businesses of all sizes. They have various benefits like automating code generation and improving code quality – all of which lead to greatly enhanced speed and efficiency in software development. The time and effort gained from deploying such a tool cannot be overstated.?
Conclusion
StarCoder is a tool that distributes the power of Code LLMs into the hands of all individuals and enterprises. Its open-source nature allows state-of-the-art code generation capabilities to be availed for free by the masses, thereby fueling a great increase in productivity and learning. Models like these encourage research and funding into the open-source AI community as well.