Unverified Commit 920b2c2b authored by Jyong's avatar Jyong Committed by GitHub

Fix/hit test tsne issue (#2581)

Co-authored-by: 's avatarjyong <jyong@dify.ai>
parent ac96d192
...@@ -59,7 +59,7 @@ class AnnotationReplyFeature: ...@@ -59,7 +59,7 @@ class AnnotationReplyFeature:
documents = vector.search_by_vector( documents = vector.search_by_vector(
query=query, query=query,
k=1, top_k=1,
score_threshold=score_threshold, score_threshold=score_threshold,
filter={ filter={
'group_id': [dataset.id] 'group_id': [dataset.id]
......
...@@ -101,7 +101,7 @@ class RetrievalService: ...@@ -101,7 +101,7 @@ class RetrievalService:
documents = keyword.search( documents = keyword.search(
query, query,
k=top_k top_k=top_k
) )
all_documents.extend(documents) all_documents.extend(documents)
...@@ -121,7 +121,7 @@ class RetrievalService: ...@@ -121,7 +121,7 @@ class RetrievalService:
documents = vector.search_by_vector( documents = vector.search_by_vector(
query, query,
search_type='similarity_score_threshold', search_type='similarity_score_threshold',
k=top_k, top_k=top_k,
score_threshold=score_threshold, score_threshold=score_threshold,
filter={ filter={
'group_id': [dataset.id] 'group_id': [dataset.id]
......
...@@ -133,8 +133,9 @@ class HitTestingService: ...@@ -133,8 +133,9 @@ class HitTestingService:
if embedding_length <= 1: if embedding_length <= 1:
return [{'x': 0, 'y': 0}] return [{'x': 0, 'y': 0}]
concatenate_data = np.array(embeddings).reshape(embedding_length, -1) noise = np.random.normal(0, 1e-4, np.array(embeddings).shape)
# concatenate_data = np.concatenate(embeddings) concatenate_data = np.array(embeddings) + noise
concatenate_data = concatenate_data.reshape(embedding_length, -1)
perplexity = embedding_length / 2 + 1 perplexity = embedding_length / 2 + 1
if perplexity >= embedding_length: if perplexity >= embedding_length:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment