Skip to content

Commit e7a97d6

Browse files
author
coresoftware dev
committed
scanning parameter tune-up
1 parent 0f65689 commit e7a97d6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

internal/repository/scan_repository_qdrant_impl.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,17 @@ func (r *ScanRepositoryQdrantImpl) processSearchResults(searchResp []*qdrant.Sco
391391
// Convert all points to results
392392
for i, point := range searchResp {
393393
result := r.convertPointToResult(point)
394-
// Avoid results with higher distances. Offset of 2 to fix "0" score comparation. Ex 0 vs 1.
395-
scoreThreshold := searchResp[0].Score*1.1 + 2.0
394+
// Avoid results with higher distances. Offset of 3 to fix "0" score comparation. Ex 0 vs 1.
395+
scoreThreshold := searchResp[0].Score*1.1 + 3.0
396396
if result.Score > scoreThreshold {
397397
fmt.Printf("Filtering out results starting at index %d. Best score: %f, threshold: %f, current score: %f\n", i, searchResp[0].Score, scoreThreshold, result.Score)
398398
break
399399
}
400+
400401
allResults = append(allResults, result)
402+
if result.Rank < 2 {
403+
break // Stop if the component is popular enough
404+
}
401405
}
402406

403407
fmt.Printf("processSearchResults: converted %d points to %d results\n", len(searchResp), len(allResults))
@@ -563,12 +567,12 @@ func (r *ScanRepositoryQdrantImpl) groupByPurl(results []entities.SearchResult)
563567

564568
// Convert an absolute distance to matching score [0,1].
565569
func distanceToScore(distance float32) float32 {
566-
const k = 0.05365 // -ln(0.2) / 30
570+
const k = 0.065 // -ln(0.2) / 30
567571
return float32(math.Exp(-k * float64(distance)))
568572
}
569573

570574
// Convert a matching score [0,1] to absolute distance.
571575
func ScoreToDistance(match float32) float32 {
572-
const k = 0.05365 // -ln(0.2) / 30
576+
const k = 0.065 // -ln(0.2) / 30
573577
return float32(-math.Log(float64(match)) / k)
574578
}

0 commit comments

Comments
 (0)