PremalMatalia commited on
Commit
8b5301c
1 Parent(s): a7eff34

Added Usage in Transformers

Browse files
Files changed (1) hide show
  1. README.md +21 -0
README.md CHANGED
@@ -36,4 +36,25 @@ CLS_threshold=-3
36
  "NoAns_exact": 88.174937
37
  "NoAns_f1": 88.174937
38
  "NoAns_total": 5945
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  ```
 
36
  "NoAns_exact": 88.174937
37
  "NoAns_f1": 88.174937
38
  "NoAns_total": 5945
39
+ ```
40
+
41
+ ## Usage
42
+ ### In Transformers
43
+ ```python
44
+ from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
45
+
46
+ model_name = "PremalMatalia/roberta-base-best-squad2"
47
+
48
+ # a) Get predictions
49
+ nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
50
+ QA_input = {
51
+ 'question': 'Which name is also used to describe the Amazon rainforest in English?',
52
+ 'context': 'The Amazon rainforest (Portuguese: Floresta Amazônica or Amazônia; Spanish: Selva Amazónica, Amazonía or usually Amazonia; French: Forêt amazonienne; Dutch: Amazoneregenwoud), also known in English as Amazonia or the Amazon Jungle, is a moist broadleaf forest that covers most of the Amazon basin of South America. This basin encompasses 7,000,000 square kilometres (2,700,000 sq mi), of which 5,500,000 square kilometres (2,100,000 sq mi) are covered by the rainforest. This region includes territory belonging to nine nations. The majority of the forest is contained within Brazil, with 60% of the rainforest, followed by Peru with 13%, Colombia with 10%, and with minor amounts in Venezuela, Ecuador, Bolivia, Guyana, Suriname and French Guiana. States or departments in four nations contain "Amazonas" in their names. The Amazon represents over half of the planet\'s remaining rainforests, and comprises the largest and most biodiverse tract of tropical rainforest in the world, with an estimated 390 billion individual trees divided into 16,000 species.'
53
+ }
54
+ res = nlp(QA_input)
55
+ print(res)
56
+
57
+ # b) Load model & tokenizer
58
+ model = AutoModelForQuestionAnswering.from_pretrained(model_name)
59
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
60
  ```