Views
No views yet
1!pip install -q huggingface_hub
2
3import os
4from huggingface_hub import hf_hub_download
5
6# --- CONFIGURATION ---
7repo_id = "Zlib2/Ternary-Bonsai-8B-GGUF-Colab-Prebuilt-GPU"
8
9print("1. Downloading pre-compiled binary...")
10bin_zip_path = hf_hub_download(repo_id=repo_id, filename="llama_bin.tar.gz")
11
12# Extract the binaries into a folder called 'llama_bin'
13!mkdir -p ./llama_bin
14!tar -xzvf {bin_zip_path} -C ./llama_bin
15# Ensure Linux knows it is an executable
16!chmod +x ./llama_bin/llama-cli
17
18print("\n2. Downloading model (this takes ~15 seconds)...")
19model_path = hf_hub_download(repo_id=repo_id, filename="Ternary-Bonsai-8B-Q2_0.gguf")
20
21# FIX: Update the system path via Python instead of Bash
22os.environ["LD_LIBRARY_PATH"] = f"./llama_bin:{os.environ.get('LD_LIBRARY_PATH', '')}"
231# 3. Run the model!
2system_prompt = "You are a helpful assistant."
3prompt = "Explain quantum computing in simple terms."
4
5print(f"\n--- Running inference ---\n")
6
7!./llama_bin/llama-cli \
8 -m "{model_path}" \
9 -ngl 99 \
10 -sys "{system_prompt}" \
11 -p "{prompt}" \
12 -n 1024
13