Update README.md
Browse files
README.md
CHANGED
|
@@ -23,10 +23,17 @@ It achieves the following results on the evaluation set:
|
|
| 23 |
|
| 24 |
```python
|
| 25 |
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig, pipeline
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
```
|
| 31 |
|
| 32 |
For generation, we can use the model's `.generate()` method. Remember that the prompt needs a **Spanish** template:
|
|
@@ -57,7 +64,9 @@ Simplifica la siguiente frase
|
|
| 57 |
output = tokenizer.decode(seq, skip_special_tokens=True)
|
| 58 |
print(output.split("### Respuesta:")[-1].strip())
|
| 59 |
|
| 60 |
-
generate("
|
|
|
|
|
|
|
| 61 |
|
| 62 |
```
|
| 63 |
|
|
|
|
| 23 |
|
| 24 |
```python
|
| 25 |
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig, pipeline
|
| 26 |
+
from peft import PeftConfig, PeftModel
|
| 27 |
+
import torch
|
| 28 |
+
from accelerate import init_empty_weights, load_checkpoint_and_dispatch, infer_auto_device_map
|
| 29 |
|
| 30 |
+
|
| 31 |
+
repo_name = "CLARA-MeD/bertin-gpt"
|
| 32 |
+
config = PeftConfig.from_pretrained(repo_name)
|
| 33 |
+
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
|
| 34 |
+
model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path,torch_dtype=torch.float16,
|
| 35 |
+
device_map="auto")
|
| 36 |
+
model = PeftModel.from_pretrained(model, repo_name)
|
| 37 |
```
|
| 38 |
|
| 39 |
For generation, we can use the model's `.generate()` method. Remember that the prompt needs a **Spanish** template:
|
|
|
|
| 64 |
output = tokenizer.decode(seq, skip_special_tokens=True)
|
| 65 |
print(output.split("### Respuesta:")[-1].strip())
|
| 66 |
|
| 67 |
+
generate("Acromegalia")
|
| 68 |
+
# La acromegalia es un trastorno causado por un exceso de hormona del crecimiento en el cuerpo.
|
| 69 |
+
|
| 70 |
|
| 71 |
```
|
| 72 |
|