BeveledCube commited on
Commit
8e724ea
1 Parent(s): 30e32ac

Added EOS toke stuff increased new token limit and added QOL features to frontent

Browse files
models/blenderbot.py CHANGED
@@ -23,6 +23,6 @@ def generate(input_text):
23
  input_ids = tokenizer.encode(input_text, return_tensors="pt")
24
 
25
  # Generate output using the model
26
- output_ids = model.generate(input_ids, no_repeat_ngram_size=2, max_new_tokens=100)
27
 
28
  return tokenizer.decode(output_ids[0], skip_special_tokens=True)
 
23
  input_ids = tokenizer.encode(input_text, return_tensors="pt")
24
 
25
  # Generate output using the model
26
+ output_ids = model.generate(input_ids, no_repeat_ngram_size=2, max_new_tokens=100, eos_token_id=tokenizer.eos_token_id)
27
 
28
  return tokenizer.decode(output_ids[0], skip_special_tokens=True)
models/fast.py CHANGED
@@ -11,6 +11,6 @@ def load():
11
 
12
  def generate(input_text):
13
  input_ids = tokenizer.encode(input_text, return_tensors="pt")
14
- output_ids = model.generate(input_ids, no_repeat_ngram_size=2, max_new_tokens=100)
15
 
16
  return tokenizer.decode(output_ids[0], skip_special_tokens=True)
 
11
 
12
  def generate(input_text):
13
  input_ids = tokenizer.encode(input_text, return_tensors="pt")
14
+ output_ids = model.generate(input_ids, no_repeat_ngram_size=2, max_new_tokens=100, eos_token_id=tokenizer.eos_token_id)
15
 
16
  return tokenizer.decode(output_ids[0], skip_special_tokens=True)
models/gpt2.py CHANGED
@@ -16,6 +16,6 @@ def generate(input_text):
16
  attention_mask = tf.ones_like(input_ids)
17
 
18
  # Generate output using the model
19
- output_ids = model.generate(input_ids, num_beams=5, no_repeat_ngram_size=2, max_new_tokens=100)
20
 
21
  return tokenizer.decode(output_ids[0], skip_special_tokens=True)
 
16
  attention_mask = tf.ones_like(input_ids)
17
 
18
  # Generate output using the model
19
+ output_ids = model.generate(input_ids, num_beams=5, no_repeat_ngram_size=2, max_new_tokens=100, eos_token_id=tokenizer.eos_token_id)
20
 
21
  return tokenizer.decode(output_ids[0], skip_special_tokens=True)
models/hermes.py CHANGED
@@ -13,6 +13,6 @@ tokenizer = AutoTokenizer.from_pretrained(model_name)
13
 
14
  def generate(messages):
15
  gen_input = tokenizer.apply_chat_template(messages, return_tensors="pt")
16
- output_ids = model.generate(**gen_input, num_beams=5, no_repeat_ngram_size=2, max_new_tokens=100)
17
 
18
  return tokenizer.decode(output_ids[0], skip_special_tokens=True)
 
13
 
14
  def generate(messages):
15
  gen_input = tokenizer.apply_chat_template(messages, return_tensors="pt")
16
+ output_ids = model.generate(**gen_input, num_beams=5, no_repeat_ngram_size=2, max_new_tokens=100, eos_token_id=tokenizer.eos_token_id)
17
 
18
  return tokenizer.decode(output_ids[0], skip_special_tokens=True)
models/llama2.py CHANGED
@@ -11,6 +11,6 @@ def load():
11
 
12
  def generate(input_text):
13
  input_ids = tokenizer.encode(input_text, return_tensors="pt")
14
- output_ids = model.generate(input_ids, no_repeat_ngram_size=2, max_new_tokens=100)
15
 
16
  return tokenizer.decode(output_ids[0], skip_special_tokens=True)
 
11
 
12
  def generate(input_text):
13
  input_ids = tokenizer.encode(input_text, return_tensors="pt")
14
+ output_ids = model.generate(input_ids, no_repeat_ngram_size=2, max_new_tokens=100, eos_token_id=tokenizer.eos_token_id)
15
 
16
  return tokenizer.decode(output_ids[0], skip_special_tokens=True)
models/llama3.py CHANGED
@@ -11,6 +11,6 @@ def load():
11
 
12
  def generate(input_text):
13
  input_ids = tokenizer.encode(input_text, return_tensors="pt")
14
- output_ids = model.generate(input_ids, no_repeat_ngram_size=2, max_new_tokens=100)
15
 
16
  return tokenizer.decode(output_ids[0], skip_special_tokens=True)
 
11
 
12
  def generate(input_text):
13
  input_ids = tokenizer.encode(input_text, return_tensors="pt")
14
+ output_ids = model.generate(input_ids, no_repeat_ngram_size=2, max_new_tokens=100, eos_token_id=tokenizer.eos_token_id)
15
 
16
  return tokenizer.decode(output_ids[0], skip_special_tokens=True)
models/llamatiny.py CHANGED
@@ -11,6 +11,6 @@ def load():
11
 
12
  def generate(input_text):
13
  input_ids = tokenizer.encode(input_text, return_tensors="pt")
14
- output_ids = model.generate(input_ids, no_repeat_ngram_size=2, max_new_tokens=100)
15
 
16
  return tokenizer.decode(output_ids[0], skip_special_tokens=True)
 
11
 
12
  def generate(input_text):
13
  input_ids = tokenizer.encode(input_text, return_tensors="pt")
14
+ output_ids = model.generate(input_ids, no_repeat_ngram_size=2, max_new_tokens=100, eos_token_id=tokenizer.eos_token_id)
15
 
16
  return tokenizer.decode(output_ids[0], skip_special_tokens=True)
models/mamba.py CHANGED
@@ -11,6 +11,6 @@ def load():
11
 
12
  def generate(input_text):
13
  input_ids = tokenizer.encode(input_text, return_tensors="pt")
14
- output_ids = model.generate(input_ids, no_repeat_ngram_size=2, max_new_tokens=100)
15
 
16
  return tokenizer.decode(output_ids[0], skip_special_tokens=True)
 
11
 
12
  def generate(input_text):
13
  input_ids = tokenizer.encode(input_text, return_tensors="pt")
14
+ output_ids = model.generate(input_ids, no_repeat_ngram_size=2, max_new_tokens=100, eos_token_id=tokenizer.eos_token_id)
15
 
16
  return tokenizer.decode(output_ids[0], skip_special_tokens=True)
models/tinystories.py CHANGED
@@ -11,6 +11,12 @@ def load():
11
 
12
  def generate(input_text):
13
  input_ids = tokenizer.encode(input_text, return_tensors="pt")
14
- output_ids = model.generate(input_ids, no_repeat_ngram_size=2, max_new_tokens=100)
 
 
 
 
 
 
15
 
16
  return tokenizer.decode(output_ids[0], skip_special_tokens=True)
 
11
 
12
  def generate(input_text):
13
  input_ids = tokenizer.encode(input_text, return_tensors="pt")
14
+ output_ids = model.generate(
15
+ input_ids,
16
+ no_repeat_ngram_size=2,
17
+ max_new_tokens=200,
18
+ eos_token_id=tokenizer.eos_token_id,
19
+ temperature=0.2
20
+ )
21
 
22
  return tokenizer.decode(output_ids[0], skip_special_tokens=True)
templates/index.html CHANGED
@@ -74,12 +74,23 @@
74
  const apiUrl = `https://beveledcube-bevelapi.hf.space/api`;
75
  const sendPromptButton = document.getElementById("send-prompt");
76
  const responseContainer = document.getElementById("responses");
 
 
 
 
 
 
 
 
 
 
77
 
78
- sendPromptButton.addEventListener("click", async () => {
79
  console.log("Sending prompt")
80
 
81
  const responseElement = document.createElement("div");
82
- const requestData = { prompt: getValue("prompt") };
 
83
 
84
  responseElement.classList.add("response-container");
85
 
@@ -114,8 +125,7 @@
114
  .catch(error => {
115
  console.error("Error:", error.message);
116
  });
117
-
118
- });
119
 
120
  function getValue(elementId) {
121
  return document.getElementById(elementId).value;
 
74
  const apiUrl = `https://beveledcube-bevelapi.hf.space/api`;
75
  const sendPromptButton = document.getElementById("send-prompt");
76
  const responseContainer = document.getElementById("responses");
77
+ let promptInput = document.getElementById("prompt")
78
+
79
+ sendPromptButton.addEventListener("click", () => sendPrompt());
80
+ promptInput.addEventListener("keydown", (event) => {
81
+ if (event.key === "Enter") {
82
+ // Prevent the default action if needed (e.g., form submission)
83
+ event.preventDefault();
84
+ sendPrompt()
85
+ }
86
+ });
87
 
88
+ function sendPrompt() {
89
  console.log("Sending prompt")
90
 
91
  const responseElement = document.createElement("div");
92
+ const requestData = { prompt: promptInput.value };
93
+ promptInput.value = "";
94
 
95
  responseElement.classList.add("response-container");
96
 
 
125
  .catch(error => {
126
  console.error("Error:", error.message);
127
  });
128
+ }
 
129
 
130
  function getValue(elementId) {
131
  return document.getElementById(elementId).value;