-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: batch transform update for sagemaker reranker integration (#6145)
Co-authored-by: Joan Martinez <[email protected]>
- Loading branch information
Showing
12 changed files
with
447 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
tests/integration/docarray_v2/sagemaker/SampleRerankerExecutor/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# SampleRerankerExecutor | ||
|
8 changes: 8 additions & 0 deletions
8
tests/integration/docarray_v2/sagemaker/SampleRerankerExecutor/config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
jtype: SampleRerankerExecutor | ||
py_modules: | ||
- executor.py | ||
metas: | ||
name: SampleRerankerExecutor | ||
description: | ||
url: | ||
keywords: [] |
53 changes: 53 additions & 0 deletions
53
tests/integration/docarray_v2/sagemaker/SampleRerankerExecutor/executor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from docarray import BaseDoc, DocList | ||
from pydantic import Field | ||
from typing import Union, Optional, List | ||
from jina import Executor, requests | ||
|
||
|
||
class TextDoc(BaseDoc): | ||
text: str = Field(description="The text of the document", default="") | ||
|
||
|
||
class RerankerInput(BaseDoc): | ||
query: Union[str, TextDoc] | ||
|
||
documents: List[TextDoc] | ||
|
||
top_n: Optional[int] | ||
|
||
|
||
class RankedObjectOutput(BaseDoc): | ||
index: int | ||
document: Optional[TextDoc] | ||
|
||
relevance_score: float | ||
|
||
|
||
class RankedOutput(BaseDoc): | ||
results: DocList[RankedObjectOutput] | ||
|
||
|
||
class SampleRerankerExecutor(Executor): | ||
@requests(on="/rerank") | ||
def foo(self, docs: DocList[RerankerInput], **kwargs) -> DocList[RankedOutput]: | ||
ret = [] | ||
for doc in docs: | ||
ret.append( | ||
RankedOutput( | ||
results=[ | ||
RankedObjectOutput( | ||
id=doc.id, | ||
index=0, | ||
document=TextDoc(text="first result"), | ||
relevance_score=-1, | ||
), | ||
RankedObjectOutput( | ||
id=doc.id, | ||
index=1, | ||
document=TextDoc(text="second result"), | ||
relevance_score=-2, | ||
), | ||
] | ||
) | ||
) | ||
return DocList[RankedOutput](ret) |
Empty file.
Oops, something went wrong.