misukisu commited on
Commit
b78f939
·
verified ·
1 Parent(s): a18f910

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -6,8 +6,7 @@ app = FastAPI()
6
 
7
  pipe = pipeline(
8
  "text-generation",
9
- model="microsoft/phi-3-mini-4k-instruct",
10
- device_map="auto"
11
  )
12
 
13
  class Req(BaseModel):
@@ -17,7 +16,7 @@ def build_prompt(user_msg: str) -> str:
17
  return (
18
  "<|system|>\n"
19
  "You are a helpful, clear, and concise assistant. "
20
- "Give accurate and well-structured answers. Avoid unnecessary fluff."
21
  "<|end|>\n"
22
  "<|user|>\n"
23
  f"{user_msg}"
@@ -35,12 +34,10 @@ def chat(req: Req):
35
  temperature=0.6,
36
  top_p=0.9,
37
  do_sample=True,
38
- repetition_penalty=1.1,
39
- eos_token_id=pipe.tokenizer.eos_token_id
40
  )
41
 
42
  text = out[0]["generated_text"]
43
-
44
  reply = text.split("<|assistant|>")[-1].strip()
45
 
46
  return {"reply": reply}
 
6
 
7
  pipe = pipeline(
8
  "text-generation",
9
+ model="microsoft/phi-3-mini-4k-instruct"
 
10
  )
11
 
12
  class Req(BaseModel):
 
16
  return (
17
  "<|system|>\n"
18
  "You are a helpful, clear, and concise assistant. "
19
+ "Give accurate and well-structured answers."
20
  "<|end|>\n"
21
  "<|user|>\n"
22
  f"{user_msg}"
 
34
  temperature=0.6,
35
  top_p=0.9,
36
  do_sample=True,
37
+ repetition_penalty=1.1
 
38
  )
39
 
40
  text = out[0]["generated_text"]
 
41
  reply = text.split("<|assistant|>")[-1].strip()
42
 
43
  return {"reply": reply}