Update README.md
Browse files
README.md
CHANGED
@@ -14,4 +14,43 @@ co2_eq_emissions: 39.76330395590446
|
|
14 |
# Model Trained Using AutoNLP
|
15 |
|
16 |
- Problem type: Extractive Question Answering
|
17 |
-
- CO2 Emissions (in grams): 39.76330395590446
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
# Model Trained Using AutoNLP
|
15 |
|
16 |
- Problem type: Extractive Question Answering
|
17 |
+
- CO2 Emissions (in grams): 39.76330395590446
|
18 |
+
|
19 |
+
|
20 |
+
## Usage
|
21 |
+
|
22 |
+
You can use cURL to access this model:
|
23 |
+
|
24 |
+
```
|
25 |
+
$ curl -X POST -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{"question": "Who loves AutoNLP?", "context": "Everyone loves AutoNLP"}' https://api-inference.huggingface.co/models/abhishek/autonlp-hindi-question-answering-23865268
|
26 |
+
```
|
27 |
+
|
28 |
+
Or Python API:
|
29 |
+
|
30 |
+
```
|
31 |
+
import torch
|
32 |
+
|
33 |
+
from transformers import AutoModelForQuestionAnswering, AutoTokenizer
|
34 |
+
|
35 |
+
model = AutoModelForQuestionAnswering.from_pretrained("abhishek/autonlp-hindi-question-answering-23865268", use_auth_token=True)
|
36 |
+
|
37 |
+
tokenizer = AutoTokenizer.from_pretrained("abhishek/autonlp-hindi-question-answering-23865268", use_auth_token=True)
|
38 |
+
|
39 |
+
from transformers import BertTokenizer, BertForQuestionAnswering
|
40 |
+
|
41 |
+
question, text = "Who loves AutoNLP?", "Everyone loves AutoNLP"
|
42 |
+
|
43 |
+
inputs = tokenizer(question, text, return_tensors='pt')
|
44 |
+
|
45 |
+
start_positions = torch.tensor([1])
|
46 |
+
|
47 |
+
end_positions = torch.tensor([3])
|
48 |
+
|
49 |
+
outputs = model(**inputs, start_positions=start_positions, end_positions=end_positions)
|
50 |
+
|
51 |
+
loss = outputs.loss
|
52 |
+
|
53 |
+
start_scores = outputs.start_logits
|
54 |
+
|
55 |
+
end_scores = outputs.end_logits
|
56 |
+
```
|