Granite 8b Code Instruct 4k

Code instruction model

Granite 8B Code Instruct 4K is a powerful AI model designed to excel in coding-related tasks. What makes it unique is its ability to follow instructions, reason logically, and solve problems efficiently. With 8 billion parameters, this model has been fine-tuned on a diverse range of data, including code commits, math datasets, and language instruction datasets. Its capabilities are impressive, allowing it to respond accurately to coding instructions and build coding assistants. But what's remarkable is its training infrastructure - it's been trained on IBM's supercomputing clusters, utilizing thousands of NVIDIA A100 and H100 GPUs. This means the model can process vast amounts of data quickly, making it a valuable tool for developers. However, it's essential to note that its performance may be limited with out-of-domain programming languages, and developers should perform safety testing and target-specific tuning before deploying it in critical applications.

Ibm Granite apache-2.0 Updated 8 months ago

Deploy Model in Dataloop Pipelines

Granite 8b Code Instruct 4k fits right into a Dataloop Console pipeline, making it easy to process and manage data at scale. It runs smoothly as part of a larger workflow, handling tasks like annotation, filtering, and deployment without extra hassle. Whether it's a single step or a full pipeline, it connects with other nodes easily, keeping everything running without slowdowns or manual work.

Table of Contents

Model Overview

Meet the Granite-8B-Code-Instruct-4K model, developed by IBM Research! This model is a game-changer for coding tasks. With 8B parameters, it’s designed to understand and respond to coding-related instructions.

What can it do?

  • Follow instructions to write code
  • Reason logically and solve problems
  • Assist with coding tasks

How was it trained?

The model was fine-tuned on a combination of instruction data, including:

  • Code commits from 92 programming languages
  • Math datasets like MathInstruct and MetaMathQA
  • Code instruction datasets like Glaive-Code-Assistant-v3
  • Language instruction datasets like HelpSteer

Capabilities

The Granite-8B-Code-Instruct-4K model is designed to respond to coding-related instructions and can be used to build coding assistants. But what does that really mean?

  • Generate code: This model can write code in response to instructions. For example, you can ask it to write a code to find the maximum value in a list of numbers, and it will generate the code for you.
  • Understand instructions: The model is trained on a combination of instruction data, which enables it to understand and follow instructions. This includes logical reasoning and problem-solving skills.
  • Support multiple programming languages: The model is trained on data from 92 programming languages, making it a versatile tool for coding tasks.

Performance

How fast can the Granite-8B-Code-Instruct-4K model generate code? With its massive 8B parameters, this model can process and respond to coding instructions in a snap. Whether you need to write a code to find the maximum value in a list of numbers or generate a complex algorithm, this model can deliver results quickly.

Limitations

The Granite-8B-Code-Instruct-4K model is a powerful tool for coding-related tasks, but it’s not perfect. Let’s take a closer look at some of its limitations.

  • Limited performance with out-of-domain programming languages: The model is primarily fine-tuned on a specific set of programming languages. This means it may not perform well with languages it’s not familiar with. For example, if you ask it to write code in a language it’s not trained on, it might struggle to produce accurate results.
  • Need for few-shot examples: To get the best out of the model, you might need to provide a few examples of the desired output. This can help steer the model in the right direction and improve its performance.

Format

The Granite-8B-Code-Instruct-4K model uses a transformer architecture, which is a type of neural network that’s particularly well-suited for natural language processing tasks. This means it’s designed to handle sequential data, like text, and can learn complex patterns and relationships within that data.

Examples
Write a code to find the maximum value in a list of numbers. max_value = max([1, 2, 3, 4, 5]) print(max_value)
Create a function that calculates the area of a rectangle. def rectangle_area(length, width): return length * width
Write a SQL query to select all columns from a table named 'employees'. SELECT * FROM employees;

Here’s an example of how to use the model to generate code in response to an instruction:

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

device = "cuda"  # or "cpu"
model_path = "ibm-granite/granite-8b-code-instruct-4k"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device)
model.eval()

# change input text as desired
chat = [
    {
        "role": "user",
        "content": "Write a code to find the maximum value in a list of numbers."
    },
]

chat = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
input_tokens = tokenizer(chat, return_tensors="pt")
for i in input_tokens:
    input_tokens[i] = input_tokens[i].to(device)

output = model.generate(**input_tokens, max_new_tokens=100)
output = tokenizer.batch_decode(output)
for i in output:
    print(i)

This code snippet shows how to use the model to generate code in response to an instruction. You can modify the input text to try out different instructions and see how the model responds.

Dataloop's AI Development Platform
Build end-to-end workflows

Build end-to-end workflows

Dataloop is a complete AI development stack, allowing you to make data, elements, models and human feedback work together easily.

  • Use one centralized tool for every step of the AI development process.
  • Import data from external blob storage, internal file system storage or public datasets.
  • Connect to external applications using a REST API & a Python SDK.
Save, share, reuse

Save, share, reuse

Every single pipeline can be cloned, edited and reused by other data professionals in the organization. Never build the same thing twice.

  • Use existing, pre-created pipelines for RAG, RLHF, RLAF, Active Learning & more.
  • Deploy multi-modal pipelines with one click across multiple cloud resources.
  • Use versions for your pipelines to make sure the deployed pipeline is the stable one.
Easily manage pipelines

Easily manage pipelines

Spend less time dealing with the logistics of owning multiple data pipelines, and get back to building great AI applications.

  • Easy visualization of the data flow through the pipeline.
  • Identify & troubleshoot issues with clear, node-based error messages.
  • Use scalable AI infrastructure that can grow to support massive amounts of data.