Find answers from the community

s
sleroi
Offline, last seen 3 months ago
Joined September 25, 2024
s
sleroi
·

CustomLLM

Hello
I don't succeed to use custom LLM with CustomRetriver. Here is what I try to do :



I try to set up a simple hybrid search
Like this one
https://gpt-index.readthedocs.io/en/latest/examples/query_engine/CustomRetrievers.html

I use a custom LLM

llm_predictor = LLMPredictor(llm=CustomLLM())
embed_model = LangchainEmbedding(HuggingFaceEmbeddings(model_name="T-Systems-onsite/cross-en-fr-roberta-sentence-transformer"))
service_context = ServiceContext.from_defaults( llm_predictor=llm_predictor, embed_model=embed_model)

And Indexes for this LLM
vector_index = VectorStoreIndex.from_documents(docs, service_context=service_context)


I set up the query engine like this :
vector_retriever = VectorIndexRetriever(index=vector_index, similarity_top_k=4)

vector_query_engine = RetrieverQueryEngine(
retriever=vector_retriever,
response_synthesizer=refined_response_synth,
)

the reponse synthetiser use refined text_qa_template
refined_response_synth = get_response_synthesizer(text_qa_template = qa_template2, response_mode = ResponseMode.COMPACT)

vector_query_engine = RetrieverQueryEngine(
retriever=vector_retriever,
response_synthesizer=refined_response_synth,
)

When I query I have this error
response = vector_query_engine.query("Quel est le contenu de l'article 222-29?")
print (response)

AuthenticationError: No API key provided. You can set your API key in code using 'openai.api_key = ', or you can set the environment variable OPENAI_API_KEY=). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = '. You can generate API keys in the OpenAI web interface. See https://platform.openai.com/account/api-keys for details.

If I initialize the VectorIndexRetriever with the service_context I have the same error....

I didn't succeed to use custom LLM
2 comments
s
L
I'm working on a legal document. It is very structured with chapter, paragraph, article.

I'thinking to create one document by article.
I think that the extra_info is not use by the index.

I'm wandering which index is the best index to keep the article atomicity and attachment to his chapter, section etc...
8 comments
L
s