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
Download convert.py from gszauer/Gab1B: direct link, hf CLI and curl.
- Browser
- Download file 2.53 kB
-
https://huggingface.co/gszauer/Gab1B/resolve/main/convert.py
- Command line
-
hf download hf://gszauer/Gab1B/convert.py
-
curl -L -o convert.py https://huggingface.co/gszauer/Gab1B/resolve/main/convert.py
2.53 kB
| #!/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:]) | |