{"id":22270094,"url":"https://github.com/kelindar/bert","last_synced_at":"2025-09-06T10:37:08.200Z","repository":{"id":264950421,"uuid":"864813342","full_name":"kelindar/bert","owner":"kelindar","description":"Go wrapper for bert.cpp embeddings library using cgo/dll approach.","archived":false,"fork":false,"pushed_at":"2024-09-30T20:41:06.000Z","size":21,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-28T15:56:55.230Z","etag":null,"topics":["bert","bert-embeddings","embeddings","nlp"],"latest_commit_sha":null,"homepage":"","language":"Go","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/kelindar.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-09-29T08:27:33.000Z","updated_at":"2025-07-06T13:42:21.000Z","dependencies_parsed_at":"2024-11-27T00:15:47.661Z","dependency_job_id":null,"html_url":"https://github.com/kelindar/bert","commit_stats":null,"previous_names":["kelindar/bert"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kelindar/bert","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelindar%2Fbert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelindar%2Fbert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelindar%2Fbert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelindar%2Fbert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kelindar","download_url":"https://codeload.github.com/kelindar/bert/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelindar%2Fbert/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273892835,"owners_count":25186561,"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-09-06T02:00:13.247Z","response_time":2576,"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":["bert","bert-embeddings","embeddings","nlp"],"created_at":"2024-12-03T12:01:46.984Z","updated_at":"2025-09-06T10:37:08.170Z","avatar_url":"https://github.com/kelindar.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Wrapper for BERT C++ Library\n\nThis repository contains a Go wrapper for the [bert.cpp](https://github.com/skeskinen/bert.cpp) library, or an updated fork. The library is semi-deprecated, since the functionality has been integrated in [llama.cpp](https://github.com/ggerganov/llama.cpp). However, `bert.cpp` is much smaller and easier to use, so it might be useful for some use cases where one does not need the full functionality of LLM and just wants to use BERT embeddings, for example when using to generate an embedding for a query in a web server or local lookups.\n\n```go\nimport (\n    \"fmt\"\n    \"path/filepath\"\n\n    \"github.com/kelindar/bert\"\n)\n\nfunc main() {\n\tfile, _ := filepath.Abs(\"../dist/minilm12-q4.bin\")\n\tmodel, err := bert.New(file)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer model.Close()\n\n\t// Create an embedding vector for a sentence\n\tembeddings, err := model.EmbedText(\"This is a test sentence.\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(\"Embeddings:\", embeddings)\n}\n```\n\n## Precompiled binaries\n\nPrecompiled binaries for Windows and Linux are available in the [dist](dist) directory. If the architecture/platform you are using is not available, you would need to compile the library yourself. I've additionally provided also a couple of models in the same directory. The model in question is [MiniLM](https://arxiv.org/abs/2002.10957) with 6 and 12 layers.\n\n## Compile library\n\nFirst, clone the repository and its submodules with the following commands. The `--recurse-submodules` flag is used to clone the `ggml` submodule, which is a header-only library for matrix operations.\n\n```bash\ngit clone --recurse-submodules https://github.com/iamlemec/bert.cpp\ncd bert.cpp\n```\n\n### Compile on Linux\n\nMake sure you have a C/C++ compiler and CMake installed. For Ubuntu, you can install them with the following commands:\n\n```bash\nsudo apt-get update\nsudo apt-get install build-essential cmake\n```\n\nThen you can compile the library with the following commands:\n\n```bash\ncd bert.cpp\ncmake -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc\nmake all\n```\n\nThis should egnerate `libbert.so` that you can use.\n\n### Compile on Windows\n\nMake sure you have a C/C++ compiler and CMake installed. For Windows, a simple option is to use [Build Tools for Visual Studio](https://visualstudio.microsoft.com/downloads/) (make sure CLI tools are included) and [CMake](https://cmake.org/download/).\n\n```bash\ncmake -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=cl -DCMAKE_C_COMPILER=cl\n```\n\nIf you are using Visual Studio, solution files are generated. You can open the solution file with Visual Studio and build the project from there. The `bin` directory would then contain `bert.dll` and `ggml.dll`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkelindar%2Fbert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkelindar%2Fbert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkelindar%2Fbert/lists"}