Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.20"
go-version: "1.24"

- name: Build
run: go build -v ./...
Expand Down
5 changes: 4 additions & 1 deletion codec/cl100k_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import "github.com/dlclark/regexp2"

func NewCl100kBase() *Codec {
cl100kBaseVocabOnce.Do(cl100kBaseVocabInit)

splitRegexp := regexp2.MustCompile(`(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\r\n\p{L}\p{N}]?\p{L}+|\p{N}{1,3}| ?[^\s\p{L}\p{N}]+[\r\n]*|\s*[\r\n]+|\s+(?!\S)|\s+`, regexp2.None)

return &Codec{
name: "cl100k_base",
vocabulary: cl100kBaseVocab,
splitRegexp: regexp2.MustCompile(`(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\r\n\p{L}\p{N}]?\p{L}+|\p{N}{1,3}| ?[^\s\p{L}\p{N}]+[\r\n]*|\s*[\r\n]+|\s+(?!\S)|\s+`, regexp2.None),
splitRegexp: splitRegexp,
specialTokens: map[string]uint{
"<|endoftext|>": 100257,
"<|fim_prefix|>": 100258,
Expand Down
18 changes: 8 additions & 10 deletions codec/o200k_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ import "github.com/dlclark/regexp2"

func NewO200kBase() *Codec {
o200kBaseVocabOnce.Do(o200kBaseVocabInit)

splitRegexp := regexp2.MustCompile(
`[^\r\n\p{L}\p{N}]?[\p{Lu}\p{Lt}\p{Lm}\p{Lo}\p{M}]*[\p{Ll}\p{Lm}\p{Lo}\p{M}]+(?i:'s|'t|'re|'ve|'m|'ll|'d)?|[^\r\n\p{L}\p{N}]?[\p{Lu}\p{Lt}\p{Lm}\p{Lo}\p{M}]+[\p{Ll}\p{Lm}\p{Lo}\p{M}]*(?i:'s|'t|'re|'ve|'m|'ll|'d)?|\p{N}{1,3}| ?[^\s\p{L}\p{N}]+[\r\n/]*|\s*[\r\n]+|\s+(?!\S)|\s+`,
regexp2.None)

return &Codec{
name: "o200k_base",
vocabulary: o200kBaseVocab,
splitRegexp: regexp2.MustCompile(
`[^\r\n\p{L}\p{N}]?[\p{Lu}\p{Lt}\p{Lm}\p{Lo}\p{M}]*[\p{Ll}\p{Lm}\p{Lo}\p{M}]+(?i:'s|'t|'re|'ve|'m|'ll|'d)?|`+
`[^\r\n\p{L}\p{N}]?[\p{Lu}\p{Lt}\p{Lm}\p{Lo}\p{M}]+[\p{Ll}\p{Lm}\p{Lo}\p{M}]*(?i:'s|'t|'re|'ve|'m|'ll|'d)?|`+
`\p{N}{1,3}|`+` ?[^\s\p{L}\p{N}]+[\r\n/]*|`+
`\s*[\r\n]+|`+
`\s+(?!\S)|`+
`\s+`,
regexp2.None),
name: "o200k_base",
vocabulary: o200kBaseVocab,
splitRegexp: splitRegexp,
specialTokens: map[string]uint{
"<|endoftext|>": 199999,
"<|endofprompt|>": 200018,
Expand Down
5 changes: 4 additions & 1 deletion codec/p50k_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import "github.com/dlclark/regexp2"

func NewP50kBase() *Codec {
p50kBaseVocabOnce.Do(p50kBaseVocabInit)

splitRegexp := regexp2.MustCompile(`'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+`, regexp2.None)

return &Codec{
name: "p50k_base",
vocabulary: p50kBaseVocab,
splitRegexp: regexp2.MustCompile(`'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+`, regexp2.None),
splitRegexp: splitRegexp,
specialTokens: map[string]uint{
"<|endoftext|>": 50256,
},
Expand Down
5 changes: 4 additions & 1 deletion codec/p50k_edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import "github.com/dlclark/regexp2"

func NewP50kEdit() *Codec {
p50kBaseVocabOnce.Do(p50kBaseVocabInit)

splitRegexp := regexp2.MustCompile(`'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+`, regexp2.None)

return &Codec{
name: "p50k_edit",
vocabulary: p50kBaseVocab,
splitRegexp: regexp2.MustCompile(`'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+`, regexp2.None),
splitRegexp: splitRegexp,
specialTokens: map[string]uint{
"<|endoftext|>": 50256,
"<|fim_prefix|>": 50281,
Expand Down
5 changes: 4 additions & 1 deletion codec/r50k_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import "github.com/dlclark/regexp2"

func NewR50kBase() *Codec {
r50kBaseVocabOnce.Do(r50kBaseVocabInit)

splitRegexp := regexp2.MustCompile(`'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+`, regexp2.None)

return &Codec{
name: "r50k_base",
vocabulary: r50kBaseVocab,
splitRegexp: regexp2.MustCompile(`'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+`, regexp2.None),
splitRegexp: splitRegexp,
specialTokens: map[string]uint{
"<|endoftext|>": 50256,
},
Expand Down
Loading