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
File size: 3,181 Bytes
546acd4 | 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | // See chat.h.
#include "chat.h"
#include <string.h>
#include "engine.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;
#define USER_LENGTH ((int)sizeof(USER) - 1)
#define ASSISTANT_LENGTH ((int)sizeof(ASSISTANT) - 1)
#define END_LENGTH ((int)sizeof(END) - 1)
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;
#define FEED(bytes, n) \
for (int i_ = 0; i_ < (n); ++i_) { \
engine_step(((const uint8_t*)(bytes))[i_], logits); \
if (settings->on_prompt) settings->on_prompt(++done, total); \
}
FEED(END + end_seen, END_LENGTH - end_seen);
FEED(USER, USER_LENGTH);
FEED(message, length);
FEED(END, END_LENGTH);
FEED(ASSISTANT, ASSISTANT_LENGTH);
#undef FEED
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;
}
|