Update app.py
Browse files
app.py
CHANGED
@@ -33,26 +33,20 @@ sft_start_token = "<|im_start|>"
|
|
33 |
sft_end_token = "<|im_end|>"
|
34 |
ct_end_token = "<|endoftext|>"
|
35 |
|
36 |
-
system_prompt=
|
37 |
-
|
38 |
-
Your answer should be friendly, unbiased, faithful, informative and detailed.'
|
39 |
-
system_prompt = f"<|im_start|>{system_role}\n{system_prompt}<|im_end|>"
|
40 |
|
41 |
# Function to generate model predictions.
|
42 |
|
43 |
@spaces.GPU()
|
44 |
def predict(message, history):
|
45 |
-
|
46 |
-
# history_transformer_format = history + [[message, ""]]
|
47 |
try:
|
48 |
stop = StopOnTokens()
|
49 |
|
50 |
-
# Formatting the input for the model.
|
51 |
-
# messages = system_prompt + sft_end_token.join([sft_end_token.join([f"\n{sft_start_token}{user_role}\n" + item[0], f"\n{sft_start_token}{assistant_role}\n" + item[1]])
|
52 |
-
# for item in history_transformer_format])
|
53 |
-
|
54 |
model_messages = []
|
55 |
print(f'history: {history}')
|
|
|
56 |
for i, item in enumerate(history):
|
57 |
model_messages.append({"role": user_role, "content": item[0]})
|
58 |
model_messages.append({"role": assistant_role, "content": item[1]})
|
@@ -70,8 +64,7 @@ def predict(message, history):
|
|
70 |
input_ids=model_inputs,
|
71 |
streamer=streamer,
|
72 |
max_new_tokens=1024,
|
73 |
-
do_sample=False
|
74 |
-
stopping_criteria=StoppingCriteriaList([stop])
|
75 |
)
|
76 |
t = Thread(target=model.generate, kwargs=generate_kwargs)
|
77 |
t.start() # Starting the generation in a separate thread.
|
|
|
33 |
sft_end_token = "<|im_end|>"
|
34 |
ct_end_token = "<|endoftext|>"
|
35 |
|
36 |
+
system_prompt= 'You are a CodeLLM developed by INF.'
|
37 |
+
|
|
|
|
|
38 |
|
39 |
# Function to generate model predictions.
|
40 |
|
41 |
@spaces.GPU()
|
42 |
def predict(message, history):
|
43 |
+
|
|
|
44 |
try:
|
45 |
stop = StopOnTokens()
|
46 |
|
|
|
|
|
|
|
|
|
47 |
model_messages = []
|
48 |
print(f'history: {history}')
|
49 |
+
model_messages.append({"role": system_role, "content": system_prompt})
|
50 |
for i, item in enumerate(history):
|
51 |
model_messages.append({"role": user_role, "content": item[0]})
|
52 |
model_messages.append({"role": assistant_role, "content": item[1]})
|
|
|
64 |
input_ids=model_inputs,
|
65 |
streamer=streamer,
|
66 |
max_new_tokens=1024,
|
67 |
+
do_sample=False)
|
|
|
68 |
)
|
69 |
t = Thread(target=model.generate, kwargs=generate_kwargs)
|
70 |
t.start() # Starting the generation in a separate thread.
|