sharpbai commited on
Commit
21a7584
·
1 Parent(s): 19b94de

Upload /README.md with huggingface_hub

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