Arvind2006 commited on
Commit
cef0524
·
verified ·
1 Parent(s): d520cc3

Upload retrieve_docs.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. retrieve_docs.py +5 -11
retrieve_docs.py CHANGED
@@ -3,6 +3,7 @@
3
  import json
4
  import faiss
5
  import numpy as np
 
6
 
7
  INDEX_PATH = "data/docs/docs.index"
8
  META_PATH = "data/docs/docs_meta.json"
@@ -17,16 +18,10 @@ QUERY_TEMPLATES = {
17
  "file_not_found": "Jenkins pipeline workspace file not found",
18
  "git_authentication_error": "Jenkins git authentication failed checkout"
19
  }
20
-
21
- # Lazy load model
22
- _model = None
23
-
24
- def get_model():
25
- global _model
26
- if _model is None:
27
- from sentence_transformers import SentenceTransformer
28
- _model = SentenceTransformer("all-MiniLM-L6-v2", cache_folder="./models")
29
- return _model
30
 
31
  def retrieve_docs(error_category: str):
32
 
@@ -39,7 +34,6 @@ def retrieve_docs(error_category: str):
39
  "Jenkins pipeline error"
40
  )
41
 
42
- model = get_model()
43
  query_embedding = model.encode([query])
44
  distances, indices = index.search(query_embedding, TOP_K)
45
 
 
3
  import json
4
  import faiss
5
  import numpy as np
6
+ from sentence_transformers import SentenceTransformer
7
 
8
  INDEX_PATH = "data/docs/docs.index"
9
  META_PATH = "data/docs/docs_meta.json"
 
18
  "file_not_found": "Jenkins pipeline workspace file not found",
19
  "git_authentication_error": "Jenkins git authentication failed checkout"
20
  }
21
+ model = SentenceTransformer(
22
+ "paraphrase-MiniLM-L3-v2",
23
+ cache_folder="./model_cache"
24
+ )
 
 
 
 
 
 
25
 
26
  def retrieve_docs(error_category: str):
27
 
 
34
  "Jenkins pipeline error"
35
  )
36
 
 
37
  query_embedding = model.encode([query])
38
  distances, indices = index.search(query_embedding, TOP_K)
39