Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -39,6 +39,13 @@ model_id = "microsoft/phi-2"
|
|
39 |
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
40 |
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float32, device_map="auto", trust_remote_code=True)
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
# Returns a faiss vector store retriever given a txt file
|
43 |
def prepare_vector_store_retriever(filename):
|
44 |
# Load data
|
@@ -56,11 +63,6 @@ def prepare_vector_store_retriever(filename):
|
|
56 |
documents = text_splitter.split_documents(raw_documents)
|
57 |
|
58 |
# Creating a vectorstore
|
59 |
-
embeddings = HuggingFaceEmbeddings(
|
60 |
-
model_name="sentence-transformers/multi-qa-MiniLM-L6-cos-v1",
|
61 |
-
model_kwargs={'device': 'cpu'},
|
62 |
-
encode_kwargs={'normalize_embeddings': False}
|
63 |
-
)
|
64 |
vectorstore = FAISS.from_documents(documents, embeddings, distance_strategy=DistanceStrategy.COSINE)
|
65 |
|
66 |
return VectorStoreRetriever(vectorstore=vectorstore, search_kwargs={"k": 2})
|
|
|
39 |
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
40 |
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float32, device_map="auto", trust_remote_code=True)
|
41 |
|
42 |
+
# sentence transformers to be used in vector store
|
43 |
+
embeddings = HuggingFaceEmbeddings(
|
44 |
+
model_name="sentence-transformers/multi-qa-MiniLM-L6-cos-v1",
|
45 |
+
model_kwargs={'device': 'cpu'},
|
46 |
+
encode_kwargs={'normalize_embeddings': False}
|
47 |
+
)
|
48 |
+
|
49 |
# Returns a faiss vector store retriever given a txt file
|
50 |
def prepare_vector_store_retriever(filename):
|
51 |
# Load data
|
|
|
63 |
documents = text_splitter.split_documents(raw_documents)
|
64 |
|
65 |
# Creating a vectorstore
|
|
|
|
|
|
|
|
|
|
|
66 |
vectorstore = FAISS.from_documents(documents, embeddings, distance_strategy=DistanceStrategy.COSINE)
|
67 |
|
68 |
return VectorStoreRetriever(vectorstore=vectorstore, search_kwargs={"k": 2})
|