Skip to content

Instantly share code, notes, and snippets.

@MLWhiz
Created May 16, 2021 20:04
Show Gist options
  • Save MLWhiz/3ec648fd270d724cfaa819dfa8b22476 to your computer and use it in GitHub Desktop.
Save MLWhiz/3ec648fd270d724cfaa819dfa8b22476 to your computer and use it in GitHub Desktop.
datasets = load_dataset("squad")
def visualize(datasets, datatype = 'train', n_questions=10):
n = len(datasets[datatype])
random_questions=random.choices(list(range(n)),k=n_questions)
for i in random_questions:
print(f"Context:{datasets[datatype][i]['context']}")
print(f"Question:{datasets[datatype][i]['question']}")
print(f"Answer:{datasets[datatype][i]['answers']['text']}")
print(f"Answer Start in Text:{datasets[datatype][i]['answers']['answer_start']}")
print("-"*100)
visualize(datasets)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment