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
Download code/k_vector/k5_percell.py from BernaLabs/berna-r8: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/BernaLabs/berna-r8/resolve/main/code/k_vector/k5_percell.py
- Command line
-
hf download hf://BernaLabs/berna-r8/code/k_vector/k5_percell.py
-
curl -L -o k5_percell.py https://huggingface.co/BernaLabs/berna-r8/resolve/main/code/k_vector/k5_percell.py
1.02 kB
| """ | |
| K5 — Freshness per-cell (R8 fix v3). | |
| """ | |
| import math | |
| import numpy as np | |
| DECAY_LAMBDA = 0.001 | |
| ABS_THRESHOLD = 0.5 # below this magnitude = not "significant" | |
| def compute_k5_percell(cells, current_step): | |
| out = {} | |
| for c in cells: | |
| last = getattr(c, "last_significant_step", None) | |
| if last is None: | |
| last = 0 | |
| age = min(500, max(0, current_step - last)) | |
| out[c.cell_id] = math.exp(-DECAY_LAMBDA * age) | |
| return out | |
| def update_significance(cell, activations, current_step, | |
| abs_threshold=ABS_THRESHOLD): | |
| """ | |
| Cell is 'significant' if its mean |activation| > abs_threshold. | |
| Simple, interpretable, produces real variance across cells. | |
| """ | |
| a = np.abs(activations) | |
| if a.size == 0: | |
| return False | |
| m = float(a.mean()) | |
| cell._last_mag = m # for debugging | |
| if m > abs_threshold: | |
| cell.last_significant_step = current_step | |
| return True | |
| return False |