diff --git a/README.md b/README.md index 156e9e0..710051d 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,8 @@ GGUF models are available at [Audio Embedding GGUF](https://huggingface.co/colle Load a converted GGUF and generate real native text or audio embeddings: ```sh -clap embedding --model larger_clap_general-q4_k_m.gguf --threads 4 --text 'Sound of a dog' -clap embedding --model larger_clap_general-q4_k_m.gguf --threads 4 --audio dog.wav +clap embedding --model larger_clap_general-q4_k_m.gguf --text 'Sound of a dog' +clap embedding --model larger_clap_general-q4_k_m.gguf --audio dog.wav ``` ### Embeddings server @@ -50,7 +50,7 @@ Start the server with a GGUF supporting the requested modality, such as CLAP, CLaMP3 or MuQ-MuLan (default listen address: `127.0.0.1:8080`): ```sh -clap serve --model larger_clap_general-q4_k_m.gguf --threads 4 --host 127.0.0.1 --port 8080 +clap serve --model larger_clap_general-q4_k_m.gguf --host 127.0.0.1 --port 8080 ``` The model is loaded once at startup. Its API identifier is the GGUF **filename** diff --git a/node/README.md b/node/README.md index 13c6fd8..295a3d6 100644 --- a/node/README.md +++ b/node/README.md @@ -17,7 +17,7 @@ npm install clap-cpp ```js const { CLAP } = require('clap-cpp'); -const model = new CLAP('larger_clap_general-q4_k_m.gguf', 4); +const model = new CLAP('larger_clap_general-q4_k_m.gguf'); try { const textEmbedding = model.encodeText('Sound of a dog'); const audioEmbedding = model.encodeAudio('dog.wav'); diff --git a/node/test/clap.test.js b/node/test/clap.test.js index f37cbbd..d9f9836 100644 --- a/node/test/clap.test.js +++ b/node/test/clap.test.js @@ -41,7 +41,7 @@ test('CLAP', async (t) => { await pipeline(file.stream(), createWriteStream(modelPath)); } - const clap = new CLAP(modelPath, 1); + const clap = new CLAP(modelPath); t.after(() => clap.close()); const audioEmbedding = clap.encodeAudio(path.join(__dirname, '..', '..', 'assets', 'dog.wav'), 0); const textEmbedding1 = clap.encodeText('Sound of a dog'); diff --git a/python/README.md b/python/README.md index 547c2e9..8fb2c62 100644 --- a/python/README.md +++ b/python/README.md @@ -26,7 +26,7 @@ pip install "clap-cpp[vulkan]" # Vulkan ```python from clap_cpp import CLAP -with CLAP("larger_clap_general-q4_k_m.gguf", threads=4) as model: +with CLAP("larger_clap_general-q4_k_m.gguf") as model: text_embedding = model.encode_text("Sound of a dog") audio_embedding = model.encode_audio("dog.wav") ``` diff --git a/python/tests/test_clap.py b/python/tests/test_clap.py index 735d6f9..b690e3a 100644 --- a/python/tests/test_clap.py +++ b/python/tests/test_clap.py @@ -33,7 +33,7 @@ def test_clap(): ) audio_path = Path(__file__).resolve().parents[2] / "assets" / "dog.wav" - with CLAP(model_path, threads=1) as clap: + with CLAP(model_path) as clap: audio_embedding = clap.encode_audio(audio_path, 0) text_embedding_1 = clap.encode_text("Sound of a dog") text_embedding_2 = clap.encode_text("Sound of vaccum cleaner") diff --git a/src/clap.cpp b/src/clap.cpp index f4d5bfa..ccca04a 100644 --- a/src/clap.cpp +++ b/src/clap.cpp @@ -22,7 +22,7 @@ int main(int argc, char **argv) { auto *devices = app.add_subcommand("devices", "List available GGML devices"); auto *serve = app.add_subcommand("serve", "Start the embeddings HTTP server"); serve->add_option("-m,--model", server_model, "Converted model GGUF")->required()->check(CLI::ExistingFile); - serve->add_option("-t,--threads", server_threads, "ggml CPU threads (0: automatic)") + serve->add_option("-t,--threads", server_threads, "ggml CPU threads (0: hardware concurrency)") ->check(CLI::NonNegativeNumber) ->capture_default_str(); serve->add_option("--device", server_device, "GGML device name, auto or cpu (default: CLAP_DEVICE or auto)"); @@ -35,7 +35,7 @@ int main(int argc, char **argv) { embedding->add_option("-m,--model", options.model_path, "Converted CLAP/CLaMP3/MERT/MERT2/MuQ/MuLan GGUF") ->required() ->check(CLI::ExistingFile); - embedding->add_option("-t,--threads", options.threads, "ggml CPU threads (0: automatic)") + embedding->add_option("-t,--threads", options.threads, "ggml CPU threads (0: hardware concurrency)") ->check(CLI::NonNegativeNumber) ->capture_default_str(); embedding->add_option("--device", options.device, "GGML device name, auto or cpu (default: CLAP_DEVICE or auto)"); diff --git a/src/graph.cpp b/src/graph.cpp index a3fd0be..719dd8e 100644 --- a/src/graph.cpp +++ b/src/graph.cpp @@ -79,8 +79,8 @@ struct GraphRuntime::State { cpu.reset(ggml_backend_cpu_init()); if (!cpu) throw std::runtime_error("CLAP: CPU backend initialization failed"); - ggml_backend_cpu_set_n_threads( - cpu.get(), threads > 0 ? threads : int(std::max(1u, std::min(8u, std::thread::hardware_concurrency())))); + ggml_backend_cpu_set_n_threads(cpu.get(), + threads > 0 ? threads : int(std::max(1u, std::thread::hardware_concurrency()))); if (requested == "auto") { for (size_t i = 0; i < ggml_backend_dev_count() && !gpu; ++i) { auto device = ggml_backend_dev_get(i);