abarbosa commited on
Commit
12dbdb8
1 Parent(s): 4c87f25

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +21 -9
README.md CHANGED
@@ -16,23 +16,35 @@ This model is a fine-tuned model of Roberta-large applied on RACE
16
 
17
  #### How to use
18
 
19
- ```pythonimport datasets
20
- from transformers import RobertaTokenizer, RobertaForMultipleChoice
21
- tokenizer = RobertaTokenizer.from_pretrained('LIAMF-USP/roberta-large-finetuned-race')
22
- model = RobertaForMultipleChoice.from_pretrained("LIAMF-USP/roberta-large-finetuned-race")
 
 
 
 
 
 
23
  dataset = datasets.load_dataset(
24
  "race",
25
  "all",
26
  split=["train", "validation", "test"],
27
  )training_examples = dataset[0]
28
  evaluation_examples = dataset[1]
29
- test_examples = dataset[2]example=training_examples[0] example_id = example["example_id"]question = example["question"]
 
 
 
 
30
  context = example["article"]
31
  options = example["options"]
32
  label_example = example["answer"]
33
- label_map = {label: i for i, label in enumerate(["A", "B", "C", "D"])}
 
34
  choices_inputs = []
35
- for ending_idx, (_, ending) in enumerate(zip(context, options)):
 
36
  if question.find("_") != -1:
37
  # fill in the banks questions
38
  question_option = question.replace("_", ending)
@@ -51,8 +63,8 @@ label = label_map[label_example]
51
  input_ids = [x["input_ids"] for x in choices_inputs]
52
  attention_mask = (
53
  [x["attention_mask"] for x in choices_inputs]
54
- # as the senteces follow the same structure, just one of them is
55
- # necessary to check
56
  if "attention_mask" in choices_inputs[0]
57
  else None
58
  )
 
16
 
17
  #### How to use
18
 
19
+ ```python
20
+
21
+ import datasets
22
+ from transformers import RobertaTokenizer
23
+ from transformers import RobertaForMultipleChoice
24
+
25
+ tokenizer = RobertaTokenizer.from_pretrained(
26
+ 'LIAMF-USP/roberta-large-finetuned-race')
27
+ model = RobertaForMultipleChoice.from_pretrained(
28
+ "LIAMF-USP/roberta-large-finetuned-race")
29
  dataset = datasets.load_dataset(
30
  "race",
31
  "all",
32
  split=["train", "validation", "test"],
33
  )training_examples = dataset[0]
34
  evaluation_examples = dataset[1]
35
+ test_examples = dataset[2]
36
+
37
+ example=training_examples[0]
38
+ example_id = example["example_id"]
39
+ question = example["question"]
40
  context = example["article"]
41
  options = example["options"]
42
  label_example = example["answer"]
43
+ label_map = {label: i
44
+ for i, label in enumerate(["A", "B", "C", "D"])}
45
  choices_inputs = []
46
+ for ending_idx, (_, ending) in enumerate(
47
+ zip(context, options)):
48
  if question.find("_") != -1:
49
  # fill in the banks questions
50
  question_option = question.replace("_", ending)
 
63
  input_ids = [x["input_ids"] for x in choices_inputs]
64
  attention_mask = (
65
  [x["attention_mask"] for x in choices_inputs]
66
+ # as the senteces follow the same structure,
67
+ #just one of them is necessary to check
68
  if "attention_mask" in choices_inputs[0]
69
  else None
70
  )