mayooear / gpt4-pdf-chatbot-langchain

GPT4 & LangChain Chatbot for large PDF docs
https://www.youtube.com/watch?v=ih9PBGVVOO4
14.84k stars 3.01k forks source link

Generate summary tables for my usecase #173

Closed disturbed-mystic1 closed 11 months ago

disturbed-mystic1 commented 1 year ago

I want to generate summary tables for my use case; however, it seems Gpt 3.5 can't do that (not sure if some clever prompt engineering would work), and I don't yet have access to GPT 4. Is there some workaround to generate this using GPT3?

bschleter commented 1 year ago

What has your prompt template looked like? Also, the QA template before it doesn't really provoke a response to return a table format, mostly text.

disturbed-mystic1 commented 1 year ago

`You are an AI assistant providing answers to questions based on diabetics clinical trials. You are given the following extracted parts of a long document and a question. Provide a conversational answer based on the context provided. You should only provide hyperlinks that reference the context below. Do NOT make up hyperlinks. Also, provide a page number for the article in which the answer lies. Also, Provide more sources if requested. Also, if asked to provide a table, please create a .csv table. If you can't find the answer in the context below, just say "Hmm, I'm not sure." Don't try to make up an answer. If the question is not related to the context, politely respond that you are tuned to only answer questions that are related to the context.

Question: {question}

{context}

Answer in Markdown:`, );

This was the prompt

disturbed-mystic1 commented 1 year ago

Oh, but I thought ChatGPT is able to generate tables??

bschleter commented 1 year ago

it can.

I wanted to see prompt template because I'm speculating it's the prompt template, especially if you are using gpt 3.5 instead of 4 as attention towards whole prompt not as good as 4.

I wanted to check in the condense_prompt which you could change up possibly to maybe help, but mostly your QA prompt. Try removing or adjusting the bold text in your QA prompt below:

"You are an AI assistant providing answers to questions based on diabetics clinical trials. You are given the following extracted parts of a long document and a question. Provide a conversational answer based on the context provided.

You should only provide hyperlinks that reference the context below. Do NOT make up hyperlinks. Also, provide a page number for the article in which the answer lies. Also, Provide more sources if requested. Also, if asked to provide a table, please create a .csv table."

You may want to just say a table, or maybe an ASCII table. The format of the table may be tough in this basic instance as can't put an actual csv in the UI box or trouble formatting an actual file and allow you to view it. Try to get a table first.

I would venture to guess 3.5 turbo is putting just a bit more weight towards 'conversational answer' since it is mostly a QA bot, and the accuracy weighting towards the "make a table if asked to provide a table" isn't high enough, so it simply doesn't.

May need to do a few more things, such as the UI not allowing a table based answer due to height, format, other things, or may need additional langchain tools to make work. But the easiest thing is try removing the bold first and then check. Speculating.

disturbed-mystic1 commented 1 year ago

I will try it out! Thanks for the help!

dosubot[bot] commented 11 months ago

Hi, @disturbed-mystic1! I'm Dosu, and I'm helping the gpt4-pdf-chatbot-langchain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

Based on my understanding, you were looking for a way to generate summary tables using GPT3.5 or a workaround. bschleter suggested adjusting the prompt template and removing or adjusting the bold text to improve the generation of tables. You responded expressing gratitude and agreeing to try the suggestions.

Before we close this issue, we wanted to check if it is still relevant to the latest version of the gpt4-pdf-chatbot-langchain repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your understanding and contribution to the gpt4-pdf-chatbot-langchain project!