blob: b4ee33263f1e83dc56862c3388b9ea6fbc20fe2b (
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
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.ranking;
import ai.vespa.models.evaluation.FunctionEvaluator;
import ai.vespa.models.evaluation.Model;
import ai.vespa.models.evaluation.ModelsEvaluator;
import com.yahoo.api.annotations.Beta;
import com.yahoo.component.AbstractComponent;
import com.yahoo.component.annotation.Inject;
import com.yahoo.filedistribution.fileacquirer.FileAcquirer;
import com.yahoo.vespa.config.search.RankProfilesConfig;
import com.yahoo.vespa.config.search.core.OnnxModelsConfig;
import com.yahoo.vespa.config.search.core.RankingConstantsConfig;
import com.yahoo.vespa.config.search.core.RankingExpressionsConfig;
/**
* proxy for model-evaluation components
* @author arnej
*/
@Beta
public class RankingExpressionEvaluatorProxy extends AbstractComponent {
private final ModelsEvaluator evaluator;
@Inject
public RankingExpressionEvaluatorProxy(
RankProfilesConfig rankProfilesConfig,
RankingConstantsConfig constantsConfig,
RankingExpressionsConfig expressionsConfig,
OnnxModelsConfig onnxModelsConfig,
FileAcquirer fileAcquirer)
{
this.evaluator = new ModelsEvaluator(
rankProfilesConfig,
constantsConfig,
expressionsConfig,
onnxModelsConfig,
fileAcquirer);
}
public Model modelForRankProfile(String rankProfile) {
var m = evaluator.models().get(rankProfile);
if (m == null) {
throw new IllegalArgumentException("unknown rankprofile: " + rankProfile);
}
return m;
}
public FunctionEvaluator evaluatorForFunction(String rankProfile, String functionName) {
return modelForRankProfile(rankProfile).evaluatorOf(functionName);
}
}
|