Text Generation
Transformers
Safetensors
English
mistral
code
text-generation-inference
conversational
Inference Endpoints
beowolx commited on
Commit
44e2e64
1 Parent(s): 78c79cd

Update README

Browse files
Files changed (1) hide show
  1. README.md +103 -0
README.md CHANGED
@@ -1,3 +1,106 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ datasets:
4
+ - glaiveai/glaive-code-assistant-v2
5
+ - TokenBender/code_instructions_122k_alpaca_style
6
+ language:
7
+ - en
8
+ metrics:
9
+ - code_eval
10
+ pipeline_tag: text-generation
11
+ tags:
12
+ - code
13
+ - text-generation-inference
14
  ---
15
+
16
+
17
+
18
+ <p align="center">
19
+ <img width="700px" alt="DeepSeek Coder" src="https://cdn-uploads.huggingface.co/production/uploads/64b566ab04fa6584c03b5247/5COagfF6EwrV4utZJ-ClI.png">
20
+ </p>
21
+ <hr>
22
+
23
+
24
+ ## 1. Introduction of CodeNinja
25
+
26
+ CodeNinja is a fine tuned version of the excellent model [openchat/openchat-3.5-1210](https://huggingface.co/openchat/openchat-3.5-1210). It is a 7B model that was fine tuned using Supervised Fine Tuning in 2 instructions datasets containing in total more than 400 000 code instructions.
27
+
28
+ The model is quite good for coding tasks and it's goal is to be a coding assistant that you can use daily.
29
+
30
+ The quantized versions can be found here: [beowolx/CodeNinja-1.0-OpenChat-7B-GGUF](https://huggingface.co/beowolx/CodeNinja-1.0-OpenChat-7B-GGUF).
31
+
32
+ The model performs very good in a serie of different tasks.
33
+
34
+ - **Massive Training Data**: Fine-tuned using the datasets [glaiveai/glaive-code-assistant-v2](https://huggingface.co/datasets/glaiveai/glaive-code-assistant-v2) and [TokenBender/code_instructions_122k_alpaca_style](https://huggingface.co/datasets/TokenBender/code_instructions_122k_alpaca_style) it contains around 400 000 code instructions in different programming languages such as Python, C, C++, Rust, Java, JavaScript and etc.
35
+
36
+ - **Highly Flexible & Scalable**: Offered in model sizes of 7B, enabling users to run it locally.
37
+
38
+ - **Superior Model Performance**: State-of-the-art performance among publicly available code models on HumanEval.
39
+
40
+ - **Advanced Code Completion Capabilities**: A context window size of 8192 supporting project-level code completion.
41
+
42
+ ## 2. Prompt Format
43
+ CodeNinja uses the same prompt format than OpenChat 3.5 so you will need to use it to get good results.
44
+
45
+ The prompt format looks like this:
46
+
47
+ ```
48
+ GPT4 Correct User: Hello<|end_of_turn|>GPT4 Correct Assistant: Hi<|end_of_turn|>GPT4 Correct User: How are you today?<|end_of_turn|>GPT4 Correct Assistant:
49
+ ```
50
+ 🚨 Notice: Remember to set `<|end_of_turn|>` as end of generation token.
51
+
52
+ **You must use this prompt format to get good results**
53
+
54
+ ## 3. How to Use
55
+
56
+ #### Using LM Studio
57
+ The easiest way to start using the model is to download one of the [quantized](https://huggingface.co/beowolx/CodeNinja-1.0-OpenChat-7B-GGUF) versions
58
+ using [LM Studio](https://lmstudio.ai/).
59
+
60
+ You then need to make sure that you are using the "OpenChat" preset that contain the prompt format mentioned above already set.
61
+
62
+ If you want, you can get the preset from this [gist](https://gist.github.com/beowolx/b219466681c02ff67baf8f313a3ad817).
63
+
64
+ #### Using the transformers library
65
+
66
+ ```python
67
+ from transformers import AutoTokenizer, AutoModelForCausalLM
68
+ import torch
69
+
70
+ # Initialize the model
71
+ model_path = "beowolx/CodeNinja-1.0-OpenChat-7B"
72
+ model = AutoModelForCausalLM.from_pretrained(model_path, device_map="auto")
73
+ # Import openchat tokenizer
74
+ tokenizer = AutoTokenizer.from_pretrained("openchat/openchat-3.5-1210", use_fast=True)
75
+
76
+ def generate_one_completion(prompt: str):
77
+ messages = [
78
+ {"role": "user", "content": prompt},
79
+ {"role": "assistant", "content": ""} # Placeholder for the model's response
80
+ ]
81
+
82
+ # Apply the chat template to get the list of token IDs
83
+ input_ids = tokenizer.apply_chat_template(messages, add_generation_prompt=True)
84
+
85
+ # Generate completion
86
+ generate_ids = model.generate(
87
+ torch.tensor([input_ids]).to("cuda"), # Convert list to tensor and send to GPU
88
+ max_length=256,
89
+ pad_token_id=tokenizer.pad_token_id,
90
+ eos_token_id=tokenizer.eos_token_id
91
+ )
92
+
93
+ # Decode and clean up the completion
94
+ completion = tokenizer.decode(generate_ids[0], skip_special_tokens=True)
95
+ completion = completion.split("\n\n\n")[0].strip()
96
+
97
+ return completion
98
+ ```
99
+
100
+ ## 4. License
101
+ This code repository is licensed under the MIT License. The use of CodeNinja model is subject to the Model License.
102
+
103
+
104
+ ## 5. Contact
105
+
106
+ If you have any questions, please raise an issue here.