
Stable Code 3B by Stability AI is a 3 billion parameter model capable of performing on devices with hardware limitations, Its performance is comparable to counterparts double the size. It also has fill-in-the-middle capability and is trained in 18 programming languages.
StableCode Instruct Alpha 3B and StableCode Completion Alpha 3B by Stability AI are two more coding LLMs that can perform inference workloads on edge devices. The former can generate code according to the instructions provided and later has the capability of code completion. All three models are under non commercial license that means you cannot use these models for any other purposes than research without enrolling for StabilityAI membership.
In this article, you are to perform inference workloads on the 3 models mentioned above, and compare their tokens per second generating capability and their VRAM consumptions respectively.
80 GB GPU RAM.In the section, you are to perform inference workload on the Stablecode 3B model by installing the required dependencies, initializing the model and tokenizer, providing a response to the model for code completion, and calculating tokens per second generated by the model.
You can follow along with the demonstration by using the commands given in the Stable-code-3B Jupyter Notebook.
Install the dependency packages.
Open a terminal within the Jupyter lab interface.
Open a new Notebook session, and set its name to Stable-code-3b.
Initialize the model and tokenizer.
In the above code block, you are initializing the stable-code-3b model with its tokenizer using the HuggingFace pipeline.
Give input and tokenize the input.
The model will try to complete the prompt provided above in the code block.
Define model parameters and initialize time calculation.
In the above code block, you are initializing time calculation functions that will calculate tokens per second, and you are initializing model parameters that can be modified to change model response.
Print generated text.
Calculate and print tokens per second
In the above code block, you are calculating tokens per second generated by the model.
Stablecode 3B generates an average of 35 tokens per second.
StableCode Instruct Alpha 3B and StableCode Completion Alpha 3B both are gated models so to perform inference workloads you need to have access to their repositories.
Visit the settings menu of your HuggingFace account.
Select Access tokens from the left-hand side of the menu.
Click New token and type in a name for the token.
Click Generate a token, and copy and paste the token into your clipboard.
In your existing collab notebook, install the required dependency.
Gain access to the models
Please make sure to replace the token field with the actual value in your clipboard, not doing so will result in authentication errors in the steps performed further.
In the section, you are to perform inference workload on the Stablecode Instruct Alpha 3B model by installing the required dependencies, initializing the model and tokenizer, providing a response to the model to generate code according to the instruction provided, and calculating tokens per second generated by the model.
You can follow along with the demonstration by using the commands given in the Stablecode-instruct-alpha-3B Jupyter Notebook.
Open a new Notebook and set its name to Stablecode-instruct-alpha-3b.
Navigate to the Kernel menu option in your Jupyter Notebook, and click Shutdown Down All Kernels to clear GPU memory.
Initialize the model and tokenizer.
In the above code block, you are initializing the stablecode-instruct-alpha-3b model along with its tokenizer.
Give input and tokenize the input.
The model will try to generate an output according to the instructions provided.
Define model parameters and initialize time calculation.
Print generated response.
Calculate and print tokens per second.
The tokens per second generated by the StableCode Instruct Alpha 3B model is an average of 30 tokens per second.
In the section, you are to perform inference workload on the StableCode Completion Alpha 3B model by installing the required dependencies, initializing the model and tokenizer, providing a response to the model for code completion, and calculating tokens per second generated by the model.
You can follow along with the demonstration by using the commands given in the Stablecode-completion-alpha-3B Jupyter Notebook.
Open a new Notebook and set its name to Stablecode-completion-alpha-3b.
Navigate to the Kernel menu option in your Jupyter Notebook, and click Shutdown Down All Kernels to clear GPU memory.
Initialize the model and tokenizer.
Provide a prompt and tokenize it.
Initialize model parameters and time functions.
Calculate and measure tokens per second.
StableCode Completion Alpha 3B generates an average of 25 tokens per second
Following are the VRAM consumptions of both the models demonstrated in this article:
In this article, you performed inference workloads on Stable Code 3B, StableCode Instruct Alpha 3B, and StableCode Completion Alpha 3B and compared their tokens per second generating capability and their VRAM consumptions respectively.
0 Comments
Be the first to comment and share your perspective with the community.