michaelfeil commited on
Commit
9fbacf4
1 Parent(s): eccd076

Upload VMware/open-llama-7b-open-instruct ctranslate fp16 weights

Browse files
README.md ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - ctranslate2
4
+ - int8
5
+ - float16
6
+
7
+ license: cc
8
+ datasets:
9
+ - VMware/open-instruct-v1-oasst-dolly-hhrlhf
10
+ language:
11
+ - en
12
+ library_name: transformers
13
+ pipeline_tag: text-generation
14
+ ---
15
+ # # Fast-Inference with Ctranslate2
16
+ Speedup inference while reducing memory by 2x-4x using int8 inference in C++ on CPU or GPU.
17
+
18
+ quantized version of [VMware/open-llama-7b-open-instruct](https://huggingface.co/VMware/open-llama-7b-open-instruct)
19
+ ```bash
20
+ pip install hf-hub-ctranslate2>=2.0.8 ctranslate2>=3.14.0
21
+ ```
22
+ Converted on 2023-06-14 using
23
+ ```
24
+ ct2-transformers-converter --model VMware/open-llama-7b-open-instruct --output_dir /home/michael/tmp-ct2fast-open-llama-7b-open-instruct --force --copy_files README.md tokenizer_config.json generation_config.json special_tokens_map.json .gitattributes --quantization int8_float16 --trust_remote_code
25
+ ```
26
+
27
+ Checkpoint compatible to [ctranslate2>=3.15.0](https://github.com/OpenNMT/CTranslate2)
28
+ and [hf-hub-ctranslate2>=2.0.8](https://github.com/michaelfeil/hf-hub-ctranslate2)
29
+ - `compute_type=int8_float16` for `device="cuda"`
30
+ - `compute_type=int8` for `device="cpu"`
31
+
32
+ ```python
33
+ from hf_hub_ctranslate2 import TranslatorCT2fromHfHub, GeneratorCT2fromHfHub
34
+ from transformers import AutoTokenizer
35
+
36
+ model_name = "michaelfeil/ct2fast-open-llama-7b-open-instruct"
37
+ # use either TranslatorCT2fromHfHub or GeneratorCT2fromHfHub here, depending on model.
38
+ model = GeneratorCT2fromHfHub(
39
+ # load in int8 on CUDA
40
+ model_name_or_path=model_name,
41
+ device="cuda",
42
+ compute_type="int8_float16",
43
+ # tokenizer=AutoTokenizer.from_pretrained("VMware/open-llama-7b-open-instruct")
44
+ )
45
+ outputs = model.generate(
46
+ text=["def fibonnaci(", "User: How are you doing? Bot:"],
47
+ max_length=64,
48
+ include_prompt_in_result=False
49
+ )
50
+ print(outputs)
51
+ ```
52
+
53
+ # Licence and other remarks:
54
+ This is just a quantized version. Licence conditions are intended to be idential to original huggingface repo.
55
+
56
+ # Original description
57
+
58
+
59
+ # VMware/open-llama-7B-open-instruct
60
+ Instruction-tuned version of the fully trained Open LLama 7B model. The model is open for <b>COMMERCIAL USE</b>. <br>
61
+
62
+ <b> NOTE </b> : The model was trained using the Alpaca prompt template
63
+ <b> NOTE </b> : Fast tokenizer results in incorrect encoding, set the ```use_fast = False``` parameter, when instantiating the tokenizer
64
+
65
+ ## License
66
+ - <b>Commercially Viable </b>
67
+ - Instruction dataset, [VMware/open-instruct-v1-oasst-dolly-hhrlhf](https://huggingface.co/datasets/VMware/open-instruct-v1-oasst-dolly-hhrlhf) is under cc-by-sa-3.0
68
+ - Language Model, ([openlm-research/open_llama_7b](https://huggingface.co/openlm-research/open_llama_7b)) is under apache-2.0
69
+
70
+
71
+ ## Nomenclature
72
+
73
+ - Model : Open-llama
74
+ - Model Size: 7B parameters
75
+ - Dataset: Open-instruct-v1 (oasst,dolly, hhrlhf)
76
+
77
+ ## Use in Transformers
78
+
79
+ ```
80
+ import os
81
+ import torch
82
+ from transformers import AutoModelForCausalLM, AutoTokenizer
83
+
84
+ model_name = 'VMware/open-llama-7b-open-instruct'
85
+
86
+
87
+ tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=False)
88
+
89
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map='sequential')
90
+
91
+ prompt_template = "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n### Instruction:\n{instruction}\n\n### Response:"
92
+
93
+ prompt = 'Explain in simple terms how the attention mechanism of a transformer model works'
94
+
95
+
96
+ inputt = prompt_template.format(instruction= prompt)
97
+ input_ids = tokenizer(inputt, return_tensors="pt").input_ids.to("cuda")
98
+
99
+ output1 = model.generate(input_ids, max_length=512)
100
+ input_length = input_ids.shape[1]
101
+ output1 = output1[:, input_length:]
102
+ output = tokenizer.decode(output1[0])
103
+
104
+ print(output)
105
+
106
+ '''
107
+ Attention is a mechanism used in deep learning models, such as transformer models, to capture global dependencies between different parts of the input. In a transformer model, the attention mechanism works by computing a weighted sum of the input vectors and then applying a non-linear activation function to the result.
108
+
109
+ The attention mechanism in a transformer model works in two steps:
110
+
111
+ 1. Query-Key Mapping: First, the input sequence is divided into two parts: the query vector and the key vector. The query vector represents the input at the current position, and the key vector represents the input at a previous position.
112
+
113
+ 2. Attention Weight Calculation: Second, the attention weights are calculated using the dot product between the query vector and each key vector. The attention weights represent the importance of the input at the previous position to the current position.
114
+
115
+ The attention weights are then used to compute the attention score for each input element. The attention score represents the relevance of the input element to the current position.
116
+
117
+ The attention mechanism in a transformer model is designed to capture global dependencies between different parts of the input. By attending to input elements from different positions, the model can learn to understand the relationships between different parts of the input. This allows the model to perform more complex tasks, such as understanding the relationships between words in a sentence or pixels in an image.</s>
118
+
119
+ '''
120
+ ```
121
+
122
+ ## Finetuning details
123
+ The finetuning scripts will be available in our [RAIL Github Repository](https://github.com/vmware-labs/research-and-development-artificial-intelligence-lab/tree/main/instruction-tuning)
124
+ ## Evaluation
125
+
126
+ <B>TODO</B>
config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "eos_token": "</s>",
4
+ "layer_norm_epsilon": null,
5
+ "unk_token": "<unk>"
6
+ }
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "pad_token_id": 0,
6
+ "transformers_version": "4.28.1"
7
+ }
model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e7d5b8584442aa023e3bf8862411b5424aa9c2c761627c8f50964b245ef4a8a5
3
+ size 6744405708
special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": true,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": true,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": "<unk>",
17
+ "unk_token": {
18
+ "content": "<unk>",
19
+ "lstrip": false,
20
+ "normalized": true,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
tokenizer_config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "bos_token": {
5
+ "__type": "AddedToken",
6
+ "content": "<s>",
7
+ "lstrip": false,
8
+ "normalized": true,
9
+ "rstrip": false,
10
+ "single_word": false
11
+ },
12
+ "clean_up_tokenization_spaces": false,
13
+ "eos_token": {
14
+ "__type": "AddedToken",
15
+ "content": "</s>",
16
+ "lstrip": false,
17
+ "normalized": true,
18
+ "rstrip": false,
19
+ "single_word": false
20
+ },
21
+ "model_max_length": 2048,
22
+ "pad_token": null,
23
+ "padding_side": "right",
24
+ "sp_model_kwargs": {},
25
+ "tokenizer_class": "LlamaTokenizer",
26
+ "unk_token": {
27
+ "__type": "AddedToken",
28
+ "content": "<unk>",
29
+ "lstrip": false,
30
+ "normalized": true,
31
+ "rstrip": false,
32
+ "single_word": false
33
+ }
34
+ }
vocabulary.txt ADDED
The diff for this file is too large to render. See raw diff