Instructions to use BernaLabs/berna-r8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use BernaLabs/berna-r8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="BernaLabs/berna-r8")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("BernaLabs/berna-r8", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use BernaLabs/berna-r8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "BernaLabs/berna-r8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BernaLabs/berna-r8", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/BernaLabs/berna-r8
- SGLang
How to use BernaLabs/berna-r8 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "BernaLabs/berna-r8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BernaLabs/berna-r8", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "BernaLabs/berna-r8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BernaLabs/berna-r8", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use BernaLabs/berna-r8 with Docker Model Runner:
docker model run hf.co/BernaLabs/berna-r8
File size: 1,865 Bytes
90d0886 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | """
K6 — Encompassment per-cell (R8 fix).
R7 bug: K6 = 0.6138 uniform across all cells
Cause: encompassment_engine_v2 uses a global pattern index.
R8 fix: K6[cell] = fraction of layer-distinct fingerprints
that this cell has seen (via fp_history).
"""
import numpy as np
def _hamming_sim(a, b):
"""Similarity = 1 - normalized hamming distance on hex strings."""
if not a or not b or len(a) != len(b):
return 0.0
try:
x = int(a, 16) ^ int(b, 16)
except ValueError:
return 0.0
n_bits = len(a) * 4
dist = bin(x).count("1") / n_bits
return 1.0 - dist
def build_layer_fingerprints(cells, history_window=100):
"""Group distinct fingerprints by layer."""
out = {}
for c in cells:
h = getattr(c, "fp_history", [])
if not h:
continue
out.setdefault(c.layer_idx, set()).update(h[-history_window:])
return out
def compute_k6_percell(cells, layer_fps, sim_threshold=0.7,
history_window=100):
"""
For each cell:
K6 = fraction of layer's distinct fingerprints
that the cell has 'seen' (similarity >= sim_threshold).
Returns {cell_id: K6 in [0, 1]}.
"""
out = {}
for c in cells:
lfps = layer_fps.get(c.layer_idx, set())
if not lfps:
out[c.cell_id] = 0.0
continue
history = getattr(c, "fp_history", [])
if not history:
out[c.cell_id] = 0.0
continue
recent = history[-history_window:]
matched = 0
for fp in lfps:
for h in recent:
if _hamming_sim(fp, h) >= sim_threshold:
matched += 1
break
out[c.cell_id] = matched / max(1, len(lfps))
return out |