Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
9e1c084
fix imports for caikit >=0.15.0
dtrifiro Sep 27, 2023
cf75fc2
:bug: Add support for accepting tokenization via model path
gkumbhat Sep 21, 2023
e2fc1dd
:art: Fix formatting
gkumbhat Sep 21, 2023
c686cfe
:loud_sound: Add info level log message for tokenizer load from model…
gkumbhat Sep 21, 2023
3bd95c7
:sparkles: Add stepwise logging for prompt tuning
gkumbhat Sep 23, 2023
aa08009
:construction: Changing logging in FT HF Trainer to step level
gkumbhat Sep 23, 2023
758142a
:bug: Remove epoch number validation for training loss
gkumbhat Sep 25, 2023
7bb7c13
:construction: Make changes to enable logging for FT in distributed c…
gkumbhat Sep 26, 2023
7bf55f7
:construction: Update trainers to include base classes and create log…
gkumbhat Sep 27, 2023
7df1e03
:art: Fix formatting and linting
gkumbhat Sep 27, 2023
aae6a72
:bug: Fix empty training metadata issue
gkumbhat Sep 27, 2023
9433af5
:recycle: Revert back run fine tuning print statement
gkumbhat Sep 27, 2023
e9759da
:sparkles: Add trainer util file
gkumbhat Sep 27, 2023
53d895a
:art: Fix formatting for trainer utils
gkumbhat Sep 27, 2023
fd6cdb7
:recycle: Refactor HF trainer logic and move to utils
gkumbhat Sep 21, 2023
b5a5586
:art: Fix formatting
gkumbhat Sep 21, 2023
f2a8bca
:construction:
gkumbhat Sep 21, 2023
cd1b58a
:construction: Add launch training from utils to prompt tuning
gkumbhat Sep 27, 2023
7ed5ac9
:construction: Fix gradientcheckpointing issue along with empty datas…
gkumbhat Sep 28, 2023
799651d
:art: Fix formatting and linting
gkumbhat Sep 28, 2023
df0d89d
:coffin: Remove unused functions from peft prompt tuning
gkumbhat Sep 28, 2023
e5ffbd5
:heavy_minus_sign: Remove unused imports
gkumbhat Sep 28, 2023
a7045bd
:recycle: Refactor trainer argument collection
gkumbhat Sep 28, 2023
3a150f6
:bug: Fix learning rate parameter passing from prompt tuning script
gkumbhat Sep 28, 2023
ce660d2
:bug: Fix dtype issue
gkumbhat Sep 28, 2023
37d57d6
:loud_sound: Add logging for end training result
gkumbhat Oct 1, 2023
63626ee
:bug::contruction: Fix peft model not getting sent for training issue
gkumbhat Oct 2, 2023
c97ab0d
:sparkles: Add support for reading base model from base models dir
gkumbhat Sep 28, 2023
ee245e1
:art: Run formatter
gkumbhat Sep 28, 2023
2212d7b
:bug: Fix case for handling base model full path only if file exists
gkumbhat Sep 28, 2023
b6acc47
:white_check_mark: Add test for resolving base model function
gkumbhat Sep 28, 2023
e5f90e4
:art: Fix formatting
gkumbhat Sep 28, 2023
f84670b
:art: Fix linting by making regex with r
gkumbhat Sep 28, 2023
a94202e
:white_check_mark: Add test for checking base path
gkumbhat Sep 29, 2023
4fe477f
:art: Fix formatting
gkumbhat Sep 29, 2023
94a02e4
:art: Fix formatting
gkumbhat Sep 29, 2023
3effbf1
🐛 Stop sequence default shouldn't be eos_token
tharapalanivel Sep 28, 2023
e44d856
:bug: Add support for setting random seed for prompt tuning training
gkumbhat Oct 2, 2023
f519ced
:bulb: Comment out full determinism option
gkumbhat Oct 2, 2023
1907987
Add forward for seq2seq tokenization
alex-jw-brooks Sep 18, 2023
0893afc
Add comparator test for seq2seq forwarding
alex-jw-brooks Sep 24, 2023
dc6d3e9
Split seq2seq tokenization preprocessing
alex-jw-brooks Sep 24, 2023
04b1888
Add forward to seq2seq tokenization (no batch)
alex-jw-brooks Sep 24, 2023
d230e10
Add batch forwarding tests for seq2seq/causal lm
alex-jw-brooks Sep 24, 2023
90f1785
Add batch forward for causal lm / seq2seq
alex-jw-brooks Sep 24, 2023
822f628
rewrite causal lm tok tests to check chunking
alex-jw-brooks Sep 25, 2023
5c4f69a
Implement chunked tokenization for causal lm
alex-jw-brooks Sep 25, 2023
f447ae4
linting, formatting
alex-jw-brooks Sep 25, 2023
c71bd58
Turn on seq2seq tokenization by default
alex-jw-brooks Sep 26, 2023
db5e910
Approximate port of old causal lm tokenization logic
alex-jw-brooks Sep 27, 2023
7be4d3a
Hack - use default collator for causal LM
alex-jw-brooks Sep 28, 2023
b0ab2f9
Add generic test for left/right padding causal lm seq approach
alex-jw-brooks Sep 28, 2023
68b1644
Do left / right padding via tokenizer pad
alex-jw-brooks Sep 28, 2023
9997c58
Add simple tests for default data collator
alex-jw-brooks Sep 29, 2023
ef1e2f1
Update concat seq test for corrected padding
alex-jw-brooks Sep 29, 2023
e0e20c5
Fix legacy ported sequence length bug
alex-jw-brooks Sep 29, 2023
0afef67
Update comments for tokenizer changes
alex-jw-brooks Sep 29, 2023
e59008b
linting and formatting
alex-jw-brooks Sep 29, 2023
3c4cf04
Update causal lm docstrings and type hints
alex-jw-brooks Sep 29, 2023
c5827a4
Fix remainder handling in chunking test
alex-jw-brooks Sep 29, 2023
c16d6c3
Add chunk example, use extend
alex-jw-brooks Oct 2, 2023
27a1d31
:wrench: Tune inference parameter to match TGIS validation
gkumbhat Oct 3, 2023
671aaac
:truck: Rename random_seed to seed to match inference time parameter
gkumbhat Oct 3, 2023
ca5d7ca
:art: Fix formatting
gkumbhat Oct 3, 2023
238121d
:recycle: Refactor default values to be None for inf opts
gkumbhat Oct 3, 2023
0b40815
:bug: Fix None handling for the parameter value checks
gkumbhat Oct 3, 2023
13b8563
:bulb: Fix error message
gkumbhat Oct 3, 2023
53db97b
:goal_net: Disallow empty train streams
evaline-ju Oct 3, 2023
e6f5613
:white_check_mark: Update test fixtures for no empty train streams
evaline-ju Oct 3, 2023
0a80f99
:art: Format
evaline-ju Oct 3, 2023
5f3d846
:arrow_up: Update caikit[runtime-grpc,runtime-http] requirement
dependabot[bot] Oct 6, 2023
fafac37
model_run_utils: return correct input_token_count
dtrifiro Oct 7, 2023
17f60ae
Add support for sequence lengths in eval
alex-jw-brooks Oct 11, 2023
bc3ab03
WIP - merged code
jolson-ibm Oct 18, 2023
1849390
:sparkles: Add support for reading base model from base models dir
gkumbhat Sep 28, 2023
120350c
:art: Run formatter
gkumbhat Sep 28, 2023
d1c6730
:white_check_mark: Add test for resolving base model function
gkumbhat Sep 28, 2023
dcf0e73
:art: Fix formatting
gkumbhat Sep 28, 2023
4c3bf1b
:white_check_mark: Add test for checking base path
gkumbhat Sep 29, 2023
304908b
:art: Fix formatting
gkumbhat Sep 29, 2023
7e64932
:bug: Add support for setting random seed for prompt tuning training
gkumbhat Oct 2, 2023
dec91bd
Add forward for seq2seq tokenization
alex-jw-brooks Sep 18, 2023
89a56e6
Split seq2seq tokenization preprocessing
alex-jw-brooks Sep 24, 2023
a6ec2e6
Add forward to seq2seq tokenization (no batch)
alex-jw-brooks Sep 24, 2023
e15cadf
Add batch forwarding tests for seq2seq/causal lm
alex-jw-brooks Sep 24, 2023
66a0c55
Add batch forward for causal lm / seq2seq
alex-jw-brooks Sep 24, 2023
c87f5b5
linting and formatting
alex-jw-brooks Sep 29, 2023
adfbeae
:wrench: Tune inference parameter to match TGIS validation
gkumbhat Oct 3, 2023
036027e
:goal_net: Disallow empty train streams
evaline-ju Oct 3, 2023
959edec
Revert ":goal_net: Disallow empty train streams"
gkumbhat Oct 12, 2023
236b68a
Update tests/modules/text_generation/test_peft_prompt_tuning.py
gkumbhat Oct 12, 2023
6472bf1
:arrow_up: Update build requirement from <1.0,>=0.10.0 to >=0.10.0,<2.0
dependabot[bot] Sep 1, 2023
63ef9e7
Make verbalizer rendering optional in eval script
alex-jw-brooks Oct 11, 2023
c539256
:technologist: Fix docstring formatting function call
gkumbhat Oct 3, 2023
b3b372c
:art: Fix linting
gkumbhat Oct 3, 2023
d9daf1a
pyproject: use setuptools to build the project
dtrifiro Oct 2, 2023
0921cbb
add __version__ and __version_tuple__
dtrifiro Oct 2, 2023
f17ec40
🐛 Update task class field for caikit upgrade
tharapalanivel Oct 17, 2023
c017c58
🐛 Remove use of private attr
tharapalanivel Oct 17, 2023
a175a8c
⬆️ Bump caikit
tharapalanivel Oct 17, 2023
376f5e7
♻️ Refactor validation
tharapalanivel Oct 17, 2023
31306b6
🦺 Validate module supports only 1 allowed task
tharapalanivel Oct 17, 2023
5004295
add __init__.py for text_generation submodule
dtrifiro Oct 18, 2023
f5d0e98
pyproject: use setuptools' automatic discovery
dtrifiro Oct 18, 2023
6361559
fix pylint warnings
dtrifiro Oct 18, 2023
f2fbbb3
:ambulance::wrench: Fix sequencing of arguments on run function
gkumbhat Oct 19, 2023
3e9673c
:art: Fix formatting
gkumbhat Oct 19, 2023
c0cc3d4
Add support for FSDP prompt tuning
alex-jw-brooks Oct 20, 2023
8090407
add caikit resource to trainer
alex-jw-brooks Oct 23, 2023
5d96929
Code formatting, linting
alex-jw-brooks Oct 24, 2023
a4bec3c
:technologist: Deprecate accumulation step to speed up training with …
gkumbhat Nov 13, 2023
568a70d
tox: run pytest with --durations flag to list tests run time
dtrifiro Oct 26, 2023
68fbb37
model_run_utils: add/fix type hints
dtrifiro Sep 28, 2023
24aac93
model_run_utils: fix logic for EOS_TOKEN finish reason
dtrifiro Sep 28, 2023
74d8d69
model_run_utils: add STOP_SEQUENCE finish reason
dtrifiro Oct 27, 2023
55ccf92
model_run_utils: use MAX_TOKENS as default finish_reason in generate_…
dtrifiro Oct 7, 2023
6a4a19b
tests: speed up test_bad_tgis_connection by adding connect_timeout to…
dtrifiro Oct 27, 2023
d0f8a91
:construction: initate config changes
gkumbhat Nov 1, 2023
fcbec63
:white_check_mark: Add test for training data validation
gkumbhat Nov 1, 2023
fee487f
:art: Fix formatting
gkumbhat Nov 1, 2023
f0186a5
:memo: Add comment in the config yaml file indicating prompt tuning m…
gkumbhat Nov 1, 2023
9655e21
:package: Update caikit to include len of stream fix
gkumbhat Nov 1, 2023
3361249
:bug::package: fix deps declaration in pyproject.toml file
gkumbhat Nov 1, 2023
b829220
:package: Update caikit to 0.23.2
gkumbhat Nov 1, 2023
ee01ac7
:wrench: change default model to dummy model
gkumbhat Nov 2, 2023
969500c
model_run_utils: use enum values as finish_reason
dtrifiro Oct 26, 2023
dbbb5d7
:wrench: Update training data validation to consider global and modul…
gkumbhat Nov 6, 2023
df04ff3
:bug: Fix module default
gkumbhat Nov 6, 2023
deb731a
:art: Fix linter
gkumbhat Nov 6, 2023
0fac5d3
:package: Update caikit to 0.24.0
gkumbhat Nov 7, 2023
3832262
tests: make models fixtures session-scoped
dtrifiro Nov 3, 2023
f5c29bf
:goal_net: Disallow empty train streams
evaline-ju Oct 3, 2023
ff4d18a
:white_check_mark: Update test fixtures for no empty train streams
evaline-ju Oct 3, 2023
8615ebe
:art: Format
evaline-ju Nov 2, 2023
c0b3899
add Dockerfile
dtrifiro Oct 25, 2023
f20df11
gha: add build-image workflow
dtrifiro Oct 26, 2023
6caf98f
README: add docker instructions
dtrifiro Oct 26, 2023
da706c7
README: improve getting started section
dtrifiro Oct 26, 2023
5bd1bf8
dockerfile: add LICENSE and README.md
dtrifiro Nov 8, 2023
eb07cf3
:bug: Fix converting of peft model to type errorneously
gkumbhat Nov 13, 2023
45e6c18
:wrench::bug: Fix rebasing small descripencies
gkumbhat Nov 13, 2023
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
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
venv
*
!dist
!README.md
!LICENSE
32 changes: 32 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
push:
branches: [main]
paths:
- "caikit_nlp"
- "README.md"
- "pyproject.toml"
- "Dockerfile"

pull_request:

name: Build Image

jobs:
build-image:
name: Build Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Setup tox
run: |
pip install -U pip wheel
pip install tox
- name: Build wheel
run: |
tox -e build
- name: Build image
run: |
docker build -t caikit-nlp:latest .
15 changes: 7 additions & 8 deletions .github/workflows/publish-library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ jobs:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
- name: Release
env:
FLIT_PASSWORD: ${{ secrets.PYPI_TOKEN }}
- name: Build and check package
run: |
pip install tox
RELEASE_VERSION=${GITHUB_REF#refs/*/}
RELEASE_VERSION=${RELEASE_VERSION#v*}
sed -i "s/^version = .*/version = \"${RELEASE_VERSION}\"/" pyproject.toml
tox -e publish
tox -e build,twinecheck
- name: Upload package
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,4 @@ prompt_prefixes
sample_prompt
transformers_cache
generated_interfaces
/caikit_nlp/_version.py
45 changes: 45 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest as builder

RUN microdnf update -y && \
microdnf install -y \
git python39-pip && \
pip3 install --upgrade --no-cache-dir pip && \
microdnf clean all

RUN python3 -m venv /opt/caikit/

ENV VIRTUAL_ENV=/opt/caikit
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

COPY dist/caikit_nlp*.whl /tmp/
RUN pip install --no-cache /tmp/caikit_nlp*.whl && rm /tmp/caikit_nlp*.whl


FROM registry.access.redhat.com/ubi8/ubi-minimal:latest as deploy

RUN microdnf update -y && \
microdnf install -y \
shadow-utils python39 && \
microdnf clean all

COPY --from=builder /opt/caikit /opt/caikit
COPY LICENSE /opt/caikit/
COPY README.md /opt/caikit/

RUN groupadd --system caikit --gid 1001 && \
adduser --system --uid 1001 --gid 0 --groups caikit \
--home-dir /caikit --shell /sbin/nologin \
--comment "Caikit User" caikit

ENV VIRTUAL_ENV=/opt/caikit
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

USER caikit

ENV RUNTIME_LIBRARY=caikit_nlp
# Optional: use `CONFIG_FILES` and the /caikit/ volume to explicitly provide a configuration file and models
# ENV CONFIG_FILES=/caikit/caikit.yml
VOLUME ["/caikit/"]
WORKDIR /caikit

CMD ["python"]
132 changes: 127 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,142 @@ Capabilities provided by `caikit-nlp`:
| Tokenization | 1. `RegexSentenceSplitter` | 1. Demo purposes only |
| Embedding | [COMING SOON] | [COMING SOON] |

### Getting Started
## Getting Started

### Notebooks

To help you quickly get started with using Caikit, we have prepared a [Jupyter notebook](examples/Caikit_Getting_Started.ipynb) that can be run in Google Colab. Caikit-nlp is a powerful library that leverages prompt tuning and fine-tuning to add NLP domain capabilities to caikit.

### Installation

To install from git repo:

```bash
python -m venv .venv
source .venv/bin/activate
pip install git+https://github.com/caikit/caikit-nlp
```

### Bootstrapping models

`caikit_nlp` can use Hugging Face models, allowing for direct download and bootstrapping.

For example, to use [google/flan-t5-small](https://huggingface.co/google/flan-t5-small):

```python
import os
# The env var ALLOW_DOWNLOADS has to be set to allow model downloads before importing caikit_nlp
os.environ['ALLOW_DOWNLOADS'] = "1"

import caikit_nlp

model_name = "google/flan-t5-small"
model = caikit_nlp.text_generation.TextGeneration.bootstrap(model_name)
model.save(f"{model_name}-caikit") # optionally save the model
```

### Serving models

To serve models, the following basic configuration can be used:

```yaml
# config.yml
runtime:
library: caikit_nlp
local_models_dir: ./models

log:
formatter: pretty # optional: log formatter is set to json by default
```

Start the server:

```bash
env CONFIG_FILES=./config.yml python -m caikit.runtime
```

The model can now be queried at `localhost:8080` via http or at `localhost:8085` via grpc.

For example, using the http server and using curl to send a POST request:

```bash
curl --json '{
"model_id": "flan-t5-small-caikit",
"inputs": "At what temperature does liquid Nitrogen boil?"
}' localhost:8080/api/v1/task/text-generation
```

We get the following response:

```json
{
"generated_text": "74 degrees F",
"generated_tokens": 5,
"finish_reason": "MAX_TOKENS",
"producer_id": {
"name": "Text Generation",
"version": "0.1.0"
},
"input_token_count": 10,
"seed": null
}
```

All the available API endpoints and protos can be dumped using [`scripts/dump_apis.sh`](/scripts/dump_apis.sh).

### Docker

To build the docker image:

```bash
python -m build --wheel
docker build -t caikit-nlp:latest .
```

A volume can be mounted at `/caikit` providing configuration and (optionally) models:

```bash
mkdir -p caikit
$EDITOR caikit/config.yml # edit as required
cp -r <path/to/models> ./caikit/models
docker run -e CONFIG_FILES=/caikit/config.yml -v $PWD/caikit/:/caikit -p 8080:8080 -p 8085:8085 python -m caikit.runtime
```

#### Serving with containers

In order to start the serving runtime:

```bash
docker run -e CONFIG_FILES=/caikit/config.yml \
-v $PWD/caikit/:/caikit -p 8080:8080 -p 8085 \
python -m caikit.runtime
```

Assuming the standard configuration with port `8080` for the http server and `8085` for the grpc server.

### Configuration

Configuration can be provided via environment variables or by providing a yaml configuration file thanks to [`alchemy-config`](https://github.com/IBM/alchemy-config).

For example, to set the caikit runtime, setting `RUNTIME_LIBRARY=caikit_nlp` via environment variables or providing the following yaml configuration is equivalent.

```yaml
# config.yml
runtime:
library: caikit_nlp
```

For configuration options see `caikit_nlp`'s example config: [`config.yml`](/caikit_nlp/config/config.yml) or `caikit`'s example [`caikit.yml`](https://github.com/caikit/caikit/blob/main/caikit/config/config.yml).

### Contributing
## Contributing

We welcome contributions from the community! If you would like to contribute to `caikit-nlp`, please read the guidelines in the main project's [CONTRIBUTING.md](CONTRIBUTING.md) file. It includes information on submitting bug reports, feature requests, and pull requests. Make sure to follow our coding standards, [code of conduct](code-of-conduct.md), [security standards](https://github.com/caikit/community/blob/main/SECURITY.md), and documentation guidelines to streamline the contribution process.

### License
## License

This project is licensed under the [ASFv2 License](LICENSE).

### Glossary
## Glossary

A list of terms that either may be unfamiliar or that have nebulous definitions based on who and where you hear them, defined for how they are used/thought of in the `caikit`/`caikit-nlp` project:

Expand All @@ -41,7 +163,7 @@ Prompt tuning - learning soft prompts. This is different from prompt engineering

The important difference between fine tuning and capabilities like prompt tuning/multi-taskprompt tuning is that the latter doesn't change the base model's weights at all. So when you run inference for prompt tuned models, you can have n prompts to 1 base model, and just inject the prompt tensors you need when they're requested instead of having _n_ separate fine-tuned models.

### Runtime Performance Benchmarking
## Runtime Performance Benchmarking

[Runtime Performance Benchmarking](./benchmarks/README.md) for tuning various models.

Expand Down
1 change: 1 addition & 0 deletions caikit_nlp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from .data_model import *
from .modules import *
from .resources import *
from .version import __version__, __version_tuple__

# Configure the library with library-specific configuration file
CONFIG_PATH = os.path.realpath(
Expand Down
9 changes: 9 additions & 0 deletions caikit_nlp/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,20 @@ torch_dtype: float32
# Path of folder that will contain all the source prompts
source_prompt_base: ""

# Path for searching base models from
base_models_dir: ""

# Whether or not to purge TGIS prompts on model deletion
unload_tgis_prompt_artifacts: false
# Torchrun elastic launch configuration, e.g., for fine tuning on multiple GPUs
master_addr: localhost
master_port: 29550

training_data_limit:
__default__: -1
# Configuration for PeftPromptTuning module
6655831b-960a-4dc5-8df4-867026e2cd41:
add_model_name_here: 10000

runtime:
library: caikit_nlp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import torch

# First Party
from caikit.core.exceptions import error_handler
from caikit.core.modules import ModuleBase, ModuleLoader, ModuleSaver, module
from caikit.core.toolkit import error_handler
from caikit.interfaces.nlp.data_model import ClassificationResult, ClassificationResults
from caikit.interfaces.nlp.tasks import TextClassificationTask
import alog
Expand Down
19 changes: 18 additions & 1 deletion caikit_nlp/modules/text_generation/peft_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# Standard
from enum import Enum
import os
import re

# Third Party
from peft import MultitaskPromptTuningInit
Expand Down Expand Up @@ -44,6 +45,8 @@
log = alog.use_channel("PFT_CNFG_TLKT")
error = error_handler.get(log)

SOURCE_DIR_VALIDATION_REGEX = re.compile(r"^[-a-zA-Z_0-9\/]+")


class TuningType(str, Enum):
PROMPT_TUNING = "PROMPT_TUNING"
Expand All @@ -56,6 +59,20 @@ class TuningType(str, Enum):

def resolve_base_model(base_model, cls, torch_dtype):
if isinstance(base_model, str):

error.value_check(
"<NLP66932773E>",
re.fullmatch(SOURCE_DIR_VALIDATION_REGEX, base_model),
"invalid characters in base_model name",
)
if get_config().base_models_dir:

base_model_full_path = os.path.join(
get_config().base_models_dir, base_model
)
if os.path.exists(base_model_full_path):
base_model = base_model_full_path

model_config = AutoConfig.from_pretrained(
base_model, local_files_only=not get_config().allow_downloads
)
Expand Down Expand Up @@ -200,4 +217,4 @@ def get_peft_config(
output_model_types=output_model_types,
)

return task_type, output_model_types, peft_config, tuning_type
return task_type, output_model_types, peft_config, tuning_type
Loading