Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
LAE
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
文靖昊
LAE
Commits
b6378c25
Commit
b6378c25
authored
Jul 04, 2024
by
tinywell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Add test for faiss search function
parent
4d063424
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
12 deletions
+32
-12
k_store_test.py
test/k_store_test.py
+16
-2
rag_test.py
test/rag_test.py
+16
-10
No files found.
test/k_store_test.py
View file @
b6378c25
...
...
@@ -17,7 +17,7 @@ from src.config.consts import (
from
src.loader.callback
import
BaseCallback
from
src.server.rerank
import
BgeRerank
sys
.
path
.
append
(
"../"
)
import
time
# 当返回值中带有“思考题”字样的时候,默认将其忽略。
...
...
@@ -81,6 +81,19 @@ def test_faiss_load():
reset
=
False
)
print
(
vecstore_faiss
.
join_document
(
vecstore_faiss
.
get_text_similarity
(
"我国什么时候全面开放低空领域"
)))
def
test_faiss_search
():
vecstore_faiss
=
VectorStore_FAISS
(
embedding_model_name
=
EMBEEDING_MODEL_PATH
,
store_path
=
FAISS_STORE_PATH
,
index_name
=
INDEX_NAME
,
info
=
{
"port"
:
VEC_DB_PORT
,
"host"
:
VEC_DB_HOST
,
"dbname"
:
VEC_DB_DBNAME
,
"username"
:
VEC_DB_USER
,
"password"
:
VEC_DB_PASSWORD
},
show_number
=
SIMILARITY_SHOW_NUMBER
,
reset
=
False
)
tic
=
time
.
perf_counter
()
print
(
vecstore_faiss
.
get_text_similarity
(
"化隆县的降雨情况如何"
))
toc
=
time
.
perf_counter
()
-
tic
print
(
"Time:"
,
toc
)
def
test_reranker
():
from
langchain_core.documents
import
Document
...
...
@@ -93,4 +106,5 @@ def test_reranker():
if
__name__
==
"__main__"
:
# test_faiss_from_dir()
# test_faiss_load()
test_reranker
()
# test_reranker()
test_faiss_search
()
test/rag_test.py
View file @
b6378c25
...
...
@@ -13,13 +13,18 @@ base_llm = ChatOpenAI(
verbose
=
True
)
ext
=
QAExt
(
base_llm
)
question
=
"明天适合去吗?"
message
=
[
(
"我们明天去爬山吧"
,
"好呀"
),
(
"天气怎么样"
,
"天气晴朗"
),
]
result
=
ext
.
extend_query
(
question
,
message
)
print
(
result
.
content
)
def
test_qaext
():
ext
=
QAExt
(
base_llm
)
question
=
"明天适合去吗?"
message
=
[
(
"我们明天去爬山吧"
,
"好呀"
),
(
"天气怎么样"
,
"天气晴朗"
),
]
result
=
ext
.
extend_query
(
question
,
message
)
print
(
result
.
content
)
if
__name__
==
"__main__"
:
pass
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment