Skip to content

Instantly share code, notes, and snippets.

@caleb-kaiser
Last active June 15, 2020 08:45
Show Gist options
  • Select an option

  • Save caleb-kaiser/f6f86c20900df7ca3b6e4ec4d912b0fc to your computer and use it in GitHub Desktop.

Select an option

Save caleb-kaiser/f6f86c20900df7ca3b6e4ec4d912b0fc to your computer and use it in GitHub Desktop.
from allennlp.predictors.predictor import Predictor as AllenNLPPredictor
class Predictor:
def __init__(self, config):
self.predictor = AllenNLPPredictor.from_path(
"https://storage.googleapis.com/allennlp-public-models/bidaf-elmo-model-2018.11.30-charpad.tar.gz"
)
def predict(self, payload):
prediction = self.predictor.predict(
passage=payload["passage"], question=payload["question"]
)
return prediction["best_span_str"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment