--- title: text.data.question_answering keywords: fastai sidebar: home_sidebar summary: "Question/Answering tasks are models that require two text inputs (a context that includes the answer and the question). The objective is to predict the start/end tokens of the answer in the context). This module contains the bits required to use the fastai DataBlock API and/or mid-level data processing pipelines to organize your data for question/answering tasks." description: "Question/Answering tasks are models that require two text inputs (a context that includes the answer and the question). The objective is to predict the start/end tokens of the answer in the context). This module contains the bits required to use the fastai DataBlock API and/or mid-level data processing pipelines to organize your data for question/answering tasks." nb_path: "nbs/14_text-data-question-answering.ipynb" ---
{% raw %}
{% endraw %} {% raw %}
 
{% endraw %} {% raw %}
{% endraw %} {% raw %}
What we're running with at the time this documentation was generated:
torch: 1.10.1+cu111
fastai: 2.5.6
transformers: 4.16.2
{% endraw %}

Setup

We'll use a subset of squad_v2 to demonstrate how to configure your blurr code for extractive question answering

{% raw %}
raw_datasets = load_dataset("squad_v2", split=["train[:1000]", "validation[:200]"])
Reusing dataset squad_v2 (/home/wgilliam/.cache/huggingface/datasets/squad_v2/squad_v2/2.0.0/09187c73c1b837c95d9a249cd97c2c3f1cebada06efe667b4427714b27639b1d)
{% endraw %} {% raw %}
raw_train_ds, raw_valid_ds = raw_datasets[0], raw_datasets[1]
{% endraw %} {% raw %}
raw_train_df = pd.DataFrame(raw_train_ds)
raw_valid_df = pd.DataFrame(raw_valid_ds)

raw_train_df["is_valid"] = False
raw_valid_df["is_valid"] = True

print(len(raw_train_df))
print(len(raw_valid_df))
1000
200
{% endraw %} {% raw %}
raw_train_df.head(2)
id title context question answers is_valid
0 56be85543aeaaa14008c9063 Beyoncé Beyoncé Giselle Knowles-Carter (/biːˈjɒnseɪ/ bee-YON-say) (born September 4, 1981) is an America... When did Beyonce start becoming popular? {'text': ['in the late 1990s'], 'answer_start': [269]} False
1 56be85543aeaaa14008c9065 Beyoncé Beyoncé Giselle Knowles-Carter (/biːˈjɒnseɪ/ bee-YON-say) (born September 4, 1981) is an America... What areas did Beyonce compete in when she was growing up? {'text': ['singing and dancing'], 'answer_start': [207]} False
{% endraw %} {% raw %}
raw_valid_df.head(2)
id title context question answers is_valid
0 56ddde6b9a695914005b9628 Normans The Normans (Norman: Nourmands; French: Normands; Latin: Normanni) were the people who in the 10... In what country is Normandy located? {'text': ['France', 'France', 'France', 'France'], 'answer_start': [159, 159, 159, 159]} True
1 56ddde6b9a695914005b9629 Normans The Normans (Norman: Nourmands; French: Normands; Latin: Normanni) were the people who in the 10... When were the Normans in Normandy? {'text': ['10th and 11th centuries', 'in the 10th and 11th centuries', '10th and 11th centuries'... True
{% endraw %} {% raw %}
squad_df = pd.concat([raw_train_df, raw_valid_df])
len(squad_df)
1200
{% endraw %} {% raw %}
squad_df["ans_start_char_idx"] = squad_df.answers.apply(lambda v: v["answer_start"][0] if len(v["answer_start"]) > 0 else "0")
squad_df["answer_text"] = squad_df.answers.apply(lambda v: v["text"][0] if len(v["text"]) > 0 else "")
squad_df["ans_end_char_idx"] = squad_df["ans_start_char_idx"].astype(int) + squad_df["answer_text"].str.len()

print(len(squad_df))
squad_df[squad_df.is_valid == True].head(2)
1200
id title context question answers is_valid ans_start_char_idx answer_text ans_end_char_idx
0 56ddde6b9a695914005b9628 Normans The Normans (Norman: Nourmands; French: Normands; Latin: Normanni) were the people who in the 10... In what country is Normandy located? {'text': ['France', 'France', 'France', 'France'], 'answer_start': [159, 159, 159, 159]} True 159 France 165
1 56ddde6b9a695914005b9629 Normans The Normans (Norman: Nourmands; French: Normands; Latin: Normanni) were the people who in the 10... When were the Normans in Normandy? {'text': ['10th and 11th centuries', 'in the 10th and 11th centuries', '10th and 11th centuries'... True 94 10th and 11th centuries 117
{% endraw %} {% raw %}
model_cls = AutoModelForQuestionAnswering

pretrained_model_name = "roberta-base"  #'xlm-mlm-ende-1024'
hf_arch, hf_config, hf_tokenizer, hf_model = NLP.get_hf_objects(pretrained_model_name, model_cls=model_cls)

max_seq_len = 128
vocab = dict(enumerate(range(max_seq_len)))
{% endraw %}

Preprocessing

With version 2.0.0 of BLURR, we include a Preprocessor for question answering that can either truncate texts or else chunk long documents into multiple examples.

Note: Unlike other NLP tasks in BLURR, extractive question answering requires preprocessing in order to convert our raw start/end character indices into start/end token indices unless your dataset includes the later. Token indicies, rather than character indices, will be used as our targets and are dependent on your tokenizer of choice.

{% raw %}

class QAPreprocessor[source]

QAPreprocessor(hf_tokenizer:PreTrainedTokenizerBase, batch_size:int=1000, id_attr:Optional[str]=None, ctx_attr:str='context', qst_attr:str='question', ans_attr:str='answer_text', ans_start_char_idx:str='ans_start_char_idx', ans_end_char_idx:str='ans_end_char_idx', is_valid_attr:Optional[str]='is_valid', tok_kwargs:dict={'return_overflowing_tokens': True}) :: Preprocessor

Type Default Details
hf_tokenizer PreTrainedTokenizerBase A Hugging Face tokenizer
batch_size int 1000 The number of examples to process at a time
id_attr typing.Optional[str] None The unique identifier in the dataset. If not specified and "return_overflowing_tokens": True, an "_id" attribute
will be added to your dataset with its value a unique, sequential integer, assigned to each record
ctx_attr str context The attribute in your dataset that contains the context (where the answer is included) (default: 'context')
qst_attr str question The attribute in your dataset that contains the question being asked (default: 'question')
ans_attr str answer_text The attribute in your dataset that contains the actual answer (default: 'answer_text')
ans_start_char_idx str ans_start_char_idx The attribute in your dataset that contains the actual answer (default: 'answer_text')
ans_end_char_idx str ans_end_char_idx The attribute in your dataset that contains the actual answer (default: 'answer_text')
is_valid_attr typing.Optional[str] is_valid The attribute that should be created if your are processing individual training and validation
datasets into a single dataset, and will indicate to which each example is associated
tok_kwargs dict return_overflowing_tokens Tokenization kwargs that will be applied with calling the tokenizer (default: {"return_overflowing_tokens": True})
{% endraw %} {% raw %}
{% endraw %}

How to preprocess your data

{% raw %}
tok_kwargs = {"return_overflowing_tokens": True, "max_length": max_seq_len, "stride": 64}
preprocessor = QAPreprocessor(hf_tokenizer, id_attr="id", tok_kwargs=tok_kwargs)
proc_df = preprocessor.process_df(squad_df)

print(len(proc_df))
proc_df.head(4)
3560
id title context question answers is_valid ans_start_char_idx answer_text ans_end_char_idx proc_question proc_context ans_start_token_idx ans_end_token_idx is_answerable
0 56be85543aeaaa14008c9063 Beyoncé Beyoncé Giselle Knowles-Carter (/biːˈjɒnseɪ/ bee-YON-say) (born September 4, 1981) is an America... When did Beyonce start becoming popular? {'text': ['in the late 1990s'], 'answer_start': [269]} False 269 in the late 1990s 286 When did Beyonce start becoming popular? Beyoncé Giselle Knowles-Carter (/biːˈjɒnseɪ/ bee-YON-say) (born September 4, 1981) is an America... 84 89 True
1 56be85543aeaaa14008c9063 Beyoncé Beyoncé Giselle Knowles-Carter (/biːˈjɒnseɪ/ bee-YON-say) (born September 4, 1981) is an America... When did Beyonce start becoming popular? {'text': ['in the late 1990s'], 'answer_start': [269]} False 269 in the late 1990s 286 When did Beyonce start becoming popular? in Houston, Texas, she performed in various singing and dancing competitions as a child, and ro... 32 37 True
2 56be85543aeaaa14008c9063 Beyoncé Beyoncé Giselle Knowles-Carter (/biːˈjɒnseɪ/ bee-YON-say) (born September 4, 1981) is an America... When did Beyonce start becoming popular? {'text': ['in the late 1990s'], 'answer_start': [269]} False 269 in the late 1990s 286 When did Beyonce start becoming popular? group became one of the world's best-selling girl groups of all time. Their hiatus saw the rele... 0 0 False
3 56be85543aeaaa14008c9065 Beyoncé Beyoncé Giselle Knowles-Carter (/biːˈjɒnseɪ/ bee-YON-say) (born September 4, 1981) is an America... What areas did Beyonce compete in when she was growing up? {'text': ['singing and dancing'], 'answer_start': [207]} False 207 singing and dancing 226 What areas did Beyonce compete in when she was growing up? Beyoncé Giselle Knowles-Carter (/biːˈjɒnseɪ/ bee-YON-say) (born September 4, 1981) is an America... 77 80 True
{% endraw %} {% raw %}
sampled_df = proc_df.sample(n=10)
for row_idx, row in sampled_df.iterrows():
    test_example = row

    inputs = hf_tokenizer(row.proc_question, row.proc_context)

    if test_example.is_answerable:
        # print(test_example.answer_text)
        test_eq(
            test_example.answer_text,
            hf_tokenizer.decode(inputs["input_ids"][test_example.ans_start_token_idx : test_example.ans_end_token_idx]).strip(),
        )
    else:
        test_eq(test_example.ans_start_token_idx, 0)
        test_eq(test_example.ans_end_token_idx, 0)
{% endraw %}

If you want to remove texts longer than your model will hold (and include only answerable contexts)

{% raw %}
preprocessor = QAPreprocessor(hf_tokenizer, tok_kwargs={"return_overflowing_tokens": False, "max_length": max_seq_len})
proc2_df = preprocessor.process_df(squad_df)
proc2_df = proc2_df[(proc2_df.ans_end_token_idx < max_seq_len) & (proc2_df.is_answerable)]

print(len(proc2_df))
proc2_df.head(2)
763
id title context question answers is_valid ans_start_char_idx answer_text ans_end_char_idx proc_question proc_context ans_start_token_idx ans_end_token_idx is_answerable
0 56be85543aeaaa14008c9063 Beyoncé Beyoncé Giselle Knowles-Carter (/biːˈjɒnseɪ/ bee-YON-say) (born September 4, 1981) is an America... When did Beyonce start becoming popular? {'text': ['in the late 1990s'], 'answer_start': [269]} False 269 in the late 1990s 286 When did Beyonce start becoming popular? Beyoncé Giselle Knowles-Carter (/biːˈjɒnseɪ/ bee-YON-say) (born September 4, 1981) is an America... 84 89 True
1 56be85543aeaaa14008c9065 Beyoncé Beyoncé Giselle Knowles-Carter (/biːˈjɒnseɪ/ bee-YON-say) (born September 4, 1981) is an America... What areas did Beyonce compete in when she was growing up? {'text': ['singing and dancing'], 'answer_start': [207]} False 207 singing and dancing 226 What areas did Beyonce compete in when she was growing up? Beyoncé Giselle Knowles-Carter (/biːˈjɒnseɪ/ bee-YON-say) (born September 4, 1981) is an America... 77 80 True
{% endraw %}

Mid-level API

{% raw %}

class QATextInput[source]

QATextInput(x, **kwargs) :: TextInput

The base represenation of your inputs; used by the various fastai show methods

{% endraw %} {% raw %}
{% endraw %} {% raw %}

class QABatchTokenizeTransform[source]

QABatchTokenizeTransform(hf_arch:str, hf_config:PretrainedConfig, hf_tokenizer:PreTrainedTokenizerBase, hf_model:PreTrainedModel, include_labels:bool=True, ignore_token_id=-100, max_length:int=None, padding:Union[bool, str]=True, truncation:Union[bool, str]='only_second', is_split_into_words:bool=False, tok_kwargs:dict={}, **kwargs) :: BatchTokenizeTransform

Handles everything you need to assemble a mini-batch of inputs and targets, as well as decode the dictionary produced as a byproduct of the tokenization process in the encodes method.

Type Default Details
hf_arch str The abbreviation/name of your Hugging Face transformer architecture (e.b., bert, bart, etc..)
hf_config PretrainedConfig A specific configuration instance you want to use
hf_tokenizer PreTrainedTokenizerBase A Hugging Face tokenizer
hf_model PreTrainedModel A Hugging Face model
include_labels bool True To control whether the "labels" are included in your inputs. If they are, the loss will be calculated in
the model's forward function and you can simply use PreCalculatedLoss as your Learner's loss function to use it
ignore_token_id int -100 The token ID that should be ignored when calculating the loss
max_length int None To control the length of the padding/truncation. It can be an integer or None,
in which case it will default to the maximum length the model can accept. If the model has no
specific maximum input length, truncation/padding to max_length is deactivated.
See Everything you always wanted to know about padding and truncation
padding typing.Union[bool, str] True To control the padding applied to your hf_tokenizer during tokenization. If None, will default to
False or `'do_not_pad'.
See Everything you always wanted to know about padding and truncation
truncation typing.Union[bool, str] only_second To control truncation applied to your hf_tokenizer during tokenization. If None, will default to
False or do_not_truncate.
See Everything you always wanted to know about padding and truncation
is_split_into_words bool False The is_split_into_words argument applied to your hf_tokenizer during tokenization. Set this to True
if your inputs are pre-tokenized (not numericalized)
tok_kwargs dict None Any other keyword arguments you want included when using your hf_tokenizer to tokenize your inputs.
kwargs No Content
{% endraw %} {% raw %}
{% endraw %}

Examples

The following eamples demonstrate several approaches to construct your DataBlock for question answering tasks using the mid-level API

Using the mid-level API

Batch-Time Tokenization

Step 1: Get your Hugging Face objects
{% raw %}
pretrained_model_name = "distilroberta-base"
hf_arch, hf_config, hf_tokenizer, hf_model = NLP.get_hf_objects(pretrained_model_name, model_cls=AutoModelForQuestionAnswering)

max_seq_len = 128
vocab = dict(enumerate(range(max_seq_len)))
{% endraw %}
Step 2: Preprocess dataset
{% raw %}
tok_kwargs = {"return_overflowing_tokens": True, "max_length": max_seq_len, "stride": 24}
preprocessor = QAPreprocessor(hf_tokenizer, id_attr="id", tok_kwargs=tok_kwargs)
proc_df = preprocessor.process_df(squad_df)

proc_df.head(1)
id title context question answers is_valid ans_start_char_idx answer_text ans_end_char_idx proc_question proc_context ans_start_token_idx ans_end_token_idx is_answerable
0 56be85543aeaaa14008c9063 Beyoncé Beyoncé Giselle Knowles-Carter (/biːˈjɒnseɪ/ bee-YON-say) (born September 4, 1981) is an America... When did Beyonce start becoming popular? {'text': ['in the late 1990s'], 'answer_start': [269]} False 269 in the late 1990s 286 When did Beyonce start becoming popular? Beyoncé Giselle Knowles-Carter (/biːˈjɒnseɪ/ bee-YON-say) (born September 4, 1981) is an America... 84 89 True
{% endraw %}
Step 3: Create your DataBlock
{% raw %}
before_batch_tfm = QABatchTokenizeTransform(hf_arch, hf_config, hf_tokenizer, hf_model, max_length=max_seq_len)

blocks = (
    TextBlock(batch_tokenize_tfm=before_batch_tfm, input_return_type=QATextInput),
    CategoryBlock(vocab=vocab),
    CategoryBlock(vocab=vocab),
)

dblock = DataBlock(
    blocks=blocks,
    get_x=lambda x: (x.proc_question, x.proc_context),
    get_y=[ColReader("ans_start_token_idx"), ColReader("ans_end_token_idx")],
    splitter=ColSplitter(),
    n_inp=1,
)
{% endraw %}
Step 4: Build your DataLoaders
{% raw %}
dls = dblock.dataloaders(proc_df, bs=4)
len(dls.train), len(dls.valid)
(590, 94)
{% endraw %} {% raw %}
b = dls.one_batch()
len(b), len(b[0]), len(b[1]), len(b[2])
(3, 8, 4, 4)
{% endraw %} {% raw %}
b[0]["input_ids"].shape, b[0]["attention_mask"].shape, b[1].shape, b[2].shape
(torch.Size([4, 128]), torch.Size([4, 128]), torch.Size([4]), torch.Size([4]))
{% endraw %} {% raw %}
b[0]["start_positions"], b[0]["end_positions"]
(TensorCategory([ 0, 38,  0, 21], device='cuda:1'),
 TensorCategory([ 0, 46,  0, 23], device='cuda:1'))
{% endraw %} {% raw %}
{% endraw %}

The show_batch method above allows us to create a more interpretable view of our question/answer data.

{% raw %}
dls.show_batch(dataloaders=dls, max_n=4)
text found start/end answer
0 Beyonce has been awarded how many Grammy nominations? ously in Love, B'Day and I Am... Sasha Fierce have all won Best Contemporary R&B Album. Beyoncé set the record for the most Grammy awards won by a female artist in one night in 2010 when she won six awards, breaking the tie she previously held with Alicia Keys, Norah Jones, Alison Krauss, and Amy Winehouse, with Adele equaling this in 2012. Following her role in Dreamgirls she was nominated for Best Original Song for "Listen" and Best Actress at the Golden Globe Awards, and Outstanding Actress False (0, 0)
1 In 2012 who placed Beyonce at 16 in the Celebrity List? cé and Jay Z placed at number one on the "World's Highest-Paid Celebrity Couples", for collectively earning $78 million. The couple made it into the previous year's Guinness World Records as the "highest-earning power couple" for collectively earning $122 million in 2009. For the years 2009 to 2011, Beyoncé earned an average of $70 million per year, and earned $40 million in 2012. In 2013, Beyoncé's endorsements of Pepsi and H&M made her and Jay Z the world's first billion dollar False (0, 0)
2 What is the lead single on Beyoncé's first album?, and has since sold 11 million copies worldwide. The album's lead single, "Crazy in Love", featuring Jay Z, became Beyoncé's first number-one single as a solo artist in the US. The single "Baby Boy" also reached number one, and singles, "Me, Myself and I" and "Naughty Girl", both reached the top-five. The album earned Beyoncé a then record-tying five awards at the 46th Annual Grammy Awards; Best Contemporary R&B Album, Best Female R&B V False (0, 0)
3 What did the person who Chopin went with to Berlin do for his work? In September 1828 Chopin, while still a student, visited Berlin with a family friend, zoologist Feliks Jarocki, enjoying operas directed by Gaspare Spontini and attending concerts by Carl Friedrich Zelter, Felix Mendelssohn and other celebrities. On an 1829 return trip to Berlin, he was a guest of Prince Antoni Radziwiłł, governor of the Grand Duchy of Posen—himself an accomplished composer and aspiring cellist. For the prince and his pian True (38, 40) zoologist
{% endraw %}

Passing extra information

As mentioned in the data.core module documentation, BLURR now also allows you to pass extra information alongside your inputs in the form of a dictionary. If we are splitting long documents into chunks but want to predict/aggregation by example (rather than by chunk), we'll need to include a unique identifier for each example. When we look at modeling.question_answer module, we'll see how the question answering bits can use such an Id for this purpose.

Step 1: Get your Hugging Face objects
{% raw %}
pretrained_model_name = "bert-large-uncased-whole-word-masking-finetuned-squad"
hf_arch, hf_config, hf_tokenizer, hf_model = NLP.get_hf_objects(pretrained_model_name, model_cls=AutoModelForQuestionAnswering)

max_seq_len = 128
vocab = dict(enumerate(range(max_seq_len)))
{% endraw %}
Step 2: Preprocess dataset
{% raw %}
preprocessor = QAPreprocessor(
    hf_tokenizer, id_attr="id", tok_kwargs={"return_overflowing_tokens": True, "max_length": max_seq_len, "stride": 64}
)

proc_df = preprocessor.process_df(squad_df)
proc_df.head(1)
id title context question answers is_valid ans_start_char_idx answer_text ans_end_char_idx proc_question proc_context ans_start_token_idx ans_end_token_idx is_answerable
0 56be85543aeaaa14008c9063 Beyoncé Beyoncé Giselle Knowles-Carter (/biːˈjɒnseɪ/ bee-YON-say) (born September 4, 1981) is an America... When did Beyonce start becoming popular? {'text': ['in the late 1990s'], 'answer_start': [269]} False 269 in the late 1990s 286 When did Beyonce start becoming popular? Beyoncé Giselle Knowles-Carter (/biːˈjɒnseɪ/ bee-YON-say) (born September 4, 1981) is an America... 75 79 True
{% endraw %}
Step 2: Create your DataBlock
{% raw %}
before_batch_tfm = QABatchTokenizeTransform(hf_arch, hf_config, hf_tokenizer, hf_model, max_length=max_seq_len)

blocks = (
    TextBlock(batch_tokenize_tfm=before_batch_tfm, input_return_type=QATextInput),
    CategoryBlock(vocab=vocab),
    CategoryBlock(vocab=vocab),
)

# since its preprocessed, we include an "text" key with the values of our question and context
def get_x(item):
    return {"text": (item.proc_question, item.proc_context), "id": item.id}


dblock = DataBlock(
    blocks=blocks,
    get_x=get_x,
    get_y=[ItemGetter("ans_start_token_idx"), ItemGetter("ans_end_token_idx")],
    splitter=ColSplitter(),
    n_inp=1,
)
{% endraw %}
Step 3: Build your DataLoaders
{% raw %}
dls = dblock.dataloaders(proc_df, bs=4)
len(dls.train), len(dls.valid)
(733, 108)
{% endraw %} {% raw %}
b = dls.one_batch()
len(b), len(b[0]), len(b[1]), len(b[2])
(3, 10, 4, 4)
{% endraw %} {% raw %}
b[0].keys()
dict_keys(['input_ids', 'token_type_ids', 'attention_mask', 'special_tokens_mask', 'offset_mapping', 'id', 'cls_index', 'p_mask', 'start_positions', 'end_positions'])
{% endraw %} {% raw %}
b[0]["input_ids"].shape, b[0]["attention_mask"].shape, b[1].shape, b[2].shape
(torch.Size([4, 128]), torch.Size([4, 128]), torch.Size([4]), torch.Size([4]))
{% endraw %}

We can see that any additional data is now located in the inputs dictionary

{% raw %}
b[0]["id"]
['56be8bab3aeaaa14008c90a1',
 '56d1ca30e7d4791d009021a7',
 '56d313b559d6e41400146211',
 '56d4e8512ccc5a1400d83327']
{% endraw %} {% raw %}
dls.show_batch(dataloaders=dls, max_n=4)
text found start/end answer
0 who was the first record label to give the girls a record deal? ped and danced on the talent show circuit in houston. after seeing the group, r & b producer arne frager brought them to his northern california studio and placed them in star search, the largest talent show on national tv at the time. girl's tyme failed to win, and beyonce later said the song they performed was not good. in 1995 beyonce's father resigned from his job to manage the group. the move reduced beyonce's family's income by half, and her parents were forced to move into separated apartments. mathew False (0, 0)
1 who filed a lawsuit over survivor? the 19th century opera carmen by french composer georges bizet. when the third album survivor was released in may 2001, luckett and roberson filed a lawsuit claiming that the songs were aimed at them. the album debuted at number one on the u. s. billboard 200, with first - week sales of 663, 000 copies sold. the album spawned other number - one hits, " bootylicious " and the title track, " survivor ", the latter of which earned the group a grammy award for best r & b performance by a duo or group with vocals. after True (33, 38) luckett and roberson
2 who released the single girls love beyonce? of jazz hands, was credited by the toronto star as having started the " first major dance craze of both the new millennium and the internet ", triggering a number of parodies of the dance choreography and a legion of amateur imitators on youtube. in 2013, drake released a single titled " girls love beyonce ", which featured an interpolation from destiny child's " say my name " and discussed his relationship with women. in january 2012, research scientist bryan lessard named scaptia beyonceae, a species of horse fly found in northern queensland, australia after True (65, 66) drake
3 which song did beyonce sing to win a competition at age 7? beyonce attended st. mary's elementary school in fredericksburg, texas, where she enrolled in dance classes. her singing talent was discovered when dance instructor darlette johnson began humming a song and she finished it, able to hit the high - pitched notes. beyonce's interest in music and performing continued after winning a school talent show at age seven, singing john lennon's " imagine " to beat 15 / 16 - year - olds. in fall of 1990, beyonce enrolled in parker elementary school, a music magnet school in houston, where she would perform with True (91, 92) imagine
{% endraw %}