bloomsburyai/question-generation

Example usage for /api/generate_batch

Closed this issue · 2 comments

Can you please provide an example query for generate_batch?

Thank you.

I think this should do the trick:

{
  'queries': [
    ['This is document 1', 'document 1', 8],
    ['This is document 2', '2', 17],
    ....
  ]
}

The relevant part of the api is here - you could probably refactor this to be less awful if you wanted! Basically ctxts, ans, ans_pos are all lists of documents, answers, and answer character offsets.

perfect thanks, to anyone else looking for a quick minimal code

import requests

data = {"queries": [
    ["The Normans were the people who in the 10th and 11th centuries gave their name to Normandy, a region in France.", "Normans", 4],
]}

r = requests.post("http://<IP>:5004/api/generate_batch", json=data)
print(r.json())
>>> {'status': 'OK', 'results': [{'q': "what were the people who 's name to normandy ? &lt;/Sent&gt;", 'a': 'Normans'}]}