diff --git a/.env.template b/.env.template index f91a75c7613e4262fb3cf6d2f8154041d043a924..b42cfed6550dc82aed13f93fd582dba902520b44 100644 --- a/.env.template +++ b/.env.template @@ -4,6 +4,10 @@ PHOENIX_PORT=6006 # API KEY TO OPENAI / CHATGPT API OPENAI_API_KEY=sk-hj8dfs8f9dsfsdgibberish +# PATH TO LOCALLY INSTALLED OLLAMA DAEMON +# to use a LLM via OLLAMA it must be installed already +OLLAMA_API_BASE=http://localhost:11434 + #CHUNK SIZE OF DOMAIN FILES DOCUMENTS_CHUNK_SIZE=512 diff --git a/evaluateRAG.py b/evaluateRAG.py index a096e584e4367bcb4978b71783124ad9ad8334d0..45886c9b67691102f3168beaad578f6bae5a2b23 100644 --- a/evaluateRAG.py +++ b/evaluateRAG.py @@ -21,7 +21,7 @@ nest_asyncio.apply() from colorist import Color, BrightColor, bright_yellow, magenta, red, green # phoenix is the framework & webservice from arize (https://docs.arize.com/phoenix) import phoenix as px -from phoenix.evals import OpenAIModel, llm_generate, HallucinationEvaluator, QAEvaluator, run_evals +from phoenix.evals import OpenAIModel, LiteLLMModel, llm_generate, HallucinationEvaluator, QAEvaluator, run_evals from phoenix.session.evaluation import get_retrieved_documents, get_qa_with_reference from phoenix.evals import RelevanceEvaluator, run_evals from phoenix.trace import DocumentEvaluations, SpanEvaluations @@ -114,7 +114,7 @@ nodes = node_parser.get_nodes_from_documents(documents) vector_index = VectorStoreIndex(nodes) print(f'created {length_hint(nodes)} chunks') countQuestions = length_hint(nodes) * int(os.environ['QUESTIONS_PER_CHUNK']) -# # Build a QueryEngine and start querying. +# Build a QueryEngine and start querying. query_engine = vector_index.as_query_engine() ########## @@ -153,11 +153,12 @@ def output_parser(response: str, index: int): return {"__error__": str(e)} # prompt template to LLM and store > questions_df +# You can choose among multiple models supported by LiteLLM (https://docs.litellm.ai/docs/providers) questions_df = llm_generate( dataframe=document_chunks_df, template=generate_questions_template, - model=OpenAIModel( - model="gpt-3.5-turbo", + model=LiteLLMModel( + model="ollama/llama2", ), output_parser=output_parser, concurrency=20, diff --git a/using_llamaindex_with_huggingface_models.ipynb b/using_llamaindex_with_huggingface_models.ipynb new file mode 100755 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391