|
13 | 13 | import com.yahoo.tensor.Tensor;
|
14 | 14 | import com.yahoo.tensor.TensorType;
|
15 | 15 | import com.yahoo.vespa.indexinglanguage.expressions.ExecutionContext;
|
| 16 | +import com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression; |
| 17 | +import com.yahoo.vespa.indexinglanguage.expressions.StatementExpression; |
16 | 18 | import com.yahoo.vespa.indexinglanguage.expressions.VerificationContext;
|
17 | 19 | import com.yahoo.vespa.indexinglanguage.expressions.VerificationException;
|
18 | 20 | import org.junit.Ignore;
|
@@ -374,4 +376,35 @@ public void testIt() {
|
374 | 376 | expression.verify(new VerificationContext(adapter));
|
375 | 377 | }
|
376 | 378 |
|
| 379 | + @Test |
| 380 | + public void binarizeFromSeparateField() { |
| 381 | + /* |
| 382 | + field text_embeddings type tensor<float>(c{},x[768]) { |
| 383 | + indexing: attribute | summary |
| 384 | + attribute: paged |
| 385 | + } |
| 386 | + field text_embeddings_quant_binary type tensor<int8>(c{},x[96]) { |
| 387 | + indexing: input text_embeddings | binarize | pack_bits | attribute | index |
| 388 | + attribute { |
| 389 | + distance-metric: hamming |
| 390 | + } |
| 391 | + } |
| 392 | + */ |
| 393 | + |
| 394 | + var tester = new EmbeddingScriptTester(Map.of("emb1", new EmbeddingScriptTester.MockMappedEmbedder("myDocument.my2DSparseTensor"))); |
| 395 | + |
| 396 | + SimpleTestAdapter adapter = new SimpleTestAdapter(); |
| 397 | + TensorType textEmbeddingsType = TensorType.fromSpec("tensor<float>(c{},x[768])"); |
| 398 | + adapter.createField(new Field("text_embeddings", new TensorDataType(textEmbeddingsType))); |
| 399 | + |
| 400 | + TensorType textEmbeddingsQuantBinaryType = TensorType.fromSpec("tensor<int8>(c{},x[96])"); |
| 401 | + adapter.createField(new Field("text_embeddings_quant_binary", new TensorDataType(textEmbeddingsQuantBinaryType))); |
| 402 | + |
| 403 | + var text_embeddings_expression = (StatementExpression)tester.expressionFrom("input text_embeddings | summary text_embeddings | attribute text_embeddings"); |
| 404 | + var text_embeddings_quant_binary_expression = (StatementExpression)tester.expressionFrom("input text_embeddings | binarize | pack_bits | attribute text_embeddings_quant_binary | index text_embeddings_quant_binary"); |
| 405 | + |
| 406 | + var script = new ScriptExpression(text_embeddings_expression, text_embeddings_quant_binary_expression); |
| 407 | + script.verify(adapter); |
| 408 | + } |
| 409 | + |
377 | 410 | }
|
0 commit comments