Instructions to use 01-ai/Yi-Coder-1.5B-Chat with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use 01-ai/Yi-Coder-1.5B-Chat with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="01-ai/Yi-Coder-1.5B-Chat") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("01-ai/Yi-Coder-1.5B-Chat") model = AutoModelForCausalLM.from_pretrained("01-ai/Yi-Coder-1.5B-Chat") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use 01-ai/Yi-Coder-1.5B-Chat with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "01-ai/Yi-Coder-1.5B-Chat" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "01-ai/Yi-Coder-1.5B-Chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/01-ai/Yi-Coder-1.5B-Chat
- SGLang
How to use 01-ai/Yi-Coder-1.5B-Chat 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 "01-ai/Yi-Coder-1.5B-Chat" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "01-ai/Yi-Coder-1.5B-Chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "01-ai/Yi-Coder-1.5B-Chat" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "01-ai/Yi-Coder-1.5B-Chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use 01-ai/Yi-Coder-1.5B-Chat with Docker Model Runner:
docker model run hf.co/01-ai/Yi-Coder-1.5B-Chat
[wish] Release SAMPLE datasets
Yi Coder 1.5b is potentially a great model for fine-tuning on one's own codebase. It'd be great if you could release some SAMPLE portions of the dataset used for base training & instruction tuning (and perhaps recipes), so that fine-tuning could be done in a compatible format.
I have an app that includes built-in Python scripting with an app-specific API, and would love to add a chatbot tuned on that API, so that users could get small scripts written from natural language prompts, or even written and executed, without the user ever needed to see the code.
Hi π @twardoch , thank you so much π. We've already forwarded the request regarding the example data for the Coder model. We also have some example datasets for fine-tuning available at https://github.com/01-ai/Yi/tree/main/finetune/yi_example_dataset/data. Although they are not directly related to code, the format is the same. Thanks again!
Yi Coder 1.5b is potentially a great model for fine-tuning on one's own codebase. It'd be great if you could release some SAMPLE portions of the dataset used for base training & instruction tuning (and perhaps recipes), so that fine-tuning could be done in a compatible format.
I have an app that includes built-in Python scripting with an app-specific API, and would love to add a chatbot tuned on that API, so that users could get small scripts written from natural language prompts, or even written and executed, without the user ever needed to see the code.
Hi twardoch,
Pasting my reply from github issue:
Unfortunately we will not be releasing our data, but I'd be happy to provide some directions for your requirement.
For pertaining, check https://huggingface.co/datasets/bigcode/starcoderdata and https://huggingface.co/datasets/bigcode/the-stack-dedup .
For code SFT, check Code Feedback / CodeAlpaca / Evol-Instruct-code.
For library-specific SDK, start with library-specific SFT pairs mixed with general-purpose SFT first, continue train is very difficult to do correctly without performance loss, and python codes are not extremely hard to generalize. Just remember to keep your SFT pairs as diverse(both semantic-wise and task-wise) and as high-quality as possible.
Best Regards,
Nuo