You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromlangchain.llmsimportLlamaCppfromlangchain.callbacks.managerimportCallbackManagerfromlangchain.callbacks.streaming_stdoutimportStreamingStdOutCallbackHandlerfromllama_indeximportSimpleDirectoryReader, GPTListIndex, PromptHelper, load_index_from_storage, StorageContextfromllama_indeximportLLMPredictor, ServiceContext# define prompt helpermax_input_size=2048# set number of output tokensnum_output=256# set maximum chunk overlapmax_chunk_overlap=20prompt_helper=PromptHelper(max_input_size, num_output, max_chunk_overlap)
# Callbacks support token-wise streamingcallback_manager=CallbackManager([StreamingStdOutCallbackHandler()])
# Verbose is required to pass to the callback manager# Make sure the model path is correct for your system!llama=LlamaCpp(
model_path="./ggml-model-q4_0.bin",
callback_manager=callback_manager,
verbose=False,
max_tokens=256,
n_ctx=1024,
n_batch=256,
)
llm_predictor=LLMPredictor(llm=llama)
service_context=ServiceContext.from_defaults(llm_predictor=llm_predictor, prompt_helper=prompt_helper)
# Load the your datadocuments=SimpleDirectoryReader('./docs').load_data()
index=GPTListIndex.from_documents(documents, service_context=service_context)
index.storage_context.persist(persist_dir="./index/")
# storage_context = StorageContext.from_defaults(persist_dir="./index/")# index = load_index_from_storage(storage_context, service_context=service_context)# Query and print responsequery_engine=index.as_query_engine()
response=query_engine.query("<my_query>")
print(response)
But I have a problem with settings of llamacpp and llamaindex. I'm new to NLP, could you tell me which parameters are best configured for fast indexing of any files of any size and a quick response?the response generation is too long (1.5 minutes) and does not end after the message: Llama.generate: prefix-match hit
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I use llama-cpp-python in llama-index as follows:
But I have a problem with settings of llamacpp and llamaindex. I'm new to NLP, could you tell me which parameters are best configured for fast indexing of any files of any size and a quick response?the response generation is too long (1.5 minutes) and does not end after the message:
Llama.generate: prefix-match hit
Beta Was this translation helpful? Give feedback.
All reactions