{"id":16364685,"url":"https://github.com/anush008/fastembed-go","last_synced_at":"2025-03-16T15:32:45.709Z","repository":{"id":198774830,"uuid":"701478363","full_name":"Anush008/fastembed-go","owner":"Anush008","description":"Go implementation of @qdrant/fastembed.","archived":false,"fork":false,"pushed_at":"2024-05-24T17:16:09.000Z","size":3377,"stargazers_count":45,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-12T02:31:32.862Z","etag":null,"topics":["embeddings","rag","retrieval","retrieval-augmented-generation","vector-search"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/anush008/fastembed-go","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/Anush008.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}},"created_at":"2023-10-06T18:11:19.000Z","updated_at":"2024-10-02T01:54:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"95d6e6b6-6d64-4e6b-a1e6-3468650df3af","html_url":"https://github.com/Anush008/fastembed-go","commit_stats":null,"previous_names":["anush008/fastembed-go"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anush008%2Ffastembed-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anush008%2Ffastembed-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anush008%2Ffastembed-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anush008%2Ffastembed-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Anush008","download_url":"https://codeload.github.com/Anush008/fastembed-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221665555,"owners_count":16860277,"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":["embeddings","rag","retrieval","retrieval-augmented-generation","vector-search"],"created_at":"2024-10-11T02:31:30.787Z","updated_at":"2024-10-27T10:51:19.194Z","avatar_url":"https://github.com/Anush008.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n \u003ch1 style=\"display: inline-block; vertical-align: middle;\"\u003e\n    \u003ca href=\"https://crates.io/crates/fastembed\"\u003eFastEmbed-go\u003c/a\u003e\n    \u003cimg src=\"https://github.com/Anush008/fastembed-rs/assets/46051506/4bd3cefe-12da-48b9-8cc2-7489145c9cb5\" style=\"display: inline-block; vertical-align: middle; width: auto; height: 100px;\"\u003e\n \u003c/h1\u003e\n \u003ch3\u003eGo implementation of \u003ca href=\"https://github.com/qdrant/fastembed\" target=\"_blank\"\u003e@Qdrant/fastembed\u003c/a\u003e\u003c/h3\u003e\n  \u003ca href=\"https://pkg.go.dev/github.com/anush008/fastembed-go\"\u003e\u003cimg src=\"https://pkg.go.dev/badge/github.com/anush008/fastembed-go.svg\" alt=\"Go Reference\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/Anush008/fastembed-go/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-mit-blue.svg\" alt=\"MIT Licensed\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/Anush008/fastembed-go/actions/workflows/release.yml\"\u003e\u003cimg src=\"https://github.com/Anush008/fastembed-go/actions/workflows/release.yml/badge.svg?branch=main\" alt=\"Semantic release\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n## 🍕 Features\n\n- Supports batch embeddings with parallelism using go-routines.\n- Uses [@sugarme/tokenizer](https://github.com/sugarme/tokenizer) for fast tokenization.\n- Optimized embedding models.\n\nThe default embedding supports \"query\" and \"passage\" prefixes for the input text. The default model is Flag Embedding, which is top of the [MTEB](https://huggingface.co/spaces/mteb/leaderboard) leaderboard.\n\n## 🔍 Not looking for Go?\n\n- Python 🐍: [fastembed](https://github.com/qdrant/fastembed)\n- Rust 🦀: [fastembed-rs](https://github.com/Anush008/fastembed-rs)\n- JavaScript 🌐: [fastembed-js](https://github.com/Anush008/fastembed-js)\n  \n## 🤖 Models\n\n- [**BAAI/bge-base-en**](https://huggingface.co/BAAI/bge-base-en)\n- [**BAAI/bge-base-en-v1.5**](https://huggingface.co/BAAI/bge-base-en-v1.5)\n- [**BAAI/bge-small-en**](https://huggingface.co/BAAI/bge-small-en)\n- [**BAAI/bge-small-en-v1.5**](https://huggingface.co/BAAI/bge-small-en-v1.5) - Default\n- [**BAAI/bge-base-zh-v1.5**](https://huggingface.co/BAAI/bge-base-zh-v1.5)\n- [**sentence-transformers/all-MiniLM-L6-v2**](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)\n\n## 🚀 Installation\n\nRun the following Go CLI command in your project directory:\n\n```bash\ngo get -u github.com/anush008/fastembed-go\n```\n\n## ℹ︎ Notice:\n\nThe Onnx runtime path is automatically loaded on most environments. However, if you encounter\n```sh\npanic: Platform-specific initialization failed: Error loading ONNX shared library\n```\nSet the `ONNX_PATH` env to your Onnx installation.\nFor eg, on MacOS:\n```sh\nexport ONNX_PATH=\"/path/to/onnx/lib/libonnxruntime.dylib\"\n```\nOn Linux:\n```sh\nexport ONNX_PATH=\"/path/to/onnx/lib/libonnxruntime.so\"\n```\nYou can find the Onnx runtime releases [here](https://github.com/microsoft/onnxruntime/releases).\n\n## 📖 Usage\n\n```go\nimport \"github.com/anush008/fastembed-go\"\n\n// With default options\nmodel, err := fastembed.NewFlagEmbedding(nil)\nif err != nil {\n panic(err)\n}\ndefer model.Destroy()\n\n// With custom options\noptions := fastembed.InitOptions{\n Model:     fastembed.BGEBaseEN,\n CacheDir:  \"model_cache\",\n MaxLength: 200,\n}\n\nmodel, err = fastembed.NewFlagEmbedding(\u0026options)\nif err != nil {\n panic(err)\n}\ndefer model.Destroy()\n\ndocuments := []string{\n \"passage: Hello, World!\",\n \"query: Hello, World!\",\n \"passage: This is an example passage.\",\n // You can leave out the prefix but it's recommended\n \"fastembed-go is licensed under MIT\",\n}\n\n// Generate embeddings with a batch-size of 25, defaults to 256\nembeddings, err := model.Embed(documents, 25)  //  -\u003e Embeddings length: 4\nif err != nil {\n panic(err)\n}\n```\n\n### Supports passage and query embeddings for more accurate results\n\n```go\n// Generate embeddings for the passages\n// The texts are prefixed with \"passage\" for better results\n// The batch size is set to 1 for demonstration purposes\npassages := []string{\n \"This is the first passage. It contains provides more context for retrieval.\",\n \"Here's the second passage, which is longer than the first one. It includes additional information.\",\n \"And this is the third passage, the longest of all. It contains several sentences and is meant for more extensive testing.\",\n}\n\nembeddings, err := model.PassageEmbed(passages, 1)  //  -\u003e Embeddings length: 3\nif err != nil {\n panic(err)\n}\n\n// Generate embeddings for the query\n// The text is prefixed with \"query\" for better retrieval\nquery := \"What is the answer to this generic question?\";\n\nembeddings, err := model.QueryEmbed(query)\nif err != nil {\n panic(err)\n}\n```\n\n## 🚒 Under the hood\n\n### Why fast?\n\nIt's important we justify the \"fast\" in FastEmbed. FastEmbed is fast because:\n\n1. Quantized model weights\n2. ONNX Runtime which allows for inference on CPU, GPU, and other dedicated runtimes\n\n### Why light?\n\n1. No hidden dependencies via Huggingface Transformers\n\n### Why accurate?\n\n1. Better than OpenAI Ada-002\n2. Top of the Embedding leaderboards e.g. [MTEB](https://huggingface.co/spaces/mteb/leaderboard)\n\n## 📄 LICENSE\n\nMIT © [2023](https://github.com/Anush008/fastembed-go/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanush008%2Ffastembed-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanush008%2Ffastembed-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanush008%2Ffastembed-go/lists"}