Text Generation
Transformers
Safetensors
English
gabgpt
gift-of-gab
small-language-model
trained-from-scratch
byte-level
game-boy-advance
browser
conversational
custom_code
Instructions to use gszauer/ChatGBA with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use gszauer/ChatGBA with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="gszauer/ChatGBA", 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/ChatGBA", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use gszauer/ChatGBA with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "gszauer/ChatGBA" # 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/ChatGBA", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/gszauer/ChatGBA
- SGLang
How to use gszauer/ChatGBA 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/ChatGBA" \ --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/ChatGBA", "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/ChatGBA" \ --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/ChatGBA", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use gszauer/ChatGBA with Docker Model Runner:
docker model run hf.co/gszauer/ChatGBA
Download source/chat.c from gszauer/ChatGBA: direct link, hf CLI and curl.
- Browser
- Download file 3.18 kB
-
https://huggingface.co/gszauer/ChatGBA/resolve/main/source/chat.c
- Command line
-
hf download hf://gszauer/ChatGBA/source/chat.c
-
curl -L -o chat.c https://huggingface.co/gszauer/ChatGBA/resolve/main/source/chat.c
3.18 kB
| // See chat.h. | |
| // The chat markers the weights were fine-tuned with (export.py writes them | |
| // into model_config.h): <|u|>, <|a|>, <|e|> for the production ChatGBA, | |
| // <|user|>, <|assistant|>, <|end|> for the Mac runs. Below, <|end|> stands for | |
| // whichever end marker it is. | |
| static const char USER[] = CHAT_USER; | |
| static const char ASSISTANT[] = CHAT_ASSISTANT; | |
| static const char END[] = CHAT_END; | |
| static int end_seen = END_LENGTH; // bytes of the last reply's closing <|end|> the engine has processed | |
| static int32_t logits[MODEL_VOCAB]; | |
| void chat_reset(void) { | |
| end_seen = END_LENGTH; // nothing to close | |
| engine_reset(); | |
| } | |
| // The longest k such that the reply ends with the first k bytes of <|end|>. | |
| static int partial_end(const uint8_t* reply, int length) { | |
| for (int k = END_LENGTH - 1; k > 0; --k) { | |
| if (k <= length && memcmp(reply + length - k, END, k) == 0) return k; | |
| } | |
| return 0; | |
| } | |
| int chat_reply(const uint8_t* message, int length, ChatSettings* settings, uint8_t* reply, int capacity) { | |
| // The rest of the last reply's <|end|>, then the new turn. | |
| int total = (END_LENGTH - end_seen) + USER_LENGTH + length + END_LENGTH + ASSISTANT_LENGTH; | |
| int done = 0; | |
| FEED(END + end_seen, END_LENGTH - end_seen); | |
| FEED(USER, USER_LENGTH); | |
| FEED(message, length); | |
| FEED(END, END_LENGTH); | |
| FEED(ASSISTANT, ASSISTANT_LENGTH); | |
| int budget = settings->max_reply < capacity ? settings->max_reply : capacity; | |
| int n = 0, shown = 0, ended = 0; | |
| while (n < budget) { | |
| if (n > 0 && settings->stop && settings->stop()) break; | |
| int byte = engine_sample(logits, settings->temperature, settings->top_k, &settings->rng); | |
| reply[n++] = (uint8_t)byte; | |
| if (n >= END_LENGTH && memcmp(reply + n - END_LENGTH, END, END_LENGTH) == 0) { | |
| n -= END_LENGTH; | |
| ended = 1; | |
| break; // its last byte waits for the next message | |
| } | |
| int hold = partial_end(reply, n); | |
| while (shown < n - hold) { | |
| if (settings->on_byte) settings->on_byte(reply[shown]); | |
| ++shown; | |
| } | |
| engine_step(byte, logits); | |
| } | |
| // The engine has seen every reply byte, and the part of <|end|> sampled so | |
| // far, except the very last byte of a complete one. A reply cut off in the | |
| // start of <|end|> keeps that start as the start of its closing <|end|>. | |
| if (ended) { | |
| end_seen = END_LENGTH - 1; | |
| } else { | |
| end_seen = partial_end(reply, n); | |
| n -= end_seen; | |
| } | |
| while (shown < n) { | |
| if (settings->on_byte) settings->on_byte(reply[shown]); | |
| ++shown; | |
| } | |
| return n; | |
| } | |