TechxGenus
commited on
Commit
•
0df9b32
1
Parent(s):
e24e3e3
Upload 3 files
Browse files- README.md +68 -0
- Yi-Coder.jpg +0 -0
- config.json +1 -1
README.md
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
tags:
|
3 |
+
- code
|
4 |
+
- llama
|
5 |
+
library_name: transformers
|
6 |
+
pipeline_tag: text-generation
|
7 |
+
license: other
|
8 |
+
license_name: yi-license
|
9 |
+
license_link: https://huggingface.co/01-ai/Yi-9B/blob/main/LICENSE
|
10 |
+
---
|
11 |
+
|
12 |
+
<p align="center">
|
13 |
+
<img width="300px" alt="Yi-Coder" src="https://huggingface.co/TechxGenus/Yi-9B-Coder/resolve/main/Yi-Coder.jpg">
|
14 |
+
</p>
|
15 |
+
|
16 |
+
### Yi-Coder
|
17 |
+
|
18 |
+
We've fine-tuned Yi-9B with an additional 0.5 billion high-quality, code-related tokens for 3 epochs. We used DeepSpeed ZeRO 3 and Flash Attention 2 to accelerate the training process. It achieves **69.5 pass@1** on HumanEval-Python. This model operates using the Alpaca instruction format (excluding the system prompt).
|
19 |
+
|
20 |
+
### Usage
|
21 |
+
|
22 |
+
Here give some examples of how to use our model:
|
23 |
+
|
24 |
+
```python
|
25 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
26 |
+
import torch
|
27 |
+
PROMPT = """### Instruction
|
28 |
+
{instruction}
|
29 |
+
### Response
|
30 |
+
"""
|
31 |
+
instruction = <Your code instruction here>
|
32 |
+
prompt = PROMPT.format(instruction=instruction)
|
33 |
+
tokenizer = AutoTokenizer.from_pretrained("TechxGenus/Yi-9B-Coder")
|
34 |
+
model = AutoModelForCausalLM.from_pretrained(
|
35 |
+
"TechxGenus/Yi-9B-Coder",
|
36 |
+
torch_dtype=torch.bfloat16,
|
37 |
+
device_map="auto",
|
38 |
+
)
|
39 |
+
inputs = tokenizer.encode(prompt, return_tensors="pt")
|
40 |
+
outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=2048)
|
41 |
+
print(tokenizer.decode(outputs[0]))
|
42 |
+
```
|
43 |
+
|
44 |
+
With text-generation pipeline:
|
45 |
+
|
46 |
+
|
47 |
+
```python
|
48 |
+
from transformers import pipeline
|
49 |
+
import torch
|
50 |
+
PROMPT = """### Instruction
|
51 |
+
{instruction}
|
52 |
+
### Response
|
53 |
+
"""
|
54 |
+
instruction = <Your code instruction here>
|
55 |
+
prompt = PROMPT.format(instruction=instruction)
|
56 |
+
generator = pipeline(
|
57 |
+
model="TechxGenus/Yi-9B-Coder",
|
58 |
+
task="text-generation",
|
59 |
+
torch_dtype=torch.bfloat16,
|
60 |
+
device_map="auto",
|
61 |
+
)
|
62 |
+
result = generator(prompt, max_length=2048)
|
63 |
+
print(result[0]["generated_text"])
|
64 |
+
```
|
65 |
+
|
66 |
+
### Note
|
67 |
+
|
68 |
+
Model may sometimes make errors, produce misleading contents, or struggle to manage tasks that are not related to coding. It has undergone very limited testing. Additional safety testing should be performed before any real-world deployments.
|
Yi-Coder.jpg
ADDED
config.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
{
|
2 |
-
"_name_or_path": "/
|
3 |
"architectures": [
|
4 |
"LlamaForCausalLM"
|
5 |
],
|
|
|
1 |
{
|
2 |
+
"_name_or_path": "01-ai/Yi-9B",
|
3 |
"architectures": [
|
4 |
"LlamaForCausalLM"
|
5 |
],
|