{"id":17919386,"url":"https://github.com/eliben/go-sentencepiece","last_synced_at":"2025-08-11T19:30:50.919Z","repository":{"id":252243331,"uuid":"838550648","full_name":"eliben/go-sentencepiece","owner":"eliben","description":"Go implementation of the SentencePiece tokenizer","archived":false,"fork":false,"pushed_at":"2024-09-05T13:15:58.000Z","size":205,"stargazers_count":22,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-03T10:23:19.519Z","etag":null,"topics":["encoding","go","golang","language-model","llm","sentencepiece","tokenization"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eliben.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-08-05T21:59:49.000Z","updated_at":"2024-11-26T22:18:52.000Z","dependencies_parsed_at":"2024-08-26T15:56:09.724Z","dependency_job_id":null,"html_url":"https://github.com/eliben/go-sentencepiece","commit_stats":null,"previous_names":["eliben/go-sentencepiece"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliben%2Fgo-sentencepiece","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliben%2Fgo-sentencepiece/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliben%2Fgo-sentencepiece/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliben%2Fgo-sentencepiece/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eliben","download_url":"https://codeload.github.com/eliben/go-sentencepiece/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229585165,"owners_count":18096336,"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","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":["encoding","go","golang","language-model","llm","sentencepiece","tokenization"],"created_at":"2024-10-28T20:16:26.211Z","updated_at":"2024-12-13T18:29:01.180Z","avatar_url":"https://github.com/eliben.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-sentencepiece\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"Logo\" src=\"doc/toklogo2.png\" /\u003e\n\u003c/p\u003e\n\n----\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/eliben/go-sentencepiece.svg)](https://pkg.go.dev/github.com/eliben/go-sentencepiece)\n\nThis is a pure Go implementation of encoding and decoding text with\nthe [SentencePiece tokenizer](https://github.com/google/sentencepiece).\n\n\"Encoding\" is the operation used to split text into tokens, using\na trained tokenizer model. \"Decoding\" is the reverse process - converting\na list of tokens into the original text.\n\nSentencePiece is a general family of tokenizers that is configured\nby a protobuf configuration file. This repository currently focuses\non implementing just the functionality required to reproduce the\ntokenization of [Gemma models](https://ai.google.dev/gemma) (the same\ntokenizer is used for Google's proprietary Gemini family of models).\nSpecifically, it only implements BPE tokenization since this is what\nGemma uses.\n\n## Current status\n\nThis package should be ready to use for encoding text into tokens\nusing the Gemma tokenizer; it's been reasonably optimized and extensively\ntested vs. the [SentencePiece Python bindings](https://pypi.org/project/sentencepiece/)\n(see `system_test.go` in this repository).\n\nIf you find any problems or discrepancies, please open an issue.\n\n## Tokenizer configuration\n\nThe configuration file for the tokenizer is a protobuf (structured\ndata, serialized in the [protocol buffer format](https://protobuf.dev/))\nthat describes a trained tokenizer model; it includes\nthe complete learned vocabulary used for tokenization, as well as\nother configuration information.\n\nIt is not part of this repository. Please fetch it from the\n[official Gemma implementation repository](https://github.com/google/gemma_pytorch/tree/main/tokenizer).\n`NewProcessor*` constructors will expect to read this file.\n\n## Developing\n\nA protobuf is used to configure the tokenizer. The structure of the\nprotobuf is described by the `internal/model/sentencepiece_model.proto` file,\nwhich is vendored from https://github.com/google/sentencepiece\n\nTo re-generate the `*.pb.go` file from it:\n\n```\n$ cd internal/model\n$ ./gen.sh\n```\n\nThe configuration protobuf itself is obtained as described in the\n[Tokenizer configuration](#tokenizer-configuration) section. All\ntests require the `MODELPATH` env var to point to a local\ncopy of the tokenizer configuration file.\n\n## Online demo\n\nTo see an in-browser demo of this tokenizer in action, visit\nhttps://eliben.github.io/go-sentencepiece/\n\nThe Go code is compiled to WebAssembly and loaded from a small\nJS program to allow interactive encoding of text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feliben%2Fgo-sentencepiece","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feliben%2Fgo-sentencepiece","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feliben%2Fgo-sentencepiece/lists"}