Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,84 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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="150px">
|
| 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 series models are trained for coding tasks with two sizes available, 1.5B and 9B, supporting 52 major coding languages. Notably, the Yi-Coder-9B outperforms other models under 10 billion parameters such as CodeQwen1.5 7B and CodeGeex4 9B, and even achieves performance on par with DeepSeek-Coder 33B.
|
| 27 |
+
|
| 28 |
+
Yi-Coder excels in long-context understanding, handling up to 128K tokens for project-level code comprehension and generation. Despite its relatively small size, Yi-coder is versatile in tasks like programming, code editing, debugging, completion, and mathematical reasoning.
|
| 29 |
+
|
| 30 |
+
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).
|
| 31 |
+
|
| 32 |
+
<p align="left">
|
| 33 |
+
<img src="https://github.com/01-ai/Yi/blob/main/assets/img/coder/demo1.gif?raw=true" alt="demo1" width="500"/>
|
| 34 |
+
</p>
|
| 35 |
+
|
| 36 |
+
# Models
|
| 37 |
+
|
| 38 |
+
# Benchmarks
|
| 39 |
+
|
| 40 |
+
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%.
|
| 41 |
+
|
| 42 |
+
<p align="left">
|
| 43 |
+
<img src="https://github.com/01-ai/Yi/blob/main/assets/img/coder/b1.jpg?raw=true" alt="b1" width="500"/>
|
| 44 |
+
</p>
|
| 45 |
+
|
| 46 |
+
# Quick Start
|
| 47 |
+
|
| 48 |
+
You can use transformers to run inference with Yi-Coder models (both chat and base versions) as follows:
|
| 49 |
+
```python
|
| 50 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 51 |
+
|
| 52 |
+
device = "cuda" # the device to load the model onto
|
| 53 |
+
model_path = "01-ai/Yi-Coder-9B-Chat"
|
| 54 |
+
|
| 55 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
| 56 |
+
model = AutoModelForCausalLM.from_pretrained(model_path, device_map="auto").eval()
|
| 57 |
+
|
| 58 |
+
prompt = "Write a quick sort algorithm."
|
| 59 |
+
messages = [
|
| 60 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
| 61 |
+
{"role": "user", "content": prompt}
|
| 62 |
+
]
|
| 63 |
+
text = tokenizer.apply_chat_template(
|
| 64 |
+
messages,
|
| 65 |
+
tokenize=False,
|
| 66 |
+
add_generation_prompt=True
|
| 67 |
+
)
|
| 68 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(device)
|
| 69 |
+
|
| 70 |
+
generated_ids = model.generate(
|
| 71 |
+
model_inputs.input_ids,
|
| 72 |
+
max_new_tokens=1024,
|
| 73 |
+
eos_token_id=tokenizer.eos_token_id
|
| 74 |
+
)
|
| 75 |
+
generated_ids = [
|
| 76 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
| 77 |
+
]
|
| 78 |
+
|
| 79 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 80 |
+
print(response)
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
For getting up and running with Yi-Coder series models quickly, see [Yi-Coder README](https://github.com/01-ai/Yi-Coder).
|
| 84 |
+
|