Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jinchat-server
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
aigc-pioneer
jinchat-server
Commits
0abd2d99
提交
0abd2d99
authored
6月 13, 2023
作者:
glide-the
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
llama_llm.py 提示词修改
上级
f1cfd6d6
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
10 行增加
和
8 行删除
+10
-8
model_config.py
configs/model_config.py
+1
-1
llama_llm.py
models/llama_llm.py
+7
-5
moss_llm.py
models/moss_llm.py
+2
-2
没有找到文件。
configs/model_config.py
浏览文件 @
0abd2d99
...
@@ -74,7 +74,7 @@ llm_model_dict = {
...
@@ -74,7 +74,7 @@ llm_model_dict = {
"vicuna-13b-hf"
:
{
"vicuna-13b-hf"
:
{
"name"
:
"vicuna-13b-hf"
,
"name"
:
"vicuna-13b-hf"
,
"pretrained_model_name"
:
"vicuna-13b-hf"
,
"pretrained_model_name"
:
"vicuna-13b-hf"
,
"local_model_path"
:
"/media/checkpoint/vicuna-13b-hf"
,
"local_model_path"
:
None
,
"provides"
:
"LLamaLLM"
"provides"
:
"LLamaLLM"
},
},
...
...
models/llama_llm.py
浏览文件 @
0abd2d99
...
@@ -98,9 +98,10 @@ class LLamaLLM(BaseAnswer, LLM, ABC):
...
@@ -98,9 +98,10 @@ class LLamaLLM(BaseAnswer, LLM, ABC):
"""
"""
formatted_history
=
''
formatted_history
=
''
history
=
history
[
-
self
.
history_len
:]
if
self
.
history_len
>
0
else
[]
history
=
history
[
-
self
.
history_len
:]
if
self
.
history_len
>
0
else
[]
for
i
,
(
old_query
,
response
)
in
enumerate
(
history
):
if
len
(
history
)
>
0
:
formatted_history
+=
"[Round {}]
\n
问:{}
\n
答:{}
\n
"
.
format
(
i
,
old_query
,
response
)
for
i
,
(
old_query
,
response
)
in
enumerate
(
history
):
formatted_history
+=
"[Round {}]
\n
问:{}
\n
答:"
.
format
(
len
(
history
),
query
)
formatted_history
+=
"### Human:{}
\n
### Assistant:{}
\n
"
.
format
(
old_query
,
response
)
formatted_history
+=
"### Human:{}
\n
### Assistant:"
.
format
(
query
)
return
formatted_history
return
formatted_history
def
prepare_inputs_for_generation
(
self
,
def
prepare_inputs_for_generation
(
self
,
...
@@ -140,12 +141,13 @@ class LLamaLLM(BaseAnswer, LLM, ABC):
...
@@ -140,12 +141,13 @@ class LLamaLLM(BaseAnswer, LLM, ABC):
"max_new_tokens"
:
self
.
max_new_tokens
,
"max_new_tokens"
:
self
.
max_new_tokens
,
"num_beams"
:
self
.
num_beams
,
"num_beams"
:
self
.
num_beams
,
"top_p"
:
self
.
top_p
,
"top_p"
:
self
.
top_p
,
"do_sample"
:
True
,
"top_k"
:
self
.
top_k
,
"top_k"
:
self
.
top_k
,
"repetition_penalty"
:
self
.
repetition_penalty
,
"repetition_penalty"
:
self
.
repetition_penalty
,
"encoder_repetition_penalty"
:
self
.
encoder_repetition_penalty
,
"encoder_repetition_penalty"
:
self
.
encoder_repetition_penalty
,
"min_length"
:
self
.
min_length
,
"min_length"
:
self
.
min_length
,
"temperature"
:
self
.
temperature
,
"temperature"
:
self
.
temperature
,
"eos_token_id"
:
self
.
eos_token_id
,
"eos_token_id"
:
self
.
checkPoint
.
tokenizer
.
eos_token_id
,
"logits_processor"
:
self
.
logits_processor
}
"logits_processor"
:
self
.
logits_processor
}
# 向量转换
# 向量转换
...
@@ -178,6 +180,6 @@ class LLamaLLM(BaseAnswer, LLM, ABC):
...
@@ -178,6 +180,6 @@ class LLamaLLM(BaseAnswer, LLM, ABC):
response
=
self
.
_call
(
prompt
=
softprompt
,
stop
=
[
'
\n
###'
])
response
=
self
.
_call
(
prompt
=
softprompt
,
stop
=
[
'
\n
###'
])
answer_result
=
AnswerResult
()
answer_result
=
AnswerResult
()
answer_result
.
history
=
history
+
[[
None
,
response
]]
answer_result
.
history
=
history
+
[[
prompt
,
response
]]
answer_result
.
llm_output
=
{
"answer"
:
response
}
answer_result
.
llm_output
=
{
"answer"
:
response
}
yield
answer_result
yield
answer_result
models/moss_llm.py
浏览文件 @
0abd2d99
...
@@ -75,8 +75,8 @@ class MOSSLLM(BaseAnswer, LLM, ABC):
...
@@ -75,8 +75,8 @@ class MOSSLLM(BaseAnswer, LLM, ABC):
repetition_penalty
=
1.02
,
repetition_penalty
=
1.02
,
num_return_sequences
=
1
,
num_return_sequences
=
1
,
eos_token_id
=
106068
,
eos_token_id
=
106068
,
pad_token_id
=
self
.
tokenizer
.
pad_token_id
)
pad_token_id
=
self
.
checkPoint
.
tokenizer
.
pad_token_id
)
response
=
self
.
tokenizer
.
decode
(
outputs
[
0
][
inputs
.
input_ids
.
shape
[
1
]:],
skip_special_tokens
=
True
)
response
=
self
.
checkPoint
.
tokenizer
.
decode
(
outputs
[
0
][
inputs
.
input_ids
.
shape
[
1
]:],
skip_special_tokens
=
True
)
self
.
checkPoint
.
clear_torch_cache
()
self
.
checkPoint
.
clear_torch_cache
()
history
+=
[[
prompt
,
response
]]
history
+=
[[
prompt
,
response
]]
answer_result
=
AnswerResult
()
answer_result
=
AnswerResult
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论