File size: 1,584 Bytes
5077b36
 
 
 
 
 
b033ee4
5077b36
 
 
 
 
 
 
7b18832
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
language:
- it
pipeline_tag: question-answering
tags:
- Biomedical Language Modeling
library_name: Haystack
---

๐Ÿค— + ๐Ÿ“š๐Ÿฉบ๐Ÿ‡ฎ๐Ÿ‡น  + โ“ =  **BioBIT_QA**

From this repository you can download the **BioBIT_QA** (Biomedical Bert for ITalian for Question Answering) checkpoint.

**BioBIT_QA** is built on top of [BioBIT](https://huggingface.co/IVN-RIN/bioBIT), fine-tuned on an Italian Neuropsychological Italian datasets.
More details will follow!


## Install libraries:

```
pip install farm-haystack[inference]
```


## Download model locally:

```
git clone https://huggingface.co/IVN-RIN/bioBIT_QA
```


## Run the code

```
# Import libraries
from haystack.nodes import FARMReader
from haystack.schema import Document

# Define the reader
reader = FARMReader(
    model_name_or_path="bioBIT_QA",
    return_no_answer=True
)

# Define context and question
context = '''
This is an example of context
'''
question = 'This is a question example, ok?'

# Wrap context in Document
docs = Document(
    content = context
)

# Predict answer
prediction = reader.predict(
    query = question,
    documents = [docs],
    top_k = 5
)

# Print the 5 first predicted answers
for i, ans in enumerate(prediction['answers']):
    print(f'Answer num {i+1}, with score {ans.score*100:.2f}%: "{ans.answer}"')
    
# Inferencing Samples: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 1/1 [00:01<00:00,  1.14s/ Batches]
# Answer num 1, with score 97.91%: "Example answer 01"
# Answer num 2, with score 53.69%: "Example answer 02"
# Answer num 3, with score 0.03%: "Example answer 03"
# ...


```