Skip to content

Commit

Permalink
Merge branch 'main' into feature/test-gitflow
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexejPenner authored Nov 25, 2024
2 parents 33fc151 + cf029d1 commit e851e4a
Show file tree
Hide file tree
Showing 15 changed files with 337 additions and 74 deletions.
2 changes: 1 addition & 1 deletion llm-complete-guide/ZENML_VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.71.0
0.71.0
3 changes: 3 additions & 0 deletions llm-complete-guide/configs/dev/rag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ settings:
- rerankers
- 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/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
6 changes: 4 additions & 2 deletions llm-complete-guide/configs/production/rag.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
enable_cache: True
enable_cache: False

# environment configuration
settings:
Expand All @@ -16,6 +16,9 @@ settings:
- rerankers
- pygithub
- rerankers[flashrank]
- matplotlib
- elasticsearch

environment:
ZENML_PROJECT_SECRET_NAME: llm_complete
ZENML_ENABLE_RICH_TRACEBACK: FALSE
Expand All @@ -26,7 +29,6 @@ steps:
parameters:
docs_url: https://docs.zenml.io
use_dev_set: false
enable_cache: true
# generate_embeddings:
# step_operator: "sagemaker"
# settings:
Expand Down
2 changes: 1 addition & 1 deletion llm-complete-guide/configs/staging/embeddings.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# enable_cache: False
enable_cache: False

# environment configuration
settings:
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
4 changes: 3 additions & 1 deletion llm-complete-guide/configs/staging/rag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ settings:
- rerankers
- pygithub
- rerankers[flashrank]
- matplotlib
- elasticsearch

environment:
ZENML_PROJECT_SECRET_NAME: llm_complete
ZENML_ENABLE_RICH_TRACEBACK: FALSE
Expand All @@ -29,4 +32,3 @@ steps:
parameters:
docs_url: https://docs.zenml.io
use_dev_set: false
enable_cache: true
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: 0 additions & 2 deletions llm-complete-guide/gh_action_rag.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ def main(
zenml_model_name (str): The ZenML model name.
zenml_model_version (str): The ZenML model version.
"""
pipeline_args = {"enable_cache": not no_cache}

client = Client()
config_path = Path(__file__).parent / "configs" / config

Expand Down
10 changes: 2 additions & 8 deletions llm-complete-guide/pipelines/finetune_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,10 @@
prepare_load_data,
visualize_results,
)
from zenml import Model, pipeline
from zenml.model.model import ModelStages

model_definition = Model(
name=EMBEDDINGS_MODEL_NAME_ZENML,
version=ModelStages.LATEST,
)
from zenml import pipeline


@pipeline(model=model_definition)
@pipeline
def finetune_embeddings():
data = prepare_load_data()
base_results = evaluate_base_model(dataset=data)
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]==0.68.1
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 e851e4a

Please sign in to comment.