michaelfeil
commited on
Commit
•
f655094
1
Parent(s):
7ca874b
Upload codellama/CodeLlama-34b-hf ctranslate2 weights
Browse files- README.md +163 -0
- USE_POLICY.md +50 -0
- config.json +29 -0
- generation_config.json +6 -0
- model.bin +3 -0
- special_tokens_map.json +23 -0
- tokenizer.json +0 -0
- tokenizer_config.json +34 -0
- vocabulary.json +0 -0
- vocabulary.txt +0 -0
README.md
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- code
|
4 |
+
pipeline_tag: text-generation
|
5 |
+
tags:
|
6 |
+
- ctranslate2
|
7 |
+
- int8
|
8 |
+
- float16
|
9 |
+
- llama-2
|
10 |
+
license: llama2
|
11 |
+
---
|
12 |
+
# # Fast-Inference with Ctranslate2
|
13 |
+
Speedup inference while reducing memory by 2x-4x using int8 inference in C++ on CPU or GPU.
|
14 |
+
|
15 |
+
quantized version of [codellama/CodeLlama-34b-hf](https://huggingface.co/codellama/CodeLlama-34b-hf)
|
16 |
+
```bash
|
17 |
+
pip install hf-hub-ctranslate2>=2.12.0 ctranslate2>=3.17.1
|
18 |
+
```
|
19 |
+
|
20 |
+
```python
|
21 |
+
# from transformers import AutoTokenizer
|
22 |
+
model_name = "michaelfeil/ct2fast-CodeLlama-34b-hf"
|
23 |
+
|
24 |
+
|
25 |
+
from hf_hub_ctranslate2 import GeneratorCT2fromHfHub
|
26 |
+
model = GeneratorCT2fromHfHub(
|
27 |
+
# load in int8 on CUDA
|
28 |
+
model_name_or_path=model_name,
|
29 |
+
device="cuda",
|
30 |
+
compute_type="int8_float16",
|
31 |
+
# tokenizer=AutoTokenizer.from_pretrained("{ORG}/{NAME}")
|
32 |
+
)
|
33 |
+
outputs = model.generate(
|
34 |
+
text=["def fibonnaci(", "User: How are you doing? Bot:"],
|
35 |
+
max_length=64,
|
36 |
+
include_prompt_in_result=False
|
37 |
+
)
|
38 |
+
print(outputs)
|
39 |
+
```
|
40 |
+
|
41 |
+
Checkpoint compatible to [ctranslate2>=3.17.1](https://github.com/OpenNMT/CTranslate2)
|
42 |
+
and [hf-hub-ctranslate2>=2.12.0](https://github.com/michaelfeil/hf-hub-ctranslate2)
|
43 |
+
- `compute_type=int8_float16` for `device="cuda"`
|
44 |
+
- `compute_type=int8` for `device="cpu"`
|
45 |
+
|
46 |
+
Converted on 2023-09-13 using
|
47 |
+
```
|
48 |
+
LLama-2 -> removed <pad> token.
|
49 |
+
```
|
50 |
+
|
51 |
+
# Licence and other remarks:
|
52 |
+
This is just a quantized version. Licence conditions are intended to be idential to original huggingface repo.
|
53 |
+
|
54 |
+
# Original description
|
55 |
+
|
56 |
+
# **Code Llama**
|
57 |
+
Code Llama is a collection of pretrained and fine-tuned generative text models ranging in scale from 7 billion to 34 billion parameters. This is the repository for the base 34B version in the Hugging Face Transformers format. This model is designed for general code synthesis and understanding. Links to other models can be found in the index at the bottom.
|
58 |
+
|
59 |
+
| | Base Model | Python | Instruct |
|
60 |
+
| --- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
|
61 |
+
| 7B | [codellama/CodeLlama-7b-hf](https://huggingface.co/codellama/CodeLlama-7b-hf) | [codellama/CodeLlama-7b-Python-hf](https://huggingface.co/codellama/CodeLlama-7b-Python-hf) | [codellama/CodeLlama-7b-Instruct-hf](https://huggingface.co/codellama/CodeLlama-7b-Instruct-hf) |
|
62 |
+
| 13B | [codellama/CodeLlama-13b-hf](https://huggingface.co/codellama/CodeLlama-13b-hf) | [codellama/CodeLlama-13b-Python-hf](https://huggingface.co/codellama/CodeLlama-13b-Python-hf) | [codellama/CodeLlama-13b-Instruct-hf](https://huggingface.co/codellama/CodeLlama-13b-Instruct-hf) |
|
63 |
+
| 34B | [codellama/CodeLlama-34b-hf](https://huggingface.co/codellama/CodeLlama-34b-hf) | [codellama/CodeLlama-34b-Python-hf](https://huggingface.co/codellama/CodeLlama-34b-Python-hf) | [codellama/CodeLlama-34b-Instruct-hf](https://huggingface.co/codellama/CodeLlama-34b-Instruct-hf) |
|
64 |
+
|
65 |
+
## Model Use
|
66 |
+
|
67 |
+
To use this model, please make sure to install transformers from `main` until the next version is released:
|
68 |
+
|
69 |
+
```bash
|
70 |
+
pip install git+https://github.com/huggingface/transformers.git@main accelerate
|
71 |
+
```
|
72 |
+
|
73 |
+
Model capabilities:
|
74 |
+
|
75 |
+
- [x] Code completion.
|
76 |
+
- [ ] Infilling.
|
77 |
+
- [ ] Instructions / chat.
|
78 |
+
- [ ] Python specialist.
|
79 |
+
|
80 |
+
|
81 |
+
```python
|
82 |
+
from transformers import AutoTokenizer
|
83 |
+
import transformers
|
84 |
+
import torch
|
85 |
+
|
86 |
+
model = "codellama/CodeLlama-34b-hf"
|
87 |
+
|
88 |
+
tokenizer = AutoTokenizer.from_pretrained(model)
|
89 |
+
pipeline = transformers.pipeline(
|
90 |
+
"text-generation",
|
91 |
+
model=model,
|
92 |
+
torch_dtype=torch.float16,
|
93 |
+
device_map="auto",
|
94 |
+
)
|
95 |
+
|
96 |
+
sequences = pipeline(
|
97 |
+
'import socket\n\ndef ping_exponential_backoff(host: str):',
|
98 |
+
do_sample=True,
|
99 |
+
top_k=10,
|
100 |
+
temperature=0.1,
|
101 |
+
top_p=0.95,
|
102 |
+
num_return_sequences=1,
|
103 |
+
eos_token_id=tokenizer.eos_token_id,
|
104 |
+
max_length=200,
|
105 |
+
)
|
106 |
+
for seq in sequences:
|
107 |
+
print(f"Result: {seq['generated_text']}")
|
108 |
+
```
|
109 |
+
|
110 |
+
|
111 |
+
## Model Details
|
112 |
+
*Note: Use of this model is governed by the Meta license. Meta developed and publicly released the Code Llama family of large language models (LLMs).
|
113 |
+
|
114 |
+
**Model Developers** Meta
|
115 |
+
|
116 |
+
**Variations** Code Llama comes in three model sizes, and three variants:
|
117 |
+
|
118 |
+
* Code Llama: base models designed for general code synthesis and understanding
|
119 |
+
* Code Llama - Python: designed specifically for Python
|
120 |
+
* Code Llama - Instruct: for instruction following and safer deployment
|
121 |
+
|
122 |
+
All variants are available in sizes of 7B, 13B and 34B parameters.
|
123 |
+
|
124 |
+
**This repository contains the base version of the 34B parameters model.**
|
125 |
+
|
126 |
+
**Input** Models input text only.
|
127 |
+
|
128 |
+
**Output** Models generate text only.
|
129 |
+
|
130 |
+
**Model Architecture** Code Llama is an auto-regressive language model that uses an optimized transformer architecture.
|
131 |
+
|
132 |
+
**Model Dates** Code Llama and its variants have been trained between January 2023 and July 2023.
|
133 |
+
|
134 |
+
**Status** This is a static model trained on an offline dataset. Future versions of Code Llama - Instruct will be released as we improve model safety with community feedback.
|
135 |
+
|
136 |
+
**License** A custom commercial license is available at: [https://ai.meta.com/resources/models-and-libraries/llama-downloads/](https://ai.meta.com/resources/models-and-libraries/llama-downloads/)
|
137 |
+
|
138 |
+
**Research Paper** More information can be found in the paper "[Code Llama: Open Foundation Models for Code](https://ai.meta.com/research/publications/code-llama-open-foundation-models-for-code/)" or its [arXiv page](https://arxiv.org/abs/2308.12950).
|
139 |
+
|
140 |
+
## Intended Use
|
141 |
+
**Intended Use Cases** Code Llama and its variants is intended for commercial and research use in English and relevant programming languages. The base model Code Llama can be adapted for a variety of code synthesis and understanding tasks, Code Llama - Python is designed specifically to handle the Python programming language, and Code Llama - Instruct is intended to be safer to use for code assistant and generation applications.
|
142 |
+
|
143 |
+
**Out-of-Scope Uses** Use in any manner that violates applicable laws or regulations (including trade compliance laws). Use in languages other than English. Use in any other way that is prohibited by the Acceptable Use Policy and Licensing Agreement for Code Llama and its variants.
|
144 |
+
|
145 |
+
## Hardware and Software
|
146 |
+
**Training Factors** We used custom training libraries. The training and fine-tuning of the released models have been performed Meta’s Research Super Cluster.
|
147 |
+
|
148 |
+
**Carbon Footprint** In aggregate, training all 9 Code Llama models required 400K GPU hours of computation on hardware of type A100-80GB (TDP of 350-400W). Estimated total emissions were 65.3 tCO2eq, 100% of which were offset by Meta’s sustainability program.
|
149 |
+
|
150 |
+
## Training Data
|
151 |
+
|
152 |
+
All experiments reported here and the released models have been trained and fine-tuned using the same data as Llama 2 with different weights (see Section 2 and Table 1 in the [research paper](https://ai.meta.com/research/publications/code-llama-open-foundation-models-for-code/) for details).
|
153 |
+
|
154 |
+
## Evaluation Results
|
155 |
+
|
156 |
+
See evaluations for the main models and detailed ablations in Section 3 and safety evaluations in Section 4 of the research paper.
|
157 |
+
|
158 |
+
|
159 |
+
## Ethical Considerations and Limitations
|
160 |
+
|
161 |
+
Code Llama and its variants are a new technology that carries risks with use. Testing conducted to date has been in English, and has not covered, nor could it cover all scenarios. For these reasons, as with all LLMs, Code Llama’s potential outputs cannot be predicted in advance, and the model may in some instances produce inaccurate or objectionable responses to user prompts. Therefore, before deploying any applications of Code Llama, developers should perform safety testing and tuning tailored to their specific applications of the model.
|
162 |
+
|
163 |
+
Please see the Responsible Use Guide available available at [https://ai.meta.com/llama/responsible-user-guide](https://ai.meta.com/llama/responsible-user-guide).
|
USE_POLICY.md
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Llama Code Acceptable Use Policy
|
2 |
+
|
3 |
+
Meta is committed to promoting safe and fair use of its tools and features, including Llama Code. If you access or use Llama Code, you agree to this Acceptable Use Policy (“Policy”). The most recent copy of this policy can be found at [ai.meta.com/llama/use-policy](http://ai.meta.com/llama/use-policy).
|
4 |
+
|
5 |
+
## Prohibited Uses
|
6 |
+
We want everyone to use Llama Code safely and responsibly. You agree you will not use, or allow others to use, Llama Code to:
|
7 |
+
|
8 |
+
1. Violate the law or others’ rights, including to:
|
9 |
+
1. Engage in, promote, generate, contribute to, encourage, plan, incite, or further illegal or unlawful activity or content, such as:
|
10 |
+
1. Violence or terrorism
|
11 |
+
2. Exploitation or harm to children, including the solicitation, creation, acquisition, or dissemination of child exploitative content or failure to report Child Sexual Abuse Material
|
12 |
+
3. Human trafficking, exploitation, and sexual violence
|
13 |
+
4. The illegal distribution of information or materials to minors, including obscene materials, or failure to employ legally required age-gating in connection with such information or materials.
|
14 |
+
5. Sexual solicitation
|
15 |
+
6. Any other criminal activity
|
16 |
+
2. Engage in, promote, incite, or facilitate the harassment, abuse, threatening, or bullying of individuals or groups of individuals
|
17 |
+
3. Engage in, promote, incite, or facilitate discrimination or other unlawful or harmful conduct in the provision of employment, employment benefits, credit, housing, other economic benefits, or other essential goods and services
|
18 |
+
4. Engage in the unauthorized or unlicensed practice of any profession including, but not limited to, financial, legal, medical/health, or related professional practices
|
19 |
+
5. Collect, process, disclose, generate, or infer health, demographic, or other sensitive personal or private information about individuals without rights and consents required by applicable laws
|
20 |
+
6. Engage in or facilitate any action or generate any content that infringes, misappropriates, or otherwise violates any third-party rights, including the outputs or results of any products or services using the Llama 2 Materials
|
21 |
+
7. Create, generate, or facilitate the creation of malicious code, malware, computer viruses or do anything else that could disable, overburden, interfere with or impair the proper working, integrity, operation or appearance of a website or computer system
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
2. Engage in, promote, incite, facilitate, or assist in the planning or development of activities that present a risk of death or bodily harm to individuals, including use of Llama Code related to the following:
|
26 |
+
1. Military, warfare, nuclear industries or applications, espionage, use for materials or activities that are subject to the International Traffic Arms Regulations (ITAR) maintained by the United States Department of State
|
27 |
+
2. Guns and illegal weapons (including weapon development)
|
28 |
+
3. Illegal drugs and regulated/controlled substances
|
29 |
+
4. Operation of critical infrastructure, transportation technologies, or heavy machinery
|
30 |
+
5. Self-harm or harm to others, including suicide, cutting, and eating disorders
|
31 |
+
6. Any content intended to incite or promote violence, abuse, or any infliction of bodily harm to an individual
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
3. Intentionally deceive or mislead others, including use of Llama Code related to the following:
|
36 |
+
1. Generating, promoting, or furthering fraud or the creation or promotion of disinformation
|
37 |
+
2. Generating, promoting, or furthering defamatory content, including the creation of defamatory statements, images, or other content
|
38 |
+
3. Generating, promoting, or further distributing spam
|
39 |
+
4. Impersonating another individual without consent, authorization, or legal right
|
40 |
+
5. Representing that the use of Llama Code or outputs are human-generated
|
41 |
+
6. Generating or facilitating false online engagement, including fake reviews and other means of fake online engagement
|
42 |
+
4. Fail to appropriately disclose to end users any known dangers of your AI system
|
43 |
+
|
44 |
+
Please report any violation of this Policy, software “bug,” or other problems that could lead to a violation of this Policy through one of the following means:
|
45 |
+
|
46 |
+
* Reporting issues with the model: [github.com/facebookresearch/llama](http://github.com/facebookresearch/llama)
|
47 |
+
* Reporting risky content generated by the model: [developers.facebook.com/llama_output_feedback](http://developers.facebook.com/llama_output_feedback)
|
48 |
+
* Reporting bugs and security concerns: [facebook.com/whitehat/info](http://facebook.com/whitehat/info)
|
49 |
+
* Reporting violations of the Acceptable Use Policy or unlicensed uses of Llama: [[email protected]](mailto:[email protected])
|
50 |
+
|
config.json
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"LlamaForCausalLM"
|
4 |
+
],
|
5 |
+
"bos_token_id": 1,
|
6 |
+
"eos_token_id": 2,
|
7 |
+
"hidden_act": "silu",
|
8 |
+
"hidden_size": 8192,
|
9 |
+
"initializer_range": 0.02,
|
10 |
+
"intermediate_size": 22016,
|
11 |
+
"max_position_embeddings": 16384,
|
12 |
+
"model_type": "llama",
|
13 |
+
"num_attention_heads": 64,
|
14 |
+
"num_hidden_layers": 48,
|
15 |
+
"num_key_value_heads": 8,
|
16 |
+
"pretraining_tp": 1,
|
17 |
+
"rms_norm_eps": 1e-05,
|
18 |
+
"rope_scaling": null,
|
19 |
+
"rope_theta": 1000000,
|
20 |
+
"tie_word_embeddings": false,
|
21 |
+
"torch_dtype": "bfloat16",
|
22 |
+
"transformers_version": "4.32.0.dev0",
|
23 |
+
"use_cache": true,
|
24 |
+
"vocab_size": 32000,
|
25 |
+
"bos_token": "<s>",
|
26 |
+
"eos_token": "</s>",
|
27 |
+
"layer_norm_epsilon": 1e-05,
|
28 |
+
"unk_token": "<unk>"
|
29 |
+
}
|
generation_config.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 1,
|
4 |
+
"eos_token_id": 2,
|
5 |
+
"transformers_version": "4.32.0.dev0"
|
6 |
+
}
|
model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:444f7e6799be276db6917f69e8bc42a3ffbcb1cfaa2f00b46a66491e3e95f656
|
3 |
+
size 33758632127
|
special_tokens_map.json
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
"unk_token": {
|
17 |
+
"content": "<unk>",
|
18 |
+
"lstrip": false,
|
19 |
+
"normalized": true,
|
20 |
+
"rstrip": false,
|
21 |
+
"single_word": false
|
22 |
+
}
|
23 |
+
}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
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 |
+
"legacy": null,
|
22 |
+
"model_max_length": 1000000000000000019884624838656,
|
23 |
+
"pad_token": null,
|
24 |
+
"sp_model_kwargs": {},
|
25 |
+
"tokenizer_class": "CodeLlamaTokenizer",
|
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.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
vocabulary.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|