Fix extra EOS tokens (#91)
* Fix extra EOS tokens * Fix pre-commit error
This commit is contained in:
committed by
GitHub
parent
0c08f3a7e4
commit
2a2931ba8d
@@ -1,6 +1,6 @@
|
||||
repos:
|
||||
- repo: https://github.com/slessans/pre-commit-swift-format
|
||||
rev: ""
|
||||
rev: "fd627de92bdf84a75c924ed95691336d14e94cf1"
|
||||
hooks:
|
||||
- id: swift-format
|
||||
args: ["--configuration", ".swift-format"]
|
||||
|
||||
@@ -183,19 +183,10 @@ public func generate(
|
||||
var start = Date.timeIntervalSinceReferenceDate
|
||||
var promptTime: TimeInterval = 0
|
||||
|
||||
// build a set of additional stop tokens
|
||||
let additionalEOSTokenIds = Set(
|
||||
(extraEOSTokens ?? [])
|
||||
.map {
|
||||
tokenizer.encode(text: $0)
|
||||
}
|
||||
.filter {
|
||||
// discard anything that is not a single token. sometimes
|
||||
// the tokenizer will insert a <s> token, so accept that too
|
||||
$0.count == 1 || ($0.count == 2 && $0[0] == 1)
|
||||
}
|
||||
.map {
|
||||
$0.last!
|
||||
.compactMap {
|
||||
tokenizer.convertTokenToId($0)
|
||||
})
|
||||
|
||||
var tokens = [Int]()
|
||||
|
||||
Reference in New Issue
Block a user