invalid-coder commited on
Commit
4a70e5a
1 Parent(s): fe23c3f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -63
README.md CHANGED
@@ -1,63 +0,0 @@
1
- ---
2
- license: apache-2.0
3
- ---
4
- Uses
5
-
6
- Important: Please use the exact chat template provided below for the model. Otherwise there will be a degrade in the performance. The model output can be verbose in rare cases. Please consider setting temperature = 0 to make this happen less.
7
-
8
- Our model follows the exact chat template and usage as Openchat-3.5-0106. Please refer to their model card for more details. In addition, our model is hosted on LMSYS Chatbot Arena for free test.
9
-
10
- The conversation template is the same as Openchat-3.5-0106:
11
-
12
- import transformers
13
- tokenizer = transformers.AutoTokenizer.from_pretrained("openchat/openchat-3.5-0106")
14
-
15
- # Single-turn
16
- tokens = tokenizer("GPT4 Correct User: Hello<|end_of_turn|>GPT4 Correct Assistant:").input_ids
17
- assert tokens == [1, 420, 6316, 28781, 3198, 3123, 1247, 28747, 22557, 32000, 420, 6316, 28781, 3198, 3123, 21631, 28747]
18
-
19
- # Multi-turn
20
- tokens = tokenizer("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:").input_ids
21
- assert tokens == [1, 420, 6316, 28781, 3198, 3123, 1247, 28747, 22557, 32000, 420, 6316, 28781, 3198, 3123, 21631, 28747, 15359, 32000, 420, 6316, 28781, 3198, 3123, 1247, 28747, 1602, 460, 368, 3154, 28804, 32000, 420, 6316, 28781, 3198, 3123, 21631, 28747]
22
-
23
- # Coding Mode
24
- tokens = tokenizer("Code User: Implement quicksort using C++<|end_of_turn|>Code Assistant:").input_ids
25
- assert tokens == [1, 7596, 1247, 28747, 26256, 2936, 7653, 1413, 334, 1680, 32000, 7596, 21631, 28747]
26
-
27
- Code Examples
28
- import transformers
29
-
30
- tokenizer = transformers.AutoTokenizer.from_pretrained("invalid-coder/Starling-LM-7B-beta-laser-dpo")
31
- model = transformers.AutoModelForCausalLM.from_pretrained("invalid-coder/Starling-LM-7B-beta-laser-dpo")
32
-
33
- def generate_response(prompt):
34
- input_ids = tokenizer(prompt, return_tensors="pt").input_ids
35
- outputs = model.generate(
36
- input_ids,
37
- max_length=256,
38
- pad_token_id=tokenizer.pad_token_id,
39
- eos_token_id=tokenizer.eos_token_id,
40
- )
41
- response_ids = outputs[0]
42
- response_text = tokenizer.decode(response_ids, skip_special_tokens=True)
43
- return response_text
44
-
45
- # Single-turn conversation
46
- prompt = "Hello, how are you?"
47
- single_turn_prompt = f"GPT4 Correct User: {prompt}<|end_of_turn|>GPT4 Correct Assistant:"
48
- response_text = generate_response(single_turn_prompt)
49
- print("Response:", response_text)
50
-
51
- ## Multi-turn conversation
52
- prompt = "Hello"
53
- follow_up_question = "How are you today?"
54
- response = ""
55
- multi_turn_prompt = f"GPT4 Correct User: {prompt}<|end_of_turn|>GPT4 Correct Assistant: {response}<|end_of_turn|>GPT4 Correct User: {follow_up_question}<|end_of_turn|>GPT4 Correct Assistant:"
56
- response_text = generate_response(multi_turn_prompt)
57
- print("Multi-turn conversation response:", response_text)
58
-
59
- ### Coding conversation
60
- prompt = "Implement quicksort using C++"
61
- coding_prompt = f"Code User: {prompt}<|end_of_turn|>Code Assistant:"
62
- response = generate_response(coding_prompt)
63
- print("Coding conversation response:", response)