How to Get Started with the distilbert-base-cased-distilled-finqa
Here is how to use this model in PyTorch:
from transformers import DistilBertTokenizer, DistilBertModel
import torch
tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-cased-distilled-finqa')
model = DistilBertModel.from_pretrained('distilbert-base-cased-distilled-finqa')
question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"
inputs = tokenizer(question, text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
print(outputs)
And in TensorFlow:
from transformers import DistilBertTokenizer, TFDistilBertForQuestionAnswering
import tensorflow as tf
tokenizer = DistilBertTokenizer.from_pretrained("distilbert-base-cased-distilled-finqa")
model = TFDistilBertForQuestionAnswering.from_pretrained("distilbert-base-cased-distilled-finqa")
question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"
inputs = tokenizer(question, text, return_tensors="tf")
outputs = model(**inputs)
answer_start_index = int(tf.math.argmax(outputs.start_logits, axis=-1)[0])
answer_end_index = int(tf.math.argmax(outputs.end_logits, axis=-1)[0])
predict_answer_tokens = inputs.input_ids[0, answer_start_index : answer_end_index + 1]
tokenizer.decode(predict_answer_tokens)
- Downloads last month
- 6
Datasets used to train tim001/distilbert-base-cased-distilled-finqa
Evaluation results
- Exact Match on finacial question answer data + squadvalidation set self-reported79.600
- F1 on finacial question answer data + squadvalidation set self-reported86.996