Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: simplify model asset preparation #151

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ npm install
### Prepare Model Assets
Execute the script per model folder. Make sure Python is installed properly.

First, navigate to the model directory and run the prepare_model.sh script. This script requires an S3 bucket name as an argument, which will be used to upload the model.
First, navigate to the model directory and run the prepare_model.sh script. This script requires an S3 bucket name as an argument, which will be used to upload the model. Please make sure the bucket name is located in the same region as the CDK deployment.

```bash
cd source/model/<rerank/embedding/instruct>/model
cd source/model/
./prepare_model.sh -s <Your S3 Bucket Name>
```

Expand Down Expand Up @@ -87,14 +87,13 @@ Please make sure **docker** is installed and the CDK command is executed in the

```bash
cd source/infrastructure
npx cdk deploy --parameters S3ModelAssets=<Your S3 Bucket Name> --parameters SubEmail=<Your email address> --parameters OpenSearchIndex=<Your OpenSearch Index Name> --parameters EtlImageName=<Your ETL model name> --parameters ETLTag=<Your ETL tag name>
npx cdk deploy --parameters S3ModelAssets=<Your S3 Bucket Name> --parameters SubEmail=<Your email address> --parameters EtlImageName=<Your ETL model name> --parameters ETLTag=<Your ETL tag name>
```

To deploy the offline process only, you can configure context parameters to skip the online process.

```bash
npx cdk deploy --parameters S3ModelAssets=<Your S3 Bucket Name> --parameters SubEmail=<Your email address> --parameters OpenSearchIndex=<Your OpenSearch Index Name> --parameters EtlImageName=<Your ETL model name> --parameters ETLTag=<Your ETL tag name> --context DeploymentMode="OFFLINE_EXTRACT"

npx cdk deploy --parameters S3ModelAssets=<Your S3 Bucket Name> --parameters SubEmail=<Your email address> --parameters EtlImageName=<Your ETL model name> --parameters ETLTag=<Your ETL tag name> --context DeploymentMode="OFFLINE_EXTRACT"
```

## Deployment Parameters
Expand All @@ -111,9 +110,8 @@ npx cdk deploy --parameters S3ModelAssets=<Your S3 Bucket Name> --parameters Sub

| Context | Description |
|---------|-------------|
| DeploymentMode | The mode for deployment. There are three modes: `OFFLINE_EXTRACT`, `OFFLINE_OPENSEARCH`, and `ALL`. |
| LayerPipOption | The configuration option for the Python package installer (pip) for the Lambda layer. Please use it when the instance you are using is in China. |
| JobPipOption | The configuration option for the Python package installer (pip). Please use it when this solution is deployed in GCR region. |
| DeploymentMode | The mode for deployment. There are three modes: `OFFLINE_EXTRACT`, `OFFLINE_OPENSEARCH`, and `ALL`. Default deployment mode is `ALL`. |
| LayerPipOption | The configuration option for the Python package installer (pip) for the Lambda layer. Please use it to set PyPi mirror(e.g. -i https://pypi.tuna.tsinghua.edu.cn/simple) when your local development environment is in GCR region. Default LayerPipOption is set to ``. |


## API Reference
Expand Down
2 changes: 1 addition & 1 deletion source/lambda/executor/utils/context_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def contexts_trunc(docs: list[dict], context_num=2):
docs = [doc for doc in docs[:context_num]]
# the most related doc will be placed last
docs.sort(key=lambda x: x["score"])
logger.info(f'max context score: {docs[-1]["score"]}')
# logger.info(f'max context score: {docs[-1]["score"]}')
# filter same docs
s = set()
context_strs = []
Expand Down
21 changes: 15 additions & 6 deletions source/lambda/executor/utils/executor_entries/common_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,21 @@ def get_qd_chain(qd_config, qd_workspace_list):
compression_retriever = ContextualCompressionRetriever(
base_compressor=compressor, base_retriever=lotr
)
qd_chain = chain_logger(
RunnablePassthrough.assign(
docs=compression_retriever | RunnableLambda(retriever_results_format)
),
"qd chain",
)
if not qd_workspace_list:
qd_chain = chain_logger(
RunnablePassthrough.assign(
docs=RunnableLambda(lambda x: [])
| RunnableLambda(retriever_results_format)
),
"qd chain",
)
else:
qd_chain = chain_logger(
RunnablePassthrough.assign(
docs=compression_retriever | RunnableLambda(retriever_results_format)
),
"qd chain",
)
return qd_chain


Expand Down
Empty file.
76 changes: 0 additions & 76 deletions source/model/embedding/model/bge-large-en-v1-5_model.py

This file was deleted.

76 changes: 0 additions & 76 deletions source/model/embedding/model/bge-large-zh-v1-5_model.py

This file was deleted.

34 changes: 0 additions & 34 deletions source/model/embedding/model/prepare_model.sh

This file was deleted.

116 changes: 0 additions & 116 deletions source/model/instruct/internlm2-chat-20b-global-lmdeploy/code/model.py

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading