diff options
author | Lester Solbakken <lesters@oath.com> | 2021-09-29 14:34:47 +0200 |
---|---|---|
committer | Lester Solbakken <lesters@oath.com> | 2021-09-29 14:34:47 +0200 |
commit | a3466761eff7aa6fc777c53801e7ef24dafeed88 (patch) | |
tree | 35136484e22d5414fbf966ea449492356b23f62f /model-evaluation/src | |
parent | 8923accf7e72d147d6d57185eecc4faf2b4adeb7 (diff) |
Add tensor short form format option for result rendering
Diffstat (limited to 'model-evaluation/src')
-rw-r--r-- | model-evaluation/src/main/java/ai/vespa/models/handler/ModelsEvaluationHandler.java | 3 | ||||
-rw-r--r-- | model-evaluation/src/test/java/ai/vespa/models/handler/ModelsEvaluationHandlerTest.java | 7 |
2 files changed, 4 insertions, 6 deletions
diff --git a/model-evaluation/src/main/java/ai/vespa/models/handler/ModelsEvaluationHandler.java b/model-evaluation/src/main/java/ai/vespa/models/handler/ModelsEvaluationHandler.java index 9e365056355..8283d79fa2e 100644 --- a/model-evaluation/src/main/java/ai/vespa/models/handler/ModelsEvaluationHandler.java +++ b/model-evaluation/src/main/java/ai/vespa/models/handler/ModelsEvaluationHandler.java @@ -10,7 +10,6 @@ import com.yahoo.container.jdisc.ThreadedHttpRequestHandler; import com.yahoo.searchlib.rankingexpression.ExpressionFunction; import com.yahoo.slime.Cursor; import com.yahoo.slime.Slime; -import com.yahoo.tensor.IndexedTensor; import com.yahoo.tensor.Tensor; import com.yahoo.tensor.TensorType; import com.yahoo.tensor.serialization.JsonFormat; @@ -90,7 +89,7 @@ public class ModelsEvaluationHandler extends ThreadedHttpRequestHandler { } Tensor result = evaluator.evaluate(); - Optional<String> format = property(request, "format"); + Optional<String> format = property(request, "format.tensors"); if (format.isPresent() && format.get().equalsIgnoreCase("short")) { return new Response(200, JsonFormat.encodeShortForm(result)); } diff --git a/model-evaluation/src/test/java/ai/vespa/models/handler/ModelsEvaluationHandlerTest.java b/model-evaluation/src/test/java/ai/vespa/models/handler/ModelsEvaluationHandlerTest.java index 7029be24a60..992747b7866 100644 --- a/model-evaluation/src/test/java/ai/vespa/models/handler/ModelsEvaluationHandlerTest.java +++ b/model-evaluation/src/test/java/ai/vespa/models/handler/ModelsEvaluationHandlerTest.java @@ -1,7 +1,6 @@ // Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package ai.vespa.models.handler; -import ai.vespa.models.evaluation.ModelTester; import ai.vespa.models.evaluation.ModelsEvaluator; import ai.vespa.models.evaluation.RankProfilesConfigImporterWithMockedConstants; import com.yahoo.config.subscription.ConfigGetter; @@ -186,7 +185,7 @@ public class ModelsEvaluationHandlerTest { public void testMnistSoftmaxEvaluateSpecificFunctionWithShortOutput() { Map<String, String> properties = new HashMap<>(); properties.put("Placeholder", inputTensorShortForm()); - properties.put("format", "short"); + properties.put("format.tensors", "short"); String url = "http://localhost/model-evaluation/v1/mnist_softmax/default.add/eval"; String expected = "{\"type\":\"tensor(d0[],d1[10])\",\"values\":[[-0.3546536862850189,0.3759574592113495,0.06054411828517914,-0.251544713973999,0.017951013520359993,1.2899067401885986,-0.10389615595340729,0.6367976665496826,-1.4136744737625122,-0.2573896050453186]]}"; handler.assertResponse(url, properties, 200, expected); @@ -216,7 +215,7 @@ public class ModelsEvaluationHandlerTest { @Test public void testVespaModelShortOutput() { Map<String, String> properties = new HashMap<>(); - properties.put("format", "short"); + properties.put("format.tensors", "short"); String url = "http://localhost/model-evaluation/v1/vespa_model/"; handler.assertResponse(url + "test_mapped/eval", properties, 200, "{\"type\":\"tensor(d0{})\",\"cells\":{\"a\":1.0,\"b\":2.0}}"); @@ -231,7 +230,7 @@ public class ModelsEvaluationHandlerTest { @Test public void testVespaModelLiteralOutput() { Map<String, String> properties = new HashMap<>(); - properties.put("format", "string"); + properties.put("format.tensors", "string"); String url = "http://localhost/model-evaluation/v1/vespa_model/"; handler.assertResponse(url + "test_mapped/eval", properties, 200, "tensor(d0{}):{a:1.0,b:2.0}"); |