Building a llm ChatGPT for pdf

trying to build a llm for a pdf analyser that can answer any questions about the pdf you input into the model and i decided to use the text davinci 003 model but when i get to this line of code where i call the model
“llm = OpenAI(temperature=0, model_name=“text-davinci-003”, max_tokens=-1)”
i get this error, any ideas?

From the API documentation it seems that ‘max_tokens’ parameters must be a positive integer or null. It’s also optional. In your example ‘max_tokens’ is set to ‘-1’.
Try a positive value or try to simply omit this parameter.

2 Likes

decided to pass it a max_tokens value of -1 so it’s considered as unlimited.
idk if that makes sense?

1 Like

Indeed, I imagined. Usually it’s like this, ‘-1’ means ‘end’ or ‘max’. But maybe in the case of OpenAI API it is an invalid value.

2 Likes

Don’t use the text completion models, they’ll be deprecated in a few weeks. starting Jan 4th, 2024:

https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo

You should be using a Chat based model, like gpt-3.5-turbo with LangChain:
https://api.python.langchain.com/en/stable/chat_models/langchain.chat_models.openai.ChatOpenAI.html#langchain.chat_models.openai.ChatOpenAI


from langchain.chat_models import ChatOpenAI
openai = ChatOpenAI(model_name="gpt-3.5-turbo")
3 Likes

do you know any IDE i can use to build this chatgpt for pdf because the one i am using currently (replit) requires money for me to deploy it

1 Like

do you know any IDE i can use to build this chatgpt for pdf because the one i am using currently (replit) requires money for me to deploy it.

1 Like

Here is an open-source project you can follow to setup chat with pdf GitHub - Anil-matcha/ChatPDF: Chat with any PDF. Easily upload the PDF documents you'd like to chat with. Instant answers. Ask questions, extract information, and summarize documents with AI. Sources included.

2 Likes

I’m used to develop command line utilities with command line tools, so my opinion is not the more reliable. Anyway, I think you can check ‘gradio.app’ option (https://www.gradio.app/).

A few weeks ago, for fun, I managed to create 4 simple applications in a single afternoon. So I think it’s worth a try. For a quick start with OpenAI python api you can check Creating A Chatbot Fast

2 Likes

do you have a twitter account so i can message you there about your work,i am trying to build exactly what you are building for my final year project and would like to discuss with you freely and ask any questions i can

Sure, you can connect with me from here https://twitter.com/matchaman11

1 Like