Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Update LLM pipeline to support GPU parameter with llama.cpp backend, closes #724

davidmezzettib3a99f019785
diff --git a/src/python/txtai/pipeline/llm/llama.py b/src/python/txtai/pipeline/llm/llama.py
index dea052b4..e590e4ad 100644
--- a/src/python/txtai/pipeline/llm/llama.py
+++ b/src/python/txtai/pipeline/llm/llama.py
@@ -45,6 +45,9 @@ class LlamaCpp(Generation):
# Check if this is a local path, otherwise download from the HF Hub
path = path if os.path.exists(path) else self.download(path)
+ # Default GPU layers if not already set
+ kwargs["n_gpu_layers"] = kwargs.get("n_gpu_layers", -1 if kwargs.get("gpu", True) else 0)
+
# Create llama.cpp instance
self.llm = Llama(path, verbose=kwargs.pop("verbose", False), **kwargs)