ecastera commited on
Commit
4e00df9
1 Parent(s): de2c944

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +68 -0
README.md ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - ecastera/wiki_fisica
5
+ - ecastera/filosofia-es
6
+ - somosnlp/somos-clean-alpaca-es
7
+ language:
8
+ - es
9
+ - en
10
+ tags:
11
+ - mistral
12
+ - ehartford/dolphin
13
+ ---
14
+
15
+ # eva-mistral-dolphin-7b-spanish
16
+
17
+ Mistral 7b based model fine tuned in Spanish to add high quality Spanish text generation.
18
+
19
+ * Base model Mistral
20
+ * Based on the excelent job of Eric Hartfod's dolphin models cognitivecomputations/dolphin-2.1-mistral-7b
21
+ * Fine-tuned in Spanish with a collection of poetry, books, wikipedia articles, phylosophy texts and alpaca-es datasets.
22
+ * Trained using Lora and PEFT on 2 GPUs for several days.
23
+
24
+
25
+ ## Usage:
26
+
27
+ Strongly advice to run inference in INT8 or INT4 mode, with the help of BitsandBytes library.
28
+
29
+
30
+ ```
31
+ import torch
32
+ from transformers import AutoTokenizer, pipeline, AutoModel, AutoModelForCausalLM, BitsAndBytesConfig
33
+
34
+ MODEL = "ecastera/eva-mistral-dolphin-7b-spanish"
35
+
36
+ quantization_config = BitsAndBytesConfig(
37
+ load_in_4bit=True,
38
+ load_in_8bit=False,
39
+ llm_int8_threshold=6.0,
40
+ llm_int8_has_fp16_weight=False,
41
+ bnb_4bit_compute_dtype="float16",
42
+ bnb_4bit_use_double_quant=True,
43
+ bnb_4bit_quant_type="nf4")
44
+
45
+ model = AutoModelForCausalLM.from_pretrained(
46
+ MODEL,
47
+ load_in_8bit=True,
48
+ low_cpu_mem_usage=True,
49
+ torch_dtype=torch.float16,
50
+ quantization_config=quantization_config,
51
+ offload_state_dict=True,
52
+ offload_folder="./offload",
53
+ trust_remote_code=True,
54
+ )
55
+
56
+ tokenizer = AutoTokenizer.from_pretrained(MODEL)
57
+ print(f"Loading complete {model} {tokenizer}")
58
+
59
+ prompt = "Soy Eva una inteligencia artificial y pienso que la esperanza "
60
+
61
+ inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
62
+ outputs = model.generate(**inputs, do_sample=True, temperature=0.4, top_p=1.0, top_k=50,
63
+ no_repeat_ngram_size=3, max_new_tokens=100, pad_token_id=tokenizer.eos_token_id)
64
+ text_out = tokenizer.batch_decode(outputs, skip_special_tokens=True)
65
+
66
+ print(text_out)
67
+ ```
68
+