IMJONEZZ commited on
Commit
08bf969
•
1 Parent(s): e5fc54d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +131 -0
README.md CHANGED
@@ -1,3 +1,134 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ language:
4
+ - en
5
+ tags:
6
+ - llama
7
+ - openchat
8
  ---
9
+
10
+ Since this is an OpenChat model, here's the OpenChat card.
11
+
12
+ # OpenChat: Less is More for Open-source Models
13
+
14
+ OpenChat is a series of open-source language models fine-tuned on a diverse and high-quality dataset of multi-round conversations. With only ~6K GPT-4 conversations filtered from the ~90K ShareGPT conversations, OpenChat is designed to achieve high performance with limited data.
15
+
16
+ **Generic models:**
17
+
18
+ - OpenChat: based on LLaMA-13B (2048 context length)
19
+ - **🚀 105.7%** of ChatGPT score on Vicuna GPT-4 evaluation
20
+ - **🔥 80.9%** Win-rate on AlpacaEval
21
+ - **🤗 Only used 6K data for finetuning!!!**
22
+ - OpenChat-8192: based on LLaMA-13B (extended to 8192 context length)
23
+ - **106.6%** of ChatGPT score on Vicuna GPT-4 evaluation
24
+ - **79.5%** of ChatGPT score on Vicuna GPT-4 evaluation
25
+
26
+ **Code models:**
27
+
28
+ - OpenCoderPlus: based on StarCoderPlus (native 8192 context length)
29
+ - **102.5%** of ChatGPT score on Vicuna GPT-4 evaluation
30
+ - **78.7%** Win-rate on AlpacaEval
31
+
32
+ *Note:* Please load the pretrained models using *bfloat16*
33
+
34
+ ## Code and Inference Server
35
+
36
+ We provide the full source code, including an inference server compatible with the "ChatCompletions" API, in the [OpenChat](https://github.com/imoneoi/openchat) GitHub repository.
37
+
38
+ ## Web UI
39
+
40
+ OpenChat also includes a web UI for a better user experience. See the GitHub repository for instructions.
41
+
42
+ ## Conversation Template
43
+
44
+ The conversation template **involves concatenating tokens**.
45
+
46
+ Besides base model vocabulary, an end-of-turn token `<|end_of_turn|>` is added, with id `eot_token_id`.
47
+
48
+ ```python
49
+ # OpenChat
50
+ [bos_token_id] + tokenize("Human: ") + tokenize(user_question) + [eot_token_id] + tokenize("Assistant: ")
51
+ # OpenCoder
52
+ tokenize("User:") + tokenize(user_question) + [eot_token_id] + tokenize("Assistant:")
53
+ ```
54
+
55
+ *Hint: In BPE, `tokenize(A) + tokenize(B)` does not always equals to `tokenize(A + B)`*
56
+
57
+ Following is the code for generating the conversation templates:
58
+
59
+ ```python
60
+ @dataclass
61
+ class ModelConfig:
62
+ # Prompt
63
+ system: Optional[str]
64
+
65
+ role_prefix: dict
66
+ ai_role: str
67
+ eot_token: str
68
+ bos_token: Optional[str] = None
69
+
70
+ # Get template
71
+ def generate_conversation_template(self, tokenize_fn, tokenize_special_fn, message_list):
72
+ tokens = []
73
+ masks = []
74
+
75
+ # begin of sentence (bos)
76
+ if self.bos_token:
77
+ t = tokenize_special_fn(self.bos_token)
78
+ tokens.append(t)
79
+ masks.append(False)
80
+
81
+ # System
82
+ if self.system:
83
+ t = tokenize_fn(self.system) + [tokenize_special_fn(self.eot_token)]
84
+ tokens.extend(t)
85
+ masks.extend([False] * len(t))
86
+
87
+ # Messages
88
+ for idx, message in enumerate(message_list):
89
+ # Prefix
90
+ t = tokenize_fn(self.role_prefix[message["from"]])
91
+ tokens.extend(t)
92
+ masks.extend([False] * len(t))
93
+
94
+ # Message
95
+ if "value" in message:
96
+ t = tokenize_fn(message["value"]) + [tokenize_special_fn(self.eot_token)]
97
+ tokens.extend(t)
98
+ masks.extend([message["from"] == self.ai_role] * len(t))
99
+ else:
100
+ assert idx == len(message_list) - 1, "Empty message for completion must be on the last."
101
+
102
+ return tokens, masks
103
+
104
+
105
+ MODEL_CONFIG_MAP = {
106
+ # OpenChat / OpenChat-8192
107
+ "openchat": ModelConfig(
108
+ # Prompt
109
+ system=None,
110
+
111
+ role_prefix={
112
+ "human": "Human: ",
113
+ "gpt": "Assistant: "
114
+ },
115
+ ai_role="gpt",
116
+ eot_token="<|end_of_turn|>",
117
+ bos_token="<s>",
118
+ ),
119
+
120
+ # OpenCoder / OpenCoderPlus
121
+ "opencoder": ModelConfig(
122
+ # Prompt
123
+ system=None,
124
+
125
+ role_prefix={
126
+ "human": "User:",
127
+ "gpt": "Assistant:"
128
+ },
129
+ ai_role="gpt",
130
+ eot_token="<|end_of_turn|>",
131
+ bos_token=None,
132
+ )
133
+ }
134
+ ```