Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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**
Expand Down
2 changes: 1 addition & 1 deletion node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion node/test/clap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
```
2 changes: 1 addition & 1 deletion python/tests/test_clap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions src/clap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)");
Expand All @@ -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)");
Expand Down
4 changes: 2 additions & 2 deletions src/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading