Skip to content

Commit

Permalink
Upgrade jinja (#160)
Browse files Browse the repository at this point in the history
* Upgrade jinja

* Deepseek chat template test
  • Loading branch information
pcuenca authored Jan 24, 2025
1 parent 1fab24c commit 8a83416
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.4.0"),
.package(url: "https://github.com/maiqingqiang/Jinja", from: "1.0.6")
.package(url: "https://github.com/johnmai-dev/Jinja", from: "1.1.0")
],
targets: [
.executableTarget(
Expand Down
11 changes: 11 additions & 0 deletions Tests/TokenizersTests/ChatTemplateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ class ChatTemplateTests: XCTestCase {
XCTAssertEqual(decoded, decodedTarget)
}

func testDeepSeekQwenChatTemplate() async throws {
let tokenizer = try await AutoTokenizer.from(pretrained: "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B")
let encoded = try tokenizer.applyChatTemplate(messages: messages)
let encodedTarget = [151646, 151644, 74785, 279, 23670, 15473, 4128, 13, 151645]
XCTAssertEqual(encoded, encodedTarget)

let decoded = tokenizer.decode(tokens: encoded)
let decodedTarget = "<|begin▁of▁sentence|><|User|>Describe the Swift programming language.<|Assistant|>"
XCTAssertEqual(decoded, decodedTarget)
}

func testDefaultTemplateFromArrayInConfig() async throws {
let tokenizer = try await AutoTokenizer.from(pretrained: "mlx-community/Mistral-7B-Instruct-v0.3-4bit")
let encoded = try tokenizer.applyChatTemplate(messages: messages)
Expand Down

0 comments on commit 8a83416

Please sign in to comment.