{"id":24957380,"url":"https://github.com/seasonjs/rwkv","last_synced_at":"2025-04-10T19:13:08.571Z","repository":{"id":192619748,"uuid":"687034132","full_name":"seasonjs/rwkv","owner":"seasonjs","description":"pure go for rwkv","archived":false,"fork":false,"pushed_at":"2023-12-31T05:15:03.000Z","size":8943,"stargazers_count":19,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T16:55:20.597Z","etag":null,"topics":["deep-learning","ggml","go","golang","language-model","llm","rwkv"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/seasonjs/rwkv","language":"Go","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/seasonjs.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":"2023-09-04T13:12:24.000Z","updated_at":"2025-01-23T22:38:21.000Z","dependencies_parsed_at":"2023-11-26T06:19:45.065Z","dependency_job_id":"220983ad-fa7b-455c-a8fb-f80e25eff3d2","html_url":"https://github.com/seasonjs/rwkv","commit_stats":null,"previous_names":["seasonjs/rwkv"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seasonjs%2Frwkv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seasonjs%2Frwkv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seasonjs%2Frwkv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seasonjs%2Frwkv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seasonjs","download_url":"https://codeload.github.com/seasonjs/rwkv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248280150,"owners_count":21077410,"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":["deep-learning","ggml","go","golang","language-model","llm","rwkv"],"created_at":"2025-02-03T07:00:25.219Z","updated_at":"2025-04-10T19:13:08.551Z","avatar_url":"https://github.com/seasonjs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rwkv\n\npure go for rwkv and support cross-platform.\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/seasonjs/rwkv.svg)](https://pkg.go.dev/github.com/seasonjs/rwkv)\n\nrwkv.go is a wrapper around [rwkv.cpp](https://github.com/saharNooby/rwkv.cpp), which is an adaption of ggml.cpp.\n\n## Installation\n\n```bash\ngo get github.com/seasonjs/rwkv\n```\n\n## AutoModel Compatibility\n\nSee `deps` folder for dylib compatibility,or you can [build the library by yourself](https://github.com/saharNooby/rwkv.cpp#option-22-build-the-library-yourself), and push request is welcome.\n\n`NewRwkvAutoModel` both gpu support `AMD` and `NVIDIA` on Windows.\n\n`NewRwkvModel` need you to load the dynamic library manually, and the dynamic library is platform dependent.\n\nWindows AMD GPU User may need check [rocm architecture](https://rocm.docs.amd.com/en/latest/release/windows_support.html#windows-supported-gpus) to get more information.\n\nWindows NVIDIA GPU User may need check [cuda architecture](https://developer.nvidia.com/cuda-gpus) to get more information.\n\n| platform | x32         | x64                     | arm         | AMD/ROCM        | NVIDIA/CUDA    |\n|----------|-------------|-------------------------|-------------|-----------------|----------------|\n| windows  | not support | support avx/avx2/avx512 | not support | rocm5.5 support | cuda12 support |\n| linux    | not support | support                 | not support | not support     | not support    |\n| darwin   | not support | support                 | support     | not support     | not support    |\n\n## AutoModel Dynamic Libraries Disclaimer\n\n#### The Source Of Dynamic Libraries\nThese dynamic libraries come from [rwkv.cpp release](https://github.com/saharNooby/rwkv.cpp/releases), The dynamic library version can be obtained by viewing [rwkv.version file](./deps/rwkv.version)\nAnyone can check the consistency of the file by checksum the md5 of the file. \n\n#### The Security Of Dynamic Libraries\nAll I can say is that the creation of the dynamic library is public and does not contain any subjective malicious logic.\nIf you are worried about the security of the dynamic library during the use process, you can build it yourself.\n\n**I and any author related to dynamic libraries do not assume any problems, responsibilities or legal liability during use.**\n\n## Usage\n\nYou can find a complete example in [examples](./examples) folder.\n\nHere is a simple example:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/seasonjs/rwkv\"\n)\n\nfunc main() {\n\tmodel, err := rwkv.NewRwkvAutoModel(rwkv.RwkvOptions{\n\t\tMaxTokens:     500,\n\t\tStopString:    \"\\n\\n\",\n\t\tTemperature:   0.8,\n\t\tTopP:          0.5,\n\t\tTokenizerType: rwkv.World, //or World\n\t\tPrintError:    true,\n\t\tCpuThreads:    10,\n\t\tGpuEnable:     false,\n\t})\n\n\tif err != nil {\n\t\tfmt.Print(err.Error())\n\t\treturn\n\t}\n\n\tdefer model.Close()\n\n\terr = model.LoadFromFile(\"./models/RWKV-5-World-0.4B-v2-20231113-ctx4096-F16.bin\")\n\tif err != nil {\n\t\tfmt.Print(err.Error())\n\t\treturn\n\t}\n\tprompt := `The following is a coherent verbose detailed conversation between a Chinese girl named Alice and her friend Bob.\nAlice is very intelligent, creative and friendly.\nAlice likes to tell Bob a lot about herself and her opinions.\nAlice usually gives Bob kind, helpful and informative advices.\n\nBob: lhc\nAlice: LHC是指大型强子对撞机（Large Hadron Collider），是世界最大最强的粒子加速器，由欧洲核子中心（CERN）在瑞士日内瓦地下建造。\nLHC的原理是加速质子（氢离子）并让它们相撞，让科学家研究基本粒子和它们之间的相互作用，并在2012年证实了希格斯玻色子的存在。\n\nBob: 企鹅会飞吗\nAlice: 企鹅是不会飞的。企鹅的翅膀短而扁平，更像是游泳时的一对桨。企鹅的身体结构和羽毛密度也更适合在水中游泳，而不是飞行。\n\n`\n\tuser := `Bob: 请介绍北京的旅游景点？\nAlice: `\n\n\tctx, err := model.InitState(prompt)\n\n\tif err != nil {\n\t\tprint(err.Error())\n\t\treturn\n\t}\n\n\tout, err := ctx.Predict(user)\n\n\tif err != nil {\n\t\tprint(err.Error())\n\t\treturn\n\t}\n\n\tprint(out)\n}\n```\n\n## Packaging\n\nTo ship a working program that includes this AI, you will need to include the following files:\n\n* librwkv.dylib / librwkv.so / rwkv.dll (buildin)\n* the model file\n* the tokenizer file (buildin)\n\n## Low level API\n\nThis package also provide low level Api which is same as [rwkv-cpp](https://github.com/saharNooby/rwkv.cpp).\nSee detail at [rwkv-doc](https://pkg.go.dev/github.com/seasonjs/rwkv).\n\n## Thanks\n\n* [rwkv-cpp](https://github.com/saharNooby/rwkv.cpp)\n* [ggml.cpp](https://github.com/saharNooby/ggml.cpp)\n* [purego](https://github.com/ebitengine/purego)\n* [go-rwkv.cpp](https://github.com/donomii/go-rwkv.cpp)\n* [sugarme/tokenizer](https://github.com/sugarme/tokenizer)\n\n## Sponsor\n\nSpecial thanks to [JetBrains support](https://jb.gg/OpenSourceSupport) for sponsoring.\n\n![JetBrains Logo (Main) logo](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)\n\n## License\n\nCopyright (c) seasonjs. All rights reserved.\nLicensed under the MIT License. See License.txt in the project root for license information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseasonjs%2Frwkv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseasonjs%2Frwkv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseasonjs%2Frwkv/lists"}