]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix: Use a persistent, writeable location for hugging face models (#12771)
authorTrenton H <797416+stumpylog@users.noreply.github.com>
Sun, 10 May 2026 01:23:11 +0000 (18:23 -0700)
committerGitHub <noreply@github.com>
Sun, 10 May 2026 01:23:11 +0000 (18:23 -0700)
src/paperless_ai/embedding.py
src/paperless_ai/tests/test_embedding.py

index 7fb594a979262ca2bd52f87fc89ca59e83643a88..e03ddae723729506c91c07ad14c2d21cf8aa35b9 100644 (file)
@@ -39,6 +39,7 @@ def get_embedding_model() -> "BaseEmbedding":
             return HuggingFaceEmbedding(
                 model_name=config.llm_embedding_model
                 or "sentence-transformers/all-MiniLM-L6-v2",
+                cache_folder=str(settings.DATA_DIR / "hf_cache"),
             )
         case LLMEmbeddingBackend.OLLAMA:
             from llama_index.embeddings.ollama import OllamaEmbedding
index 3fb5c39ce8a28c8e5b2298e92c1dde041531ce6e..6ee1994b84c4cedc87569d2cd5fa9c395bfe9e9d 100644 (file)
@@ -3,6 +3,7 @@ from unittest.mock import MagicMock
 from unittest.mock import patch
 
 import pytest
+from django.conf import settings
 
 from documents.models import Document
 from paperless.models import LLMEmbeddingBackend
@@ -116,6 +117,7 @@ def test_get_embedding_model_huggingface(mock_ai_config):
         model = get_embedding_model()
         MockHuggingFaceEmbedding.assert_called_once_with(
             model_name="sentence-transformers/all-MiniLM-L6-v2",
+            cache_folder=str(settings.DATA_DIR / "hf_cache"),
         )
         assert model == MockHuggingFaceEmbedding.return_value