Nihal Nayak commited on
Commit
7c5f508
1 Parent(s): 7ebf5ca

wip: respond

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -26,6 +26,20 @@ def respond(
26
  "\n<|context|>\n" + context.strip() + "\n<|task|>\n"
27
  )
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
 
31
  # for token in client.text_generation(input_text, max_tokens=max_tokens, temperature=temperature, top_p=top_p, stream=True):
 
26
  "\n<|context|>\n" + context.strip() + "\n<|task|>\n"
27
  )
28
 
29
+ input_ids = tokenizer.encode(input_text, return_tensors="pt").to("cuda")
30
+ outputs = model.generate(
31
+ input_ids,
32
+ max_new_tokens=max_tokens,
33
+ temperature=temperature,
34
+ do_sample=True,
35
+ top_p=top_p,
36
+ )
37
+ pred_start = int(input_ids.shape[-1])
38
+ pred = tokenizer.decode(outputs[pred_start:], skip_special_tokens=True)
39
+
40
+ # replace the context
41
+
42
+ return pred
43
 
44
 
45
  # for token in client.text_generation(input_text, max_tokens=max_tokens, temperature=temperature, top_p=top_p, stream=True):