{"data":{"slug":"kelindar-search","name":"search","tagline":"Go library for embedded vector search and semantic embeddings with llamacpp","github_url":"https://github.com/kelindar/search","owner":"kelindar","repo":"search","owner_avatar_url":"https://avatars.githubusercontent.com/u/583116?v=4","primary_language":"Go","stars":559,"forks":24,"topics":["ai","bert","embeddings","gguf","gpu","llamacpp","search-engine","semantic-search","simd","vector-search"],"archived":false,"github_pushed_at":"2026-09-19T08:35:34+00:00","maintenance_label":"Very active","stars_delta_30d":4,"url":"https://www.graphcanon.com/tools/kelindar-search","markdown_url":"https://www.graphcanon.com/tools/kelindar-search.md","api_url":"https://www.graphcanon.com/api/graphcanon/tools/kelindar-search","graph_url":"https://www.graphcanon.com/api/graphcanon/graph?tool=kelindar-search","description":"Go library for embedded vector search and semantic embeddings using llama.cpp","homepage_url":null,"license":"MIT","open_issues":5,"watchers":3,"ai_summary":"Provides tools in Go for embedding vector search and creating semantic embeddings using the llama.cpp framework.","readme_excerpt":"<p align=\"center\">\n<img width=\"300\" height=\"100\" src=\".github/logo.png\" border=\"0\" alt=\"kelindar/search\">\n<br>\n<img src=\"https://img.shields.io/github/go-mod/go-version/kelindar/search\" alt=\"Go Version\">\n<a href=\"https://pkg.go.dev/github.com/kelindar/search\"><img src=\"https://pkg.go.dev/badge/github.com/kelindar/search\" alt=\"PkgGoDev\"></a>\n<a href=\"https://goreportcard.com/report/github.com/kelindar/search\"><img src=\"https://goreportcard.com/badge/github.com/kelindar/search\" alt=\"Go Report Card\"></a>\n<a href=\"https://opensource.org/licenses/MIT\"><img src=\"https://img.shields.io/badge/License-MIT-blue.svg\" alt=\"License\"></a>\n<a href=\"https://coveralls.io/github/kelindar/search\"><img src=\"https://coveralls.io/repos/github/kelindar/search/badge.svg\" alt=\"Coverage\"></a>\n</p>\n\n# Vector search and embeddings\n\nAn exact cosine similarity index for small and medium datasets, with optional local and cloud embedding providers. Requires Go 1.27 or newer.\n\n| Package | Purpose |\n|---|---|\n| `github.com/kelindar/search` | Vector indexing, search, and persistence. No native library required. |\n| `github.com/kelindar/search/llama` | Local GGUF embeddings through llama.cpp and purego. |\n| `github.com/kelindar/search/openai` | Text embeddings through OpenAI-compatible APIs, including OpenRouter. |\n\nEach library has its own `go.mod` and `go.sum`. Core `search` has no dependency on either embedding module or `purego`. The `openai` module uses only the standard library at runtime; `llama` owns the native inference dependency. Testify and its YAML dependency are used only by tests. Import paths and APIs are unchanged.\n\nThe interactive `example` has a separate development module with local replacements for `search` and `llama`. Native quality evaluation lives under `llama/internal/eval`, so neither introduces provider dependencies into core search.\n\n## Search with your own vectors\n\n```go\nindex := search.NewIndex[string]()\nindex.Add([]float32{1, 0}, \"cat\")\nindex.Add([]float32{0, 1}, \"dog\")\nresults := index.Search([]float32{1, 0}, 1)\nfmt.Println(results[0].Value) // cat\n```\n\n`Add` normalizes the vector in place and retains its backing array. Do not modify it afterward. `Search` normalizes the query in place. Results contain cosine similarity in descending order, so larger `Relevance` values are better. Use nonzero, finite vectors from the same model with the same dimensions for all documents and queries. Changing models requires re-embedding the dataset, even if dimensions match.\n\nExisting `ReadFile`, `WriteFile`, `ReadFrom`, and `WriteTo` formats remain unchanged. Search scans every vector; large datasets may need a different indexing algorithm. Concurrent searches require separate query slices and no concurrent index writes.\n\n## Local embeddings\n\nImport `github.com/kelindar/search/llama` and install the native library as described below.\n\n```go\nmodel, err := llama.New(\"dist/MiniLM-L6-v2.Q8_0.gguf\", 0)\nif err != nil {\n    return err\n}\ndefer model.Close()\nvector, err := model.EmbedText(ctx, \"Your text here\")\n```\n\nZero GPU layers uses the CPU. The library initializes on the first valid constructor call, never on import; initialization failures are returned as errors and cached for the process lifetime. Configure library paths before constructing a model.\n\nEmbedding calls on a model may run concurrently. Finish all calls and close any explicitly created `model.Context(size)` values before closing the model. Individual contexts must not be shared concurrently. Contexts retain `Tokens()` accounting. Cancellation is checked around native inference and between batch items; it cannot interrupt native inference already in progress.\n\n## Cloud embeddings\n\nImport `github.com/kelindar/search/openai`. Supply credentials and a model explicitly.\n\n```go\nclient, err := openai.New(os.Getenv(\"OPENAI_API_KEY\"), \"text-embedding-3-small\")\nif err != nil {\n    return err\n}\nvector, err := client.EmbedText(ctx, \"Your text here\")\nvectors, err := client.EmbedBatch(ctx, []string{","github_created_at":"2024-09-29T17:05:04+00:00","created_at":"2026-07-11T11:35:08.715191+00:00","updated_at":"2026-09-20T06:23:48.831634+00:00","categories":[{"slug":"data-retrieval","name":"Data & Retrieval","url":"https://www.graphcanon.com/categories/data-retrieval","markdown_url":"https://www.graphcanon.com/categories/data-retrieval.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/data-retrieval"},{"slug":"vector-databases","name":"Vector Databases","url":"https://www.graphcanon.com/categories/vector-databases","markdown_url":"https://www.graphcanon.com/categories/vector-databases.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/vector-databases"}],"tags":[{"slug":"ai","name":"ai"},{"slug":"bert","name":"bert"},{"slug":"embeddings","name":"embeddings"},{"slug":"gguf","name":"gguf"},{"slug":"gpu","name":"gpu"},{"slug":"llamacpp","name":"llamacpp"},{"slug":"search-engine","name":"search-engine"},{"slug":"semantic-search","name":"semantic-search"}],"trust":{"provenance":{"is_fork":false,"github_id":864976834,"owner_type":"User","methodology":"github_public_v1","parent_repo":null,"near_duplicate_slugs":[]},"computed_at":"2026-09-20T06:23:47.198Z","maintenance":{"label":"Very active","score":96,"methodology":"github_public_v1","releases_90d":1,"days_since_push":0,"last_release_at":"2026-09-19T08:35:35Z","stars_delta_30d":4,"open_issues_delta_30d":0},"security_summary":{"status":"no_lockfile","scanner":null,"low_count":0,"high_count":0,"last_scan_at":"2026-07-11T11:35:10.020Z","medium_count":0,"scan_profile":"none","critical_count":0}},"capability_facts":{"scan":{"source":"repo_scan","observed_at":"2026-09-20T06:23:48.218Z"},"languages":{"value":["go"],"source":"github.language","observed_at":"2026-09-20T06:23:48.218Z"},"license_spdx":{"value":"MIT","source":"github.license","observed_at":"2026-09-20T06:23:48.218Z"}},"decision_facts":{"hosting":null,"pricing":null,"requirements":null,"constraints":null,"when_to_use":["Use for projects needing a lightweight, fast integration of semantic search capabilities within applications written in Go","Consider if your project benefits from the direct use of llamacpp for creating embeddings, emphasizing efficiency in embedding generation"],"when_not_to_use":["Avoid if relying on out-of-the-box support beyond Go or requiring heavy customization that is not supported directly by llama.cpp's capabilities","Not suitable when a more comprehensive database service with extensive querying and integration features is desired over an embedded solution"],"source":"enrich:decision_facts","observed_at":"2026-07-17T08:18:51.378Z"},"constraint_facets":null,"decision_summary":[{"label":"Adopt for","value":"search is a Go library enabling embedded vector search and semantic embeddings via the llama.cpp framework."}]}}