Trickshotblaster commited on
Commit
70d8b6d
·
1 Parent(s): 8de17f5
Files changed (4) hide show
  1. __pycache__/gpt.cpython-310.pyc +0 -0
  2. app.py +3 -1
  3. gpt.py +14 -2
  4. mike-code-15k.pth +3 -0
__pycache__/gpt.cpython-310.pyc CHANGED
Binary files a/__pycache__/gpt.cpython-310.pyc and b/__pycache__/gpt.cpython-310.pyc differ
 
app.py CHANGED
@@ -7,7 +7,9 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
7
  demo = gr.Interface(fn=gpt.get_response, inputs=["textbox",
8
  gr.Slider(0, 100, value=50, step=1),
9
  gr.Slider(0.1, 2.0, value=1.0),
10
- ], outputs="textbox", title="Mike Chat", article="""Mike is the greatest AI ever created. It was trained for about 8 hrs on my pc using fineweb-edu and open orca datasets. While it hallucinates a lot, it seems to be about on par with other lms of its size (about 160M params). Model details:
 
 
11
  block_size: 512
12
  n_layers: 12
13
  n_heads: 12
 
7
  demo = gr.Interface(fn=gpt.get_response, inputs=["textbox",
8
  gr.Slider(0, 100, value=50, step=1),
9
  gr.Slider(0.1, 2.0, value=1.0),
10
+ gr.Dropdown(
11
+ ["mike-chat", "mike-code"], value="mike-chat"),
12
+ ], outputs=gr.Markdown(line_breaks=True), title="Mike Chat", article="""Mike is the greatest AI ever created. It was trained for about 8 hrs on my pc using fineweb-edu and open orca datasets. While it hallucinates a lot, it seems to be about on par with other lms of its size (about 160M params). Model details:
13
  block_size: 512
14
  n_layers: 12
15
  n_heads: 12
gpt.py CHANGED
@@ -134,9 +134,21 @@ my_GPT = load_compiled_model_state_dict(my_GPT, 'latest_model_finetune.pth')
134
  #my_GPT.load_state_dict(torch.load('latest_model_finetune.pth', map_location=torch.device('cpu')))
135
  my_GPT.eval()
136
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  eot = enc._special_tokens['<|endoftext|>']
138
 
139
- def get_response(in_text, top_k=50, temperature=1):
140
  with torch.inference_mode():
141
  prompt = "USER: " + in_text + "\nASSISTANT: "
142
  input_tokens = enc.encode(prompt)
@@ -146,7 +158,7 @@ def get_response(in_text, top_k=50, temperature=1):
146
  input_tokens = input_tokens[1:]
147
  context_tensor = torch.tensor(input_tokens).view(1, -1).to(device)
148
 
149
- logits, loss = my_GPT(context_tensor)
150
  logits = logits[:, -1, :] / temperature
151
  if top_k > 0:
152
  # Remove all tokens with a probability less than the last token of the top-k
 
134
  #my_GPT.load_state_dict(torch.load('latest_model_finetune.pth', map_location=torch.device('cpu')))
135
  my_GPT.eval()
136
 
137
+ my_GPT_code = GPT(enc.n_vocab, block_size, n_layers, n_heads, d_model, dropout=0.1) #enc.n_vocab
138
+ my_GPT_code = my_GPT_code.to(device)
139
+ #my_GPT = torch.compile(my_GPT, mode='reduce-overhead')
140
+ my_GPT_code = load_compiled_model_state_dict(my_GPT_code, 'mike-code-15k.pth')
141
+ #my_GPT.load_state_dict(torch.load('latest_model_finetune.pth', map_location=torch.device('cpu')))
142
+ my_GPT_code.eval()
143
+
144
+ models = {
145
+ "mike-chat": my_GPT,
146
+ "mike-code": my_GPT_code
147
+ }
148
+
149
  eot = enc._special_tokens['<|endoftext|>']
150
 
151
+ def get_response(in_text, top_k=50, temperature=1, model="mike-chat"):
152
  with torch.inference_mode():
153
  prompt = "USER: " + in_text + "\nASSISTANT: "
154
  input_tokens = enc.encode(prompt)
 
158
  input_tokens = input_tokens[1:]
159
  context_tensor = torch.tensor(input_tokens).view(1, -1).to(device)
160
 
161
+ logits, loss = models[model](context_tensor)
162
  logits = logits[:, -1, :] / temperature
163
  if top_k > 0:
164
  # Remove all tokens with a probability less than the last token of the top-k
mike-code-15k.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3a3f92898af4acb8f41a571e6a4f2b597b7cca1316120787f51cb8d11ba84977
3
+ size 650652710