Skip to content

Commit

Permalink
revert changes in text embedding and sparse encoding processor
Browse files Browse the repository at this point in the history
Signed-off-by: yuye-aws <[email protected]>
  • Loading branch information
yuye-aws committed Mar 6, 2024
1 parent 0140fc0 commit a2b9f04
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void doExecute(
BiConsumer<IngestDocument, Exception> handler
) {
mlCommonsClientAccessor.inferenceSentencesWithMapResult(this.modelId, inferenceList, ActionListener.wrap(resultMaps -> {
setTargetFieldsToDocument(ingestDocument, ProcessMap, TokenWeightUtil.fetchListOfTokenWeightMap(resultMaps));
setVectorFieldsToDocument(ingestDocument, ProcessMap, TokenWeightUtil.fetchListOfTokenWeightMap(resultMaps));
handler.accept(ingestDocument, null);
}, e -> { handler.accept(null, e); }));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void doExecute(
BiConsumer<IngestDocument, Exception> handler
) {
mlCommonsClientAccessor.inferenceSentences(this.modelId, inferenceList, ActionListener.wrap(vectors -> {
setTargetFieldsToDocument(ingestDocument, ProcessMap, vectors);
setVectorFieldsToDocument(ingestDocument, ProcessMap, vectors);
handler.accept(ingestDocument, null);
}, e -> { handler.accept(null, e); }));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public void testProcessResponse_successful() throws Exception {
Map<String, Object> knnMap = processor.buildMapWithProcessorKeyAndOriginalValue(ingestDocument);

List<List<Float>> modelTensorList = createMockVectorResult();
processor.setTargetFieldsToDocument(ingestDocument, knnMap, modelTensorList);
processor.setVectorFieldsToDocument(ingestDocument, knnMap, modelTensorList);
assertEquals(12, ingestDocument.getSourceAndMetadata().size());
}

Expand All @@ -378,7 +378,7 @@ public void testBuildVectorOutput_withPlainStringValue_successful() {
assertEquals(knnKeyList.get(lastIndex), configValueList.get(lastIndex).toString());

List<List<Float>> modelTensorList = createMockVectorResult();
Map<String, Object> result = processor.buildResult(knnMap, modelTensorList, ingestDocument.getSourceAndMetadata());
Map<String, Object> result = processor.buildNLPResult(knnMap, modelTensorList, ingestDocument.getSourceAndMetadata());
assertTrue(result.containsKey("oriKey1_knn"));
assertTrue(result.containsKey("oriKey2_knn"));
assertTrue(result.containsKey("oriKey3_knn"));
Expand All @@ -395,7 +395,7 @@ public void testBuildVectorOutput_withNestedMap_successful() {
TextEmbeddingProcessor processor = createInstanceWithNestedMapConfiguration(config);
Map<String, Object> knnMap = processor.buildMapWithProcessorKeyAndOriginalValue(ingestDocument);
List<List<Float>> modelTensorList = createMockVectorResult();
processor.buildResult(knnMap, modelTensorList, ingestDocument.getSourceAndMetadata());
processor.buildNLPResult(knnMap, modelTensorList, ingestDocument.getSourceAndMetadata());
Map<String, Object> favoritesMap = (Map<String, Object>) ingestDocument.getSourceAndMetadata().get("favorites");
assertNotNull(favoritesMap);
Map<String, Object> favoriteGames = (Map<String, Object>) favoritesMap.get("favorite.games");
Expand All @@ -411,7 +411,7 @@ public void testBuildVectorOutput_withNestedList_successful() {
TextEmbeddingProcessor textEmbeddingProcessor = createInstanceWithNestedMapConfiguration(config);
Map<String, Object> knnMap = textEmbeddingProcessor.buildMapWithProcessorKeyAndOriginalValue(ingestDocument);
List<List<Float>> modelTensorList = createMockVectorResult();
textEmbeddingProcessor.buildResult(knnMap, modelTensorList, ingestDocument.getSourceAndMetadata());
textEmbeddingProcessor.buildNLPResult(knnMap, modelTensorList, ingestDocument.getSourceAndMetadata());
List<Map<String, Object>> nestedObj = (List<Map<String, Object>>) ingestDocument.getSourceAndMetadata().get("nestedField");
assertTrue(nestedObj.get(0).containsKey("vectorField"));
assertTrue(nestedObj.get(1).containsKey("vectorField"));
Expand All @@ -425,7 +425,7 @@ public void testBuildVectorOutput_withNestedList_Level2_successful() {
TextEmbeddingProcessor textEmbeddingProcessor = createInstanceWithNestedMapConfiguration(config);
Map<String, Object> knnMap = textEmbeddingProcessor.buildMapWithProcessorKeyAndOriginalValue(ingestDocument);
List<List<Float>> modelTensorList = createMockVectorResult();
textEmbeddingProcessor.buildResult(knnMap, modelTensorList, ingestDocument.getSourceAndMetadata());
textEmbeddingProcessor.buildNLPResult(knnMap, modelTensorList, ingestDocument.getSourceAndMetadata());
Map<String, Object> nestedLevel1 = (Map<String, Object>) ingestDocument.getSourceAndMetadata().get("nestedField");
List<Map<String, Object>> nestedObj = (List<Map<String, Object>>) nestedLevel1.get("nestedField");
assertTrue(nestedObj.get(0).containsKey("vectorField"));
Expand All @@ -440,10 +440,10 @@ public void test_updateDocument_appendVectorFieldsToDocument_successful() {
TextEmbeddingProcessor processor = createInstanceWithNestedMapConfiguration(config);
Map<String, Object> knnMap = processor.buildMapWithProcessorKeyAndOriginalValue(ingestDocument);
List<List<Float>> modelTensorList = createMockVectorResult();
processor.setTargetFieldsToDocument(ingestDocument, knnMap, modelTensorList);
processor.setVectorFieldsToDocument(ingestDocument, knnMap, modelTensorList);

List<List<Float>> modelTensorList1 = createMockVectorResult();
processor.setTargetFieldsToDocument(ingestDocument, knnMap, modelTensorList1);
processor.setVectorFieldsToDocument(ingestDocument, knnMap, modelTensorList1);
assertEquals(12, ingestDocument.getSourceAndMetadata().size());
assertEquals(2, ((List<?>) ingestDocument.getSourceAndMetadata().get("oriKey6_knn")).size());
}
Expand Down

0 comments on commit a2b9f04

Please sign in to comment.