Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
strategy_embedding
Project
Project
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
rank
strategy_embedding
Commits
a45d3de3
Commit
a45d3de3
authored
Nov 26, 2020
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update method
parent
8249f3d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
to_vector.py
personas_vector/to_vector.py
+4
-2
No files found.
personas_vector/to_vector.py
View file @
a45d3de3
...
...
@@ -10,9 +10,9 @@ import faiss
import
numpy
as
np
import
pandas
as
pd
from
gensim.models
import
Word2Vec
,
word2vec
from
utils.cache
import
redis_client_db
from
utils.defs
import
nth_element
from
utils.files
import
get_df
from
utils.cache
import
redis_client_db
def
device_tractate_fe
():
...
...
@@ -80,7 +80,9 @@ if __name__ == "__main__":
tractate_embeddings
=
np
.
array
(
list
(
tractate_vector_dict
.
values
()))
.
astype
(
"float32"
)
# index = faiss.IndexFlatL2(tractate_embeddings.shape[1])
index
=
faiss
.
IndexIVFFlat
(
tractate_embeddings
.
shape
[
1
])
quantizer
=
faiss
.
IndexFlatL2
(
tractate_embeddings
.
shape
[
1
])
index
=
faiss
.
IndexIVFFlat
(
quantizer
,
tractate_embeddings
.
shape
[
1
],
100
,
faiss
.
METRIC_L2
)
print
(
"trained: "
+
str
(
index
.
is_trained
))
index2
=
faiss
.
IndexIDMap
(
index
)
...
...
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