New
Clarifai is recognized as a Leader in The Forrester Wave™: Computer Vision Tools, Q1 2024
August 29, 2023

Run Code Llama with an API

Table of Contents:
 

CodeLlama Blog header

Introducing Code Llama, a large language model (LLM) from Meta AI that can generate and discuss code using text prompts.

You can now access Code Llama 7B Instruct Model with the Clarifai API.

Table of Contents

  1. Introduction
  2. Running Code Llama with Python

  3. Model Demo

  4. Best Usecases

  5. Evaluation

  6. Advantages

Introduction:

Code Llama is a code-specialized version of Llama2 created by further training Llama 2 on code-specific datasets. It can generate code and natural language about code, from both code and natural language prompts (e.g., “Write a python function calculator that takes in two numbers and returns the result of the addition operation”).

It can also be used for code completion and debugging. It supports many of the most popular programming languages including Python, C++, Java, PHP, Typescript (Javascript), C#, Bash and more.

The model is available in three sizes with 7B, 13B and 34B parameters respectively. Also the 7B and 13B base and instruct models have also been trained with fill-in-the-middle (FIM) capability, this allows them to insert code into existing code, meaning they can support tasks like code completion.

There are other two fine-tuned variations of Code Llama: Code Llama – Python which is further fine-tuned on 100B tokens of Python code and Code Llama – Instruct which is an instruction fine-tuned variation of Code Llama.

code llama

Running Code Llama 7B Instruct model with Python

You can run Code Llama 7B Instruct Model using the Clarifai's Python client: 

 

You can also run Code Llama 7B Instruct Model using other Clarifai Client Libraries like Javascript, Java, cURL, NodeJS, PHP, etc here

Model Demo in the Clarifai Platform:

Try out the Code Llama 7B Instruct model here: clarifai.com/meta/Llama-2/models/codellama-7b-instruct-gptq

CodeLlama_Platform

Best Use Cases

CodeLlama and its variants, including CodeLlama-Python and CodeLlama-Instruct, are intended for commercial and research use in English and relevant programming languages. The base model CodeLlama can be adapted for a variety of code synthesis and understanding tasks, including code completion, code generation, and code summarization.

CodeLlama-Instruct is intended to be safer to use for code assistant and generation applications. It is particularly useful for tasks that require natural language interpretation and safer deployment, such as instruction following and infilling. 

Evaluation

CodeLlama-7B-Instruct has been evaluated on major code generation benchmarks, including HumanEval, MBPP, and APPS, as well as a multilingual version of HumanEval (MultiPL-E). The model has established a new state-of-the-art amongst open-source LLMs of similar size. Notably, CodeLlama-7B outperforms larger models such as CodeGen-Multi or StarCoder, and is on par with Codex. 

Advantages

  • State-of-the-art performance: CodeLlama-Instruct has established a new state of the art amongst open-source LLMs, making it a valuable tool for developers and researchers alike.
  • Safer deployment: CodeLlama-Instruct is designed to be safer to use for code assistant and generation applications, making it a valuable tool for tasks that require natural language interpretation and safer deployment. 
  • Instruction following: CodeLlama-Instruct is particularly useful for tasks that require instruction following, such as infilling and command-line program interpretation. 
  • Large input contexts: CodeLlama-Instruct supports large input contexts, making it a valuable tool for programming tasks that require natural language interpretation and support for long contexts. 
  • Fine-tuned for instruction following: CodeLlama-Instruct is fine-tuned with an additional approximately 5 billion tokens to better follow human instructions, making it a valuable tool for tasks that require natural language interpretation and instruction following.

Keep up to speed with AI

  • Follow us on X to get the latest from the LLMs

  • Join us in our Slack Community to talk LLMs