Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion Sources/Hub/Hub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,14 @@ public struct Config {
}

/// Tuple of token identifier and string value
public var tokenValue: (UInt, String)? { value as? (UInt, String) }
public var tokenValue: (UInt, String)? {
switch value {
case let (i, t) as (UInt, String): return (i, t)
case let (t, i) as (String, UInt): return (i, t)
Comment on lines +106 to +107
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know if both versions exist in the wild?

case let a as [Any] where a.count == 2: return (a[1], a[0]) as? (UInt, String)
default: return nil
}
}
}

public class LanguageModelConfigurationFromHub {
Expand Down
1 change: 1 addition & 0 deletions Sources/Tokenizers/Tokenizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public protocol PreTrainedTokenizerModel: TokenizingModel {

struct TokenizerModel {
static let knownTokenizers: [String : PreTrainedTokenizerModel.Type] = [
"BartTokenizer" : BertTokenizer.self,
"BertTokenizer" : BertTokenizer.self,
"DistilbertTokenizer": BertTokenizer.self,
"DistilBertTokenizer": BertTokenizer.self,
Expand Down