Jupyter AI brings generative AI capabilities proper into the interface. Having a neighborhood AI assistant ensures privateness, reduces latency, and gives offline performance, making it a robust software for builders. On this article, we’ll learn to arrange a neighborhood AI coding assistant in JupyterLab utilizing Jupyter AI, Ollama and Hugging Face. By the tip of this text, you’ll have a totally useful coding assistant in JupyterLab able to autocompleting code, fixing errors, creating new notebooks from scratch, and far more, as proven within the screenshot under.

⚠️ Jupyter AI continues to be underneath heavy growth, so some options could break. As of writing this text, I’ve examined the setup to verify it really works, however count on potential adjustments because the undertaking evolves. Additionally the efficiency of the assistant depends upon the mannequin that you choose so ensure you select the one that’s match on your use case.
First issues first — what’s Jupyter AI? Because the identify suggests, Jupyter AI is a JupyterLab extension for generative AI. This highly effective software transforms your commonplace Jupyter notebooks or JupyterLab atmosphere right into a generative AI playground. The most effective half? It additionally works seamlessly in environments like Google Colaboratory and Visible Studio Code. This extension does all of the heavy lifting, offering entry to a wide range of mannequin suppliers (each open and closed supply) proper inside your Jupyter atmosphere.

Establishing the atmosphere entails three essential parts:
- JupyterLab
- The Jupyter AI extension
- Ollama (for Native Mannequin Serving)
- [Optional] Hugging Face (for GGUF fashions)
Truthfully, getting the assistant to resolve coding errors is the simple half. What is difficult is making certain all of the installations have been executed appropriately. It’s subsequently important you comply with the steps appropriately.
1. Putting in the Jupyter AI Extension
It’s really helpful to create a new atmosphere particularly for Jupyter AI to maintain your present atmosphere clear and organised. As soon as executed comply with the following steps. Jupyter AI requires JupyterLab 4.x or Jupyter Pocket book 7+, so ensure you have the most recent model of Jupyter Lab put in. You’ll be able to set up/improve JupyterLab with pip or conda:
# Set up JupyterLab 4 utilizing pip
pip set up jupyterlab~=4.0
Subsequent, set up the Jupyter AI extension as follows.
pip set up "jupyter-ai[all]"
That is the best methodology for set up because it contains all supplier dependencies (so it helps Hugging Face, Ollama, and many others., out of the field). To this point, Jupyter AI helps the next mannequin suppliers :

If you happen to encounter errors in the course of the Jupyter AI set up, manually set up Jupyter AI utilizing pip
with out the [all] non-compulsory dependency group. This manner you may management which fashions can be found in your Jupyter AI atmosphere. For instance, to put in Jupyter AI with solely added assist for Ollama fashions, use the next:
pip set up jupyter-ai langchain-ollama
The dependencies rely upon the mannequin suppliers (see desk above). Subsequent, restart your JupyterLab occasion. If you happen to see a chat icon on the left sidebar, this implies every part has been put in completely. With Jupyter AI, you may chat with fashions or use inline magic instructions instantly inside your notebooks.

2. Setting Up Ollama for Native Fashions
Now that Jupyter AI is put in, we have to configure it with a mannequin. Whereas Jupyter AI integrates with Hugging Face fashions instantly, some fashions could not work correctly. As a substitute, Ollama gives a extra dependable strategy to load fashions regionally.
Ollama is a useful software for operating Giant Language Fashions regionally. It allows you to obtain pre-configured AI fashions from its library. Ollama helps all main platforms (macOS, Home windows, Linux), so select the tactic on your OS and obtain and set up it from the official web site. After set up, confirm that it’s arrange appropriately by operating:
Ollama --version
------------------------------
ollama model is 0.6.2
Additionally, be certain that your Ollama server should be operating which you’ll be able to examine by calling ollama serve
on the terminal:
$ ollama serve
Error: hear tcp 127.0.0.1:11434: bind: deal with already in use
If the server is already energetic, you will notice an error like above confirming that Ollama is operating and in use.
Choice 1: Utilizing Pre-Configured Fashions
Ollama gives a library of pre-trained fashions that you would be able to obtain and run regionally. To begin utilizing a mannequin, obtain it utilizing the pull command. For instance, to make use of qwen2.5-coder:1.5b
, run:
ollama pull qwen2.5-coder:1.5b
This may obtain the mannequin in your native atmosphere. To substantiate if the mannequin has been downloaded, run:
ollama record
This may record all of the fashions you’ve downloaded and saved regionally in your system utilizing Ollama.
Choice 2: Loading a Customized Mannequin
If the mannequin you want isn’t obtainable in Ollama’s library, you may load a customized mannequin by making a Mannequin File that specifies the mannequin’s supply.For detailed directions on this course of, check with the Ollama Import Documentation.
Choice 3: Working GGUF Fashions instantly from Hugging Face
Ollama now helps GGUF fashions instantly from the Hugging Face Hub, together with each private and non-private fashions. This implies if you wish to use GGUF mannequin instantly from Hugging Face Hub you are able to do so with out requiring a customized Mannequin File as talked about in Choice 2 above.
For instance, to load a 4-bit quantized Qwen2.5-Coder-1.5B-Instruct mannequin
from Hugging Face:
1. First, allow Ollama underneath your Native Apps settings.

2. On the mannequin web page, select Ollama from the Use this mannequin dropdown as proven under.

We’re nearly there. In JupyterLab, open the Jupyter AI chat interface on the sidebar. On the high of the chat panel or in its settings (gear icon), there’s a dropdown or subject to pick out the Mannequin supplier and mannequin ID. Select Ollama because the supplier, and enter the mannequin identify precisely as proven by Ollama record within the terminal (e.g. qwen2.5-coder:1.5b
). Jupyter AI will connect with the native Ollama server and cargo that mannequin for queries. No API keys are wanted since that is native.
- Set Language mannequin, Embedding mannequin and inline completions fashions based mostly on the fashions of your selection.
- Save the settings and return to the chat interface.

This configuration hyperlinks Jupyter AI to the regionally operating mannequin through Ollama. Whereas inline completions must be enabled by this course of, if that doesn’t occur, you are able to do it manually by clicking on the Jupyternaut icon, which is positioned within the backside bar of the JupyterLab interface to the left of the Mode indicator (e.g., Mode: Command). This opens a dropdown menu the place you may choose Allow completions by Jupyternaut
to activate the characteristic.

As soon as arrange, you should use the AI coding assistant for varied duties like code autocompletion, debugging assist, and producing new code from scratch. It’s essential to notice right here that you would be able to work together with the assistant both by the chat sidebar or instantly in pocket book cells utilizing %%ai magic instructions
. Let’s take a look at each the methods.
Coding assistant through Chat interface
That is fairly simple. You’ll be able to merely chat with the mannequin to carry out an motion. As an illustration, right here is how we are able to ask the mannequin to clarify the error within the code after which subsequently repair the error by deciding on code within the pocket book.

You can too ask the AI to generate code for a activity from scratch, simply by describing what you want in pure language. Here’s a Python operate that returns all prime numbers as much as a given constructive integer N, generated by Jupyternaut.

Coding assistant through pocket book cell or IPython shell:
You can too work together with fashions instantly inside a Jupyter pocket book. First, load the IPython extension:
%load_ext jupyter_ai_magics
Now, you should use the %%ai
cell magic to work together along with your chosen language mannequin utilizing a specified immediate. Let’s replicate the above instance however this time throughout the pocket book cells.

For extra particulars and choices you may check with the official documentation.
As you may gauge from this text, Jupyter AI makes it simple to arrange a coding assistant, supplied you’ve got the correct installations and setup in place. I used a comparatively small mannequin, however you may select from a wide range of fashions supported by Ollama or Hugging Face. The important thing benefit right here is that utilizing a neighborhood mannequin affords important advantages: it enhances privateness, reduces latency, and reduces dependence on proprietary mannequin suppliers. Nonetheless, operating large fashions regionally with Ollama may be resource-intensive so guarantee that you’ve ample RAM. With the fast tempo at which open-source fashions are enhancing, you may obtain comparable efficiency even with these alternate options.