REST API new user question

Trying to get BERT QA working via REST API. Suggestions? Got basic container running with docs endpoint. Trying to do:

from deeppavlov import build_model, configs

model_qa = build_model(configs.squad.squad_bert, download=True)
model_qa(["School holidays were spent at home."],
         ["Where were school holidays spent?"])

Did this:

docker run -e CONFIG=ner_ontonotes_bert_mult -p 5555:5000 -v dockerComponents -v venv deeppavlov/base-cpu

Runs fine on my macbook. Trying to connect to REST rather than in python.

Thanks…Joel

To use BERT-based question answering (QA) via a REST API with DeepPavlov, you’ll need to set up a server that can handle API requests for QA tasks. Here’s how you can do it:

Install DeepPavlov on your server: Ensure you have DeepPavlov installed on your server where you want to run the REST API. You can use Docker as you mentioned or install DeepPavlov manually.

Configuration: Make sure you have the appropriate model configuration file for BERT-based QA. You can use the squad_bert configuration as you mentioned in your Python code.

Run the REST API server: To run the REST API server, use the following command:
docker run -e CONFIG=configs.squad.squad_bert -p 5555:5000 deepmipt/odqa

This command should start a server with the DeepPavlov QA model exposed via REST API on port 5555.

Make API Requests: You can now make API requests to the running server from your local machine or any other device. Here’s an example using curl to make a POST request:
curl -X POST -H “Content-Type: application/json” -d ‘{
“context”: “School holidays were spent at home.”,
“questions”: [“Where were school holidays spent?”]
}’ http://your-server-ip:5555/answer

Replace http:// your-server-ip:5555 with the actual IP address or hostname of your server where the DeepPavlov REST API is running.

Receive the Response: You will receive a JSON response with the answer to your question. You can parse the response to extract the answer.
That’s it! You should now have BERT-based question answering working via a REST API. Ensure that your server is accessible from the machine where you are making the API requests and that the necessary ports are open and accessible.