{"id":22062131,"url":"https://github.com/jkrukowski/swift-sentencepiece","last_synced_at":"2025-10-11T14:31:54.819Z","repository":{"id":265506168,"uuid":"895592001","full_name":"jkrukowski/swift-sentencepiece","owner":"jkrukowski","description":"Use SentencePiece in Swift for tokenization and detokenization.","archived":false,"fork":false,"pushed_at":"2025-06-26T16:59:43.000Z","size":2547,"stargazers_count":15,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-01T08:51:39.538Z","etag":null,"topics":["sentencepiece","tokenization"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jkrukowski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-28T13:51:07.000Z","updated_at":"2025-08-12T20:18:55.000Z","dependencies_parsed_at":"2025-01-28T23:28:46.869Z","dependency_job_id":"54d6942f-4393-445a-a817-3a44a07edee8","html_url":"https://github.com/jkrukowski/swift-sentencepiece","commit_stats":null,"previous_names":["jkrukowski/swift-sentencepiece"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/jkrukowski/swift-sentencepiece","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkrukowski%2Fswift-sentencepiece","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkrukowski%2Fswift-sentencepiece/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkrukowski%2Fswift-sentencepiece/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkrukowski%2Fswift-sentencepiece/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jkrukowski","download_url":"https://codeload.github.com/jkrukowski/swift-sentencepiece/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkrukowski%2Fswift-sentencepiece/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279007457,"owners_count":26084313,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["sentencepiece","tokenization"],"created_at":"2024-11-30T18:17:20.240Z","updated_at":"2025-10-11T14:31:54.814Z","avatar_url":"https://github.com/jkrukowski.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `swift-sentencepiece`\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fjkrukowski%2Fswift-sentencepiece%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/jkrukowski/swift-sentencepiece)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fjkrukowski%2Fswift-sentencepiece%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/jkrukowski/swift-sentencepiece)\n\nUse [SentencePiece](https://github.com/google/sentencepiece) in Swift for tokenization and detokenization. It wraps `v0.2.0` of the original library.\n\n## Installation\n\nAdd the following to your `Package.swift` file. In the package dependencies add:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/jkrukowski/swift-sentencepiece\", from: \"0.0.3\")\n]\n```\n\nIn the target dependencies add:\n\n```swift\ndependencies: [\n    .product(name: \"SentencepieceTokenizer\", package: \"swift-sentencepiece\")\n]\n```\n\n## Usage\n\n### Encoding\n\n```swift\nimport SentencepieceTokenizer\n\n// load tokenizer from file\nlet tokenizer = try SentencepieceTokenizer(modelPath: \"/path/to/sentencepiece.model\")\n\n// encode text\nlet encoded = tokenizer.encode(\"Hello, world!\")\nprint(encoded)\n\n// decode tokens\nlet decoded = tokenizer.decode([35378, 4, 8999, 38])\nprint(decoded)\n```\n\n## Command Line Demo\n\nTo run the command line demo, use the following command:\n\n```bash\nswift run sentencepiece-cli --model-path \u003cmodel-path\u003e [--text \u003ctext\u003e]\n```\n\nCommand line options:\n\n```bash\n--model-path \u003cmodel-path\u003e\n--text \u003ctext\u003e           (default: Hello, world!)\n-h, --help              Show help information.\n```\n\n## Code Formatting\n\nThis project uses [swift-format](https://github.com/swiftlang/swift-format). To format the code run:\n\n```bash\nswift format . -i -r --configuration .swift-format\n```\n\n## Acknowledgements\n\nThis project wraps the original implementation [SentencePiece](https://github.com/google/sentencepiece)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjkrukowski%2Fswift-sentencepiece","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjkrukowski%2Fswift-sentencepiece","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjkrukowski%2Fswift-sentencepiece/lists"}