Skip to content

Commit

Permalink
Merge branch 'main' into feature/PRD-700-replacing-zenml-login-refere…
Browse files Browse the repository at this point in the history
…nces
  • Loading branch information
bcdurak authored Dec 12, 2024
2 parents f393f96 + 300dad0 commit 0941de4
Show file tree
Hide file tree
Showing 24 changed files with 661 additions and 63 deletions.
1 change: 0 additions & 1 deletion .github/workflows/production_run_complete_llm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ jobs:
working-directory: ./llm-complete-guide
run: |
zenml init
zenml connect --url $ZENML_STORE_URL --api-key $ZENML_STORE_API_KEY
- name: Set stack (Production)
working-directory: ./llm-complete-guide
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/staging_run_complete_llm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ jobs:
working-directory: ./llm-complete-guide
run: |
zenml init
zenml connect --url $ZENML_STORE_URL --api-key $ZENML_STORE_API_KEY
- name: Set stack (Staging)
working-directory: ./llm-complete-guide
Expand Down
2 changes: 1 addition & 1 deletion llm-complete-guide/ZENML_VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.68.1
0.71.0
1 change: 1 addition & 0 deletions llm-complete-guide/configs/dev/rag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ settings:
- pygithub
- rerankers[flashrank]
- matplotlib
- elasticsearch

environment:
ZENML_PROJECT_SECRET_NAME: llm_complete
Expand Down
1 change: 1 addition & 0 deletions llm-complete-guide/configs/dev/rag_eval.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ settings:
- psycopg2-binary
- tiktoken
- pygithub
- elasticsearch
python_package_installer: "uv"
1 change: 1 addition & 0 deletions llm-complete-guide/configs/production/eval.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ settings:
- matplotlib
- pillow
- pygithub
- elasticsearch
environment:
ZENML_PROJECT_SECRET_NAME: llm_complete
ZENML_ENABLE_RICH_TRACEBACK: FALSE
Expand Down
2 changes: 2 additions & 0 deletions llm-complete-guide/configs/production/rag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ settings:
- pygithub
- rerankers[flashrank]
- matplotlib
- elasticsearch

environment:
ZENML_PROJECT_SECRET_NAME: llm_complete
ZENML_ENABLE_RICH_TRACEBACK: FALSE
Expand Down
1 change: 1 addition & 0 deletions llm-complete-guide/configs/staging/eval.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ settings:
- matplotlib
- pillow
- pygithub
- elasticsearch
environment:
ZENML_PROJECT_SECRET_NAME: llm_complete
ZENML_ENABLE_RICH_TRACEBACK: FALSE
Expand Down
1 change: 1 addition & 0 deletions llm-complete-guide/configs/staging/rag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ settings:
- pygithub
- rerankers[flashrank]
- matplotlib
- elasticsearch

environment:
ZENML_PROJECT_SECRET_NAME: llm_complete
Expand Down
4 changes: 4 additions & 0 deletions llm-complete-guide/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
384 # Update this to match the dimensionality of the new model
)

# ZenML constants
ZENML_CHATBOT_MODEL = "zenml-docs-qa-chatbot"

# Scraping constants
RATE_LIMIT = 5 # Maximum number of requests per second

Expand Down Expand Up @@ -78,3 +81,4 @@
USE_ARGILLA_ANNOTATIONS = False

SECRET_NAME = os.getenv("ZENML_PROJECT_SECRET_NAME", "llm-complete")
SECRET_NAME_ELASTICSEARCH = "elasticsearch-zenml"
2 changes: 1 addition & 1 deletion llm-complete-guide/requirements-argilla.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
zenml[server]>=0.68.1
zenml[server]
sentence-transformers>=3,<=3.0.1
transformers<=4.44.0
litellm
Expand Down
3 changes: 2 additions & 1 deletion llm-complete-guide/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
zenml[server]>=0.68.1
zenml[server]
ratelimit
pgvector
psycopg2-binary
Expand All @@ -20,6 +20,7 @@ datasets
torch
gradio
huggingface-hub
elasticsearch

# optional requirements for S3 artifact store
# s3fs>2022.3.0
Expand Down
18 changes: 16 additions & 2 deletions llm-complete-guide/steps/eval_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@

from datasets import load_dataset
from utils.llm_utils import (
find_vectorstore_name,
get_db_conn,
get_embeddings,
get_es_client,
get_topn_similar_docs,
rerank_documents,
)
Expand Down Expand Up @@ -76,11 +78,23 @@ def query_similar_docs(
Tuple containing the question, URL ending, and retrieved URLs.
"""
embedded_question = get_embeddings(question)
db_conn = get_db_conn()
conn = None
es_client = None

vector_store_name = find_vectorstore_name()
if vector_store_name == "pgvector":
conn = get_db_conn()
else:
es_client = get_es_client()

num_docs = 20 if use_reranking else returned_sample_size
# get (content, url) tuples for the top n similar documents
top_similar_docs = get_topn_similar_docs(
embedded_question, db_conn, n=num_docs, include_metadata=True
embedded_question,
conn=conn,
es_client=es_client,
n=num_docs,
include_metadata=True
)

if use_reranking:
Expand Down
Loading

0 comments on commit 0941de4

Please sign in to comment.