Is text-ada-001 a valid LLM?
Try something like gpt-3.5-turbo using the ChatOpenAI class, it will be 10x cheaper than the default LLM
No, text-davinci-003 is the default, and it is $0.02/1k tokens
gpt-3.5-turbo is $0.002/1k tokens
Like this ?: llm_predictor = LLMPredictor(llm=OpenAI(temperature=0.7, model_name="gpt-3.5-turbo", max_tokens=num_outputs))
Try something like this
from llama_index import LLMPredictor, ServiceContext
from langchain.chat_models import ChatOpenAI
llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo"))
service_context = ServiceContext.from_defaults(llm_predictor=llm_predictor, chunk_size_limit=1024)
Chunk size limit is optional haha
first thanks π
I would appreciate a brief explanation.
And what is Langchain used for here ?
Langchain is just used as a wrapper around the api calls to openAI. Llama index uses langchain for a few small things to avoid duplicating code
So they have the specific wrapper to call gpt-3.5 already written
Then it gets wrapped with the llama index specific object
Hi Can you explain the role of this line : service_context = ServiceContext.from_defaults(llm_predictor=llm_predictor, chunk_size_limit=1024 ? is it mandatory ? what do i need to do with service_context?
The service context sets up certain parameters about how the index will do things. This includes the llm_prediction, embedding model, node parser, prompt helper, chunk size limit, and llama logger.
By using from_defaults
, it sets everything to the defaults, except for what we pass in. Then, you can pass it into the index constructor or query calls
index.query(..., service_context=service_context)
index = GPTSimpleVectorIndex.from_documents(..., service_context=service_context)
It's only needed for when you want to change one of the settings that the service context holds. In my example, I changed the llm_predictor and the chunk_size_limit
Cannot even load the llama_index.... from llama_index import LLMPredictor, ServiceContext
ModuleNotFoundError: No module named 'llama_index'
Cannot even load the llama_index.... from llama_index import LLMPredictor, ServiceContext
ModuleNotFoundError: No module named 'llama_index'
sounds like something broke in your env π
maybe try installing again? pip install --upgrade llama_index
WOW Logan, You are the champ!!
What is the default for : chunk_size_limit ? Does this parameter affect the length of the answer in the query? Or how to create the index file?
It changes how your documents are chunked
If an input document is greater than that token length, it gets broken into chunks that are up to that size
I find 1024 works best for emebddings (and in newer versions, will actually be the default). The current default is 3900
By default, the vector index fetches the top 1 closest chunk that matches the query. However, since we are lowering the size, you might want to fetch more chunks
res = index.query(..., similarity_top_k=3, response_mode="compact")
The response mode there just stuffs as much text as possible into each LLM call, rather than making one LLM call per chunk/node. Will use the same number of tokens, but hopefully be a little faster
What is your recommendation for a customer service bot for a saas platform, should I use LLamaindex or fine-tuning process ?
tbh fine-tuning is pretty difficult, it can lead to some pretty unexpected results.
I would use something like a langchain agent + llamaIndex as a custom tool for the agent. You can customize the prompts for the agent to hopefully behave the way you want it to.
Additionally, you might need some sort of extra filtering layer to ignore bad inputs or outputs. One approach I've seen is to setup a large list of expected inputs, and if the similarity between that items from that list and the users text is too low, refuse to answer lol
Fine-tuning is usually a last resort, at least from what I've seen
Any idea how to implement chat history with LLM ?
Yea, for that you'd probably want to use langchain+Llama Index as a custom tool
Llama index on its own is more of a search engine
Hey Logan you are the only one that can help me.... Unfortunately I had to reinstall all packages python from scratch on a new computer and now I have this error which I do not know how to struggle with it : Python 3.11.3 (tags/v3.11.3:f3909b8, Apr 4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
= RESTART: C:\Users\orish\Desktop\PythonProjects\Fine tune bot - Read doc folder files\app - simple 3.5 chat.py
C:\Users\orish\AppData\Local\Programs\Python\Python311\pythonw.exe
Traceback (most recent call last):
File "C:\Users\orish\Desktop\PythonProjects\Fine tune bot - Read doc folder files\app - simple 3.5 chat.py", line 4, in <module>
import gpt_index
ModuleNotFoundError: No module named 'gpt_index'
I have tried to install this package few times to update it I don't know what is the problem