Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Multimodal semantic search feature #359

Conversation

martin-gaievski
Copy link
Member

@martin-gaievski martin-gaievski commented Sep 29, 2023

Description

Adding support for multimodal search.

This PR covers phase 1 of the implementation that is a simplified version that supports only models with text and image (text, image or both).
Main parts involved:

  • data ingestion. new ingestion processor created for getting embeddings for documents during ingestion. Interface is:
{
  "description": "An example neural search pipeline",
  "processors" : [
    {
      "text-image-embedding": {
        "model_id": "model1234567",
        "embedding": "multimodal_embedding"
        "field_map": {
            "text": "my_text_field", 
            "image": "my_image_field" 
        }
      }
    }
  ]
} 
  • search query. existing neural-search query enhanced by adding keyword for base64 encoded image. New interface looks like this:
{
  "query": {
        "neural": {
              "passage_vector": { 
                  "query_text": "Hello world", 
                  "query_image": "base64forimage_1234567890",
                  "model_id": "xzy76xswsd",
                  "k": 100
                }
           }
        }
    }
}

That is done in 2.x to be in sync with ml-commons that are also doings changes, and to be align better with 2.11 release that is coming soon. It will be upported to main later.

Issues Resolved

#318
#362

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed as per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@martin-gaievski martin-gaievski added Features Introduces a new unit of functionality that satisfies a requirement v2.11.0 Issues targeting release v2.11.0 labels Sep 29, 2023
@martin-gaievski martin-gaievski force-pushed the feature/multimodal_semantic_search branch from 8811b48 to 2192bb5 Compare September 29, 2023 04:35
@codecov
Copy link

codecov bot commented Sep 29, 2023

Codecov Report

Merging #359 (fd8b1fd) into 2.x (8d749b8) will increase coverage by 0.18%.
The diff coverage is 82.66%.

@@             Coverage Diff              @@
##                2.x     #359      +/-   ##
============================================
+ Coverage     80.51%   80.69%   +0.18%     
- Complexity      447      496      +49     
============================================
  Files            39       41       +2     
  Lines          1411     1554     +143     
  Branches        210      237      +27     
============================================
+ Hits           1136     1254     +118     
- Misses          187      200      +13     
- Partials         88      100      +12     
Files Coverage Δ
...g/opensearch/neuralsearch/plugin/NeuralSearch.java 72.72% <100.00%> (+1.29%) ⬆️
...rch/neuralsearch/processor/InferenceProcessor.java 92.71% <100.00%> (ø)
...ocessor/factory/TextEmbeddingProcessorFactory.java 100.00% <100.00%> (ø)
...or/factory/TextImageEmbeddingProcessorFactory.java 100.00% <100.00%> (ø)
...earch/neuralsearch/ml/MLCommonsClientAccessor.java 94.28% <93.10%> (-0.59%) ⬇️
...nsearch/neuralsearch/query/NeuralQueryBuilder.java 88.88% <83.33%> (ø)
...lsearch/processor/TextImageEmbeddingProcessor.java 78.43% <78.43%> (ø)

@navneet1v
Copy link
Collaborator

@martin-gaievski Haven't reviewed the code completely. Will try to do it by tonight

@navneet1v
Copy link
Collaborator

@martin-gaievski overall code looks good to me. Lets make sure that we add enough tests to make the github action pass.

This file seems missing UTs. TextImageEmbeddingProcessor

@martin-gaievski
Copy link
Member Author

@martin-gaievski overall code looks good to me. Lets make sure that we add enough tests to make the github action pass.

This file seems missing UTs. TextImageEmbeddingProcessor

Sure, let me work backwards from the unit test coverage report

@martin-gaievski martin-gaievski force-pushed the feature/multimodal_semantic_search branch from 768a024 to b3bf6b4 Compare October 3, 2023 17:00
@martin-gaievski martin-gaievski force-pushed the feature/multimodal_semantic_search branch from b3bf6b4 to 21f356b Compare October 3, 2023 17:49
@navneet1v navneet1v self-requested a review October 3, 2023 19:24
import com.google.common.collect.ImmutableList;

/**
* Testing text_and_image_embedding ingest processor. We can only test text in integ tests, none of pre-built models
Copy link
Member

@jmazanec15 jmazanec15 Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are we confirming that this works with images if we dont have model? Has offline testing been done?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have tested that offline by setting up one of BedRock titan models and registering it using remote connector feature in ml-commons.

@martin-gaievski martin-gaievski merged commit 841f280 into opensearch-project:2.x Oct 3, 2023
14 checks passed
martin-gaievski added a commit to martin-gaievski/neural-search that referenced this pull request Oct 11, 2023
* Adding inference processor and factory, register that in plugin class

Signed-off-by: Martin Gaievski <[email protected]>
(cherry picked from commit 841f280)
martin-gaievski added a commit to martin-gaievski/neural-search that referenced this pull request Oct 11, 2023
* Adding inference processor and factory, register that in plugin class

Signed-off-by: Martin Gaievski <[email protected]>
(cherry picked from commit 841f280)
martin-gaievski added a commit that referenced this pull request Oct 11, 2023
* Added Multimodal semantic search feature (#359)

Signed-off-by: Martin Gaievski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Features Introduces a new unit of functionality that satisfies a requirement v2.11.0 Issues targeting release v2.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants