Spaces:
Runtime error
Runtime error
makcrx
commited on
Commit
·
454c118
1
Parent(s):
b068669
test
Browse files- .gitignore +2 -0
- app.py +4 -3
- faiss_qa/index.pkl +1 -1
- test.ipynb +6 -6
.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__pycache__
|
| 2 |
+
*.sqlite
|
app.py
CHANGED
|
@@ -7,11 +7,12 @@ embeddings = SentenceTransformerEmbeddings(model_name="multi-qa-MiniLM-L6-cos-v1
|
|
| 7 |
db = FAISS.load_local('faiss_qa', embeddings)
|
| 8 |
|
| 9 |
def main(query):
|
|
|
|
| 10 |
result_docs = db.similarity_search_with_score(query, k=20)
|
| 11 |
sentences = [doc[0].page_content for doc in result_docs]
|
| 12 |
-
#
|
| 13 |
-
#
|
| 14 |
-
#
|
| 15 |
score, index = reranking.search(query, sentences)
|
| 16 |
return result_docs[index][0].metadata['answer'], score, result_docs[index][0].page_content
|
| 17 |
|
|
|
|
| 7 |
db = FAISS.load_local('faiss_qa', embeddings)
|
| 8 |
|
| 9 |
def main(query):
|
| 10 |
+
query = query.lower()
|
| 11 |
result_docs = db.similarity_search_with_score(query, k=20)
|
| 12 |
sentences = [doc[0].page_content for doc in result_docs]
|
| 13 |
+
#print('----------------------------------------------------------------')
|
| 14 |
+
#for doc in result_docs:
|
| 15 |
+
# print(doc[0].metadata['articleId'], ' | ', doc[0].page_content, ' | ', doc[0].metadata['answer'])
|
| 16 |
score, index = reranking.search(query, sentences)
|
| 17 |
return result_docs[index][0].metadata['answer'], score, result_docs[index][0].page_content
|
| 18 |
|
faiss_qa/index.pkl
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 263215
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:654deaa1266f3e8eab26b2506d37383b8a29231daf1af292638c0e4821c45c5f
|
| 3 |
size 263215
|
test.ipynb
CHANGED
|
@@ -22,18 +22,18 @@
|
|
| 22 |
" for res in results:\n",
|
| 23 |
" \n",
|
| 24 |
" questions = json.loads(res['questions'])\n",
|
| 25 |
-
" questions_copy = questions.copy()\n",
|
| 26 |
" \n",
|
| 27 |
" for q in questions:\n",
|
| 28 |
-
" q['query'] = \" \".join(res['section'].split() + res['title'].split() + q['question'].split())\n",
|
| 29 |
" q['articleId'] = res['articleId']\n",
|
| 30 |
" \n",
|
| 31 |
-
" for q in questions_copy:\n",
|
| 32 |
-
"
|
| 33 |
-
"
|
| 34 |
"\n",
|
| 35 |
" all_questions += questions\n",
|
| 36 |
-
" all_questions += questions_copy\n",
|
| 37 |
" return all_questions\n",
|
| 38 |
"\n",
|
| 39 |
"questions = load_questions(\"omnidesk-ai-chatgpt-questions.sqlite\")"
|
|
|
|
| 22 |
" for res in results:\n",
|
| 23 |
" \n",
|
| 24 |
" questions = json.loads(res['questions'])\n",
|
| 25 |
+
" # questions_copy = questions.copy()\n",
|
| 26 |
" \n",
|
| 27 |
" for q in questions:\n",
|
| 28 |
+
" q['query'] = \" \".join(res['section'].split() + res['title'].split() + q['question'].split()).lower()\n",
|
| 29 |
" q['articleId'] = res['articleId']\n",
|
| 30 |
" \n",
|
| 31 |
+
" # for q in questions_copy:\n",
|
| 32 |
+
" # q['query'] = q['question']\n",
|
| 33 |
+
" # q['articleId'] = res['articleId']\n",
|
| 34 |
"\n",
|
| 35 |
" all_questions += questions\n",
|
| 36 |
+
" # all_questions += questions_copy\n",
|
| 37 |
" return all_questions\n",
|
| 38 |
"\n",
|
| 39 |
"questions = load_questions(\"omnidesk-ai-chatgpt-questions.sqlite\")"
|