github-actions[bot] commited on
Commit
a7bea68
·
1 Parent(s): 9c56a9c

Deploy 5d055d7 from GitHub

Browse files
Files changed (1) hide show
  1. backend/pipeline/models.py +4 -0
backend/pipeline/models.py CHANGED
@@ -37,12 +37,16 @@ def embedder():
37
  if _embedder is None:
38
  with _lock:
39
  if _embedder is None:
 
40
  from llama_index.embeddings.huggingface import HuggingFaceEmbedding
41
 
42
  # E5 models are trained with these prefixes; other models get none.
43
  e5 = "e5" in settings.EMBED_MODEL.lower()
44
  _embedder = HuggingFaceEmbedding(
45
  model_name=settings.EMBED_MODEL,
 
 
 
46
  query_instruction="query: " if e5 else None,
47
  text_instruction="passage: " if e5 else None,
48
  normalize=True,
 
37
  if _embedder is None:
38
  with _lock:
39
  if _embedder is None:
40
+ from huggingface_hub.constants import HF_HUB_CACHE
41
  from llama_index.embeddings.huggingface import HuggingFaceEmbedding
42
 
43
  # E5 models are trained with these prefixes; other models get none.
44
  e5 = "e5" in settings.EMBED_MODEL.lower()
45
  _embedder = HuggingFaceEmbedding(
46
  model_name=settings.EMBED_MODEL,
47
+ # Hugging Face's usual cache (LlamaIndex would use its own folder), where the Dockerfile
48
+ # downloads the model at build time: the Space runs offline.
49
+ cache_folder=HF_HUB_CACHE,
50
  query_instruction="query: " if e5 else None,
51
  text_instruction="passage: " if e5 else None,
52
  normalize=True,