Multi-file FIM code completion for JupyterLab.
Project description
CellSense
Ghost-text inline code completion for JupyterLab, powered by local or remote AI models.
Overview
What is this?
CellSense is a JupyterLab 4 extension that adds FIM (Fill-In-Middle) inline completions to your notebooks and file editor. As you type, it silently assembles context from your current cell, surrounding cells, and related files across your workspace — then requests a ghost-text suggestion from your chosen model. Press Tab to accept.
Features
- Ghost-text completions — inline suggestions appear as you type, accepted with Tab
- Multi-file retrieval — Indexes your workspace and surfaces relevant code chunks automatically
- Recent State Aware - Maintains a state of recently read and editted code chunks to provide rich context to your completions
- Import tracking — resolves local imports and injects relevant signatures into the prompt
- Multi-cell context — walks outward from your cursor through surrounding cells within a configurable token budget
- Flexible providers — works with Ollama (local) or any OpenAI-compatible API (OpenAI, vLLM, LM Studio, Azure, etc.)
- Multiple model families — first-class prompt support for DeepSeek Coder, Codestral, CodeLlama, StarCoder2, and Qwen2.5-Coder
- In-JupyterLab settings — configure everything from a sidebar panel without touching config files
Why use it?
Most notebook completion tools treat each cell in isolation, or at best are aware of the surrounding cells in the currently open notebook. The quality of a completion is determined by the quality of context given to the model. CellSense is built around the idea that the most accurate completions come from a model that understands the current task, the tools at your disposal, and your typical coding style. It achieves this through three design principles:
Local awareness — Your utility functions, domain classes, and project-specific abstractions will never appear in any model's training data. CellSense addresses this by traversing your import tree and injecting the relevant function and class signatures directly into the prompt. The model reasons about your actual code, not a generic approximation of it.
Recent state — When working through a problem, the files you have been reading and editing are almost always the most relevant to your current task. CellSense maintains a rolling state of recently visited and modified code chunks, so the context reflects where your attention has actually been — not just what happens to be open in the active tab.
Relevant chunk retrieval — Beyond recency, CellSense indexes your workspace and retrieves code chunks that are lexically related to what you are currently writing. This surfaces patterns and solutions from elsewhere in your project that a cell-local view would miss entirely.
Together, these give the model a view of your work that is closer to your own mental model — without requiring any manual context management on your part. It can run entirely on local hardware if you use Ollama, with no data ever leaving your machine.
Installation
Prerequisites
- Python 3.10 or higher
- JupyterLab 4.0 or higher
- For local inference: Ollama installed and running
- For cloud inference: an API key for an OpenAI-compatible provider
Install
Option 1 — pip (recommended)
pip install jupyterlab-cellsense
Option 2 — Clone the repo and run the install script
Clone the repository, then run the script for your platform from inside the project directory:
macOS / Linux
git clone https://github.com/arunkarthik11/CellSense.git
cd CellSense
./install.sh
Windows (Command Prompt)
git clone https://github.com/arunkarthik11/CellSense.git
cd CellSense
install.bat
Windows (PowerShell)
git clone https://github.com/arunkarthik11/CellSense.git
cd CellSense
.\install.ps1
Note: On first run, PowerShell may require you to allow script execution:
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
Option 3 — GitHub release
Download the .whl file from the latest release and install it directly:
pip install jupyterlab_cellsense-<version>-py3-none-any.whl
Option 4 — pip with git
Install the latest commit directly from GitHub without cloning:
pip install git+https://github.com/arunkarthik11/CellSense.git
Verify installation
jupyter labextension list
You should see jupyterlab-cellsense in the output. Then start JupyterLab:
jupyter lab
CellSense-FIM models
CellSense works with any FIM-capable model, but we also trained a family of in-house models — CellSense-FIM — that understand the long-context, repo-, import-, and task-aware prompt structure CellSense assembles natively. They are fine-tuned from Qwen2.5-Coder on real Jupyter notebook repositories, share one prompt format across every size, and come in four sizes so you can pick the one that fits your hardware. All sizes support a 32K context window.
These models are a recommendation, not a requirement. CellSense remains fully model-agnostic — you can keep using any Ollama or OpenAI-compatible model you like (DeepSeek Coder, Codestral, CodeLlama, StarCoder2, Qwen2.5-Coder, etc.). The CellSense-FIM family is simply tuned to get the most out of the context CellSense builds.
The full interactive showcase lives in the CellSense-FIM Hugging Face Space, and the weights are on the Hugging Face hub.
Model family
| Model | Params | Context | Weights |
|---|---|---|---|
| CellSense-FIM 0.5B | 0.5B | 32K | arun11karthik/cellsense-fim-0.5b |
| CellSense-FIM 1.5B | 1.5B | 32K | arun11karthik/cellsense-fim-1.5b |
| CellSense-FIM 3B | 3B | 32K | arun11karthik/cellsense-fim-3b |
| CellSense-FIM 7B | 7B | 32K | arun11karthik/cellsense-fim-7b |
Evaluation
Held-out test split of the CellSense FIM dataset, scored against each Qwen2.5-Coder base model and a same-size, later-generation general model (Qwen3). Higher is better on all four completion-quality metrics.
BLEU climbs sharply once the model understands the notebook-native FIM format — CellSense-FIM stays roughly 10× above the base models at every size:
Bits per byte — lower is better
How tightly each model predicts held-out notebook code. CellSense-FIM is the most confident at every size.
| Size | Qwen2.5-Coder | Qwen3 | CellSense-FIM |
|---|---|---|---|
| 0.5B | 0.305 | 1.082 | 0.254 |
| 1.5B | 0.273 | 1.097 | 0.197 |
| 3B | 0.250 | 1.052 | 0.182 |
| 7B | 0.234 | 1.041 | 0.169 |
Running a CellSense-FIM model
Serve it with vLLM (OpenAI-compatible) or run it locally with Ollama, then point CellSense at it.
Serve with vLLM
vllm serve arun11karthik/cellsense-fim-7b \
--served-model-name cellsense-fim-7b \
--max-model-len 32768 --port 8000
Then in CellSense → Basic Settings: Provider OpenAI Compatible, Base URL http://localhost:8000/v1, Model cellsense-fim-7b, Model Family cellsense.
Run locally with Ollama
Make sure the Ollama server is running, then pull the model:
ollama serve
ollama pull hf.co/arun11karthik/cellsense-fim-7b-GGUF:Q5_K_M
The Hugging Face model tag is long, so copy it to a simpler local name with ollama cp:
ollama cp hf.co/arun11karthik/cellsense-fim-7b-GGUF:Q5_K_M cellsense-fim-7b
You can then just use cellsense-fim-7b as the model tag in Ollama.
Then in CellSense → Basic Settings: Provider Ollama, Base URL http://localhost:11434, Model cellsense-fim-7b (or the full hf.co/... tag), Model Family cellsense.
Swap 7b for 0.5b / 1.5b / 3b. Ollama quantization tags: Q5_K_M, Q8_0, BF16.
Quick Start
- Start Ollama and pull a FIM model:
ollama pull qwen2.5-coder:14b
- Launch JupyterLab and open a notebook.
- Open the CellSense panel from the left sidebar.
- Confirm the provider is set to Ollama and the model matches what you pulled.
- Click Save & Apply.
- Start typing in a cell — a ghost-text suggestion will appear after a short pause. Press Tab to accept.
Configuration
Open the CellSense settings panel from the left sidebar, or via the Command Palette (Ctrl+Shift+C / Cmd+Shift+C) → CellSense Settings.
Available Options
Provider
| Option | Values | Default | Description |
|---|---|---|---|
provider |
ollama, openai_compatible |
ollama |
Which backend to use for completions |
Ollama
| Option | Default | Description |
|---|---|---|
base_url |
http://localhost:11434 |
Address of your Ollama server |
model_family |
deepseek-coder |
FIM prompt format — must match your model. Options: deepseek-coder, codestral, codellama, starcoder2, qwen2.5-coder, other |
model |
deepseek-coder:6.7b |
Full Ollama model tag |
OpenAI Compatible
| Option | Default | Description |
|---|---|---|
base_url |
https://api.openai.com/v1 |
API endpoint — change for vLLM, LM Studio, Codestral, etc. |
api_key |
Provided API KEY | API key — The API key provided by the Model Provider |
model |
gpt-4o-mini |
Model identifier |
Completion
| Option | Default | Description |
|---|---|---|
debounce_ms |
500 |
Milliseconds of idle time before a completion request is sent |
max_context_tokens |
1500 |
Token budget for cell-walking — cells are included outward from your cursor until this limit is reached |
max_tokens |
256 |
Maximum tokens the model can generate per completion |
one_line_completions |
false |
Restrict suggestions to a single line. This is generally faster and more accurate, but generates fewer tokens. |
Retrieval (RAG)
| Option | Default | Description |
|---|---|---|
enabled |
true |
Enable BM25 workspace retrieval to inject relevant code chunks into the prompt |
top_k |
3 |
Number of code chunks retrieved from the workspace index (1–20) |
token_budget |
2000 |
Maximum tokens allocated to retrieved context |
Warning: If you are using an external model provider who trains on your data, be aware that enabling RAG could retrieve code chunks from your repository or workspace root to enrich the context. This means that context from other files could also be sent. If this is not something you are comfortable with, either switch to a provider who allows you to disable training or disable RAG for this feature. However, this would still traverse the import tree and retrieve the relevant signatures.
Usage
Basic Workflow
- Open a notebook and start typing code in a cell.
- Pause briefly — CellSense will assemble context from your notebook and workspace, then request a completion.
- A ghost-text suggestion appears inline.
- Press Tab to accept the full suggestion.
- To dismiss without accepting, keep typing or press Escape.
Commands / UI Elements
| Element | How to access |
|---|---|
| Settings sidebar panel | Left sidebar icon |
| CellSense Settings (full dialog) | Command Palette → "CellSense Settings" |
| Accept completion | Tab |
| Dismiss completion | Escape or continue typing |
The settings panel is divided into three sections:
- Basic Settings — provider selection, model configuration
- Advanced: Completion — debounce, token budgets, one-line mode
- Advanced: Retrieval — enable/disable RAG, top-K, token budget
Click Save & Apply after making changes. Settings take effect immediately without restarting JupyterLab.
Additional examples
Using Ollama with Codestral
- Pull the model:
ollama pull codestral - In the settings panel, set Provider to
Ollama, Model Family tocodestral, and Model tocodestral. - Save & Apply.
Using an OpenAI-compatible local server (LM Studio)
- Start your LM Studio server.
- Set Provider to
OpenAI Compatible, Base URL tohttp://localhost:1234/v1, leave API Key blank, and set Model to the model name shown in LM Studio. - Save & Apply.
Disabling retrieval for faster completions
In the settings panel, expand Advanced: Retrieval and toggle Enable Retrieval off. This skips the BM25 workspace index and sends only the notebook cell context.
Troubleshooting
No completions appear
- Check the health endpoint in the browser:
http://localhost:8888/cellsense/health - If using Ollama, confirm it is running:
ollama listand check that the right port is provided - Verify the model name in settings exactly matches the tag in Ollama.
Completions are slow
- Reduce
max_tokens(try 64–128). - Reduce
max_context_tokensto limit the amount of notebook context sent. - Enable One Line completions
- Disable retrieval if your workspace is large.
Tab key doesn't accept
- Ensure the cell is in edit mode (click inside the cell first).
- Check that JupyterLab's inline completer is enabled: Settings → Inline Completer → Enable.
jupyter labextension list doesn't show CellSense
- Run
pip show jupyterlab-cellsenseto confirm the package is installed in the active environment. - Ensure you're running
jupyter labfrom the same environment where you ranpip install.
PowerShell script is blocked
- Run:
Set-ExecutionPolicy -Scope CurrentUser RemoteSignedand try again.
Compatibility
| Component | Version |
|---|---|
| JupyterLab | 4.0+ |
| Python | 3.10+ |
| Jupyter Server | 2.x |
| Ollama | Any recent version |
Supported model families
| Family | Example models |
|---|---|
| DeepSeek Coder | deepseek-coder:6.7b, deepseek-coder:33b |
| Codestral | codestral |
| CodeLlama | codellama:7b, codellama:13b |
| StarCoder2 | starcoder2:3b, starcoder2:7b |
| Qwen2.5-Coder | qwen2.5-coder:7b |
| CellSense-FIM | cellsense-fim-0.5b, cellsense-fim-1.5b, cellsense-fim-3b, cellsense-fim-7b |
| Generic FIM | Any FIM model not listed above |
| OpenAI compatible | gpt-4o-mini, vLLM-served models, LM Studio, etc. |
Contributing
Contributions are welcome. Please open an issue before submitting a pull request for significant changes.
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Commit your changes and open a pull request against
master
For bug reports and feature requests, use the issue tracker.
Inspirations
Fill-In-Middle (FIM) — Bavarian et al., OpenAI, 2022. The foundational technique CellSense uses to structure every prompt: the model is given a prefix and a suffix and asked to generate the text that belongs in between, rather than simply continuing from the end of a document.
StarCoder — Li et al., 2023. StarCoder popularised open, openly licensed FIM-capable code models and established the <fim_prefix> / <fim_suffix> / <fim_middle> token conventions that CellSense's prompt templates are built around.
JupyterLab — CellSense is built directly on JupyterLab 4's IInlineCompletionProvider API for ghost-text suggestions and the jupyter_server extension system for server-side request handling. None of this required patching JupyterLab internals — both are stable, public extension points.
Related projects
If you are looking for a chat-based AI coding assistant for JupyterLab rather than inline completions, NotebookIntelligence is an awesome tool. CellSense focuses exclusively on rich context based ghost-text completion; the two tools are complementary.
License
CellSense is licensed under the GNU General Public License v3.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jupyterlab_cellsense-0.3.0.tar.gz.
File metadata
- Download URL: jupyterlab_cellsense-0.3.0.tar.gz
- Upload date:
- Size: 2.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4064f621c59c770d46da379adc98b531d451936a2f0ba97767c3d62993e5106
|
|
| MD5 |
f64c25fb05a4e69190c30ca75510c9ec
|
|
| BLAKE2b-256 |
75ab89d7aea05fa28b3b2b26e092869c6db144e68d7a7aa5a5d053b266a0cd54
|
File details
Details for the file jupyterlab_cellsense-0.3.0-py3-none-any.whl.
File metadata
- Download URL: jupyterlab_cellsense-0.3.0-py3-none-any.whl
- Upload date:
- Size: 139.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3709e70ce3a4bc524ede8cb86c395bfba7bba2f8e0da68337b1b2d361b7c8b92
|
|
| MD5 |
7c29bbf926f8b4ab1c3d510ecda1d13d
|
|
| BLAKE2b-256 |
da71b7c98f20917d862011b47d1450b9e77956d8a1a8efd3e6702b1bd7cba326
|