GitHub Model Catalog - Getting Started (2024)

GitHub Models - Limited Public Beta SIGNUP TODAY

Welcome toGitHub Models! We've got everything fired up and ready for you to explore AI Models hosted on Azure AI. So as Student developer you already have access to amazing GitHub Resources like Codespaces and Copilot from http://education.github.comnow you get started on developing with Generative AI and Language Models with the Model Catalog.


Access and onboarding

GitHub Models provide free access to a set of AI models for anyone with a GitHub account.
This makes it significantly easier to get familiar with AI models without having to create Azure Resources or download models from Hugging Face.

The GitHub Model; is your opportunity to test out these models for free.

Key features of GitHub Models
Seamless integration with Codespaces allows for quick learning and engagement.

  • The ease of local use, for free, in code they may have already written.
  • The ability to switch between model providers using the same API call via the Azure AI inference API, eliminating the need to change code between providers.

GitHub Model Catalog - Getting Started (1)

For more information about the Models available on GitHub Models, check out theGitHub Model Marketplace


Models Available

Each model has a dedicated playground and sample code available in a dedicated codespaces environment and utilizes the Azure Inference APIso swapping models is simply changing the model name.

GitHub Model Catalog - Getting Started (2)


Getting Started

There are a few basic examples that are ready for you to run. You can find them in the samples directory within the codespaces environment.

If you want to jump straight to your favorite language, you can find the examples in the following Languages:

  • Python
  • JavaScript
  • cURL

The dedicated Codespaces Environment is an excellent way to get started running the samples and models.

GitHub Model Catalog - Getting Started (3)


Sample Code

Below are example code snippets for a few use cases. For additional information about Azure AI Inference SDK, see full documentation and samples.

Setup

  1. Create a personal access token You do not need to give any permissions to the token. Note that the token will be sent to a Microsoft service.

To use the code snippets below, create an environment variable to set your token as the key for the client code.


If you're using bash:

export GITHUB_TOKEN="<your-github-token-goes-here>"

If you're in powershell:

$Env:GITHUB_TOKEN="<your-github-token-goes-here>"

If you're using Windows command prompt:

set GITHUB_TOKEN=<your-github-token-goes-here>

Python Sample

Install dependencies

Install the Azure AI Inference SDK using pip (Requires: Python >=3.8):

pip install azure-ai-inference

Run a basic code sample

This sample demonstrates a basic call to the chat completion API. It is leveraging the GitHub AI model inference endpoint and your GitHub token. The call is synchronous.

import osfrom azure.ai.inference import ChatCompletionsClientfrom azure.ai.inference.models import SystemMessage, UserMessagefrom azure.core.credentials import AzureKeyCredentialendpoint = "https://models.inference.ai.azure.com"# Replace Model_Name model_name = "Phi-3-small-8k-instruct"token = os.environ["GITHUB_TOKEN"]client = ChatCompletionsClient( endpoint=endpoint, credential=AzureKeyCredential(token),)response = client.complete( messages=[ SystemMessage(content="You are a helpful assistant."), UserMessage(content="What is the capital of France?"), ], model=model_name, temperature=1., max_tokens=1000, top_p=1.)print(response.choices[0].message.content)

Run a multi-turn conversation

This sample demonstrates a multi-turn conversation with the chat completion API. When using the model for a chat application, you'll need to manage the history of that conversation and send the latest messages to the model.

import osfrom azure.ai.inference import ChatCompletionsClientfrom azure.ai.inference.models import AssistantMessage, SystemMessage, UserMessagefrom azure.core.credentials import AzureKeyCredentialtoken = os.environ["GITHUB_TOKEN"]endpoint = "https://models.inference.ai.azure.com"# Replace Model_Namemodel_name = "Phi-3-small-8k-instruct"client = ChatCompletionsClient( endpoint=endpoint, credential=AzureKeyCredential(token),)messages = [ SystemMessage(content="You are a helpful assistant."), UserMessage(content="What is the capital of France?"), AssistantMessage(content="The capital of France is Paris."), UserMessage(content="What about Spain?"),]response = client.complete(messages=messages, model=model_name)print(response.choices[0].message.content)

Stream the output

For a better user experience, you will want to stream the response of the model so that the first token shows up early and you avoid waiting for long responses.

import osfrom azure.ai.inference import ChatCompletionsClientfrom azure.ai.inference.models import SystemMessage, UserMessagefrom azure.core.credentials import AzureKeyCredentialtoken = os.environ["GITHUB_TOKEN"]endpoint = "https://models.inference.ai.azure.com"# Replace Model_Namemodel_name = "Phi-3-small-8k-instruct"client = ChatCompletionsClient( endpoint=endpoint, credential=AzureKeyCredential(token),)response = client.complete( stream=True, messages=[ SystemMessage(content="You are a helpful assistant."), UserMessage(content="Give me 5 good reasons why I should exercise every day."), ], model=model_name,)for update in response: if update.choices: print(update.choices[0].delta.content or "", end="")client.close()

JavaScript

Install dependencies

Install Node.js.

Copy the following lines of text and save them as a file package.json inside your folder.

{ "type": "module", "dependencies": { "@azure-rest/ai-inference": "latest", "@azure/core-auth": "latest", "@azure/core-sse": "latest" }}

Note: @azure/core-sse is only needed when you stream the chat completions response.


Open a terminal window in this folder and run npm install.


For each of the code snippets below, copy the content into a file sample.js and run with node sample.js.

Run a basic code sample

This sample demonstrates a basic call to the chat completion API. It is leveraging the GitHub AI model inference endpoint and your GitHub token. The call is synchronous.

import ModelClient from "@azure-rest/ai-inference";import { AzureKeyCredential } from "@azure/core-auth";const token = process.env["GITHUB_TOKEN"];const endpoint = "https://models.inference.ai.azure.com";// Update your modelnameconst modelName = "Phi-3-small-8k-instruct";export async function main() { const client = new ModelClient(endpoint, new AzureKeyCredential(token)); const response = await client.path("/chat/completions").post({ body: { messages: [ { role:"system", content: "You are a helpful assistant." }, { role:"user", content: "What is the capital of France?" } ], model: modelName, temperature: 1., max_tokens: 1000, top_p: 1. } }); if (response.status !== "200") { throw response.body.error; } console.log(response.body.choices[0].message.content);}main().catch((err) => { console.error("The sample encountered an error:", err);});

Run a multi-turn conversation

This sample demonstrates a multi-turn conversation with the chat completion API. When using the model for a chat application, you'll need to manage the history of that conversation and send the latest messages to the model.

import ModelClient from "@azure-rest/ai-inference";import { AzureKeyCredential } from "@azure/core-auth";const token = process.env["GITHUB_TOKEN"];const endpoint = "https://models.inference.ai.azure.com";// Update your modelnameconst modelName = "Phi-3-small-8k-instruct";export async function main() { const client = new ModelClient(endpoint, new AzureKeyCredential(token)); const response = await client.path("/chat/completions").post({ body: { messages: [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: "What is the capital of France?" }, { role: "assistant", content: "The capital of France is Paris." }, { role: "user", content: "What about Spain?" }, ], model: modelName, } }); if (response.status !== "200") { throw response.body.error; } for (const choice of response.body.choices) { console.log(choice.message.content); }}main().catch((err) => { console.error("The sample encountered an error:", err);});

Stream the output

For a better user experience, you will want to stream the response of the model so that the first token shows up early and you avoid waiting for long responses.

import ModelClient from "@azure-rest/ai-inference";import { AzureKeyCredential } from "@azure/core-auth";import { createSseStream } from "@azure/core-sse";const token = process.env["GITHUB_TOKEN"];const endpoint = "https://models.inference.ai.azure.com";// Update your modelnameconst modelName = "Phi-3-small-8k-instruct";export async function main() { const client = new ModelClient(endpoint, new AzureKeyCredential(token)); const response = await client.path("/chat/completions").post({ body: { messages: [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: "Give me 5 good reasons why I should exercise every day." }, ], model: modelName, stream: true } }).asNodeStream(); const stream = response.body; if (!stream) { throw new Error("The response stream is undefined"); } if (response.status !== "200") { stream.destroy(); throw new Error(`Failed to get chat completions, http operation failed with ${response.status} code`); } const sseStream = createSseStream(stream); for await (const event of sseStream) { if (event.data === "[DONE]") { return; } for (const choice of (JSON.parse(event.data)).choices) { process.stdout.write(choice.delta?.content ?? ``); } }}main().catch((err) => { console.error("The sample encountered an error:", err);});

REST

Run a basic code sample

Paste the following into a shell:

curl -X POST "https://models.inference.ai.azure.com/chat/completions" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $GITHUB_TOKEN" \ -d '{ "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is the capital of France?" } ], "model": "Phi-3-small-8k-instruct" }'

Run a multi-turn conversation

Call the chat completion API and pass the chat history:

curl -X POST "https://models.inference.ai.azure.com/chat/completions" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $GITHUB_TOKEN" \ -d '{ "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is the capital of France?" }, { "role": "assistant", "content": "The capital of France is Paris." }, { "role": "user", "content": "What about Spain?" } ], "model": "Phi-3-small-8k-instruct" }'

Stream the output

This is an example of calling the endpoint and streaming the response.

curl -X POST "https://models.inference.ai.azure.com/chat/completions" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $GITHUB_TOKEN" \ -d '{ "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Give me 5 good reasons why I should exercise every day." } ], "stream": true, "model": "Phi-3-small-8k-instruct" }'

FREE Usage and Rate limits for GitHub Models

Therate limits for the playground and free API usageare intended to help you experiment with models and prototype your AI application. For use beyond those limits, and to bring your application to scale, you must provision resources from an Azure account, and authenticate from there instead of your GitHub personal access token. You don't need to change anything else in your code. Use this link to discover how to go beyond the free tier limits in Azure AI.

GitHub Model Catalog - Getting Started (2024)

FAQs

Can gpt4all be trained? ›

Our released model, gpt4all-lora, can be trained in about eight hours on a Lambda Labs DGX A100 8x 80GB for a total cost of $100.

What is Haystack GitHub? ›

Haystack is an open source framework by deepset for building production-ready LLM applications, retrieval-augmented generative pipelines and state-of-the-art search systems that work intelligently over large document collections.

What TF is GitHub? ›

GitHub is a platform for hosting code that allows for version control and collaboration. It allows you and others to collaborate on projects from anywhere. This lesson will teach you the fundamentals of GitHub, such as repositories, branches, commits, and pull requests.

How do I get started with Git and GitHub? ›

An Intro to Git and GitHub for Beginners (Tutorial)
  1. Step 0: Install git and create a GitHub account. ...
  2. Step 1: Create a local git repository. ...
  3. Step 2: Add a new file to the repo. ...
  4. Step 3: Add a file to the staging environment. ...
  5. Step 4: Create a commit. ...
  6. Step 5: Create a new branch. ...
  7. Step 6: Create a new repository on GitHub.

Can I train GPT-4 on my own data? ›

Can I train GPT on my own data? Sure thing. With access to OpenAI's ChatGPT API key, you can customize GPT models using your proprietary information.

Can GPT4All be used commercially? ›

Remember, your business can always install and use the official open-source, community edition of the GPT4All Desktop application commercially without talking to Nomic.

Does NASA use GitHub? ›

We use GitHub issues to track bugs and feature requests. To submit a new issue, navigate to the appropriate nasa-gcn repository and click on Issues. Click New Issue and fill out the form.

Does the military use GitHub? ›

Indeed, many government organizations already have accounts, but it can be a challenge to find out if yours is one of them. A partial list is here: https://government.github.com/community/ ; for US military and intelligence you can jump directly to https://government.github.com/community/#us-military-and-intelligence .

How does GitHub make money? ›

SaaS: GitHub's revenue comes 50% from GitHub Enterprise which is offered as an on-premise or cloud service. All paying subscribers have access to unlimited public repositories, unlimited private repositories, 24×7 support team, and user permissions. The Enterprise plan also allows companies to keep their code private.

Do I need both Git and GitHub? ›

In addition to its main website, GitHub features a desktop version that can be installed on local computers to help synchronize code. It should be noted that Git can be used without GitHub, but GitHub cannot be used without Git.

Is GitHub good for beginners? ›

Github is easy to use for beginners. In fact, you'll only need to know a few Git commands to learn how to push code to GitHub. If you already know Git, GitHub will be a breeze but it will be a bit harder if you don't know Git. Getting on GitHub can be a game-changer for you as a new or aspiring developer.

What is the difference between Git and GitHub? ›

The key difference between Git and GitHub is that Git is a free, open source version control tool that developers install locally on their personal computers, while GitHub is a pay-for-use online service built to run Git in the cloud. Git is a piece of software. GitHub is an online SaaS service.

Can I fine tune GPT4All? ›

GPT for All offers the potential to train and fine-tune the model on your own data set. The technical report and the GPT for All repository provide instructions and resources for reproducibility.

How does GPT4All compare to GPT4? ›

On the other hand, GPT4all is an open-source project that can be run on a local machine, offering greater flexibility and potential for customization. In addition, it is worth noting that there is also a paid version of GPT called GPT-4, which is expected to offer even more advanced features and capabilities.

Is GPT4All private? ›

GPT4All runs large language models (LLMs) privately on everyday desktops & laptops.

Does GPT4All require internet? ›

It is an open-sourced ecosystem of powerful and customizable LLM models developed by Nomic.ai. The goal of this project is that anybody can run these models locally on our devices without an internet connection.

References

Top Articles
Latest Posts
Article information

Author: Corie Satterfield

Last Updated:

Views: 6200

Rating: 4.1 / 5 (62 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Corie Satterfield

Birthday: 1992-08-19

Address: 850 Benjamin Bridge, Dickinsonchester, CO 68572-0542

Phone: +26813599986666

Job: Sales Manager

Hobby: Table tennis, Soapmaking, Flower arranging, amateur radio, Rock climbing, scrapbook, Horseback riding

Introduction: My name is Corie Satterfield, I am a fancy, perfect, spotless, quaint, fantastic, funny, lucky person who loves writing and wants to share my knowledge and understanding with you.