migtissera commited on
Commit
2606982
·
verified ·
1 Parent(s): 20f26e8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +91 -0
README.md CHANGED
@@ -97,3 +97,94 @@ special_tokens:
97
  ```
98
 
99
  </details><br>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  ```
98
 
99
  </details><br>
100
+
101
+ # Tess-3-7B-SFT
102
+
103
+ ![Tess-3](https://huggingface.co/migtissera/Tess-v2.5-Qwen2-72B/resolve/main/Tess-v2.5.png)
104
+
105
+ Tess-3-7B is a finetuned version of the Mistral-7B-v0.3 base model. This version is the first phase of the final Tess-3 model, and have been trained with supervised fine-tuning (SFT) on a curated dataset of ~500K samples. The total SFT dataset contains about 1B tokens.
106
+
107
+
108
+
109
+
110
+ # Sample code to run inference
111
+
112
+ Note that this model uses ChatML prompt format.
113
+
114
+ ```python
115
+ import torch, json
116
+ from transformers import AutoModelForCausalLM, AutoTokenizer
117
+ from stop_word import StopWordCriteria
118
+
119
+ model_path = "migtissera/Tess-3-7B-SFT"
120
+ output_file_path = "/home/migel/conversations.jsonl"
121
+
122
+ model = AutoModelForCausalLM.from_pretrained(
123
+ model_path,
124
+ torch_dtype=torch.float16,
125
+ device_map="auto",
126
+ load_in_4bit=False,
127
+ trust_remote_code=True,
128
+ )
129
+
130
+ tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
131
+
132
+ terminators = [
133
+ tokenizer.convert_tokens_to_ids("<|im_end|>")
134
+ ]
135
+
136
+ def generate_text(instruction):
137
+ tokens = tokenizer.encode(instruction)
138
+ tokens = torch.LongTensor(tokens).unsqueeze(0)
139
+ tokens = tokens.to("cuda")
140
+
141
+ instance = {
142
+ "input_ids": tokens,
143
+ "top_p": 1.0,
144
+ "temperature": 0.75,
145
+ "generate_len": 1024,
146
+ "top_k": 50,
147
+ }
148
+
149
+ length = len(tokens[0])
150
+ with torch.no_grad():
151
+ rest = model.generate(
152
+ input_ids=tokens,
153
+ max_length=length + instance["generate_len"],
154
+ use_cache=True,
155
+ do_sample=True,
156
+ top_p=instance["top_p"],
157
+ temperature=instance["temperature"],
158
+ top_k=instance["top_k"],
159
+ num_return_sequences=1,
160
+ pad_token_id=tokenizer.eos_token_id,
161
+ eos_token_id=terminators,
162
+ )
163
+ output = rest[0][length:]
164
+ string = tokenizer.decode(output, skip_special_tokens=True)
165
+ return f"{string}"
166
+
167
+ conversation = f"""<|im_start|>system\nYou are Tesoro, a helful AI assitant. You always provide detailed answers without hesitation.<|im_end|>\n<|im_start|>user\n"""
168
+
169
+ while True:
170
+ user_input = input("You: ")
171
+ llm_prompt = f"{conversation}{user_input}<|im_end|>\n<|im_start|>assistant\n"
172
+ answer = generate_text(llm_prompt)
173
+ print(answer)
174
+ conversation = f"{llm_prompt}{answer}\n"
175
+ json_data = {"prompt": user_input, "answer": answer}
176
+
177
+ with open(output_file_path, "a") as output_file:
178
+ output_file.write(json.dumps(json_data) + "\n")
179
+ ```
180
+
181
+ # Join My General AI Discord (NeuroLattice):
182
+ https://discord.gg/Hz6GrwGFKD
183
+
184
+ # Limitations & Biases:
185
+
186
+ While this model aims for accuracy, it can occasionally produce inaccurate or misleading results.
187
+
188
+ Despite diligent efforts in refining the pretraining data, there remains a possibility for the generation of inappropriate, biased, or offensive content.
189
+
190
+ Exercise caution and cross-check information when necessary. This is an uncensored model.