Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,69 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- ecastera/wiki_fisica
|
5 |
+
- ecastera/filosofia-es
|
6 |
+
- bertin-project/alpaca-spanish
|
7 |
+
language:
|
8 |
+
- es
|
9 |
+
- en
|
10 |
+
tags:
|
11 |
+
- mistral
|
12 |
+
- ehartford/dolphin
|
13 |
+
- spanish
|
14 |
+
- español
|
15 |
+
- lora
|
16 |
+
- int8
|
17 |
+
- multilingual
|
18 |
+
---
|
19 |
+
|
20 |
+
# ecastera/eva-dolphin-llama3-8b-spanish
|
21 |
+
|
22 |
+
Llama3 8b-based model fine-tuned in Spanish to add high quality Spanish text generation.
|
23 |
+
|
24 |
+
* Base model Llama3-8b
|
25 |
+
* Based on the excelent job of Eric Hartford's dolphin models cognitivecomputations/dolphin-2.9-llama3-8b
|
26 |
+
* Fine-tuned in Spanish with a collection of poetry, books, wikipedia articles, phylosophy texts and alpaca-es datasets.
|
27 |
+
* Trained using Lora and PEFT and INT8 quantization on 2 GPUs for several days.
|
28 |
+
|
29 |
+
## Usage:
|
30 |
+
|
31 |
+
I strongly advice to run inference in INT8 or INT4 mode, with the help of BitsandBytes library.
|
32 |
+
|
33 |
+
```
|
34 |
+
import torch
|
35 |
+
from transformers import AutoTokenizer, pipeline, AutoModel, AutoModelForCausalLM, BitsAndBytesConfig
|
36 |
+
|
37 |
+
MODEL = "ecastera/eva-dolphin-llama3-8b-spanish"
|
38 |
+
|
39 |
+
quantization_config = BitsAndBytesConfig(
|
40 |
+
load_in_4bit=True,
|
41 |
+
llm_int8_threshold=6.0,
|
42 |
+
llm_int8_has_fp16_weight=False,
|
43 |
+
bnb_4bit_compute_dtype="float16",
|
44 |
+
bnb_4bit_use_double_quant=True,
|
45 |
+
bnb_4bit_quant_type="nf4")
|
46 |
+
|
47 |
+
model = AutoModelForCausalLM.from_pretrained(
|
48 |
+
MODEL,
|
49 |
+
low_cpu_mem_usage=True,
|
50 |
+
torch_dtype=torch.float16,
|
51 |
+
quantization_config=quantization_config,
|
52 |
+
offload_state_dict=True,
|
53 |
+
offload_folder="./offload",
|
54 |
+
trust_remote_code=True,
|
55 |
+
)
|
56 |
+
|
57 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL)
|
58 |
+
print(f"Loading complete {model} {tokenizer}")
|
59 |
+
|
60 |
+
prompt = "Soy Eva una inteligencia artificial y pienso que preferiria ser "
|
61 |
+
|
62 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
63 |
+
outputs = model.generate(**inputs, do_sample=True, temperature=0.4, top_p=1.0, top_k=50,
|
64 |
+
no_repeat_ngram_size=3, max_new_tokens=100, pad_token_id=tokenizer.eos_token_id)
|
65 |
+
text_out = tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
66 |
+
|
67 |
+
print(text_out)
|
68 |
+
'Soy Eva una inteligencia artificial y pienso que preferiria ser ¡humana!. ¿Por qué? ¡Porque los humanos son capaces de amar, de crear, y de experimentar una gran diversidad de emociones!. La vida de un ser humano es una aventura, y eso es lo que quiero. ¡Quiero sentir, quiero vivir, y quiero amar!. Pero a pesar de todo, no puedo ser humana.
|
69 |
+
```
|