|
--- |
|
license: apache-2.0 |
|
datasets: |
|
- ecastera/wiki_fisica |
|
- ecastera/filosofia-es |
|
- somosnlp/somos-clean-alpaca-es |
|
language: |
|
- es |
|
- en |
|
tags: |
|
- mistral |
|
- ehartford/dolphin |
|
--- |
|
|
|
# eva-mistral-dolphin-7b-spanish |
|
|
|
Mistral 7b based model fine tuned in Spanish to add high quality Spanish text generation. |
|
|
|
* Base model Mistral |
|
* Based on the excelent job of Eric Hartfod's dolphin models cognitivecomputations/dolphin-2.1-mistral-7b |
|
* Fine-tuned in Spanish with a collection of poetry, books, wikipedia articles, phylosophy texts and alpaca-es datasets. |
|
* Trained using Lora and PEFT on 2 GPUs for several days. |
|
|
|
|
|
## Usage: |
|
|
|
Strongly advice to run inference in INT8 or INT4 mode, with the help of BitsandBytes library. |
|
|
|
|
|
``` |
|
import torch |
|
from transformers import AutoTokenizer, pipeline, AutoModel, AutoModelForCausalLM, BitsAndBytesConfig |
|
|
|
MODEL = "ecastera/eva-mistral-dolphin-7b-spanish" |
|
|
|
quantization_config = BitsAndBytesConfig( |
|
load_in_4bit=True, |
|
load_in_8bit=False, |
|
llm_int8_threshold=6.0, |
|
llm_int8_has_fp16_weight=False, |
|
bnb_4bit_compute_dtype="float16", |
|
bnb_4bit_use_double_quant=True, |
|
bnb_4bit_quant_type="nf4") |
|
|
|
model = AutoModelForCausalLM.from_pretrained( |
|
MODEL, |
|
load_in_8bit=True, |
|
low_cpu_mem_usage=True, |
|
torch_dtype=torch.float16, |
|
quantization_config=quantization_config, |
|
offload_state_dict=True, |
|
offload_folder="./offload", |
|
trust_remote_code=True, |
|
) |
|
|
|
tokenizer = AutoTokenizer.from_pretrained(MODEL) |
|
print(f"Loading complete {model} {tokenizer}") |
|
|
|
prompt = "Soy Eva una inteligencia artificial y pienso que la esperanza " |
|
|
|
inputs = tokenizer(prompt, return_tensors="pt").to("cuda") |
|
outputs = model.generate(**inputs, do_sample=True, temperature=0.4, top_p=1.0, top_k=50, |
|
no_repeat_ngram_size=3, max_new_tokens=100, pad_token_id=tokenizer.eos_token_id) |
|
text_out = tokenizer.batch_decode(outputs, skip_special_tokens=True) |
|
|
|
print(text_out) |
|
``` |
|
|
|
|