promptslab / Promptify

Prompt Engineering | Prompt Versioning | Use GPT or other prompt based models to get structured output. Join our discord for Prompt-Engineering, LLMs and other latest research
https://discord.gg/m88xfYMbK6
Apache License 2.0
3.28k stars 241 forks source link

Pipeline.fit() got multiple values for argument 'text_input' #92

Open Jasydom opened 1 year ago

Jasydom commented 1 year ago

Hello,

I would like to do MultiLabel Text-Classification

My code:

model        = OpenAI(api_key)
prompter     = Prompter('multilabel_classification.jinja')
pipe         = Pipeline(prompter, model)

classes = ['Medicine','Oncology','Metastasis','Breast cancer','Lung cancer','Cerebrospinal fluid','Tumor microenvironment','Single-cell RNA sequencing','Idiopathic intracranial hypertension']

sent = "The patient is a 93-year-old female with a medical history of chronic right hip pain, osteoporosis, hypertension, depression, and chronic atrial fibrillation admitted for evaluation and management of severe nausea and vomiting and urinary tract infection"
result = pipe.fit('multilabel_classification.jinja',
                          n_output_labels = len(classes),
                          domain          = 'Clinical',
                          text_input      = sent,
                          labels          = classes)

print(eval(result['text']))

I got this error Pipeline.fit() got multiple values for argument 'text_input'

Thank you for taking the time to respond to me.

Have a good day

monk1337 commented 1 year ago

You don't need to pass 'jinja' multiple times, you are passing template in prompter and again in pipe.fit function.

Try this:

result = pipe.fit(sent, 
n_output_labels = len(classes),
domain          = 'Clinical',
labels          = classes)

also no need to eval on output, it will be handle internally.

Jasydom commented 1 year ago

Thanks for the reply

Have a good day