{"id":16766119,"url":"https://github.com/cryscan/web-rwkv-ffi","last_synced_at":"2025-04-15T20:14:06.865Z","repository":{"id":253552292,"uuid":"804180247","full_name":"cryscan/web-rwkv-ffi","owner":"cryscan","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-08T03:22:59.000Z","size":69,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T20:14:00.480Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cryscan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-05-22T05:32:36.000Z","updated_at":"2025-02-08T03:23:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"10effca6-0a30-4974-ad22-ef5a73cd198d","html_url":"https://github.com/cryscan/web-rwkv-ffi","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"78d6582cd1f168af8c445b6815a59e3bd3bd1193"},"previous_names":["cryscan/web-rwkv-ffi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryscan%2Fweb-rwkv-ffi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryscan%2Fweb-rwkv-ffi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryscan%2Fweb-rwkv-ffi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryscan%2Fweb-rwkv-ffi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cryscan","download_url":"https://codeload.github.com/cryscan/web-rwkv-ffi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249145419,"owners_count":21219966,"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":[],"created_at":"2024-10-13T06:05:27.340Z","updated_at":"2025-04-15T20:14:06.837Z","avatar_url":"https://github.com/cryscan.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Web-RWKV-FFI\n\nSimple FFI for [`web-rwkv`](https://github.com/cryscan/web-rwkv).\n\n## APIs\n\nThe FFI exports the following APIs:\n\n```rust\npub struct Sampler {\n    pub temp: f32,\n    pub top_p: f32,\n    pub top_k: usize,\n}\n\npub struct ModelOutput {\n    pub len: usize,\n    pub data: *mut f32,\n}\n\npub struct ModelInfoOutput {\n    pub version: usize,\n    pub num_layer: usize,\n    pub num_hidden: usize,\n    pub num_emb: usize,\n    pub num_vocab: usize,\n    pub num_head: usize,\n}\n\n/// Initialize logger and RNG. Call this once before everything.\npub fn init(seed: u64);\n/// Set the RNG seed.\npub fn seed(seed: u64);\n/// Load a runtime.\npub fn load(model: *const c_char, quant: usize, quant_nf4: usize);\n/// Clear the model state.\npub fn clear_state();\n/// Generate the next token prediction given the input tokens and a sampler.\npub fn infer(tokens: *const u16, len: usize, sampler: Sampler) -\u003e u16;\n/// Compute the model's raw output (next token prediction only) given the input tokens.\npub fn infer_raw_last(tokens: *const u16, len: usize) -\u003e ModelOutput;\n/// Compute the model's raw output (predictions of all tokens) given the input tokens.\npub fn infer_raw_full(tokens: *const u16, len: usize) -\u003e ModelOutput;\n/// Delete the model output vector created by the infer functions.\npub fn free_raw(output: ModelOutput);\n// Returns the model info.\npub fn get_model_info() -\u003e ModelInfoOutput;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryscan%2Fweb-rwkv-ffi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcryscan%2Fweb-rwkv-ffi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryscan%2Fweb-rwkv-ffi/lists"}