aws / aws/amazon-sagemaker-examples
BatchTransform Seq2Seq example "Unable to evaluate payload provided"
- Dominant language
- Jupyter Notebook
- Stars
- 11k
- Forks
- 7k
- Avg merge
- 8h 29m
- Merged PRs (30d)
- 8
Description
## Issue Description
The [Seq2Seq example notebook](https://github.com/awslabs/amazon-sagemaker-examples/blob/master/introduction_to_amazon_algorithms/seq2seq_translation_en-de/SageMaker-Seq2Seq-Translation-English-German.ipynb) has the following step
"Using Protobuf format for inference (Suggested for efficient bulk inference)"
with the following snippet
```
# Convert strings to integers using source vocab mapping. Out-of-vocabulary strings are mapped to 1 - the mapping for
sentences = [[source.get(token, 1) for token in sentence.split()] for sentence in sentences]
f = io.BytesIO()
for sentence in sentences:
record = list_to_record_bytes(sentence, [])
write_recordio(f, record)
response = runtime.invoke_endpoint(EndpointName=endpoint_name,
ContentType='application/x-recordio-protobuf',
Body=f.getvalue())
response = response["Body"].read()
```
However, when I try running it, I get an error with the message
`"ERROR:root:Unable to evaluate payload provided"`
## Details
In the cloud watch log stream, I see the following additional details in the trace:
```
Traceback (most recent call last):
File "/opt/amazon/lib/python3.4/site-packages/seq2seq/serve.py", line 246, in invocations
response_payload, mimetype = ScoringService.render_output(content_type, cur_translator, payload)
File "/opt/amazon/lib/python3.4/site-packages/seq2seq/serve.py", line 155, in render_output
return parse_proto_request(model, payload)
File "/opt/amazon/lib/python3.4/site-packages/seq2seq/serve.py", line 344, in parse_proto_request
target_sentences = _recordio_protobuf_encoder(_translate_proto_file(translator, output_file))
File "/opt/amazon/lib/python3.4/site-packages/seq2seq/serve.py", line 313, in _recordio_protobuf_encoder
for results in data:
```
On further investigation, I found that in [the doc for Seq2Seq](https://docs.aws.amazon.com/sagemaker/latest/dg/seq-2-seq.html), it is mentioned
that
```For batch transform, inference supports JSON Lines format. Batch transform expects the input in JSON Lines format and returns the output in JSON Lines format. Both content and accept types should be application/jsonlines. The format for input is as follows:```
And I noticed that in the example notebook the step used `ContentType='application/x-recordio-protobuf` for Batch transform.
Am I missing something? Or should the example notebook be updated to use content type `application/jsonlines`?
Thanks!
Contributor guide
Assessment
This issue has not been assessed yet.