NimrodDev commited on
Commit
5b2d96e
·
1 Parent(s): 36fc4cb

load local ONNX MiniLM with absolute path (no cache)

Browse files
Files changed (1) hide show
  1. rag.py +11 -3
rag.py CHANGED
@@ -109,9 +109,17 @@ def get_texts() -> List[str]:
109
  def get_vectorstore() -> FAISS:
110
  texts = get_texts()
111
 
112
- # --- FINAL: use optimum ONNX MiniLM (already on disk in image) --------
113
- from langchain.embeddings import OptimumEmbeddings
114
- embeddings = OptimumEmbeddings.from_pretrained("optimum/all-MiniLM-L6-v2")
 
 
 
 
 
 
 
 
115
  # ------------------------------------------------------------------------
116
 
117
  if not texts: # no data → empty FAISS
 
109
  def get_vectorstore() -> FAISS:
110
  texts = get_texts()
111
 
112
+ # --- FINAL: load local ONNX MiniLM (no internet, no disk write) -------
113
+ import os
114
+ local_model_path = os.path.abspath(
115
+ os.path.join(os.path.dirname(__file__), "st_model")
116
+ )
117
+
118
+ from sentence_transformers import SentenceTransformer
119
+ model = SentenceTransformer(local_model_path, device="cpu", cache_folder=None)
120
+
121
+ from langchain.embeddings import SentenceTransformerEmbeddings
122
+ embeddings = SentenceTransformerEmbeddings(model=model)
123
  # ------------------------------------------------------------------------
124
 
125
  if not texts: # no data → empty FAISS