Skip to content

Commit 9ae4922

Browse files
committed
Furhter changes for remote execution
1 parent 4c10ff8 commit 9ae4922

File tree

9 files changed

+39
-19
lines changed

9 files changed

+39
-19
lines changed

llm-complete-guide/README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ environment and install the dependencies using the following command:
4343
pip install -r requirements.txt
4444
```
4545

46-
Depending on your setup you may run into some issues when running the `pip install` command with the
47-
`flash_attn` package. In that case running `FLASH_ATTENTION_SKIP_CUDA_BUILD=TRUE pip install flash-attn --no-build-isolation` could help you.
46+
Depending on your hardware you may run into some issues when running the `pip install` command with the
47+
`flash_attn` package. In that case running `FLASH_ATTENTION_SKIP_CUDA_BUILD=TRUE pip install flash-attn --no-build-isolation`
48+
could help you.
4849

4950
In order to use the default LLM for this query, you'll need an account and an
50-
API key from OpenAI specified as another environment variable:
51-
52-
zenml secret create supabase_postgres_db --password="YOUR_PASSWORD" --user="YOU_USER" --host="YOUR_HOST" --port="YOUR_PORT"
51+
API key from OpenAI specified as a ZenML secret:
5352

5453
```shell
5554
zenml secret create openai --api_key=<your-openai-api-key>
55+
export ZENML_OPENAI_SECRET_NAME=openai
5656
```
5757

5858
### Setting up Supabase
@@ -69,14 +69,15 @@ isn't stored in plaintext. You can do this by running the following command:
6969

7070
```shell
7171
zenml secret create supabase_postgres_db --password="YOUR_PASSWORD" --user="YOU_USER" --host="YOUR_HOST" --port="YOUR_PORT"
72+
export ZENML_SUPABASE_SECRET_NAME=supabase_postgres_db
7273
```
7374

7475
You can get the user, host and port for this database instance by getting the connection
7576
string from the Supabase dashboard.
7677

7778
![](.assets/supabase-connection-string.png)
7879

79-
Alternatively you can use a different database as the backend.
80+
In case supabase is not an option for you, you can use a different database as the backend.
8081

8182
### Running the RAG pipeline
8283

llm-complete-guide/configs/embeddings.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
enable_cache: False
2+
13
# environment configuration
24
settings:
35
docker:
@@ -14,7 +16,7 @@ settings:
1416
- pandas
1517
- numpy
1618
- sentence-transformers>=3
17-
- transformers
19+
- transformers[torch]
1820
- litellm
1921
- ollama
2022
- tiktoken

llm-complete-guide/configs/rag_local_dev.yaml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,12 @@ settings:
1212
- tiktoken
1313
- ratelimit
1414
environment:
15-
ZENML_SUPABASE_SECRET_NAME: alexej_supabase_postgres_db
16-
ZENML_OPENAI_SECRET_NAME: alexej_openai
15+
ZENML_SUPABASE_SECRET_NAME: supabase_postgres_db
16+
ZENML_OPENAI_SECRET_NAME: openai
1717
ZENML_ENABLE_RICH_TRACEBACK: FALSE
1818
ZENML_LOGGING_VERBOSITY: INFO
1919

2020
steps:
2121
url_scraper:
2222
parameters:
2323
docs_url: https://docs.zenml.io/stack-components/orchestrators
24-
# generate_embeddings:
25-
# step_operator: "terraform-gcp-6c0fd52233ca"
26-
# settings:
27-
# step_operator.vertex:
28-
# accelerator_type: "NVIDIA_TESLA_P100"
29-
# accelerator_count: 1
30-
# machine_type: "n1-standard-8"

llm-complete-guide/configs/synthetic.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# enable_cache: False
2+
13
# environment configuration
24
settings:
35
docker:
@@ -24,3 +26,7 @@ settings:
2426
- rerankers[flashrank]
2527
- datasets
2628
- torch
29+
- distilabel
30+
environment:
31+
ZENML_SUPABASE_SECRET_NAME: supabase_postgres_db
32+
ZENML_OPENAI_SECRET_NAME: openai

llm-complete-guide/steps/eval_e2e.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
from utils.llm_utils import process_input_with_retrieval
2626
from zenml import step
2727

28+
from utils.openai_utils import get_openai_api_key
29+
2830
logging.getLogger().setLevel(logging.WARNING)
2931

3032
logger = logging.getLogger(__name__)
@@ -208,7 +210,8 @@ def llm_judged_test_e2e(
208210
"""
209211
logging.debug("Prompt created.")
210212
response = completion(
211-
model="gpt-4-turbo", messages=[{"content": prompt, "role": "user"}]
213+
model="gpt-4-turbo", messages=[{"content": prompt, "role": "user"}], api_key=get_openai_api_key()
214+
212215
)
213216

214217
json_output = response["choices"][0]["message"]["content"].strip()

llm-complete-guide/steps/generate_questions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
from zenml import log_artifact_metadata, step
2424
from zenml.logger import get_logger
2525

26+
from utils.openai_utils import get_openai_api_key
27+
2628
logger = get_logger(__name__)
2729
LOCAL_MODEL = "ollama/mixtral"
2830

@@ -58,6 +60,7 @@ def generate_question(
5860
}
5961
],
6062
api_base="http://localhost:11434" if local else None,
63+
api_key=get_openai_api_key()
6164
)
6265
return response.choices[0].message.content
6366
except (Timeout, APIConnectionError) as e:

llm-complete-guide/steps/push_to_hf.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
1212
# or implied. See the License for the specific language governing
1313
# permissions and limitations under the License.
14+
from zenml.client import Client
1415

1516
from constants import DATASET_NAME_DISTILABEL
1617
from datasets import Dataset, DatasetDict
@@ -19,7 +20,12 @@
1920

2021
@step
2122
def push_to_hf(train_dataset: Dataset, test_dataset: Dataset):
23+
zenml_client = Client()
24+
2225
combined_dataset = DatasetDict(
2326
{"train": train_dataset, "test": test_dataset}
2427
)
25-
combined_dataset.push_to_hub(DATASET_NAME_DISTILABEL)
28+
combined_dataset.push_to_hub(
29+
DATASET_NAME_DISTILABEL,
30+
token=zenml_client.get_secret("argilla_secrets").secret_values["hf_token"]
31+
)

llm-complete-guide/steps/synthetic_data.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
from zenml import ArtifactConfig, step
2727
from zenml.client import Client
2828

29+
from utils.openai_utils import get_openai_api_key
30+
2931
logger = logging.getLogger(__name__)
3032

3133
LOCAL_MODEL = "ollama/mixtral"
@@ -50,6 +52,7 @@ def generate_question(chunk: str, local: bool = False) -> str:
5052
}
5153
],
5254
api_base="http://localhost:11434" if local else None,
55+
api_key=get_openai_api_key()
5356
)
5457
return response.choices[0].message.content
5558

llm-complete-guide/utils/llm_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
from zenml.cli import secret
2525

26+
from utils.openai_utils import get_openai_api_key
27+
2628
# Configure logging levels for specific modules
2729
logging.getLogger("pytorch").setLevel(logging.CRITICAL)
2830
logging.getLogger("sentence-transformers").setLevel(logging.CRITICAL)
@@ -34,7 +36,7 @@
3436

3537
import os
3638
import re
37-
from typing import Dict, List, Tuple
39+
from typing import List, Tuple
3840

3941
import litellm
4042
import numpy as np
@@ -377,6 +379,7 @@ def get_completion_from_messages(
377379
messages=messages,
378380
temperature=temperature,
379381
max_tokens=max_tokens,
382+
api_key=get_openai_api_key()
380383
)
381384
return completion_response.choices[0].message.content
382385

0 commit comments

Comments
 (0)