Upload 7 files
Browse files- README.md +97 -0
- config.json +40 -0
- generation_config.json +7 -0
- output.safetensors +3 -0
- special_tokens_map.json +30 -0
- tokenizer.model +3 -0
- tokenizer_config.json +61 -0
README.md
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
---
|
4 |
+
<div align="center">
|
5 |
+
|
6 |
+
<picture>
|
7 |
+
<img src="https://raw.githubusercontent.com/01-ai/Yi/main/assets/img/Yi_logo_icon_light.svg" width="120px">
|
8 |
+
</picture>
|
9 |
+
|
10 |
+
</div>
|
11 |
+
|
12 |
+
<p align="center">
|
13 |
+
<a href="https://github.com/01-ai">🐙 GitHub</a> •
|
14 |
+
<a href="https://discord.gg/hYUwWddeAu">👾 Discord</a> •
|
15 |
+
<a href="https://twitter.com/01ai_yi">🐤 Twitter</a> •
|
16 |
+
<a href="https://github.com/01-ai/Yi-1.5/issues/2">💬 WeChat</a>
|
17 |
+
<br/>
|
18 |
+
<a href="https://arxiv.org/abs/2403.04652">📝 Paper</a> •
|
19 |
+
<a href="https://01-ai.github.io/">💪 Tech Blog</a> •
|
20 |
+
<a href="https://github.com/01-ai/Yi/tree/main?tab=readme-ov-file#faq">🙌 FAQ</a> •
|
21 |
+
<a href="https://github.com/01-ai/Yi/tree/main?tab=readme-ov-file#learning-hub">📗 Learning Hub</a>
|
22 |
+
</p>
|
23 |
+
|
24 |
+
# Intro
|
25 |
+
|
26 |
+
Yi-Coder is a series of open-source code language models that delivers state-of-the-art coding performance with fewer than 10 billion parameters.
|
27 |
+
|
28 |
+
Key features:
|
29 |
+
- Excelling in long-context understanding with a maximum context length of 128K tokens.
|
30 |
+
- Supporting 52 major programming languages:
|
31 |
+
```bash
|
32 |
+
'java', 'markdown', 'python', 'php', 'javascript', 'c++', 'c#', 'c', 'typescript', 'html', 'go', 'java_server_pages', 'dart', 'objective-c', 'kotlin', 'tex', 'swift', 'ruby', 'sql', 'rust', 'css', 'yaml', 'matlab', 'lua', 'json', 'shell', 'visual_basic', 'scala', 'rmarkdown', 'pascal', 'fortran', 'haskell', 'assembly', 'perl', 'julia', 'cmake', 'groovy', 'ocaml', 'powershell', 'elixir', 'clojure', 'makefile', 'coffeescript', 'erlang', 'lisp', 'toml', 'batchfile', 'cobol', 'dockerfile', 'r', 'prolog', 'verilog'
|
33 |
+
```
|
34 |
+
|
35 |
+
For model details and benchmarks, see [Yi-Coder blog](https://01-ai.github.io/) and [Yi-Coder README](https://github.com/01-ai/Yi-Coder).
|
36 |
+
|
37 |
+
<p align="left">
|
38 |
+
<img src="https://github.com/01-ai/Yi/blob/main/assets/img/coder/yi-coder-calculator-demo.gif?raw=true" alt="demo1" width="500"/>
|
39 |
+
</p>
|
40 |
+
|
41 |
+
# Models
|
42 |
+
|
43 |
+
| Name | Type | Length | Download |
|
44 |
+
|--------------------|------|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
|
45 |
+
| Yi-Coder-9B-Chat | Chat | 128K | [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-Coder-9B-Chat) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-Coder-9B-Chat) • [🟣 wisemodel](https://wisemodel.cn/models/01.AI/Yi-Coder-9B-Chat) |
|
46 |
+
| Yi-Coder-1.5B-Chat | Chat | 128K | [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-Coder-1.5B-Chat) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-Coder-1.5B-Chat) • [🟣 wisemodel](https://wisemodel.cn/models/01.AI/Yi-Coder-1.5B-Chat) |
|
47 |
+
| Yi-Coder-9B | Base | 128K | [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-Coder-9B) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-Coder-9B) • [🟣 wisemodel](https://wisemodel.cn/models/01.AI/Yi-Coder-9B) |
|
48 |
+
| Yi-Coder-1.5B | Base | 128K | [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-Coder-1.5B) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-Coder-1.5B) • [🟣 wisemodel](https://wisemodel.cn/models/01.AI/Yi-Coder-1.5B) |
|
49 |
+
| |
|
50 |
+
|
51 |
+
# Benchmarks
|
52 |
+
|
53 |
+
As illustrated in the figure below, Yi-Coder-9B-Chat achieved an impressive 23% pass rate in LiveCodeBench, making it the only model with under 10B parameters to surpass 20%. It also outperforms DeepSeekCoder-33B-Ins at 22.3%, CodeGeex4-9B-all at 17.8%, CodeLLama-34B-Ins at 13.3%, and CodeQwen1.5-7B-Chat at 12%.
|
54 |
+
|
55 |
+
<p align="left">
|
56 |
+
<img src="https://github.com/01-ai/Yi/blob/main/assets/img/coder/bench1.webp?raw=true" alt="bench1" width="1000"/>
|
57 |
+
</p>
|
58 |
+
|
59 |
+
# Quick Start
|
60 |
+
|
61 |
+
You can use transformers to run inference with Yi-Coder models (both chat and base versions) as follows:
|
62 |
+
```python
|
63 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
64 |
+
|
65 |
+
device = "cuda" # the device to load the model onto
|
66 |
+
model_path = "01-ai/Yi-Coder-9B-Chat"
|
67 |
+
|
68 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
69 |
+
model = AutoModelForCausalLM.from_pretrained(model_path, device_map="auto").eval()
|
70 |
+
|
71 |
+
prompt = "Write a quick sort algorithm."
|
72 |
+
messages = [
|
73 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
74 |
+
{"role": "user", "content": prompt}
|
75 |
+
]
|
76 |
+
text = tokenizer.apply_chat_template(
|
77 |
+
messages,
|
78 |
+
tokenize=False,
|
79 |
+
add_generation_prompt=True
|
80 |
+
)
|
81 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(device)
|
82 |
+
|
83 |
+
generated_ids = model.generate(
|
84 |
+
model_inputs.input_ids,
|
85 |
+
max_new_tokens=1024,
|
86 |
+
eos_token_id=tokenizer.eos_token_id
|
87 |
+
)
|
88 |
+
generated_ids = [
|
89 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
90 |
+
]
|
91 |
+
|
92 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
93 |
+
print(response)
|
94 |
+
```
|
95 |
+
|
96 |
+
For getting up and running with Yi-Coder series models quickly, see [Yi-Coder README](https://github.com/01-ai/Yi-Coder).
|
97 |
+
|
config.json
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"LlamaForCausalLM"
|
4 |
+
],
|
5 |
+
"attention_bias": false,
|
6 |
+
"attention_dropout": 0.0,
|
7 |
+
"bos_token_id": 1,
|
8 |
+
"eos_token_id": 2,
|
9 |
+
"hidden_act": "silu",
|
10 |
+
"hidden_size": 2048,
|
11 |
+
"initializer_range": 0.02,
|
12 |
+
"intermediate_size": 5504,
|
13 |
+
"max_position_embeddings": 131072,
|
14 |
+
"mlp_bias": false,
|
15 |
+
"model_type": "llama",
|
16 |
+
"num_attention_heads": 16,
|
17 |
+
"num_hidden_layers": 24,
|
18 |
+
"num_key_value_heads": 16,
|
19 |
+
"pad_token_id": 0,
|
20 |
+
"pretraining_tp": 1,
|
21 |
+
"rms_norm_eps": 1e-05,
|
22 |
+
"rope_scaling": null,
|
23 |
+
"rope_theta": 10000000,
|
24 |
+
"tie_word_embeddings": false,
|
25 |
+
"torch_dtype": "bfloat16",
|
26 |
+
"transformers_version": "4.44.0",
|
27 |
+
"use_cache": false,
|
28 |
+
"vocab_size": 64000,
|
29 |
+
"quantization_config": {
|
30 |
+
"quant_method": "exl2",
|
31 |
+
"version": "0.2.0",
|
32 |
+
"bits": 4.0,
|
33 |
+
"head_bits": 6,
|
34 |
+
"calibration": {
|
35 |
+
"rows": 115,
|
36 |
+
"length": 2048,
|
37 |
+
"dataset": "(default)"
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
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.44.0"
|
7 |
+
}
|
output.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e9affac0742fa96c8284e068e62f378a54f8b6035935c9f42fb46e3958ca79f0
|
3 |
+
size 973490472
|
special_tokens_map.json
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": {
|
3 |
+
"content": "<|startoftext|>",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": false,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"eos_token": {
|
10 |
+
"content": "<|im_end|>",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": false,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"pad_token": {
|
17 |
+
"content": "<unk>",
|
18 |
+
"lstrip": false,
|
19 |
+
"normalized": false,
|
20 |
+
"rstrip": false,
|
21 |
+
"single_word": false
|
22 |
+
},
|
23 |
+
"unk_token": {
|
24 |
+
"content": "<unk>",
|
25 |
+
"lstrip": false,
|
26 |
+
"normalized": false,
|
27 |
+
"rstrip": false,
|
28 |
+
"single_word": false
|
29 |
+
}
|
30 |
+
}
|
tokenizer.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:386c49cf943d71aa110361135338c50e38beeff0a66593480421f37b319e1a39
|
3 |
+
size 1033105
|
tokenizer_config.json
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": false,
|
3 |
+
"add_eos_token": false,
|
4 |
+
"add_prefix_space": false,
|
5 |
+
"added_tokens_decoder": {
|
6 |
+
"0": {
|
7 |
+
"content": "<unk>",
|
8 |
+
"lstrip": false,
|
9 |
+
"normalized": false,
|
10 |
+
"rstrip": false,
|
11 |
+
"single_word": false,
|
12 |
+
"special": true
|
13 |
+
},
|
14 |
+
"1": {
|
15 |
+
"content": "<|startoftext|>",
|
16 |
+
"lstrip": false,
|
17 |
+
"normalized": false,
|
18 |
+
"rstrip": false,
|
19 |
+
"single_word": false,
|
20 |
+
"special": true
|
21 |
+
},
|
22 |
+
"2": {
|
23 |
+
"content": "<|endoftext|>",
|
24 |
+
"lstrip": false,
|
25 |
+
"normalized": false,
|
26 |
+
"rstrip": false,
|
27 |
+
"single_word": false,
|
28 |
+
"special": true
|
29 |
+
},
|
30 |
+
"6": {
|
31 |
+
"content": "<|im_start|>",
|
32 |
+
"lstrip": false,
|
33 |
+
"normalized": false,
|
34 |
+
"rstrip": false,
|
35 |
+
"single_word": false,
|
36 |
+
"special": true
|
37 |
+
},
|
38 |
+
"7": {
|
39 |
+
"content": "<|im_end|>",
|
40 |
+
"lstrip": false,
|
41 |
+
"normalized": false,
|
42 |
+
"rstrip": false,
|
43 |
+
"single_word": false,
|
44 |
+
"special": true
|
45 |
+
}
|
46 |
+
},
|
47 |
+
"bos_token": "<|startoftext|>",
|
48 |
+
"chat_template": "{% if messages[0]['role'] == 'system' %}{% set system_message = messages[0]['content'] %}{% endif %}{% if system_message is defined %}{{ '<|im_start|>system\n' + system_message + '<|im_end|>\n' }}{% endif %}{% for message in messages %}{% set content = message['content'] %}{% if message['role'] == 'user' %}{{ '<|im_start|>user\n' + content + '<|im_end|>\n<|im_start|>assistant\n' }}{% elif message['role'] == 'assistant' %}{{ content + '<|im_end|>' + '\n' }}{% endif %}{% endfor %}",
|
49 |
+
"clean_up_tokenization_spaces": false,
|
50 |
+
"eos_token": "<|im_end|>",
|
51 |
+
"legacy": true,
|
52 |
+
"model_max_length": 200000,
|
53 |
+
"pad_token": "<unk>",
|
54 |
+
"padding_side": "right",
|
55 |
+
"sp_model_kwargs": {},
|
56 |
+
"spaces_between_special_tokens": false,
|
57 |
+
"split_special_tokens": false,
|
58 |
+
"tokenizer_class": "LlamaTokenizer",
|
59 |
+
"unk_token": "<unk>",
|
60 |
+
"use_default_system_prompt": false
|
61 |
+
}
|