Instructions to use dorkai/codeX-1.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use dorkai/codeX-1.0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="dorkai/codeX-1.0")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("dorkai/codeX-1.0", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use dorkai/codeX-1.0 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "dorkai/codeX-1.0" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "dorkai/codeX-1.0", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/dorkai/codeX-1.0
- SGLang
How to use dorkai/codeX-1.0 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 "dorkai/codeX-1.0" \ --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": "dorkai/codeX-1.0", "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 "dorkai/codeX-1.0" \ --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": "dorkai/codeX-1.0", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use dorkai/codeX-1.0 with Docker Model Runner:
docker model run hf.co/dorkai/codeX-1.0
| # Copyright (c) Microsoft Corporation. | |
| # Licensed under the MIT license. | |
| from evaluator.CodeBLEU.parser import DFG_python, DFG_java, DFG_ruby, DFG_go, DFG_php, DFG_javascript, DFG_csharp | |
| from evaluator.CodeBLEU.parser import (remove_comments_and_docstrings, | |
| tree_to_token_index, | |
| index_to_code_token, | |
| tree_to_variable_index) | |
| from tree_sitter import Language, Parser | |
| import os | |
| root_dir = os.path.dirname(__file__) | |
| dfg_function = { | |
| 'python': DFG_python, | |
| 'java': DFG_java, | |
| 'ruby': DFG_ruby, | |
| 'go': DFG_go, | |
| 'php': DFG_php, | |
| 'javascript': DFG_javascript, | |
| 'c_sharp': DFG_csharp, | |
| } | |
| def calc_syntax_match(references, candidate, lang): | |
| return corpus_syntax_match([references], [candidate], lang) | |
| def corpus_syntax_match(references, candidates, lang): | |
| JAVA_LANGUAGE = Language(root_dir + '/parser/my-languages.so', lang) | |
| parser = Parser() | |
| parser.set_language(JAVA_LANGUAGE) | |
| match_count = 0 | |
| total_count = 0 | |
| for i in range(len(candidates)): | |
| references_sample = references[i] | |
| candidate = candidates[i] | |
| for reference in references_sample: | |
| try: | |
| candidate = remove_comments_and_docstrings(candidate, 'java') | |
| except: | |
| pass | |
| try: | |
| reference = remove_comments_and_docstrings(reference, 'java') | |
| except: | |
| pass | |
| candidate_tree = parser.parse(bytes(candidate, 'utf8')).root_node | |
| reference_tree = parser.parse(bytes(reference, 'utf8')).root_node | |
| def get_all_sub_trees(root_node): | |
| node_stack = [] | |
| sub_tree_sexp_list = [] | |
| depth = 1 | |
| node_stack.append([root_node, depth]) | |
| while len(node_stack) != 0: | |
| cur_node, cur_depth = node_stack.pop() | |
| sub_tree_sexp_list.append([cur_node.sexp(), cur_depth]) | |
| for child_node in cur_node.children: | |
| if len(child_node.children) != 0: | |
| depth = cur_depth + 1 | |
| node_stack.append([child_node, depth]) | |
| return sub_tree_sexp_list | |
| cand_sexps = [x[0] for x in get_all_sub_trees(candidate_tree)] | |
| ref_sexps = get_all_sub_trees(reference_tree) | |
| # print(cand_sexps) | |
| # print(ref_sexps) | |
| for sub_tree, depth in ref_sexps: | |
| if sub_tree in cand_sexps: | |
| match_count += 1 | |
| total_count += len(ref_sexps) | |
| score = match_count / total_count | |
| return score | |