← 开源
kelindar

search

Go library for embedded vector search and semantic embeddings using llama.cpp

InfrastructureIndex & SearchGo
在 GitHub 打开
增长势头
+024 小时新增 Star0.0%
561
Star
24
Fork
+1
本周
2
贡献者
创建于 2024-09-29 · 更新于 2026-10-12 · 今日第 17000 名
主要开发者
kelindarsamyfodil

kelindar/search 排名第 17,000,有 561 个星标。

同类别比较

kelindar/search 排名第 17,000,此处有 8 个同类条目;llumnix-project/llumnix-ray 排名第 17,003。

同类别比较
名称排名指标
labring/aiproxy16,965
语言:
Go
星标数:
563
分叉数:
116
简介:
AI Proxy is a high performance AI gateway using OpenAI / Claude / Gemini protocol as the entry point. It features intelligent error handling, multi-channel management, and comprehensive monitoring. With support for multiple models, rate limiting, and multi-tenant isolation.
facebookresearch/HolisticTraceAnalysis16,976
语言:
Python
星标数:
562
分叉数:
98
简介:
A library to analyze PyTorch traces.
Dstack-TEE/dstack16,988
语言:
Rust
星标数:
561
分叉数:
99
简介:
Open framework for confidential AI
cloudkj/layer16,994
语言:
Scheme
星标数:
561
分叉数:
18
简介:
Neural network inference the Unix way
llumnix-project/llumnix-ray17,003
语言:
Python
星标数:
561
分叉数:
50
简介:
Efficient and easy multi-instance LLM serving
maxbbraun/llama4micro17,005
语言:
C++
星标数:
561
分叉数:
37
简介:
A "large" language model running on a microcontroller
zengxiao-he/tessera17,012
语言:
Python
星标数:
561
分叉数:
10
WebAssembly/wasi-nn17,018
星标数:
560
分叉数:
42
简介:
Neural Network proposal for WASI
关键参数与规格
关键参数与规格
参数值
语言Go
类别Infrastructure
子类别Index & Search
关键词Embeddings, Go
星标数561
分叉数24
贡献者2
创建日期2024-09-29
更新日期2026-10-12
1 天星标数0
7 天星标数1
排名17,000
上次排名16,791
排名变化-209
7 天星标排名11,344
上次 7 天星标排名11,405
7 天星标排名变化61
总星标排名17,703
上次总星标排名17,672
总星标排名变化-31
国家UAE
README 摘录

Vector search and embeddings An exact cosine similarity index for small and medium datasets, with optional local and cloud embedding providers. | | | Local GGUF embeddings through llama. | | | Text embeddings through OpenAI-compatible APIs, including OpenRouter. Core has no dependency on either embedding module or . The module uses only the standard library at runtime; owns the native inference dependency. Testify and its YAML dependency are used only by tests. The interactive has a separate development module with local replacements for and . Native

quality evaluation lives under , so neither introduces provider dependencies into core search. Search with your own vectors normalizes the vector in place and retains its backing array. Results contain cosine similarity in descending order, so larger 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. Existing , , , and 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. Local embeddings Import and install the native library as described below. 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. Embedding calls on a model may run concurrently. Finish all calls and close any explicitly created values before closing the model. Individual contexts

must not be shared concurrently. Cancellation is checked around native inference and between batch items; it cannot interrupt native inference already in progress. Supply credentials and a model explicitly. For OpenRouter, use its base URL and model identifier: Optional configuration uses , , and . Defaults are the OpenAI endpoint, provider-default dimensions, no extra headers, and a 60-second HTTP timeout. A supplied HTTP client controls its own timeout. Headers are copied and cannot override authorization or content type. Clients may be

shared concurrently; do not mutate a supplied HTTP client during use. Batches use one HTTP request and return vectors in input order. Empty batches do no work; failures return no partial results. There are no automatic retries or batch splitting. Local uses sequential inference with the same result contract. Cloud support covers text, not multimodal inputs or provider-specific routing. Custom providers Any function returning can supply vectors to the index, without importing either provider package. Applications that swap providers

can define their own small interface: Both built-in providers satisfy this interface. Migration and tests Replace with , with , and with . Pass a as the first argument to , including calls on explicit local contexts. Index APIs and saved files require no migration. Run separately from the repository root, , , and . Native model and quality tests are opt-in via from ; they require the native library on its platform search path and the repository's MiniLM model and evaluation fixtures. The binaries in

dist predate that pin; build the wrapper from source for the updated version. Build instructions below apply only to local

常见问题

记录了多少星标和分叉?

kelindar/search 有 561 个星标和 24 个分叉。

仓库排名是多少?

kelindar/search 排名第 17,000。

记录的语言和类别是什么?

kelindar/search 有 561 个星标,语言为 Go,类别为 Infrastructure。

哪个仓库排名最接近?

kelindar/search 与 llumnix-project/llumnix-ray 比较,后者排名第 17,003,有 561 个星标。

README

Vector search and embeddings

An exact cosine similarity index for small and medium datasets, with optional local and cloud embedding providers. Requires Go 1.27 or newer.

Package Purpose
github.com/kelindar/search Vector indexing, search, and persistence. No native library required.
github.com/kelindar/search/llama Local GGUF embeddings through llama.cpp and purego.
github.com/kelindar/search/openai Text embeddings through OpenAI-compatible APIs, including OpenRouter.

Each 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.

The 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.

Search with your own vectors

index := search.NewIndex[string]()
index.Add([]float32{1, 0}, "cat")
index.Add([]float32{0, 1}, "dog")
results := index.Search([]float32{1, 0}, 1)
fmt.Println(results[0].Value) // cat

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.

Existing 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.

Local embeddings

Import github.com/kelindar/search/llama and install the native library as described below.

model, err := llama.New("dist/MiniLM-L6-v2.Q8_0.gguf", 0)
if err != nil {
    return err
}
defer model.Close()
vector, err := model.EmbedText(ctx, "Your text here")

Zero 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.

Embedding 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.

Cloud embeddings

Import github.com/kelindar/search/openai. Supply credentials and a model explicitly.

client, err := openai.New(os.Getenv("OPENAI_API_KEY"), "text-embedding-3-small")
if err != nil {
    return err
}
vector, err := client.EmbedText(ctx, "Your text here")
vectors, err := client.EmbedBatch(ctx, []string{"first document", "second document"})

For OpenRouter, use its base URL and model identifier:

client, err := openai.New(os.Getenv("OPENROUTER_API_KEY"), "openai/text-embedding-3-small",
    openai.BaseURL("https://openrouter.ai/api/v1"),
)

Optional configuration uses Dimensions(n), Headers(http.Header), and HTTPClient(*http.Client). Defaults are the OpenAI /v1 endpoint, provider-default dimensions, no extra headers, and a 60-second HTTP timeout. A supplied HTTP client controls its own timeout. Headers are copied and cannot override authorization or content type. Clients may be shared concurrently; do not mutate a supplied HTTP client during use.

Batches use one HTTP request and return vectors in input order. Returned vectors belong to the caller. Empty batches do no work; failures return no partial results. There are no automatic retries or batch splitting. Local EmbedBatch uses sequential inference with the same result contract. Cloud support covers text, not multimodal inputs or provider-specific routing.

Custom providers

Any function returning []float32 can supply vectors to the index, without importing either provider package. Applications that swap providers can define their own small interface:

type Embedder interface {
    EmbedText(context.Context, string) ([]float32, error)
}

Both built-in providers satisfy this interface. See the custom-provider example.

Migration and tests

Replace search.NewVectorizer(path, layers) with llama.New(path, layers), search.Vectorizer with llama.Vectorizer, and search.Context with llama.Context. Pass a context.Context as the first argument to EmbedText, including calls on explicit local contexts. Index APIs and saved files require no migration.

Run go test ./... separately from the repository root, llama, openai, and example. Root ./... does not cross module boundaries. Native model and quality tests are opt-in via go test -tags integration ./... from llama; they require the native library on its platform search path and the repository's MiniLM model and evaluation fixtures. The native source is pinned to llama.cpp v0.4.1. The binaries in dist predate that pin; build the wrapper from source for the updated version. Build instructions below apply only to local embeddings.

Nested modules are released with their own tags: llama/vX.Y.Z and openai/vX.Y.Z. Root releases continue to use vX.Y.Z. Tests and module maintenance run with GOWORK=off in CI to verify isolation.

🛠 Compile library

First, clone the repository and its submodules with the following commands. This checks out the pinned llama.cpp source and retrieves the model and vector fixtures.

git submodule update --init --recursive
git lfs pull

Compile on Linux

Make sure you have a C/C++ compiler and CMake installed. For Ubuntu, you can install them with the following commands:

sudo apt-get update
sudo apt-get install build-essential cmake

Then you can compile the library with the following commands:

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc ..
cmake --build . --config Release --target llama_go --parallel

This should generate libllama_go.so that statically links everything necessary. You can also install the library by coping it into /usr/lib.

Compile on macOS

Make sure you have Xcode Command Line Tools and CMake installed:

xcode-select --install
brew install cmake

Then compile the library:

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release --target llama_go --parallel

This generates libllama_go.dylib in build/lib. If you run the Go tests or example from the repository root, point the dynamic loader to that directory:

cd llama
DYLD_LIBRARY_PATH="$(pwd)/../build/lib" go test -tags integration ./...

Compile on Windows

Make sure you have a C/C++ compiler and CMake installed. For Windows, a simple option is to use Build Tools for Visual Studio (make sure CLI tools are included) and CMake.

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release --target llama_go --parallel

If 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/Release directory contains llama_go.dll. Add that directory to PATH before running local embeddings or integration tests.

GPU and other options

To enable GPU support (e.g. Vulkan), you'll need to add an appropriate flag to the CMake command, please refer to refer to the llama.cpp build documentation for more details. For example, to compile with Vulkan support on Windows make sure Vulkan SDK is installed and then run the following commands:

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DGGML_VULKAN=ON ..
cmake --build . --config Release --target llama_go --parallel
排名相邻
同类项目