Text Generation
Transformers
Safetensors
English
gift_of_gab
gift-of-gab
small-language-model
trained-from-scratch
mixture-of-experts
browser
conversational
custom_code
Instructions to use gszauer/Gab1B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use gszauer/Gab1B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="gszauer/Gab1B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("gszauer/Gab1B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use gszauer/Gab1B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "gszauer/Gab1B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "gszauer/Gab1B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/gszauer/Gab1B
- SGLang
How to use gszauer/Gab1B 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 "gszauer/Gab1B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "gszauer/Gab1B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "gszauer/Gab1B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "gszauer/Gab1B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use gszauer/Gab1B with Docker Model Runner:
docker model run hf.co/gszauer/Gab1B
File size: 2,530 Bytes
c3e462e | 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 | #!/usr/bin/env python3
"""Convert native Gab weights (a headerless flat float32 buffer in MiniGPT.js
parameters() order) to model.safetensors with Transformers-style names.
MiniGPT.js stores matrices as [in, out] row-major; nn.Linear wants [out, in].
The per-head Wq/Wk/Wv/Wo are fused into one [768, 768] matrix each: Q/K/V by
stacking the heads' outputs, O by stacking the heads' inputs (summing per-head
output projections equals one projection of the concatenated heads).
Usage: convert.py gab1b.weights [config.json] [model.safetensors]
"""
import json
import sys
import numpy as np
from safetensors.numpy import save_file
def convert(weights_path, config_path="config.json", out_path="model.safetensors"):
c = json.load(open(config_path))
d, nh, hd = c["hidden_size"], c["num_attention_heads"], c["head_dim"]
ne, h, v = c["num_experts"], c["intermediate_size"], c["vocab_size"]
flat = np.fromfile(weights_path, dtype="<f4")
pos = 0
def take(rows, cols):
nonlocal pos
m = flat[pos:pos + rows * cols].reshape(rows, cols)
pos += rows * cols
return m
t = {"model.embed_tokens.weight": take(v, d)}
for b in range(c["num_hidden_layers"]):
p = f"model.layers.{b}."
t[p + "input_layernorm.weight"] = take(1, d)[0]
q, k, val, o = [], [], [], []
for _ in range(nh):
q.append(take(d, hd)); k.append(take(d, hd)); val.append(take(d, hd)); o.append(take(hd, d))
t[p + "self_attn.q_proj.weight"] = np.concatenate(q, axis=1).T
t[p + "self_attn.k_proj.weight"] = np.concatenate(k, axis=1).T
t[p + "self_attn.v_proj.weight"] = np.concatenate(val, axis=1).T
t[p + "self_attn.o_proj.weight"] = np.concatenate(o, axis=0).T
t[p + "post_attention_layernorm.weight"] = take(1, d)[0]
t[p + "mlp.router.weight"] = take(d, ne).T
for e in range(ne):
q_ = f"{p}mlp.experts.{e}."
t[q_ + "up_proj.weight"] = take(d, h).T
t[q_ + "down_proj.weight"] = take(h, d).T
t[q_ + "up_proj.bias"] = take(1, h)[0]
t["model.norm.weight"] = take(1, d)[0]
if pos != flat.size:
sys.exit(f"Error: read {pos:,} floats but the file has {flat.size:,}; config doesn't match.")
save_file({n: np.ascontiguousarray(a, dtype=np.float32) for n, a in t.items()}, out_path,
metadata={"format": "pt"})
print(f"{flat.size:,} parameters -> {out_path} ({len(t)} tensors)")
if __name__ == "__main__":
convert(*sys.argv[1:])
|