Skip to content

Commit

Permalink
Change JS to initialize on load.
Browse files Browse the repository at this point in the history
  • Loading branch information
wbrown committed Jul 18, 2023
1 parent 9887939 commit 7d3ad02
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion js/js.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"log"
)

var encoder = gpt_bpe.GPT2Encoder
var encoder gpt_bpe.GPTEncoder

func Tokenize(text string) gpt_bpe.Tokens {
return *encoder.Encode(&text)
Expand All @@ -20,6 +20,7 @@ func Decode(arr []byte) string {
}

func init() {
encoder = gpt_bpe.NewGPT2Encoder()
js.Module.Get("exports").Set("decode", Decode)
js.Module.Get("exports").Set("tokenize", Tokenize)
log.Printf("GPT-2 BPE Decoder Loaded")
Expand Down

0 comments on commit 7d3ad02

Please sign in to comment.