Update README.md
Browse files
README.md
CHANGED
@@ -6,6 +6,8 @@ tags:
|
|
6 |
model-index:
|
7 |
- name: bertin-gpt-clara-med
|
8 |
results: []
|
|
|
|
|
9 |
---
|
10 |
|
11 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
@@ -17,9 +19,47 @@ This model is a fine-tuned version of [bertin-project/bertin-gpt-j-6B-alpaca](ht
|
|
17 |
It achieves the following results on the evaluation set:
|
18 |
- Loss: 0.6110
|
19 |
|
20 |
-
##
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
## Intended uses & limitations
|
25 |
|
@@ -62,4 +102,4 @@ The following hyperparameters were used during training:
|
|
62 |
- Transformers 4.32.1
|
63 |
- Pytorch 2.0.0+cu117
|
64 |
- Datasets 2.14.4
|
65 |
-
- Tokenizers 0.13.3
|
|
|
6 |
model-index:
|
7 |
- name: bertin-gpt-clara-med
|
8 |
results: []
|
9 |
+
datasets:
|
10 |
+
- CLARA-MeD/CLARA-MeD
|
11 |
---
|
12 |
|
13 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
|
|
19 |
It achieves the following results on the evaluation set:
|
20 |
- Loss: 0.6110
|
21 |
|
22 |
+
## Usage
|
23 |
|
24 |
+
```python
|
25 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig, pipeline
|
26 |
+
|
27 |
+
base_model = "CLARA-MeD/bertin-gpt"
|
28 |
+
tokenizer = AutoTokenizer.from_pretrained(base_model)
|
29 |
+
model = AutoModelForCausalLM.from_pretrained(base_model).cuda()
|
30 |
+
```
|
31 |
+
|
32 |
+
For generation, we can use the model's `.generate()` method. Remember that the prompt needs a **Spanish** template:
|
33 |
+
|
34 |
+
```python
|
35 |
+
# Generate responses
|
36 |
+
def generate(input):
|
37 |
+
prompt = f"""A continuaci贸n hay una instrucci贸n que describe una tarea, junto con una entrada que proporciona m谩s contexto. Escribe una respuesta que complete adecuadamente lo que se pide.
|
38 |
+
|
39 |
+
### Instrucci贸n:
|
40 |
+
Simplifica la siguiente frase
|
41 |
+
|
42 |
+
### Entrada:
|
43 |
+
{input}
|
44 |
+
|
45 |
+
### Respuesta:"""
|
46 |
+
|
47 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
48 |
+
input_ids = inputs["input_ids"].cuda()
|
49 |
+
generation_output = model.generate(
|
50 |
+
input_ids=input_ids,
|
51 |
+
generation_config=GenerationConfig(temperature=0.2, top_p=0.75, num_beams=4),
|
52 |
+
return_dict_in_generate=True,
|
53 |
+
output_scores=True,
|
54 |
+
max_new_tokens=256
|
55 |
+
)
|
56 |
+
for seq in generation_output.sequences:
|
57 |
+
output = tokenizer.decode(seq, skip_special_tokens=True)
|
58 |
+
print(output.split("### Respuesta:")[-1].strip())
|
59 |
+
|
60 |
+
generate("Al sujeto se le ha tratado previamente con antagonistas del factor de necrosis tumoral alfa (TNF-伪) sin respuesta cl铆nica documentada al tratamiento. Tambi茅n puede ocurrir que al sujeto no se le tratara anteriormente con antagonistas de TNF-伪, pero est谩 fallando el tratamiento convencional actual.")
|
61 |
+
|
62 |
+
```
|
63 |
|
64 |
## Intended uses & limitations
|
65 |
|
|
|
102 |
- Transformers 4.32.1
|
103 |
- Pytorch 2.0.0+cu117
|
104 |
- Datasets 2.14.4
|
105 |
+
- Tokenizers 0.13.3
|