Categories

## Question Answering using BERT

Final
In [ ]:
!pip install simpletransformers

In [ ]:
from simpletransformers.question_answering import QuestionAnsweringModel, QuestionAnsweringArgs

In [ ]:
context_text = "After being relatively inactive since 2014, the Hunga Tonga volcano erupted on 20 December 2021, sending particulates into the stratosphere.
A large plume of ash was visible from Nukuʻalofa, the capital city of Tonga, about 70 km (45 mi) from the volcano. The Volcanic Ash Advisory Center (VAAC) in Wellington, New Zealand, issued an advisory notice to airlines.
The eruption was heard more than 2,000 kilometres (1,200 mi) away in New Zealand, where the sound arrived two hours later.
This initial eruption ended at 02:00 on 21 December 2021. Volcanic activity continued, and on 25 December 2021, the island had increased in size on satellite imagery.
As activity on the island decreased, it was declared dormant on 11 January 2022."

predictions, raw_outputs = model.predict(
[
{
"context": context_text,
"qas": [
{
"question": "When did the initial eruption end?",
"id": "0",
}
],
}
]
)

In [6]:
predictions[0]

Out[6]:
{'answer': ['initial eruption ended at 02:00 on 21 December 2021.',
'02:00 on 21 December 2021.',
'initial eruption ended at 02:00',
'02:00',
'21 December 2021.',
'at 02:00 on 21 December 2021.',
'at 02:00',
'ended at 02:00 on 21 December 2021.',
'eruption ended at 02:00 on 21 December 2021.',
'ended at 02:00',
'eruption ended at 02:00',
'later.This initial eruption ended at 02:00 on 21 December 2021.',
'later.This initial eruption ended at 02:00',
'2021, sending particulates into the stratosphere.A large plume of ash was visible from Nukuʻalofa, the capital city of Tonga, about 70 km (45 mi) from the volcano. The Volcanic Ash Advisory Center (VAAC) in Wellington, New Zealand, issued an advisory notice to airlines. The eruption was heard more than 2,000 kilometres (1,200 mi) away in New Zealand, where the sound arrived two hours later.This initial eruption ended at 02:00',
'initial eruption ended',
'2021.',
'on 21 December 2021.',
'2021',
'20 December 2021, sending particulates into the stratosphere.A large plume of ash was visible from Nukuʻalofa, the capital city of Tonga, about 70 km (45 mi) from the volcano. The Volcanic Ash Advisory Center (VAAC) in Wellington, New Zealand, issued an advisory notice to airlines. The eruption was heard more than 2,000 kilometres (1,200 mi) away in New Zealand, where the sound arrived two hours later.This initial eruption ended at 02:00',
'eruption was heard more than 2,000 kilometres (1,200 mi) away in New Zealand, where the sound arrived two hours later.This initial eruption ended at 02:00 on 21 December 2021.'],
'id': '0'}
In [9]:
predictions[0]["answer"][0]

Out[9]:
'initial eruption ended at 02:00 on 21 December 2021.'
Categories

## The fundamental issue in determining entity level causality

Let $Y_i(t)$ denote the outcome, where $i$ denotes the entity being examined (for instance, the individual) and $t$ denotes the treatment. Individual Treatment Effect (ITE) is then defined as the difference in the outcome between the two scenarios: with treatment and without treatment. Mathematically, it is represented as $f(x)$.

However, there is a fundamental problem with such a computation. Typically, we cannot have both the treatment and control (no treatment) condition done on the same subject. For instance, if we are interested in understanding the impact of sunlight on skin acne, we can allocate an individual to just one condition: either treatment (exposure to sunlight) or control (no exposure to sunlight). As such, an entity level (individual) treatment effect cannot be computed. Instead, the approach commonly used adopts an average perspective across multiple individuals to calculate the average treatment effect (ATE).

The third (in)equation above, $ATE ≠ \mathbb{E}[Y|T=1]-\mathbb{E}[Y|T=0]$, stems from the rationale that association does not imply causation.