Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump swift-transformers to 0.1.12 #249

Closed
wants to merge 3 commits into from
Closed
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
17 changes: 13 additions & 4 deletions .swiftpm/configuration/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
{
"pins" : [
{
"identity" : "jinja",
"kind" : "remoteSourceControl",
"location" : "https://github.com/maiqingqiang/Jinja",
"state" : {
"revision" : "6dbe4c449469fb586d0f7339f900f0dd4d78b167",
"version" : "1.0.6"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "c8ed701b513cf5177118a175d85fbbbcd707ab41",
"version" : "1.3.0"
"revision" : "0fbc8848e389af3bb55c182bc19ca9d5dc2f255b",
"version" : "1.4.0"
}
},
{
"identity" : "swift-transformers",
"kind" : "remoteSourceControl",
"location" : "https://github.com/huggingface/swift-transformers.git",
"state" : {
"revision" : "74b94211bdc741694ed7e700a1104c72e5ba68fe",
"version" : "0.1.7"
"revision" : "0f2306713d48a75b862026ebb291926793773f52",
"version" : "0.1.12"
}
}
],
17 changes: 13 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
{
"pins" : [
{
"identity" : "jinja",
"kind" : "remoteSourceControl",
"location" : "https://github.com/maiqingqiang/Jinja",
"state" : {
"revision" : "6dbe4c449469fb586d0f7339f900f0dd4d78b167",
"version" : "1.0.6"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "c8ed701b513cf5177118a175d85fbbbcd707ab41",
"version" : "1.3.0"
"revision" : "0fbc8848e389af3bb55c182bc19ca9d5dc2f255b",
"version" : "1.4.0"
}
},
{
"identity" : "swift-transformers",
"kind" : "remoteSourceControl",
"location" : "https://github.com/huggingface/swift-transformers.git",
"state" : {
"revision" : "fc6543263e4caed9bf6107466d625cfae9357f08",
"version" : "0.1.8"
"revision" : "0f2306713d48a75b862026ebb291926793773f52",
"version" : "0.1.12"
}
}
],
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -20,8 +20,8 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/huggingface/swift-transformers.git", exact: "0.1.8"),
.package(url: "https://github.com/apple/swift-argument-parser.git", exact: "1.3.0"),
.package(url: "https://github.com/huggingface/swift-transformers.git", exact: "0.1.12"),
.package(url: "https://github.com/apple/swift-argument-parser.git", exact: "1.4.0"),
],
targets: [
.target(
29 changes: 29 additions & 0 deletions Sources/WhisperKit/Core/Models.swift
Original file line number Diff line number Diff line change
@@ -1313,10 +1313,18 @@ extension WhisperTokenizerWrapper: Tokenizer {
func tokenize(text: String) -> [String] {
tokenizer.tokenize(text: text)
}

func callAsFunction(_ text: String, addSpecialTokens: Bool) -> [Int] {
tokenizer.callAsFunction(text, addSpecialTokens: addSpecialTokens)
}

func encode(text: String) -> [Int] {
tokenizer.encode(text: text)
}

func encode(text: String, addSpecialTokens: Bool) -> [Int] {
tokenizer.encode(text: text, addSpecialTokens: addSpecialTokens)
}

func decode(tokens: [Int]) -> String {
tokenizer.decode(tokens: tokens)
@@ -1353,6 +1361,27 @@ extension WhisperTokenizerWrapper: Tokenizer {
var unknownTokenId: Int? {
tokenizer.unknownTokenId
}

func applyChatTemplate(messages: [[String: String]]) throws -> [Int] {
try tokenizer.applyChatTemplate(messages: messages)
}

func applyChatTemplate(
messages: [[String: String]],
chatTemplate: String?,
addGenerationPrompt: Bool,
truncation: Bool,
maxLength: Int?
) throws -> [Int] {
try tokenizer
.applyChatTemplate(
messages: messages,
chatTemplate: chatTemplate,
addGenerationPrompt: addGenerationPrompt,
truncation: truncation,
maxLength: maxLength
)
}
}

extension WhisperTokenizerWrapper {