Instructions to use TechxGenus/Yi-9B-Coder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TechxGenus/Yi-9B-Coder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="TechxGenus/Yi-9B-Coder")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("TechxGenus/Yi-9B-Coder") model = AutoModelForCausalLM.from_pretrained("TechxGenus/Yi-9B-Coder") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use TechxGenus/Yi-9B-Coder with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "TechxGenus/Yi-9B-Coder" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TechxGenus/Yi-9B-Coder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/TechxGenus/Yi-9B-Coder
- SGLang
How to use TechxGenus/Yi-9B-Coder with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "TechxGenus/Yi-9B-Coder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TechxGenus/Yi-9B-Coder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "TechxGenus/Yi-9B-Coder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TechxGenus/Yi-9B-Coder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use TechxGenus/Yi-9B-Coder with Docker Model Runner:
docker model run hf.co/TechxGenus/Yi-9B-Coder
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 |
],
|