I made a GPT-2 inference patch: GitHub - Jonathhhan/ofEmscriptenOnnxGPT-2
Download GPT-2-LM-HEAD from models/text/machine_comprehension/gpt-2/README.md at main · onnx/models · GitHub and put it into the onnx
folder. Replace template.html
and compile the patch with Emscripten. Not practical to include the model into a webpage, because it is 650 MB (quantization should be possible).
The patch uses this addon for text formatting: GitHub - braitsch/ofxParagraph: Paragraph renderer for openFrameworks
And this as the tokenizer: GitHub - niieani/gpt-tokenizer: JavaScript BPE Tokenizer Encoder Decoder for OpenAI's GPT-2 / GPT-3 / GPT-4. Port of OpenAI's tiktoken with additional features.
Here a short example video: