Downloads · 30 days
679
47% of all-time downloads
IamPradeep/Ternary-Bonsai-2-27B-GGUF-Colab-Prebuilt-GPU
Ternary-Bonsai-2-27B-GGUF-Colab-Prebuilt-GPU is a machine learning model from IamPradeep. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository provides prebuilt binaries and GGUF configurations to run Ternary-Bonsai-2-27B on Google Colab or similar GPU environments with minimal setup. The default PTQ10 variant is only ~5.95 GB and can be down…
Downloads · 30 days
679
47% of all-time downloads
All-time downloads
1.5K
Public
Repo size
68.6 GB
Likes
0
Public
Click a slice to open those files.
.gguf68.5 GB · 100%
From the Hugging Face model README
This repository provides prebuilt binaries and GGUF configurations to run Ternary-Bonsai-2-27B on Google Colab or similar GPU environments with minimal setup.
The default PTQ1_0 variant is only ~5.95 GB and can be downloaded + launched in roughly 1–2 minutes on Colab.
!pip install -q huggingface_hub
import os
from huggingface_hub import hf_hub_download
# --- CONFIGURATION ---
repo_id = "IamPradeep/Ternary-Bonsai-2-27B-GGUF-Colab-Prebuilt-GPU"
# ------------------------------------------------------------------------------
# 1. Download + extract the pre-compiled llama.cpp binaries (PrismML fork)
# ------------------------------------------------------------------------------
print("📥 1. Downloading pre-compiled binary package...")
bin_tar_path = hf_hub_download(repo_id=repo_id, filename="llama_bin.tar.gz")
# Extract the binaries into a folder called 'llama_bin'
# Using tar preserves the executable bit, unlike zip.
!mkdir -p ./llama_bin
!tar -xzf {bin_tar_path} -C ./llama_bin
# Grant executable permissions to the main CLI
!chmod +x ./llama_bin/llama-cli
print("✅ Binaries ready at ./llama_bin/")
# ------------------------------------------------------------------------------
# 1b. Install the CUDA 12 runtime libraries required by the pre‑built binary.
# ------------------------------------------------------------------------------
print("📥 Installing CUDA 12 runtime libraries...")
!pip install -q nvidia-cuda-runtime-cu12 nvidia-cublas-cu12
# ------------------------------------------------------------------------------
# 2. Download the PTQ1_0 model (dense trits, ~5.95 GB)
# ------------------------------------------------------------------------------
print("\n\n📥 2. Downloading PTQ1_0 model (this takes ~1 minute for ~5.95 GB on Colab)...")
model_path = hf_hub_download(
repo_id=repo_id,
filename="Ternary-Bonsai-2-27B-PTQ1_0.gguf",
)
# ------------------------------------------------------------------------------
# 3. Environment setup — put the extracted dir AND the CUDA pip‑installed
# libraries on LD_LIBRARY_PATH so the loader can find libcudart.so.12.
# ------------------------------------------------------------------------------
import site
import os
# The nvidia-* pip packages install their shared libraries under:
# <site-packages>/nvidia/<component>/lib
nvidia_lib_dirs = []
for pkg in ("cuda_runtime", "cublas"):
pkg_path = os.path.join(site.getsitepackages()[0], "nvidia", pkg, "lib")
if os.path.isdir(pkg_path):
nvidia_lib_dirs.append(pkg_path)
# Build the final LD_LIBRARY_PATH: ./llama_bin + NVIDIA libs + existing path
existing = os.environ.get("LD_LIBRARY_PATH", "")
parts = ["./llama_bin"] + nvidia_lib_dirs
if existing:
parts.append(existing)
os.environ["LD_LIBRARY_PATH"] = ":".join(parts)
system_prompt = "You are a helpful AI assistant."
prompt = "Explain quantum computing in simple terms."
print("\n--- Running inference with Ternary-Bonsai-2-27B (PTQ1_0) ---\n")
!./llama_bin/llama-cli \
-m "{model_path}" \
-ngl 99 \
-c 8192 \
-sys "{system_prompt}" \
-p "{prompt}" \
--temp 0.7 \
--top-p 0.95 \
-n 2048 \
--reasoning off # Use "on" to enable reasoning/thinking
You can run vision tasks by downloading a vision projector (mmproj) and uploading an image directly inside Google Colab:
from PIL import Image
from google.colab import files
from huggingface_hub import hf_hub_download
# 1. Download Vision Projector (~629 MB)
print("Downloading Vision Projector...")
mmproj_path = hf_hub_download(
repo_id=repo_id,
filename="Ternary-Bonsai-2-27B-mmproj-Q8_0.gguf",
)
# 2. Live Image Upload
print("\n" + "="*50)
print("📸 PLEASE UPLOAD AN IMAGE FROM YOUR DEVICE:")
print("="*50)
uploaded = files.upload()
if not uploaded:
print("\n❌ No file was uploaded!")
else:
# Save the uploaded file path
image_filename = list(uploaded.keys())[0]
image_path = f"./{image_filename}"
print(f"\n✅ Uploaded successfully: {image_filename}")
display(Image.open(image_path))
# 3. Run Multimodal Inference
system_prompt = "You are an expert AI vision assistant."
prompt = "Describe what you see in this image in detail."
print(f"\n🤖 Running Vision Inference on {image_filename}...\n")
!./llama_bin/llama-cli \
-m "{model_path}" \
--mmproj "{mmproj_path}" \
--image "{image_path}" \
-sys "{system_prompt}" \
-p "{prompt}" \
-ngl 99 \
-c 8192 \
--temp 0.2 \
--top-p 0.95 \
-n 2048 \
--reasoning off # Use "on" to enable reasoning/thinking
Ternary-Bonsai-2-27B-PTQ1_0.gguf is ~5.95 GB, using dense ternary trits for fast GPU inference with a small VRAM footprint.llama_bin.tar.gz is ~35.2 MB and contains the PrismML fork of llama.cpp. No build or compile step is needed.-ngl 99 offloads all layers to the GPU. Use a Colab GPU runtime for best results.--reasoning off to --reasoning on to enable reasoning/thinking.Ternary-Bonsai-2-27B-mmproj-Q8_0.gguf (~629 MB)Ternary-Bonsai-2-27B-mmproj-BF16.gguf (~931 MB)filename parameter in hf_hub_download.| File | Size | Notes |
|---|---|---|
Ternary-Bonsai-2-27B-PTQ1_0.gguf | 5.95 GB | Default, dense trits, fastest/smallest |
Ternary-Bonsai-2-27B-PQ2_0.gguf | 7.21 GB | PQ2_0 quantization |
Ternary-Bonsai-2-27B-F16.gguf | 53.8 GB | Full F16 precision |
Ternary-Bonsai-2-27B-mmproj-Q8_0.gguf | 629 MB | Vision projector, default |
Ternary-Bonsai-2-27B-mmproj-BF16.gguf | 931 MB | Vision projector, BF16 |
llama_bin.tar.gz | 35.2 MB | Prebuilt PrismML llama.cpp binaries |
Ternary-Bonsai-2-27B is part of the Bonsai-2 family, using 1.58-bit ternary quantization with weights represented as {-1, 0, +1}.
This allows a 27B parameter model to run in a compact 5.95 GB footprint while retaining strong reasoning and multimodal capability when paired with an mmproj vision projector.
The PTQ1_0 variant uses dense trits and is the recommended default for Colab and low-VRAM GPU environments.
Special thanks to PrismML, the original architecture creators behind the Bonsai model families. Their ternary / 1.58-bit quantization methods make high-capability 27B local inference possible in a very small GPU footprint.