Qiskit Code Assistant
Qiskit Code Assistant LLMs มีเป้าหมายเพื่อทำให้การประมวลผลควอนตัมเข้าถึงได้ง่ายขึ้นสำหรับผู้ใช้ Qiskit รายใหม่ และปรับปรุงประสบการณ์การเขียนโค้ดสำหรับผู้ใช้ปัจจุบัน ฝึกฝนโดยใช้ text tokens หลายล้านตัวจาก Qiskit SDK ตัวอย่างโค้ด Qiskit หลายปี และฟีเจอร์ IBM Quantum® Qiskit Code Assistant ช่วยให้เวิร์กโฟลว์การพัฒนาควอนตัมด้วยการเสนอคำแนะนำที่สร้างโดย LLM บนพื้นฐาน IBM Granite and other open-source models ซึ่งรวมฟีเจอร์และฟังก์ชันการทำงานล่าสุดจาก IBM®
- ต้องการข้ามไปยังคำแนะนำการติดตั้ง? ไปที่ส่วน Install Qiskit Code Assistant
- หากมีข้อเสนอแนะหรือต้องการติดต่อทีมพัฒนา ใช้ Qiskit Slack Workspace channel หรือ GitHub repositories สาธารณะที่เกี่ยวข้อง
Large Language Model (LLM) เบื้องหลัง Qiskit Code Assistant
เพื่อให้คำแนะนำโค้ด Qiskit Code Assistant ใช้ Large Language Model (LLM) ในกรณีนี้ Qiskit Code Assistant ปัจจุบันพึ่งพาโมเดล mistral-small-3.2-24b-qiskit ที่สร้างบน Mistral-Small-3.2-24B-Qiskit model โมเดล mistral-small-3.2-24b-qiskit ปรับปรุงความสามารถในการสร้างโค้ดของโมเดล Mistral-Small-3.2-24B-Instruct-2506 สำหรับ Qiskit ผ่านการฝึกล่วงหน้าแบบขยายและ fine-tuning บนข้อมูล Qiskit คุณภาพสูง รวมถึง Python commits และ chat สำหรับข้อมูลเพิ่มเติมเกี่ยวกับตระกูลโมเดล Mistral AI โปรดดู Mistral AI documentation สำหรับรายละเอียดเพิ่มเติมเกี่ยวกับโมเดล .*-qiskit ดู Qiskit Code Assistant: Training LLMs for generating Quantum Computing Code
LLM ที่เชี่ยวชาญสำหรับ Qiskit ของเรายังมีให้ใช้งานเป็นโมเดลโอเพนซอร์ส ดูโมเดลทั้งหมดที่มีได้ที่ https://huggingface.co/Qiskit
Qiskit HumanEval และ Qiskit HumanEval Hard benchmarks
เพื่อทดสอบโมเดล mistral-small-3.2-24b-qiskit และโมเดลอื่น ๆ เราร่วมมือกับ Qiskit Advocates และผู้เชี่ยวชาญเพื่อสร้าง execution-based benchmarks ที่เรียกว่า Qiskit HumanEval (QHE) และ Qiskit HumanEval Hard (QHE Hard) และนำมาทดสอบกับโมเดลต่าง ๆ benchmarks เหล่านี้คล้ายกับ HumanEval ประกอบด้วยปัญหาโค้ดที่ท้าทายหลายอย่างที่ต้องแก้ไข ทั้งหมดอ้างอิงจากไลบรารี Qiskit อย่างเป็นทางการ
benchmarks ประกอบด้วยการทดสอบประมาณ 150 รายการ แต่ละรายการสร้างจากนิยามฟังก์ชัน ตามด้วย docstring ที่อธิบายรายละเอียดงานที่โมเดลต้องแก้ไข แต่ละตัวอย่างยังรวมถึงโซลูชันอ้างอิงที่เป็นมาตรฐาน รวมถึง unit tests เพื่อประเมินความถูกต้องของโซลูชันที่สร้าง มีระดับความยากสามระดับสำหรับการทดสอบ: พื้นฐาน กลาง และยาก Qiskit HumanEval Hard benchmark เป็นรูปแบบหนึ่งของ Qiskit HumanEval แต่ลบข้อมูลที่เกี่ยวข้องกับ code imports ออก ทำให้ LLM ต้องหาวิธีหรือ class imports ที่ถูกต้องเอง การเปลี่ยนแปลงนี้ทำให้ dataset ท้าทายมากขึ้นสำหรับ LLM ตามการทดสอบและผลลัพธ์เบื้องต้นของเรา
datasets สำหรับ Qiskit HumanEval และ Qiskit HumanEval Hard มีอยู่ที่เว็บไซต์เหล่านี้: Qiskit HumanEval และ Qiskit HumanEval สามารถมีส่วนร่วมในการพัฒนา benchmarks เหล่านี้ได้ที่ GitHub repository
ติดตั้ง Qiskit Code Assistant
เรียนรู้วิธีติดตั้ง กำหนดค่า และใช้งานโมเดล Qiskit Code Assistant ใด ๆ บนเครื่องโลคัลของคุณ
ดาวน์โหลดจากเว็บไซต์ Hugging Face
ทำตามขั้นตอนเหล่านี้เพื่อดาวน์โหลดโมเดลที่เกี่ยวข้องกับ Qiskit Code Assistant จากเว็บไซต์ Hugging Face:
- ไปที่หน้าโมเดล Qiskit ที่ต้องการบน Hugging Face
- ไปที่แท็บ Files and Versions และดาวน์โหลดไฟล์โมเดล safetensors หรือ GGUF
ดาวน์โหลดโดยใช้ Hugging Face CLI
เพื่อดาวน์โหลดโมเดล Qiskit Code Assistant ที่มีให้ใช้งานโดยใช้ Hugging Face CLI ให้ทำตามขั้นตอนเหล่านี้:
-
ติดตั้ง Hugging Face CLI
-
เข้าสู่ระบบ Hugging Face ของคุณ
huggingface-cli login -
ดาวน์โหลดโมเดลที่คุณต้องการจากรายการก่อนหน้า
huggingface-cli download <HF REPO NAME> <MODEL PATH> --local-dir <LOCAL PATH>
ติดตั้งโมเดล Qiskit Code Assistant ในโลคัลผ่าน Ollama ด้วยตนเอง
มีหลายวิธีในการติดตั้งและโต้ตอบกับโมเดล Qiskit Code Assistant ที่ดาวน์โหลดมา คู่มือนี้สาธิตการใช้ Ollama ดังนี้: ด้วย แอปพลิเคชัน Ollama โดยใช้ Hugging Face Hub integration หรือโมเดลโลคัล หรือด้วย แพ็กเกจ llama-cpp-python
การใช้แอปพลิเคชัน Ollama
แอปพลิเคชัน Ollama มอบโซลูชันที่ง่ายในการรัน LLM ในโลคัล ใช้งานง่าย มี CLI ที่ทำให้กระบวนการตั้งค่า การจัดการโมเดล และการโต้ตอบค่อนข้างตรงไปตรงมา เหมาะสำหรับการทดลองอย่างรวดเร็วและสำหรับผู้ใช้ที่ต้องการรายละเอียดทางเทคนิคน้อยลง
ติดตั้ง Ollama
-
ดาวน์โหลด แอปพลิเคชัน Ollama
-
ติดตั้งไฟล์ที่ดาวน์โหลด
-
เปิดแอปพลิเคชัน Ollama ที่ติดตั้งแล้ว
ข้อมูลแอปพลิเคชันทำงานสำเร็จเมื่อไอคอน Ollama ปรากฏในแถบเมนูเดสก์ท็อป คุณยังสามารถตรวจสอบว่าบริการกำลังทำงานโดยไปที่
http://localhost:11434/ -
ลอง Ollama ในเทอร์มินัลของคุณและเริ่มรันโมเดล ตัวอย่างเช่น:
ollama run hf.co/Qiskit/Qwen2.5-Coder-14B-Qiskit
ตั้งค่า Ollama โดยใช้ Hugging Face Hub integration
Ollama/Hugging Face Hub integration มอบวิธีโต้ตอบกับโมเดลที่โฮสต์บน Hugging Face Hub โดยไม่ต้องสร้าง modelfile ใหม่หรือดาวน์โหลดไฟล์ GGUF หรือ safetensors ด้วยตนเอง ไฟล์ template และ params เริ่มต้นรวมอยู่กับโมเดลบน Hugging Face Hub แล้ว
-
ตรวจสอบให้แน่ใจว่าแอปพลิเคชัน Ollama กำลังทำงาน
-
ไปที่หน้าโมเดลที่ต้องการและคัดลอก URL ตัวอย่างเช่น https://huggingface.co/Qiskit/Qwen2.5-Coder-14B-Qiskit-GGUF
-
จากเทอร์มินัลของคุณ รันคำสั่ง:
ollama run hf.co/Qiskit/Qwen2.5-Coder-14B-Qiskit
คุณสามารถใช้โมเดล hf.co/Qiskit/Qwen2.5-Coder-14B-Qiskit หรือโมเดล GGUF อย่างเป็นทางการที่แนะนำอื่น ๆ hf.co/Qiskit/mistral-small-3.2-24b-qiskit-GGUF หรือ hf.co/Qiskit/granite-3.3-8b-qiskit-GGUF
ตั้งค่า Ollama ด้วยโมเดล Qiskit Code Assistant GGUF ที่ดาวน์โหลดด้วยตนเอง
หากคุณดาวน์โหลดโมเดล GGUF ด้วยตนเอง เช่น https://huggingface.co/Qiskit/Qwen2.5-Coder-14B-Qiskit-GGUF และต้องการทดลองใช้ templates และพารามิเตอร์ต่าง ๆ คุณสามารถทำตามขั้นตอนเหล่านี้เพื่อโหลดเข้าแอปพลิเคชัน Ollama โลคัลของคุณ
-
สร้าง
Modelfileโดยป้อนเนื้อหาต่อไปนี้และอย่าลืมอัปเดต<PATH-TO-GGUF-FILE>เป็นพาธจริงของโมเดลที่ดาวน์โหลดFROM <PATH-TO-GGUF-FILE>TEMPLATE """{{ if .System }}System:{{ .System }}{{ end }}{{ if .Prompt }}Question:{{ .Prompt }}{{ end }}Answer:```python{{ .Response }}"""PARAMETER stop "Question:"PARAMETER stop "Answer:"PARAMETER stop "System:"PARAMETER stop "```"PARAMETER temperature 0PARAMETER top_k 1 -
Run the following command to create a custom model instance based on the
Modelfile.ollama create Qwen2.5-Coder-14B-Qiskit -f ./path-to-model-fileหมายเหตุThis process may take some time for Ollama to read the model file, initialize the model instance, and configure it according to the specifications provided.
Run the Qiskit Code Assistant model manually downloaded in Ollama
After the Qwen2.5-Coder-14B-Qiskit model has been set up in Ollama, run the following command to launch the model and interact with it in the terminal (in chat mode).
ollama run Qwen2.5-Coder-14B-Qiskit
Some useful commands:
ollama list- List models on your computerollama rm Qwen2.5-Coder-14B-Qiskit- Delete the modelollama show Qwen2.5-Coder-14B-Qiskit- Show model informationollama stop Qwen2.5-Coder-14B-Qiskit- Stop a model that is currently runningollama ps- List which models are currently loaded
Manually deploy the Qiskit Code Assistant models in local through the llama-cpp-python package
An alternative to the Ollama application is the llama-cpp-python package, which is a Python binding for llama.cpp. It gives you more control and flexibility to run the GGUF model locally, and is ideal for users who wish to integrate the local model in their workflows and Python applications.
- Install
llama-cpp-python - Interact with the model from within your application using
llama_cpp. For example:
from llama_cpp import Llama
model_path = <PATH-TO-GGUF-FILE>
model = Llama(
model_path,
seed=17,
n_ctx=10000,
n_gpu_layers=37, # to offload in gpu, but put 0 if all in cpu
)
input = 'Generate a quantum circuit with 2 qubits'
raw_pred = model(input)["choices"][0]["text"]
You can also add text generation parameters to the model to customize the inference:
generation_kwargs = {
"max_tokens": 512,
"echo": False, # Echo the prompt in the output
"top_k": 1
}
raw_pred = model(input, **generation_kwargs)["choices"][0]["text"]
Manually deploy the Qiskit Code Assistant models in local through llama.cpp
Use the llama.cpp library
Another alternative is to use llama.cpp, an open-source library for performing LLM inference on a CPU with minimal setup.
It provides low-level control over the model execution and is typically run from the command line, pointing to a local GGUF model file.
There are several ways to install llama.cpp on your machine:
- Install llama.cpp using brew, nix, or winget
- Run with Docker: See out the Docker documentation by
llama.cppteam - Download pre-built binaries from the releases page
- Build from source by cloning this repository
Once installed, you can use llama.cpp to interact with GGUF models in conversation mode as follows:
# Use a local model file
llama-cli -m my_model.gguf -cnv
# Or download and run a model directly from Hugging Face
llama-cli -hf Qiskit/Qwen2.5-Coder-14B-Qiskit-GGUF -cnv
You can also launch an OpenAI-compatible API server for the model in the following way:
llama-server -hf Qiskit/Qwen2.5-Coder-14B-Qiskit-GGUF
Advanced parameters
With the llama-cli program, you can control the model generation using command-line options. For example, you can provide an initial “system” prompt using the -p/--prompt flag. In conversation mode (-cnv), this initial prompt acts as the system message. Otherwise, you can simply prepend any desired instruction to your prompt text. You can also adjust sampling parameters - for instance: temperature (--temp), top-k (--top-k), top-p (--top-p), repetition penalty (--repeat-penalty), and the seed to use (--seed). The following is an example invocation using these options:
llama-cli -hf Qiskit/Qwen2.5-Coder-14B-Qiskit-GGUF \
-p "You are a friendly assistant." -cnv \
--temp 0.7 \
--top-k 50 \
--top-p 0.95 \
--repeat-penalty 1.1 \
--seed 42
To ensure proper functionality of our Qiskit models, we recommend using the system prompt provided in our HF GGUF repositories: system prompt for mistral-small-3.2-24b-qiskit-GGUF, Qwen2.5-Coder-14B-Qiskit-GGUF, granite-3.3-8b-qiskit-GGUF, and granite-3.2-8b-qiskit-GGUF.
Manually connect Continue (VS Code)
Continue (VS Code)
1. Install the extension
Open VS Code, go to Extensions (Cmd+Shift+X), search Continue, install it.
2. Open the config
Click the Continue icon in the sidebar, then click the gear icon, or open the command palette (Cmd+Shift+P) and run Continue: Open Config File.
This opens ~/.continue/config.yaml (or config.json in older versions).
3. Configure the model
Add the following to config.yaml:
models:
- name: Qiskit Code Assistant
provider: ollama
model: mistral-small-3.2-24b-qiskit
apiBase: http://localhost:11434
This makes the Qiskit model available in the chat panel (sidebar conversations, inline Q&A) and for inline edit commands.
4. Test it
- Chat: Open the Continue panel in the sidebar and ask a question (e.g., "How do I create a parameterized circuit in Qiskit?")
- Inline edit: Select a block of code, press
Cmd+I(Mac) orCtrl+I(Linux/Windows)
Manually connect Jupyter AI (JupyterLab)
Jupyter AI (JupyterLab)
Note: These instructions cover Jupyter AI v2.x.
1. Install Jupyter AI and the Ollama provider
pip install "jupyter-ai<3" langchain-ollama
The "jupyter-ai<3" pin ensures you get v2.x. The langchain-ollama package is required for Jupyter AI to detect Ollama as a provider. Without it, Ollama will not appear in the settings panel.
Then restart JupyterLab.
2. Configure the chat model
Open JupyterLab and click the chat icon in the left sidebar. In the settings panel:
- Under Language model, select Ollama as the provider.
- Enter
mistral-small-3.2-24b-qiskitas the model name. - No API key is needed for Ollama (leave the field empty).
- Click the back arrow to start chatting.
3. Use the %%ai magic command
The %%ai magic lets you query the model directly in notebook cells.
%load_ext jupyter_ai_magics
Then in a cell:
%%ai ollama:mistral-small-3.2-24b-qiskit
Write a function that implements Grover's algorithm using Qiskit
4. Custom Ollama host (optional)
By default, Jupyter AI connects to http://127.0.0.1:11434. If your Ollama server runs on a different address or port:
In the chat UI: Set the "Base API URL" field in the AI settings panel.
Manually connect OpenCode (Terminal)
OpenCode (Terminal)
1. Install OpenCode
curl -fsSL https://opencode.ai/install | bash
2. Configure the Qiskit model
Create an opencode.json file in your project root (or ~/.config/opencode/opencode.json for a global config):
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ollama": {
"npm": "@ai-sdk/openai-compatible",
"name": "Ollama (local)",
"options": {
"baseURL": "http://localhost:11434/v1"
},
"models": {
"mistral-small-3.2-24b-qiskit": {
"name": "Qiskit Code Assistant"
}
}
}
}
}
3. Select the model
Launch OpenCode in your project directory:
opencode
Inside the TUI, run the /models command and select Qiskit Code Assistant from the list.
4. Test it
Ask a question directly in the chat, for example: "Define a Bell circuit and run it using QiskitRuntimeService"
Available models
Current models
These are the latest recommended models for use with Qiskit Code Assistant:
- Qiskit/mistral-small-3.2-24b-qiskit - Released October 2025
- Qiskit/Qwen2.5-Coder-14B-Qiskit - Released June 2025
- qiskit/granite-3.3-8b-qiskit - Released June 2025
- qiskit/granite-3.2-8b-qiskit - Released June 2025
GGUF models (recommended for personal environments/laptops)
GGUF format models are optimized for local use and require fewer computational resources:
-
mistral-small-3.2-24b-qiskit-GGUF – Released October 2025
Trained with Qiskit data up to version 2.1 -
Qiskit/Qwen2.5-Coder-14B-Qiskit-GGUF – Released June 2025
Trained with Qiskit data up to version 2.0 -
qiskit/granite-3.3-8b-qiskit-GGUF – Released June 2025
Trained with Qiskit data up to version 2.0 -
qiskit/granite-3.2-8b-qiskit-GGUF – Released June 2025
Trained with Qiskit data up to version 2.0
The Open Source Qiskit Code Assistant models are available in safetensors or GGUF file format and can be downloaded from the Hugging Face as explained below.
Qiskit versions used for training
| Model | Benchmark Metrics | Release date | Trained on Qiskit version | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| QiskitHumanEval-Hard | QiskitHumanEval | HumanEval | ASDiv | MathQA | SciQ | MBPP | IFEval | CrowsPairs (English) | TruthfulQA (MC1 acc) | |||
| mistral-small-3.2-24b-qiskit | 32.45 | 47.02 | 77.49 | 3.77 | 49.68 | 97.50 | 64.00 | 48.44 | 67.08 | 39.41 | January 2026 | 2.2 |
| Qwen2.5-Coder-14B-Qiskit | 25.17 | 49.01 | 91.46 | 4.21 | 53.90 | 97.00 | 77.60 | 49.64 | 65.18 | 37.82 | June 2025 | 2.0 |
| granite-3.3-8b-qiskit | 14.57 | 27.15 | 62.80 | 0.48 | 38.66 | 93.30 | 52.40 | 59.71 | 59.75 | 39.05 | June 2025 | 2.0 |
| granite-3.2-8b-qiskit | 9.93 | 24.50 | 57.32 | 0.09 | 41.41 | 96.30 | 51.80 | 60.79 | 66.79 | 40.51 | June 2025 | 2.0 |
| granite-8b-qiskit-rc-0.10 | 15.89 | 38.41 | 59.76 | — | — | — | — | — | — | — | February 2025 | 1.3 |
| granite-8b-qiskit | 17.88 | 44.37 | 53.66 | — | — | — | — | — | — | — | November 2024 | 1.2 |
Note: All models listed in the benchmark table were evaluated using their respective system prompt, defined in their Hugging Face model.
Deprecated models
These models are no longer actively maintained but remain available:
- qiskit/granite-8b-qiskit-rc-0.10 - Released February 2025 (deprecated)
- qiskit/granite-8b-qiskit - Released November 2024 (deprecated)
More information and citations
To learn more about Qiskit Code Assistant, the Qiskit HumanEval, or Qiskit HumanEval Hard benchmarks, and cite them in your scientific publications, review these recommended citations:
@misc{2405.19495,
Author = {Nicolas Dupuis and Luca Buratti and Sanjay Vishwakarma and Aitana Viudes Forrat and David Kremer and Ismael Faro and Ruchir Puri and Juan Cruz-Benito},
Title = {Qiskit Code Assistant: Training LLMs for generating Quantum Computing Code},
Year = {2024},
Eprint = {arXiv:2405.19495},
}
@misc{2406.14712,
Author = {Sanjay Vishwakarma and Francis Harkins and Siddharth Golecha and Vishal Sharathchandra Bajpe and Nicolas Dupuis and Luca Buratti and David Kremer and Ismael Faro and Ruchir Puri and Juan Cruz-Benito},
Title = {Qiskit HumanEval: An Evaluation Benchmark For Quantum Code Generative Models},
Year = {2024},
Eprint = {arXiv:2406.14712},
}
@misc{2508.20907,
Author = {Nicolas Dupuis and Adarsh Tiwari and Youssef Mroueh and David Kremer and Ismael Faro and Juan Cruz-Benito},
Title = {Quantum Verifiable Rewards for Post-Training Qiskit Code Assistant},
Year = {2025},
Eprint = {arXiv:2508.20907},
}