wangzhang commited on
Commit
0382be1
·
1 Parent(s): 73c25af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -27,7 +27,7 @@ if not torch.cuda.is_available():
27
 
28
 
29
  if torch.cuda.is_available():
30
- model_id = "wangzhang/ChatSDB-hf"
31
  model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
32
  tokenizer = AutoTokenizer.from_pretrained(model_id)
33
  tokenizer.use_default_system_prompt = False
@@ -49,9 +49,9 @@ def generate(
49
  conversation.append({"role": "system", "content": system_prompt})
50
  for user, assistant in chat_history:
51
  conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
52
- conversation.append({"role": "user", "content": "### Instruction: \n" + "根据巨杉数据库SequoiaDB的相关问题进行回答。\n" + "### Input:\n" + message + "\n ### Response:"})
53
 
54
- chat = tokenizer.apply_chat_template([{"role": "user", "content": "### Instruction: \n" + "根据巨杉数据库SequoiaDB的相关问题进行回答。\n" + "### Input:\n" + message + "\n ### Response:"}], 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:]
 
27
 
28
 
29
  if torch.cuda.is_available():
30
+ model_id = "wangzhang/ChatSDB-tb-testing"
31
  model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
32
  tokenizer = AutoTokenizer.from_pretrained(model_id)
33
  tokenizer.use_default_system_prompt = False
 
49
  conversation.append({"role": "system", "content": system_prompt})
50
  for user, assistant in chat_history:
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:]