add task chat for all chat models, like chatglm-6B (#213)

* add task chat

* update output format

---------

Co-authored-by: Zhicheng Zhang <zhangzhicheng.zzc@alibaba-inc.com>
This commit is contained in:
Zhicheng Zhang
2023-03-20 21:19:29 +08:00
committed by GitHub
parent d3cec46655
commit ab0d41afe2
4 changed files with 14 additions and 0 deletions

View File

@@ -50,6 +50,7 @@ task_default_metrics = {
Tasks.sentiment_classification: [Metrics.seq_cls_metric], Tasks.sentiment_classification: [Metrics.seq_cls_metric],
Tasks.token_classification: [Metrics.token_cls_metric], Tasks.token_classification: [Metrics.token_cls_metric],
Tasks.text_generation: [Metrics.text_gen_metric], Tasks.text_generation: [Metrics.text_gen_metric],
Tasks.chat: [Metrics.text_gen_metric],
Tasks.text_classification: [Metrics.seq_cls_metric], Tasks.text_classification: [Metrics.seq_cls_metric],
Tasks.image_denoising: [Metrics.image_denoise_metric], Tasks.image_denoising: [Metrics.image_denoise_metric],
Tasks.image_deblurring: [Metrics.image_denoise_metric], Tasks.image_deblurring: [Metrics.image_denoise_metric],

View File

@@ -736,6 +736,13 @@ TASK_OUTPUTS = {
# } # }
Tasks.text_generation: [OutputKeys.TEXT], Tasks.text_generation: [OutputKeys.TEXT],
# chat task result for single sample
# {
# "response": "this is the chat response generated by a model.",
# "history": [("hi", "nice to meet you"),("I felt happy, and you", "me too")]
# }
Tasks.chat: [OutputKeys.RESPONSE, OutputKeys.HISTORY],
# fid dialogue result for single sample # fid dialogue result for single sample
# { # {
# "text": "My name is Mike" # "text": "My name is Mike"

View File

@@ -173,6 +173,10 @@ TASK_INPUTS = {
InputType.IMAGE, InputType.IMAGE,
# ============ nlp tasks =================== # ============ nlp tasks ===================
Tasks.chat: {
'text': InputType.TEXT,
'history': InputType.LIST,
},
Tasks.text_classification: [ Tasks.text_classification: [
InputType.TEXT, InputType.TEXT,
(InputType.TEXT, InputType.TEXT), (InputType.TEXT, InputType.TEXT),

View File

@@ -160,6 +160,8 @@ class CVTasks(object):
class NLPTasks(object): class NLPTasks(object):
# chat
chat = 'chat'
# nlp tasks # nlp tasks
word_segmentation = 'word-segmentation' word_segmentation = 'word-segmentation'
part_of_speech = 'part-of-speech' part_of_speech = 'part-of-speech'