samkeet commited on
Commit
1d7f089
·
verified ·
1 Parent(s): 5c2d7dc

Upload model

Browse files
Files changed (2) hide show
  1. config.json +0 -15
  2. modeling_gpt.py +1 -2
config.json CHANGED
@@ -7,21 +7,6 @@
7
  "AutoModelForCausalLM": "modeling_gpt.GPTModelForTextGeneration"
8
  },
9
  "block_size": 1024,
10
- "custom_pipelines": {
11
- "text-generation": {
12
- "default": {
13
- "model": {
14
- "pt": "samkeet/GPT_124M"
15
- }
16
- },
17
- "impl": "pipeline_gpt.GPT124MTextGenerationPipeline",
18
- "pt": [
19
- "AutoModelForCausalLM"
20
- ],
21
- "tf": [],
22
- "type": "text"
23
- }
24
- },
25
  "model_type": "custom_gpt",
26
  "n_embd": 768,
27
  "n_head": 12,
 
7
  "AutoModelForCausalLM": "modeling_gpt.GPTModelForTextGeneration"
8
  },
9
  "block_size": 1024,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  "model_type": "custom_gpt",
11
  "n_embd": 768,
12
  "n_head": 12,
modeling_gpt.py CHANGED
@@ -1,7 +1,6 @@
1
  # Importing libraries
2
  import torch
3
  import torch.nn as nn
4
- from typing import Generator
5
  import torch.nn.functional as F
6
  from transformers import PreTrainedModel
7
  from .configuration_gpt import GPTConfig
@@ -250,7 +249,7 @@ class GPTModelForTextGeneration(PreTrainedModel):
250
  # Autoregressive token generation loop
251
  while tokens.size(1) < max_length:
252
  logits = self.forward(tokens)["logits"][:, -1, :]
253
- logits = logits / temperature
254
 
255
  if do_sample:
256
  top_k = min(top_k, logits.size(-1)) # Safety check
 
1
  # Importing libraries
2
  import torch
3
  import torch.nn as nn
 
4
  import torch.nn.functional as F
5
  from transformers import PreTrainedModel
6
  from .configuration_gpt import GPTConfig
 
249
  # Autoregressive token generation loop
250
  while tokens.size(1) < max_length:
251
  logits = self.forward(tokens)["logits"][:, -1, :]
252
+ logits = logits / max(0.01, temperature)
253
 
254
  if do_sample:
255
  top_k = min(top_k, logits.size(-1)) # Safety check