File size: 4,016 Bytes
b6d2ca2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59b9955
2abddd8
 
 
 
 
 
 
 
 
 
 
 
 
b6d2ca2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
---
language:
- en
- es
---

# Model Card for Carpincho-30b

<!-- Provide a quick summary of what the model is/does. -->

This is Carpincho-30B qlora 4-bit checkpoint, an Instruction-tuned LLM based on LLama-30B. It is trained to answer in colloquial spanish Argentine language.

It was trained on 2x3090 (48G) for 120 hs using huggingface QLoRA code (4-bit quantization)

## Model Details

The model is provided in LoRA format.

## Usage

Here is example inference code, you will need to install the following requirements:

```
bitsandbytes==0.39.0
transformers @ git+https://github.com/huggingface/transformers.git
peft @ git+https://github.com/huggingface/peft.git
accelerate @ git+https://github.com/huggingface/accelerate.git
einops==0.6.1
evaluate==0.4.0
scikit-learn==1.2.2
sentencepiece==0.1.99
wandb==0.15.3
```


```
import time
import torch
from peft import PeftModel    
from transformers import AutoModelForCausalLM, AutoTokenizer, LlamaTokenizer, StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer

model_name = "models/huggyllama_llama-30b/"
adapters_name = 'carpincho-30b-qlora'

print(f"Starting to load the model {model_name} into memory")

model = AutoModelForCausalLM.from_pretrained(
    model_name,
    load_in_4bit=True,
    torch_dtype=torch.bfloat16,
    device_map="sequential"
)

print(f"Loading {adapters_name} into memory")
model = PeftModel.from_pretrained(model, adapters_name)
tokenizer = LlamaTokenizer.from_pretrained(model_name)
tokenizer.bos_token_id = 1

stop_token_ids = [0]

print(f"Successfully loaded the model {model_name} into memory")

def main(tokenizer):
    prompt = '''Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
%s
### Response:
    ''' % "Hola, como estas?"

    batch = tokenizer(prompt, return_tensors="pt")
    batch = {k: v.cuda() for k, v in batch.items()}

    with torch.no_grad():
        generated = model.generate(inputs=batch["input_ids"],
                               do_sample=True, use_cache=True,
                               repetition_penalty=1.1,
                               max_new_tokens=100,
                               temperature=0.9,
                               top_p=0.95,
                               top_k=40,
                               return_dict_in_generate=True,
                               output_attentions=False,
                               output_hidden_states=False,
                               output_scores=False)
    result_text = tokenizer.decode(generated['sequences'].cpu().tolist()[0])
    print(result_text)

main(tokenizer)
```

### Model Description

<!-- Provide a longer summary of what this model is. -->

- **Developed by:** Alfredo Ortega (@ortegaalfredo)
- **Model type:** 30B LLM QLoRA
- **Language(s):** (NLP): English and colloquial Argentine Spanish
- **License:** Free for non-commercial use, but I'm not the police.
- **Finetuned from model:** https://huggingface.co/huggyllama/llama-30b

### Model Sources [optional]

<!-- Provide the basic links for the model. -->

- **Repository:** https://huggingface.co/huggyllama/llama-30b
- **Paper [optional]:** https://arxiv.org/abs/2302.13971

## Uses

<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
This is a generic LLM chatbot that can be used to interact directly with humans.

## Bias, Risks, and Limitations

<!-- This section is meant to convey both technical and sociotechnical limitations. -->
This bot is uncensored and may provide shocking answers. Also it contains bias present in the training material.


### Recommendations

<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->

Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. 

## Model Card Contact

Contact the creator at @ortegaalfredo on twitter/github