blob: c2e8305038c3d54a0a4331f5afdaefd95b72dfdf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <memory>
#include <vespa/eval/eval/cell_type.h>
namespace vespalib::eval { struct TypedCells; }
namespace search::tensor {
class DistanceConverter {
public:
virtual ~DistanceConverter() = default;
/**
* Convert threshold (external distance units) to internal units.
*/
virtual double convert_threshold(double threshold) const = 0;
/**
* Convert internal distance to rawscore (also used as closeness).
*/
virtual double to_rawscore(double distance) const = 0;
/**
* Convert rawscore to external distance.
* Override this when the rawscore is NOT defined as (1.0 / (1.0 + external_distance)).
*/
virtual double to_distance(double rawscore) const {
return (1.0 / rawscore) - 1.0;
}
/**
* The minimum rawscore (also used as closeness) that this distance function can return.
*/
virtual double min_rawscore() const {
return 0.0;
}
};
}
|