wangzhang commited on
Commit
8f14c60
·
1 Parent(s): 5c42807

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -38,10 +38,10 @@ def generate(
38
  message: str,
39
  chat_history: list[tuple[str, str]],
40
  system_prompt: str,
41
- max_new_tokens: int = 1024,
42
- temperature: float = 0.6,
43
  top_p: float = 0.9,
44
- top_k: int = 50,
45
  repetition_penalty: float = 1.2,
46
  ) -> Iterator[str]:
47
  conversation = []
@@ -51,7 +51,17 @@ def generate(
51
  conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
52
  conversation.append({"role": "user", "content": message})
53
 
54
- chat = tokenizer.apply_chat_template(conversation, tokenize=False)
 
 
 
 
 
 
 
 
 
 
55
  inputs = tokenizer(chat, return_tensors="pt", add_special_tokens=False).to("cuda")
56
  if len(inputs) > MAX_INPUT_TOKEN_LENGTH:
57
  inputs = inputs[-MAX_INPUT_TOKEN_LENGTH:]
 
38
  message: str,
39
  chat_history: list[tuple[str, str]],
40
  system_prompt: str,
41
+ max_new_tokens: int = 512,
42
+ temperature: float = 0.2,
43
  top_p: float = 0.9,
44
+ top_k: int = 10,
45
  repetition_penalty: float = 1.2,
46
  ) -> Iterator[str]:
47
  conversation = []
 
51
  conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
52
  conversation.append({"role": "user", "content": message})
53
 
54
+ prompt = f"""### Instruction:
55
+
56
+ ### Task:
57
+ 根据巨杉数据库SequoiaDB的相关问题进行回答。
58
+
59
+ ### Input:
60
+ {message}
61
+
62
+ ### Response:
63
+ """
64
+ chat = tokenizer.apply_chat_template(prompt, tokenize=False)
65
  inputs = tokenizer(chat, return_tensors="pt", add_special_tokens=False).to("cuda")
66
  if len(inputs) > MAX_INPUT_TOKEN_LENGTH:
67
  inputs = inputs[-MAX_INPUT_TOKEN_LENGTH:]