-
+
"""
state = gr.State()
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/__init__.py b/workflows/chatbot/demo/basic_frontend/fastchat/__init__.py
index d31c31eaeb0..4ce1bb159be 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/__init__.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/__init__.py
@@ -1 +1,15 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
__version__ = "0.2.3"
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/client/__init__.py b/workflows/chatbot/demo/basic_frontend/fastchat/client/__init__.py
index ff1f3f146bb..a0925aec00f 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/client/__init__.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/client/__init__.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
from fastchat.client.api import ChatCompletion, set_baseurl
__all__ = ["ChatCompletion", "set_baseurl"]
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/client/api.py b/workflows/chatbot/demo/basic_frontend/fastchat/client/api.py
index 0e1eb773435..39c74c4c887 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/client/api.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/client/api.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
from typing import Dict, List, Optional
import asyncio
import os
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/client/test_client.py b/workflows/chatbot/demo/basic_frontend/fastchat/client/test_client.py
index a04197532d4..a81095911ae 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/client/test_client.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/client/test_client.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
from fastchat import client
completion = client.ChatCompletion.create(
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/constants.py b/workflows/chatbot/demo/basic_frontend/fastchat/constants.py
index 70294c04e70..c1b01b3c316 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/constants.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/constants.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
CONTROLLER_HEART_BEAT_EXPIRATION = 90
WORKER_HEART_BEAT_INTERVAL = 30
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/conversation.py b/workflows/chatbot/demo/basic_frontend/fastchat/conversation.py
index f7fab977a9e..aea84131807 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/conversation.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/conversation.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
Conversation prompt template.
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/data/__init__.py b/workflows/chatbot/demo/basic_frontend/fastchat/data/__init__.py
index e69de29bb2d..28f108cb636 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/data/__init__.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/data/__init__.py
@@ -0,0 +1,13 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/data/alpaca-converter.py b/workflows/chatbot/demo/basic_frontend/fastchat/data/alpaca-converter.py
index 392ed2c2bea..47b539bbb74 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/data/alpaca-converter.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/data/alpaca-converter.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import argparse
import json
import pathlib
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/data/clean_sharegpt.py b/workflows/chatbot/demo/basic_frontend/fastchat/data/clean_sharegpt.py
index 224b0a47007..a80b97e7d2a 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/data/clean_sharegpt.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/data/clean_sharegpt.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
- Convert html to markdown with basic data cleaning.
- Deduplication.
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/data/hardcoded_questions.py b/workflows/chatbot/demo/basic_frontend/fastchat/data/hardcoded_questions.py
index 7abaff17693..c17b99b2932 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/data/hardcoded_questions.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/data/hardcoded_questions.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import json
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/data/inspect.py b/workflows/chatbot/demo/basic_frontend/fastchat/data/inspect.py
index c59e6238c3b..6911feded87 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/data/inspect.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/data/inspect.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
Usage:
python3 -m fastchat.data.inspect --in sharegpt_20230322_clean_lang_split.json
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/data/merge.py b/workflows/chatbot/demo/basic_frontend/fastchat/data/merge.py
index ea5b8a93b38..57b8b1f0f2b 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/data/merge.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/data/merge.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
Merge two conversation files into one
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/data/optional_clean.py b/workflows/chatbot/demo/basic_frontend/fastchat/data/optional_clean.py
index bbdfb67932f..74fb6474c6d 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/data/optional_clean.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/data/optional_clean.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
Do optional cleaning (e.g., remove some languages).
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/data/pretty_json.py b/workflows/chatbot/demo/basic_frontend/fastchat/data/pretty_json.py
index 426fadc2dd8..796a2a8ff41 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/data/pretty_json.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/data/pretty_json.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
Usage:
python3 pretty_json.py --in in.json --out out.json
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/data/sample.py b/workflows/chatbot/demo/basic_frontend/fastchat/data/sample.py
index b53df6a67d5..dc323559ce2 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/data/sample.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/data/sample.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
Sample some conversations from a file.
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/data/split_long_conversation.py b/workflows/chatbot/demo/basic_frontend/fastchat/data/split_long_conversation.py
index 9362a922833..f63d6e034aa 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/data/split_long_conversation.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/data/split_long_conversation.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
Split long conversations based on certain max length.
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/eval/eval_gpt_review.py b/workflows/chatbot/demo/basic_frontend/fastchat/eval/eval_gpt_review.py
index 890bca730a1..c5c130aca0b 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/eval/eval_gpt_review.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/eval/eval_gpt_review.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import argparse
import json
import os
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/eval/generate_webpage_data_from_table.py b/workflows/chatbot/demo/basic_frontend/fastchat/eval/generate_webpage_data_from_table.py
index e24175aa588..c26b7728de0 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/eval/generate_webpage_data_from_table.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/eval/generate_webpage_data_from_table.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""Generate json file for webpage."""
import json
import os
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/eval/get_model_answer.py b/workflows/chatbot/demo/basic_frontend/fastchat/eval/get_model_answer.py
index 2e9ba0bd670..0bf5eba0b8f 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/eval/get_model_answer.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/eval/get_model_answer.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import argparse
from transformers import AutoTokenizer, AutoModelForCausalLM, LlamaForCausalLM
import torch
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/eval/qa_baseline_gpt35.py b/workflows/chatbot/demo/basic_frontend/fastchat/eval/qa_baseline_gpt35.py
index f0f9f5fbc9a..924370ab8a7 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/eval/qa_baseline_gpt35.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/eval/qa_baseline_gpt35.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""Generate answers with GPT-3.5"""
# Note: you need to be using OpenAI Python v0.27.0 for the code below to work
import argparse
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/eval/requirements.txt b/workflows/chatbot/demo/basic_frontend/fastchat/eval/requirements.txt
index c2490e15ead..4a47981acfa 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/eval/requirements.txt
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/eval/requirements.txt
@@ -1,2 +1,2 @@
+ray
shortuuid
-ray
\ No newline at end of file
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/eval/script/run_model_qa.yaml b/workflows/chatbot/demo/basic_frontend/fastchat/eval/script/run_model_qa.yaml
index 64e36560e60..d94f919eaac 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/eval/script/run_model_qa.yaml
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/eval/script/run_model_qa.yaml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
resources:
accelerators: A100:4
cloud: gcp
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/model/__init__.py b/workflows/chatbot/demo/basic_frontend/fastchat/model/__init__.py
index e69de29bb2d..28f108cb636 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/model/__init__.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/model/__init__.py
@@ -0,0 +1,13 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/model/apply_delta.py b/workflows/chatbot/demo/basic_frontend/fastchat/model/apply_delta.py
index 67a1c590d41..964f4dc400c 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/model/apply_delta.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/model/apply_delta.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
Apply the delta weights on top of a base model.
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/model/apply_lora.py b/workflows/chatbot/demo/basic_frontend/fastchat/model/apply_lora.py
index 870e64a3b4b..184a319a079 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/model/apply_lora.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/model/apply_lora.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
Apply the LoRA weights on top of a base model.
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/model/convert_fp16.py b/workflows/chatbot/demo/basic_frontend/fastchat/model/convert_fp16.py
index efc40aa83bf..bce2e8d574b 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/model/convert_fp16.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/model/convert_fp16.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
Usage:
python3 -m fastchat.model.convert_fp16 --in in-folder --out out-folder
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/model/make_delta.py b/workflows/chatbot/demo/basic_frontend/fastchat/model/make_delta.py
index ebaa2db62e5..d04f6a6d2f4 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/model/make_delta.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/model/make_delta.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
Make the delta weights by subtracting base weights.
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/protocol/chat_completion.py b/workflows/chatbot/demo/basic_frontend/fastchat/protocol/chat_completion.py
index 6acf682dc80..dbe45e90127 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/protocol/chat_completion.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/protocol/chat_completion.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
from typing import Optional, List, Dict, Any
import time
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/__init__.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/__init__.py
index e69de29bb2d..28f108cb636 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/__init__.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/__init__.py
@@ -0,0 +1,13 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/api.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/api.py
index a5aeb579e5a..92efd219ea3 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/api.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/api.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""This module provides a ChatGPT-compatible Restful API for chat completion.
Usage:
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/cacheflow_worker.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/cacheflow_worker.py
index f83b2598ec2..ed0828a14ab 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/cacheflow_worker.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/cacheflow_worker.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
A model worker executes the model based on Cacheflow.
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/cli.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/cli.py
index d501338ff63..7a9deea3de8 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/cli.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/cli.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
Chat with a model with command line interface.
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/compression.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/compression.py
index 2c1dafd3907..9663eb4e26f 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/compression.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/compression.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import dataclasses
import gc
import glob
@@ -10,7 +24,7 @@
import torch.nn as nn
from torch.nn import functional as F
from tqdm import tqdm
-from transformers import AutoTokenizer, AutoModelForCausalLM, AutoConfig
+from transformers import AutoTokenizer, AutoModelForCausalLM, AutoConfig
@dataclasses.dataclass
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/controller.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/controller.py
index d46eaa29b97..cecff95572e 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/controller.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/controller.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
A controller manages distributed workers.
It sends worker addresses to clients.
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_block_arena_anony.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_block_arena_anony.py
index a2e71218743..f6f4e8c46e3 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_block_arena_anony.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_block_arena_anony.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import json
import time
@@ -240,7 +254,7 @@ def http_bot_all(
def build_side_by_side_ui_anony(models):
notice_markdown = """
-# ⚔️ Chatbot Arena ⚔️
+# ⚔️ Chatbot Arena ⚔️
Rules:
- Chat with two anonymous models side-by-side and vote for which one is better!
- The names of the models will be revealed after your vote.
@@ -400,5 +414,3 @@ def build_side_by_side_ui_anony(models):
button_row2,
parameter_row,
)
-
-
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_block_arena_named.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_block_arena_named.py
index 0db977bad88..f732157ac6e 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_block_arena_named.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_block_arena_named.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import json
import time
@@ -223,7 +237,7 @@ def http_bot_all(
def build_side_by_side_ui_named(models):
notice_markdown = """
-# ⚔️ Chatbot Arena ⚔️
+# ⚔️ Chatbot Arena ⚔️
Rules:
- Chat with two models side-by-side and vote for which one is better!
- You pick the models you want to chat with.
@@ -392,4 +406,3 @@ def build_side_by_side_ui_named(models):
button_row2,
parameter_row,
)
-
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_css.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_css.py
index 71d79b4a4b5..7416edd771e 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_css.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_css.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
code_highlight_css = """
#chatbot .hll { background-color: #ffffcc }
#chatbot .c { color: #408080; font-style: italic }
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_patch.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_patch.py
index af8731da17d..06713f51679 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_patch.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_patch.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
Adopted from https://github.com/gradio-app/gradio/blob/main/gradio/components.py
Fix a markdown render problem.
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_web_server.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_web_server.py
index ef983254cad..cbeb8b8be4f 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_web_server.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_web_server.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import argparse
from collections import defaultdict
import datetime
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_web_server_multi.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_web_server_multi.py
index ad96fcc63cc..6b919267b13 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_web_server_multi.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/gradio_web_server_multi.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import argparse
import gradio as gr
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/huggingface_api.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/huggingface_api.py
index 9dd4ea466d7..6ff1348bb53 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/huggingface_api.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/huggingface_api.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
Usage:
python3 -m fastchat.serve.huggingface_api --model ~/model_weights/vicuna-7b/
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/inference.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/inference.py
index d4cbf2a34af..6f265555c87 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/inference.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/inference.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""Inference for FastChat models."""
import abc
from typing import Optional
@@ -106,7 +120,7 @@ def load_model(
replace_llama_attn_with_non_inplace_operations()
else:
raise ValueError(f"Invalid device: {device}")
-
+
if load_8bit:
if num_gpus != 1 and num_gpus != "1":
warnings.warn("8-bit quantization is not supported for multi-gpu inference.")
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/model_worker.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/model_worker.py
index 65aa2b726fd..8633ec73983 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/model_worker.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/model_worker.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
A model worker executes the model.
"""
@@ -252,7 +266,7 @@ async def api_get_status(request: Request):
if args.num_gpus and len(args.gpus.split(",")) < int(args.num_gpus):
raise ValueError(f"Larger --num-gpus ({args.num_gpus}) than --gpus {args.gpus}!")
os.environ["CUDA_VISIBLE_DEVICES"] = args.gpus
-
+
worker = ModelWorker(
args.controller_address,
args.worker_address,
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/monkey_patch_non_inplace.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/monkey_patch_non_inplace.py
index 9661d707512..f18d3121f33 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/monkey_patch_non_inplace.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/monkey_patch_non_inplace.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
Monkey patch the llama implementation in the huggingface/transformers library.
Avoid bugs in mps backend by not using in-place operations.
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/register_worker.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/register_worker.py
index 2c2c40295e0..f1e816d1f2a 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/register_worker.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/register_worker.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
Manually register workers.
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/serve_chatglm.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/serve_chatglm.py
index 7b7745625d9..7c86e12394c 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/serve_chatglm.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/serve_chatglm.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import torch
from typing import List, Tuple
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/test_message.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/test_message.py
index ef2a2e36ec0..4a0cabe8aed 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/test_message.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/test_message.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import argparse
import json
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/serve/test_throughput.py b/workflows/chatbot/demo/basic_frontend/fastchat/serve/test_throughput.py
index 9cc5f45c7e0..254555bfd85 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/serve/test_throughput.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/serve/test_throughput.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""Benchmarking script to test the throughput of serving workers."""
import argparse
import json
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/train/llama_flash_attn_monkey_patch.py b/workflows/chatbot/demo/basic_frontend/fastchat/train/llama_flash_attn_monkey_patch.py
index 00fc39edff8..83045aab482 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/train/llama_flash_attn_monkey_patch.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/train/llama_flash_attn_monkey_patch.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
from typing import List, Optional, Tuple
import torch
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/train/train_mem.py b/workflows/chatbot/demo/basic_frontend/fastchat/train/train_mem.py
index e4b33528482..5be0e634e56 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/train/train_mem.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/train/train_mem.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
# Make it more memory efficient by monkey patching the LLaMA model with FlashAttn.
# Need to call this before importing transformers.
diff --git a/workflows/chatbot/demo/basic_frontend/fastchat/utils.py b/workflows/chatbot/demo/basic_frontend/fastchat/utils.py
index 9a6d7bffb16..8f275bc3068 100644
--- a/workflows/chatbot/demo/basic_frontend/fastchat/utils.py
+++ b/workflows/chatbot/demo/basic_frontend/fastchat/utils.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import logging
import logging.handlers
import os
diff --git a/workflows/chatbot/demo/basic_frontend/requirements.txt b/workflows/chatbot/demo/basic_frontend/requirements.txt
index f2b6c5fb339..55cb9823fe4 100644
--- a/workflows/chatbot/demo/basic_frontend/requirements.txt
+++ b/workflows/chatbot/demo/basic_frontend/requirements.txt
@@ -1,9 +1,9 @@
-pip
-torch
diffusers==0.8.1
-transformers
-requests
+gradio
huggingface_hub
markdown2
nh3
-gradio
+pip
+requests
+torch
+transformers
diff --git a/workflows/chatbot/demo/chatcli/__init__.py b/workflows/chatbot/demo/chatcli/__init__.py
index 407b29e53be..18896e7b549 100644
--- a/workflows/chatbot/demo/chatcli/__init__.py
+++ b/workflows/chatbot/demo/chatcli/__init__.py
@@ -14,4 +14,3 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
diff --git a/workflows/chatbot/demo/chatcli/model.py b/workflows/chatbot/demo/chatcli/model.py
index 6e8754546bc..77d291c1cb2 100644
--- a/workflows/chatbot/demo/chatcli/model.py
+++ b/workflows/chatbot/demo/chatcli/model.py
@@ -97,7 +97,7 @@ def __init__(self, endpoint: str, model: str, user: str, bot: str):
self.model = model
self.user = user
self.bot = bot
-
+
def prompt(self):
prompt = ""
for ctx in self.ctx:
@@ -106,7 +106,7 @@ def prompt(self):
def __headers__(self):
return {'Content-Type': 'application/json'}
-
+
def __data__(self):
return json.dumps({
"model": self.model,
@@ -123,7 +123,7 @@ def __stream__(self, chunk, newctx) -> Tuple[str, bool]:
if not text.startswith(prompt):
return ("", True)
-
+
word = text.removeprefix(prompt).removeprefix(newctx["content"])
done = word.find('\n') != -1
word = word[:word.find('\n')]
diff --git a/workflows/chatbot/demo/docker/README.md b/workflows/chatbot/demo/docker/README.md
index 82bc887b3e1..e45f9f44e2b 100644
--- a/workflows/chatbot/demo/docker/README.md
+++ b/workflows/chatbot/demo/docker/README.md
@@ -94,4 +94,3 @@ cd /itrex/workflows/chatbot/inference/backend/sd/
```
nohup bash run.sh &
```
-
diff --git a/workflows/chatbot/fine_tuning/instruction_generator/data_generation.md b/workflows/chatbot/fine_tuning/instruction_generator/data_generation.md
index ee0f5222e72..5ca955b0c3f 100644
--- a/workflows/chatbot/fine_tuning/instruction_generator/data_generation.md
+++ b/workflows/chatbot/fine_tuning/instruction_generator/data_generation.md
@@ -113,4 +113,4 @@ Below are some examples that are generated by our method,
"correct": "Popular AI models can achieve up to 19x faster performance speeds when moving from 3rd Gen to 4th Gen Intel Xeon processors using Intel AMX.",
"fake": "Popular AI models experience a dramatic decrease of up to 80% in performance speeds when moving from 3rd Gen to 4th Gen Intel Xeon processors using Intel AMX."
},
-```
\ No newline at end of file
+```
diff --git a/workflows/chatbot/fine_tuning/instruction_tuning_pipeline/finetune_seq2seq.py b/workflows/chatbot/fine_tuning/instruction_tuning_pipeline/finetune_seq2seq.py
index f96e79e88a2..7af300a8c2e 100644
--- a/workflows/chatbot/fine_tuning/instruction_tuning_pipeline/finetune_seq2seq.py
+++ b/workflows/chatbot/fine_tuning/instruction_tuning_pipeline/finetune_seq2seq.py
@@ -57,4 +57,4 @@ def main():
finetune_model(finetune_cfg)
if __name__ == "__main__":
- main()
\ No newline at end of file
+ main()
diff --git a/workflows/chatbot/fine_tuning/requirements.txt b/workflows/chatbot/fine_tuning/requirements.txt
index 927c9fc1773..8bdfbb97ccb 100644
--- a/workflows/chatbot/fine_tuning/requirements.txt
+++ b/workflows/chatbot/fine_tuning/requirements.txt
@@ -1,9 +1,9 @@
datasets
-torch
-transformers>=4.32.0
-sentencepiece
-peft
+einops
evaluate
nltk
+peft
rouge_score
-einops
+sentencepiece
+torch
+transformers>=4.32.0
diff --git a/workflows/chatbot/inference/__init__.py b/workflows/chatbot/inference/__init__.py
index e69de29bb2d..28f108cb636 100644
--- a/workflows/chatbot/inference/__init__.py
+++ b/workflows/chatbot/inference/__init__.py
@@ -0,0 +1,13 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/workflows/chatbot/inference/backend/chat/README.md b/workflows/chatbot/inference/backend/chat/README.md
index 4f00097a50a..e1a04df3217 100644
--- a/workflows/chatbot/inference/backend/chat/README.md
+++ b/workflows/chatbot/inference/backend/chat/README.md
@@ -81,4 +81,4 @@ nohup bash run_itrex.sh &
pip install speechbrain
pip install soundfile
pip install pydub
-```
\ No newline at end of file
+```
diff --git a/workflows/chatbot/inference/backend/chat/__init__.py b/workflows/chatbot/inference/backend/chat/__init__.py
index e69de29bb2d..28f108cb636 100644
--- a/workflows/chatbot/inference/backend/chat/__init__.py
+++ b/workflows/chatbot/inference/backend/chat/__init__.py
@@ -0,0 +1,13 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/workflows/chatbot/inference/backend/chat/asr.py b/workflows/chatbot/inference/backend/chat/asr.py
index 88d005511ee..9757b809800 100644
--- a/workflows/chatbot/inference/backend/chat/asr.py
+++ b/workflows/chatbot/inference/backend/chat/asr.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import torch
import intel_extension_for_pytorch as ipex
from transformers import WhisperForConditionalGeneration, WhisperProcessor
diff --git a/workflows/chatbot/inference/backend/chat/compression.py b/workflows/chatbot/inference/backend/chat/compression.py
index a839738aef4..d6bb42d429f 100644
--- a/workflows/chatbot/inference/backend/chat/compression.py
+++ b/workflows/chatbot/inference/backend/chat/compression.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import dataclasses
import torch
diff --git a/workflows/chatbot/inference/backend/chat/constants.py b/workflows/chatbot/inference/backend/chat/constants.py
index 5a16e9f1b83..85b98ab405f 100644
--- a/workflows/chatbot/inference/backend/chat/constants.py
+++ b/workflows/chatbot/inference/backend/chat/constants.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
CONTROLLER_HEART_BEAT_EXPIRATION = 2 * 60
WORKER_HEART_BEAT_INTERVAL = 30
diff --git a/workflows/chatbot/inference/backend/chat/controller.py b/workflows/chatbot/inference/backend/chat/controller.py
index 383f853847b..f078f34f3e5 100644
--- a/workflows/chatbot/inference/backend/chat/controller.py
+++ b/workflows/chatbot/inference/backend/chat/controller.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
A controller manages distributed workers.
It sends worker addresses to clients.
diff --git a/workflows/chatbot/inference/backend/chat/conversation.py b/workflows/chatbot/inference/backend/chat/conversation.py
index 69f07c99557..dd6f232d514 100644
--- a/workflows/chatbot/inference/backend/chat/conversation.py
+++ b/workflows/chatbot/inference/backend/chat/conversation.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
Conversation prompt templates.
"""
@@ -818,4 +832,4 @@ def get_default_conv_template(model_path: str) -> Conversation:
conv.append_message(conv.roles[1], "Hi!")
conv.append_message(conv.roles[0], "How are you?")
conv.append_message(conv.roles[1], None)
- print(conv.get_prompt())
\ No newline at end of file
+ print(conv.get_prompt())
diff --git a/workflows/chatbot/inference/backend/chat/inference.py b/workflows/chatbot/inference/backend/chat/inference.py
index 43f1b59e1ba..13075837cef 100644
--- a/workflows/chatbot/inference/backend/chat/inference.py
+++ b/workflows/chatbot/inference/backend/chat/inference.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""Inference for LLM models."""
import abc
import torch
@@ -71,7 +85,7 @@ def forward(self, input_ids, attention_mask=None, past_key_values=None):
# print("ipex-bf16")
with torch.cpu.amp.autocast(enabled=True, dtype=torch.bfloat16):
out = self.model(
- input_ids,
+ input_ids,
attention_mask=attention_mask,
past_key_values=past_key_values,
use_cache=True)
@@ -254,7 +268,7 @@ def generate_stream(model, model_name, tokenizer, params, device,
# torch.manual_seed(100)
token = int(torch.multinomial(probabilities, 1))
-
+
output_ids.append(token)
diff --git a/workflows/chatbot/inference/backend/chat/model_worker.py b/workflows/chatbot/inference/backend/chat/model_worker.py
index 9d78fc56c6e..39ab38d1721 100644
--- a/workflows/chatbot/inference/backend/chat/model_worker.py
+++ b/workflows/chatbot/inference/backend/chat/model_worker.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
A model worker executes the model.
"""
@@ -12,7 +26,7 @@
import uuid
from fastapi import FastAPI, Request, BackgroundTasks
-from fastapi.responses import StreamingResponse, PlainTextResponse
+from fastapi.responses import StreamingResponse, PlainTextResponse
import requests
from transformers import AutoTokenizer, AutoModelForCausalLM, LlamaTokenizer, GenerationConfig, StoppingCriteria, StoppingCriteriaList
import torch
diff --git a/workflows/chatbot/inference/backend/chat/register_worker.py b/workflows/chatbot/inference/backend/chat/register_worker.py
index 819a6a85dd0..569f86b372b 100644
--- a/workflows/chatbot/inference/backend/chat/register_worker.py
+++ b/workflows/chatbot/inference/backend/chat/register_worker.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
"""
Manually register workers.
diff --git a/workflows/chatbot/inference/backend/chat/run_ipex.sh b/workflows/chatbot/inference/backend/chat/run_ipex.sh
index 0dd3b87b7ba..a92927e0197 100644
--- a/workflows/chatbot/inference/backend/chat/run_ipex.sh
+++ b/workflows/chatbot/inference/backend/chat/run_ipex.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
# Kill the exist and re-run
ps -ef |grep 'controller' |awk '{print $2}' |xargs kill -9
ps -ef |grep 'model_worker' |awk '{print $2}' |xargs kill -9
diff --git a/workflows/chatbot/inference/backend/chat/run_itrex.sh b/workflows/chatbot/inference/backend/chat/run_itrex.sh
index 9aceeb2f1c4..1c0bfc1069e 100644
--- a/workflows/chatbot/inference/backend/chat/run_itrex.sh
+++ b/workflows/chatbot/inference/backend/chat/run_itrex.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
# Kill the exist and re-run
ps -ef |grep 'controller' |awk '{print $2}' |xargs kill -9
ps -ef |grep 'model_worker' |awk '{print $2}' |xargs kill -9
diff --git a/workflows/chatbot/inference/backend/chat/tts.py b/workflows/chatbot/inference/backend/chat/tts.py
index c713cfe7637..8b1bb3b1586 100644
--- a/workflows/chatbot/inference/backend/chat/tts.py
+++ b/workflows/chatbot/inference/backend/chat/tts.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
from transformers import SpeechT5Processor, SpeechT5ForTextToSpeech, set_seed
from datasets import load_dataset, Audio, Dataset, Features, ClassLabel
import os
diff --git a/workflows/chatbot/inference/backend/chat/utils.py b/workflows/chatbot/inference/backend/chat/utils.py
index 0964a1bf157..757ef2025ad 100644
--- a/workflows/chatbot/inference/backend/chat/utils.py
+++ b/workflows/chatbot/inference/backend/chat/utils.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import datetime
import logging
import logging.handlers
diff --git a/workflows/chatbot/inference/backend/database/db_config.py b/workflows/chatbot/inference/backend/database/db_config.py
index 41a4e516af1..0190607d82c 100644
--- a/workflows/chatbot/inference/backend/database/db_config.py
+++ b/workflows/chatbot/inference/backend/database/db_config.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import os
from dotenv import load_dotenv
@@ -37,4 +51,3 @@ class Settings(BaseSettings):
def get_settings() -> BaseSettings:
# logger.info("Loading config settings from the environment...")
return Settings()
-
diff --git a/workflows/chatbot/inference/backend/database/mysqldb.py b/workflows/chatbot/inference/backend/database/mysqldb.py
index a67c5d9cf02..db3a0a0bf6e 100644
--- a/workflows/chatbot/inference/backend/database/mysqldb.py
+++ b/workflows/chatbot/inference/backend/database/mysqldb.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
from db_config import get_settings
from pymysql import connect
diff --git a/workflows/chatbot/inference/backend/fastrag/doc_index.py b/workflows/chatbot/inference/backend/fastrag/doc_index.py
index 4a39b7d57f0..a88f038f4e4 100644
--- a/workflows/chatbot/inference/backend/fastrag/doc_index.py
+++ b/workflows/chatbot/inference/backend/fastrag/doc_index.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import os
import argparse
from langchain.embeddings import HuggingFaceEmbeddings, HuggingFaceInstructEmbeddings
@@ -357,4 +371,3 @@ def load_pdf(pdf_path):
document_store.save(index_path="my_index.faiss")
else:
print("in memory db is done")
-
diff --git a/workflows/chatbot/inference/backend/fastrag/embedding_xlsx.py b/workflows/chatbot/inference/backend/fastrag/embedding_xlsx.py
index 5b4cb65883b..e942e84ae99 100644
--- a/workflows/chatbot/inference/backend/fastrag/embedding_xlsx.py
+++ b/workflows/chatbot/inference/backend/fastrag/embedding_xlsx.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import os
from langchain.embeddings import HuggingFaceEmbeddings, HuggingFaceInstructEmbeddings
from langchain.vectorstores import Chroma
diff --git a/workflows/chatbot/inference/backend/fastrag/fastrag_service.py b/workflows/chatbot/inference/backend/fastrag/fastrag_service.py
index 43def493810..bb083862df3 100644
--- a/workflows/chatbot/inference/backend/fastrag/fastrag_service.py
+++ b/workflows/chatbot/inference/backend/fastrag/fastrag_service.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
from haystack.document_stores import InMemoryDocumentStore,ElasticsearchDocumentStore
from fastapi import FastAPI, Request, BackgroundTasks
@@ -150,7 +164,7 @@ def ask_gm_documents_sparse_embedding(folder_path, process_content=False):
with tempfile.TemporaryDirectory(dir="/tmp/my_subdirectory") as temp_dir:
english_embeddings = HuggingFaceInstructEmbeddings(model_name="hkunlp/instructor-large")
chinese_embeddings = HuggingFaceInstructEmbeddings(model_name="shibing624/text2vec-base-chinese")
-
+
young_pat_vectordb = Chroma(persist_directory=temp_dir,
embedding_function=english_embeddings)
young_pat_dense_retriever = young_pat_vectordb.as_retriever(search_type="mmr",
@@ -664,5 +678,3 @@ def _format_filters(filters):
put("test","test")
uvicorn.run(app, host=args.host, port=args.port, log_level="info")
-
-
diff --git a/workflows/chatbot/inference/backend/fastrag/inc_document.py b/workflows/chatbot/inference/backend/fastrag/inc_document.py
index a15db1c8383..bdbc14b8bf4 100644
--- a/workflows/chatbot/inference/backend/fastrag/inc_document.py
+++ b/workflows/chatbot/inference/backend/fastrag/inc_document.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
inc_examples = [{"doc": "## FX Introduction\nFX is a PyTorch toolkit for developers to use to transform nn.Module instance. FX consists of three main components: a symbolic tracer, an intermediate representation, and Python code generation.\n\nWith converted torch.fx.GraphModule, we can resolve three problems in quantization:\n1. Automatically insert quant/dequant operation within PyTorch.\n2. Use FloatFunctional to wrap tensor operations that require special handling for quantization into modules. Examples are operations like add and cat which require special handling to determine output quantization parameters.\n3. Fuse modules: combine operations/modules into a single module to obtain higher accuracy and performance. This is done using the fuse_modules() API, which takes in lists of modules to be fused. We currently support the following fusions: [Conv, Relu], [Conv, BatchNorm], [Conv, BatchNorm, Relu], [Linear, Relu].\n\nFor detailed description, please refer to [PyTorch FX](https://pytorch.org/docs/stable/fx.html) and [FX Graph Mode Quantization](https://pytorch.org/docs/master/quantization.html#prototype-fx-graph-mode-quantization)", "doc_id": 0},
{"doc": "## FX Mode Support Matrix in Neural Compressor\n\n|quantization |FX |\n|-----------------------|:-----------:|\n|Static Quantization |✔ |\n|Dynamic Quantization |✔ |\n|Quantization-Aware Training |✔ |", "doc_id": 1},
{"doc": "## Get Start with FX in Neural Compressor\n\n**Note:** \"backend\" field indicates the backend used by the user in configure. And the \"default\" value means it will quantization model with fx backend for PyTorch model.\n\n### Post Training Static Quantization\n\n```\n from neural_compressor import quantization, PostTrainingQuantConfig\n conf = PostTrainingQuantConfig(backend=\"default\")\n model.eval()\n q_model = quantization.fit(model, conf, calib_dataloader=dataloader, eval_func=eval_func)\n q_model.save(\"save/to/path\")\n```", "doc_id": 2},
@@ -201,4 +215,3 @@
{"doc": "# Intel Neural Compressor User YAML Configuration Files\n## Introduction\n\nIntel\u00ae Neural Compressor uses YAML files for quick \nand user-friendly configurations. There are two types of YAML files - \nuser YAML files and framework YAML files, which are used in \nrunning user cases and setting up framework capabilities, respectively.\n\nFirst, let's take a look at a user YAML file, It defines the model, tuning\nstrategies, tuning calibrations and evaluations, and performance benchmarking\nof the passing model vs. original model.", "doc_id": 200},
{"doc": "# Intel Neural Compressor User YAML Configuration Files\n## Supported Feature Matrix\n\n| Optimization Techniques | YAML Configuration Files |\n|-------------------------|:------------------------:|\n| Quantization | ✔ |\n| Pruning | ✔ |\n| Distillation | ✔ |", "doc_id": 201},
{"doc": "# Intel Neural Compressor User YAML Configuration Files\n## Get started with User YAML Files\nA complete user YAML file is organized logically into several sections: \n* ***model***: The model specifications define a user model's name, inputs, outputs and framework.\n\n```yaml\nmodel: # mandatory. used to specify model specific information.\n name: mobilenet_v1 \n framework: tensorflow # mandatory. supported values are tensorflow, pytorch, pytorch_ipex, onnxrt_integer, onnxrt_qlinear or mxnet; allow new framework backend extension.\n inputs: image_tensor # optional. inputs field is only required in tensorflow.\n outputs: num_detections,detection_boxes,detection_scores,detection_classes # optional. outputs field is only required in tensorflow.\n```\n* ***quantization***: The quantization specifications define quantization tuning space and related calibrations. To calibrate, users can \nspecify *sampling_size* (optional) and use the subsection *dataloader* to specify\nthe dataset location using *root* and transformation using *transform*. To \nimplement tuning space constraints, users can use the subsection *model_wise* and *op_wise* for specific configurations.\n \n```yaml\nquantization: # optional. tuning constraints on model-wise for advance user to reduce tuning space.\n calibration:\n sampling_size: 20 # optional. default value is 100. used to set how many samples should be used in calibration.\n dataloader:\n dataset:\n ImageRecord:\n root: /path/to/imagenet/ # NOTE: modify to calibration dataset location if needed\n transform:\n BilinearImagenet: \n height: 224\n width: 224\n model_wise: # optional. tuning constraints on model-wise for advance user to reduce tuning space.\n weight:\n granularity: per_channel\n scheme: asym\n dtype: int8\n algorithm: minmax\n activation:\n granularity: per_tensor\n scheme: asym\n dtype: int8, fp32\n algorithm: minmax, kl\n op_wise: { # optional. tuning constraints on op-wise for advance user to reduce tuning space. \n 'conv1': {\n 'activation': {'dtype': ['uint8', 'fp32'], \n 'algorithm': ['minmax', 'kl'], \n 'scheme':['sym']},\n 'weight': {'dtype': ['int8', 'fp32'], \n 'algorithm': ['minmax']}\n }\n }\n```\n\n* ***pruning***: The pruning specifications define pruning tuning space. To define the training behavior, uses can \nuse the subsection *train* to specify the training hyper-parameters and the training dataloader. \nTo define the pruning approach, users can use the subsection *approach* to specify \npruning target, choose the type of pruning algorithm, and the way to apply it \nduring training process. \n\n```yaml\npruning:\n train:\n dataloader:\n ... \n epoch: 40\n optimizer:\n Adam:\n learning_rate: 1e-06\n beta_1: 0.9\n beta_2: 0.999\n epsilon: 1e-07\n criterion:\n SparseCategoricalCrossentropy:\n reduction: sum_over_batch_size\n from_logits: False\n approach:\n weight_compression:\n initial_sparsity: 0.0\n target_sparsity: 0.54\n start_epoch: 0\n end_epoch: 19\n pruners:\n - !Pruner\n start_epoch: 0\n end_epoch: 19\n prune_type: basic_magnitude\n```\n* ***distillation***: The distillation specifications define distillation's tuning\nspace. Similar to pruning, to define the training behavior, users can use the \nsubsection *train* to specify the training hyper-parameters and the training \ndataloader and it is optional if users implement *train_func* and set the attribute\nof distillation instance to *train_func*. For criterion, Intel\u00ae Neural Compressor provides a built-in \nknowledge distillation loss class to calculate distillation loss.\n```yaml\ndistillation:\n train:\n start_epoch: 0\n end_epoch: 90\n iteration: 1000\n frequency: 1\n dataloader:\n ...\n optimizer:\n SGD:\n learning_rate: 0.001 \n momentum: 0.1\n nesterov: True\n weight_decay: 0.001\n criterion:\n KnowledgeDistillationLoss:\n temperature: 1.0\n loss_types: ['CE', 'CE']\n loss_weights: [0.5, 0.5]\n```\n* ***evaluation***: The evaluation specifications define the dataloader and metric for accuracy evaluation as well as dataloader \nand configurations for performance benchmarking. \n```yaml\nevaluation: # optional. required if user doesn't provide eval_func in neural_compressor.Quantization.\n accuracy: \n metric:\n ...\n dataloader:\n ...\n```\n* ***tuning***: The tuning specifications define overall tuning targets. Users can\nuse *accuracy_criterion* to specify the target of accuracy loss percentage and use\n*exit_policy* to specify the tuning timeout in seconds. The random\nseed can be specified using *random_seed*. \n\n```yaml\ntuning:\n accuracy_criterion:\n relative: 0.01 # the tuning target of accuracy loss percentage: 1%\n higher_is_better: True\n exit_policy:\n timeout: 0 # tuning timeout (seconds), 0 means early stop\n random_seed: 9527 # random seed\n```", "doc_id": 202}]
-
diff --git a/workflows/chatbot/inference/backend/fastrag/llm_invocation.py b/workflows/chatbot/inference/backend/fastrag/llm_invocation.py
index 3889692142b..f616b8aad3d 100644
--- a/workflows/chatbot/inference/backend/fastrag/llm_invocation.py
+++ b/workflows/chatbot/inference/backend/fastrag/llm_invocation.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import logging
from typing import Dict, List, Optional, Type, Union
@@ -176,4 +190,3 @@ def __init__(
def invoke(self, prompt: Union[str, List[str]], **kwargs) -> List[str]:
output = self.model_invocation_layer.invoke(prompt=prompt, **kwargs, **self.model_kwargs)
return output
-
diff --git a/workflows/chatbot/inference/backend/fastrag/logger.py b/workflows/chatbot/inference/backend/fastrag/logger.py
index 61e6300cd27..3e72f1d15f1 100644
--- a/workflows/chatbot/inference/backend/fastrag/logger.py
+++ b/workflows/chatbot/inference/backend/fastrag/logger.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import sys
import platform
import os
@@ -92,4 +106,4 @@ def build_logger(logger_name, logger_filename):
if isinstance(item, logging.Logger):
item.addHandler(handler)
- return logger
\ No newline at end of file
+ return logger
diff --git a/workflows/chatbot/inference/backend/fastrag/mpt_invocation.py b/workflows/chatbot/inference/backend/fastrag/mpt_invocation.py
index 46ceb5d11d9..bea43cbdd7e 100644
--- a/workflows/chatbot/inference/backend/fastrag/mpt_invocation.py
+++ b/workflows/chatbot/inference/backend/fastrag/mpt_invocation.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import time
import logging
from typing import Dict, List, Optional, Type, Union
diff --git a/workflows/chatbot/inference/backend/fastrag/run.sh b/workflows/chatbot/inference/backend/fastrag/run.sh
index a53b8f0c01c..50f5f84ca72 100644
--- a/workflows/chatbot/inference/backend/fastrag/run.sh
+++ b/workflows/chatbot/inference/backend/fastrag/run.sh
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
# Kill the exist and re-run
ps -ef |grep 'fastrag_service' |awk '{print $2}' |xargs kill -9
diff --git a/workflows/chatbot/inference/backend/fastrag/utils.py b/workflows/chatbot/inference/backend/fastrag/utils.py
index 646291709f6..1351f6224c1 100644
--- a/workflows/chatbot/inference/backend/fastrag/utils.py
+++ b/workflows/chatbot/inference/backend/fastrag/utils.py
@@ -1,4 +1,18 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
def detect_language(query):
is_english = all(ord(c) < 128 for c in query)
is_chinese = any('\u4e00' <= c <= '\u9fff' for c in query)
diff --git a/workflows/chatbot/inference/backend/llmcache/__init__.py b/workflows/chatbot/inference/backend/llmcache/__init__.py
index e69de29bb2d..28f108cb636 100644
--- a/workflows/chatbot/inference/backend/llmcache/__init__.py
+++ b/workflows/chatbot/inference/backend/llmcache/__init__.py
@@ -0,0 +1,13 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/workflows/chatbot/inference/backend/llmcache/cache.py b/workflows/chatbot/inference/backend/llmcache/cache.py
index ad18b509976..458fe2f703d 100644
--- a/workflows/chatbot/inference/backend/llmcache/cache.py
+++ b/workflows/chatbot/inference/backend/llmcache/cache.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
# pylint: disable=wrong-import-position
from typing import Any, Optional, Callable
diff --git a/workflows/chatbot/inference/backend/llmcache/cache_config.yml b/workflows/chatbot/inference/backend/llmcache/cache_config.yml
index 24faabb7855..f9195153a25 100644
--- a/workflows/chatbot/inference/backend/llmcache/cache_config.yml
+++ b/workflows/chatbot/inference/backend/llmcache/cache_config.yml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
# For `model_src`, `evaluation`, `post_function`, `pre_function`,
# `storage_config` options, Check README for more.
@@ -15,7 +29,7 @@ storage_config:
sqlite,faiss
vector_params:
# Set vector storage related params here
-evaluation:
+evaluation:
distance
evaluation_config:
max_distance: 1.0
diff --git a/workflows/chatbot/inference/backend/sd/README.md b/workflows/chatbot/inference/backend/sd/README.md
index 557bd270fe3..31e1323335f 100644
--- a/workflows/chatbot/inference/backend/sd/README.md
+++ b/workflows/chatbot/inference/backend/sd/README.md
@@ -59,4 +59,4 @@ Start the Stable Diffusion server:
```bash
nohup bash run.sh &
-```
\ No newline at end of file
+```
diff --git a/workflows/chatbot/inference/backend/sd/config.py b/workflows/chatbot/inference/backend/sd/config.py
index 0e9749f3ad9..b0961c2714c 100644
--- a/workflows/chatbot/inference/backend/sd/config.py
+++ b/workflows/chatbot/inference/backend/sd/config.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import socket
MODEL_PATH="runwayml/stable-diffusion-v1-5"
diff --git a/workflows/chatbot/inference/backend/sd/inference_server_ipex.py b/workflows/chatbot/inference/backend/sd/inference_server_ipex.py
index 666ec63ddbb..aab8b2aced2 100644
--- a/workflows/chatbot/inference/backend/sd/inference_server_ipex.py
+++ b/workflows/chatbot/inference/backend/sd/inference_server_ipex.py
@@ -1,5 +1,19 @@
# -*- coding: utf-8 -*
#!/usr/bin/env python3
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
from gevent import monkey
monkey.patch_all()
import gevent
diff --git a/workflows/chatbot/inference/backend/sd/run.sh b/workflows/chatbot/inference/backend/sd/run.sh
index 0b4de4bb2be..1c089fc3dda 100644
--- a/workflows/chatbot/inference/backend/sd/run.sh
+++ b/workflows/chatbot/inference/backend/sd/run.sh
@@ -1,5 +1,19 @@
#!/bin/bash
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
# IOMP
export OMP_NUM_THREADS=32
export LD_PRELOAD=${LD_PRELOAD}:${CONDA_PREFIX}/lib/libiomp5.so
diff --git a/workflows/chatbot/inference/backend/sd/sql_conn.py b/workflows/chatbot/inference/backend/sd/sql_conn.py
index fddf53af9d5..dbb4b804f1f 100644
--- a/workflows/chatbot/inference/backend/sd/sql_conn.py
+++ b/workflows/chatbot/inference/backend/sd/sql_conn.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import pymysql
from threading import Condition
import threading
@@ -44,7 +58,7 @@ def run(self):
"""
LOGGER.info("ping mysql.")
self.conn.ping(reconnect=True)
-
+
if not self._ping():
self.re_connection()
"""
@@ -89,7 +103,7 @@ def update(self, *values):
self.conn.commit()
finally:
self.lock.release()
-
+
return result
@@ -111,7 +125,7 @@ def insert(self, *values):
self.conn.commit()
finally:
self.lock.release()
-
+
return result
mysql = MysqlWorker()
diff --git a/workflows/chatbot/inference/document_indexing/README.md b/workflows/chatbot/inference/document_indexing/README.md
index 2312c216d0b..a9946bc62de 100644
--- a/workflows/chatbot/inference/document_indexing/README.md
+++ b/workflows/chatbot/inference/document_indexing/README.md
@@ -48,4 +48,4 @@ embeddings = OpenAIEmbeddings()
The user can start the dense indexing with,
```bash
python doc_index.py --file_path "xxx" --output_path "xxx" --embedding_model hkunlp/instructor-large --embedding_method dense --store Chroma
- ```
\ No newline at end of file
+ ```
diff --git a/workflows/chatbot/inference/document_indexing/doc_index.py b/workflows/chatbot/inference/document_indexing/doc_index.py
index 629e55dd7f1..e81e47fd0a7 100644
--- a/workflows/chatbot/inference/document_indexing/doc_index.py
+++ b/workflows/chatbot/inference/document_indexing/doc_index.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import os
import argparse
from langchain.embeddings import HuggingFaceEmbeddings, HuggingFaceInstructEmbeddings
@@ -71,7 +85,7 @@ def d_load_jsonl_file(file_path, process, max_length=378):
# def d_load_xlsx_file(file_path, process, max_length=378):
# data = []
# data = pd.read_excel(file_path)
-#
+#
# new_sens = []
# documents = []
# paragraphs = []
@@ -215,7 +229,7 @@ def s_load_file(file_path, process, document_store, max_length=378):
new_doc = SDocument(content=paragraph, metadata=metadata)
documents.append(new_doc)
document_store.write_documents(documents)
-
+
return document_store
@@ -226,7 +240,7 @@ def persist_embedding(documents, persist_directory, model_path):
vectordb.persist()
vectordb = None
-
+
def read_docx(doc_path):
doc = DDocument(doc_path)
text = ''
@@ -282,4 +296,3 @@ def load_pdf(pdf_path):
document_store.save(index_path="my_index.faiss")
else:
print("in memory db is done")
-
diff --git a/workflows/chatbot/inference/document_indexing/docker/README.md b/workflows/chatbot/inference/document_indexing/docker/README.md
index d4e9c18d751..2fb9f297deb 100644
--- a/workflows/chatbot/inference/document_indexing/docker/README.md
+++ b/workflows/chatbot/inference/document_indexing/docker/README.md
@@ -38,5 +38,3 @@ Users have the flexibility to choose their preferred pretrained encoder model fo
```
python doc_index.py --file_path "xxx" --output_path "xxx" --embedding_model hkunlp/instructor-large --embedding_method dense --store Chroma
```
-
-
diff --git a/workflows/chatbot/inference/document_indexing/requirements.txt b/workflows/chatbot/inference/document_indexing/requirements.txt
index 5c4d9cba3a3..b20b74004a0 100644
--- a/workflows/chatbot/inference/document_indexing/requirements.txt
+++ b/workflows/chatbot/inference/document_indexing/requirements.txt
@@ -1,6 +1,6 @@
-langchain
chromadb
+InstructorEmbedding
+langchain
+pandas
PyPDF2
python-docx
-pandas
-InstructorEmbedding
\ No newline at end of file
diff --git a/workflows/chatbot/inference/memory_controller/Entity_Memory.py b/workflows/chatbot/inference/memory_controller/Entity_Memory.py
index 28f3f87f094..7a50ca4c3a3 100644
--- a/workflows/chatbot/inference/memory_controller/Entity_Memory.py
+++ b/workflows/chatbot/inference/memory_controller/Entity_Memory.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
from langchain.schema import BaseMemory
from pydantic import BaseModel
from typing import List, Dict, Any
@@ -44,4 +58,4 @@ def save_context(self, inputs: Dict[str, Any], outputs: Dict[str, str]) -> None:
if ent_str in self.entities:
self.entities[ent_str] += f"\n{text}"
else:
- self.entities[ent_str] = text
\ No newline at end of file
+ self.entities[ent_str] = text
diff --git a/workflows/chatbot/inference/memory_controller/chat_with_memory.py b/workflows/chatbot/inference/memory_controller/chat_with_memory.py
index 4913cffd25c..8cbdfaf1e10 100644
--- a/workflows/chatbot/inference/memory_controller/chat_with_memory.py
+++ b/workflows/chatbot/inference/memory_controller/chat_with_memory.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import os, re
from langchain.llms import HuggingFacePipeline
from langchain.prompts import PromptTemplate
@@ -26,7 +40,7 @@ def inference(args, query, memory):
template=prompt_template, input_variables=["entities", "question"]
)
else:
- prompt_template = """The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context.
+ prompt_template = """The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context.
AI should revise the answer according to the human feedback.
{chat_history}
diff --git a/workflows/chatbot/inference/models/__init__.py b/workflows/chatbot/inference/models/__init__.py
index e69de29bb2d..28f108cb636 100644
--- a/workflows/chatbot/inference/models/__init__.py
+++ b/workflows/chatbot/inference/models/__init__.py
@@ -0,0 +1,13 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/workflows/chatbot/inference/models/mpt/__init__.py b/workflows/chatbot/inference/models/mpt/__init__.py
index e69de29bb2d..28f108cb636 100755
--- a/workflows/chatbot/inference/models/mpt/__init__.py
+++ b/workflows/chatbot/inference/models/mpt/__init__.py
@@ -0,0 +1,13 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/workflows/chatbot/inference/models/mpt/mpt_trace.py b/workflows/chatbot/inference/models/mpt/mpt_trace.py
index 59b1b82f464..39c0cc83d6a 100644
--- a/workflows/chatbot/inference/models/mpt/mpt_trace.py
+++ b/workflows/chatbot/inference/models/mpt/mpt_trace.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import torch
from typing import Optional, Tuple
from transformers.modeling_outputs import CausalLMOutputWithPast
diff --git a/workflows/chatbot/inference/requirements.txt b/workflows/chatbot/inference/requirements.txt
index 43c62b04c5f..df899c47d4f 100644
--- a/workflows/chatbot/inference/requirements.txt
+++ b/workflows/chatbot/inference/requirements.txt
@@ -1,11 +1,11 @@
datasets
-torch
-intel_extension_for_pytorch
-git+https://github.com/huggingface/transformers.git
-sentencepiece
-peft
+einops
evaluate
+git+https://github.com/huggingface/transformers.git
+gptcache
+intel_extension_for_pytorch
nltk
+peft
rouge_score
-einops
-gptcache
\ No newline at end of file
+sentencepiece
+torch
diff --git a/workflows/compression_aware_training/chart/Chart.yaml b/workflows/compression_aware_training/chart/Chart.yaml
index 8867b821919..c03e111b21e 100644
--- a/workflows/compression_aware_training/chart/Chart.yaml
+++ b/workflows/compression_aware_training/chart/Chart.yaml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
apiVersion: v2
name: Compression Aware
description: A Helm chart for Kubernetes
diff --git a/workflows/compression_aware_training/chart/templates/workflowTemplate.yaml b/workflows/compression_aware_training/chart/templates/workflowTemplate.yaml
index 0a17dbada48..ed910f1f001 100644
--- a/workflows/compression_aware_training/chart/templates/workflowTemplate.yaml
+++ b/workflows/compression_aware_training/chart/templates/workflowTemplate.yaml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
@@ -10,8 +24,8 @@ spec:
tasks:
- name: compression-aware
template: compression-aware
- arguments:
- parameters:
+ arguments:
+ parameters:
- name: config
value: '{{"{{workflow.parameters.config}}"}}'
failFast: true
@@ -26,7 +40,7 @@ spec:
{{ end }}
parameters:
- name: config
- outputs:
+ outputs:
artifacts:
- name: 'compression-aware-output'
path: /workspace/output
@@ -55,7 +69,7 @@ spec:
{{ if eq .Values.dataset.type "nfs" }}
volumes:
- name: config-dir
- nfs:
+ nfs:
server: {{ .Values.dataset.nfs.server }}
path: {{ .Values.dataset.nfs.path }}
readOnly: true
diff --git a/workflows/compression_aware_training/chart/values.yaml b/workflows/compression_aware_training/chart/values.yaml
index 62bf39dc599..a39c18beb22 100644
--- a/workflows/compression_aware_training/chart/values.yaml
+++ b/workflows/compression_aware_training/chart/values.yaml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
serviceAccountName: argo
metadata:
name: compression-aware
diff --git a/workflows/compression_aware_training/config/config.yaml b/workflows/compression_aware_training/config/config.yaml
index 383fe741cc3..48e31757b6e 100755
--- a/workflows/compression_aware_training/config/config.yaml
+++ b/workflows/compression_aware_training/config/config.yaml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
model_name_or_path: "prajjwal1/bert-mini"
teacher_model_name_or_path: "bert-base-uncased"
task_name: "sst2"
@@ -13,4 +27,4 @@ perf_tol: 0.03
quantization: true
quantization_approach: "QuantizationAwareTraining"
is_relative: true
-int8: false
\ No newline at end of file
+int8: false
diff --git a/workflows/compression_aware_training/config/distillation.yaml b/workflows/compression_aware_training/config/distillation.yaml
index 673bf0d9145..ca267e46166 100755
--- a/workflows/compression_aware_training/config/distillation.yaml
+++ b/workflows/compression_aware_training/config/distillation.yaml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
model_name_or_path: "prajjwal1/bert-mini"
teacher_model_name_or_path: "bert-base-uncased"
task_name: "sst2"
diff --git a/workflows/compression_aware_training/config/distillation_multinode.yaml b/workflows/compression_aware_training/config/distillation_multinode.yaml
index d623e0bb634..5dfbb2746f7 100755
--- a/workflows/compression_aware_training/config/distillation_multinode.yaml
+++ b/workflows/compression_aware_training/config/distillation_multinode.yaml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
model_name_or_path: "prajjwal1/bert-mini"
teacher_model_name_or_path: "bert-base-uncased"
task_name: "sst2"
diff --git a/workflows/compression_aware_training/config/distillation_with_qat.yaml b/workflows/compression_aware_training/config/distillation_with_qat.yaml
index 0975fc1af07..48e31757b6e 100755
--- a/workflows/compression_aware_training/config/distillation_with_qat.yaml
+++ b/workflows/compression_aware_training/config/distillation_with_qat.yaml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
model_name_or_path: "prajjwal1/bert-mini"
teacher_model_name_or_path: "bert-base-uncased"
task_name: "sst2"
diff --git a/workflows/compression_aware_training/config/qat.yaml b/workflows/compression_aware_training/config/qat.yaml
index c4f300a3fb6..faf0416ed2f 100644
--- a/workflows/compression_aware_training/config/qat.yaml
+++ b/workflows/compression_aware_training/config/qat.yaml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
model_name_or_path: "prajjwal1/bert-mini"
task_name: "sst2"
distillation: false
diff --git a/workflows/compression_aware_training/config/sat.yaml b/workflows/compression_aware_training/config/sat.yaml
index 608f51bca9f..7731f0dfb69 100755
--- a/workflows/compression_aware_training/config/sat.yaml
+++ b/workflows/compression_aware_training/config/sat.yaml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
model_name_or_path: "Intel/distilbert-base-uncased-sparse-90-unstructured-pruneofa"
teacher_model_name_or_path: "distilbert-base-uncased-finetuned-sst-2-english"
task_name: "sst2"
diff --git a/workflows/compression_aware_training/docker/docker-compose.yaml b/workflows/compression_aware_training/docker/docker-compose.yaml
index 64914b11417..46fef68f3be 100644
--- a/workflows/compression_aware_training/docker/docker-compose.yaml
+++ b/workflows/compression_aware_training/docker/docker-compose.yaml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
services:
dev:
build:
@@ -8,7 +22,7 @@ services:
context: ../
dockerfile: ./docker/Dockerfile
command: python /workspace/src/run.py --config_file /workspace/config/${CONFIG}.yaml
- environment:
+ environment:
- http_proxy=${http_proxy}
- https_proxy=${https_proxy}
- no_proxy=${no_proxy}
diff --git a/workflows/compression_aware_training/requirements.txt b/workflows/compression_aware_training/requirements.txt
index 3e016988a92..40bc25c1adf 100644
--- a/workflows/compression_aware_training/requirements.txt
+++ b/workflows/compression_aware_training/requirements.txt
@@ -1,8 +1,8 @@
-transformers
+--extra-index-url https://download.pytorch.org/whl/cpu
+accelerate==0.21.0
datasets==2.11.0
+intel-extension-for-transformers==1.1
+intel_extension_for_pytorch==1.13.100
neural-compressor==2.1
---extra-index-url https://download.pytorch.org/whl/cpu
torch==1.13.1
-intel_extension_for_pytorch==1.13.100
-intel-extension-for-transformers==1.1
-accelerate==0.21.0
\ No newline at end of file
+transformers
diff --git a/workflows/compression_aware_training/src/itrex_opt.py b/workflows/compression_aware_training/src/itrex_opt.py
index b20d6a4e31b..b727d22c412 100755
--- a/workflows/compression_aware_training/src/itrex_opt.py
+++ b/workflows/compression_aware_training/src/itrex_opt.py
@@ -90,7 +90,7 @@ def __init__(self, config_file, no_cuda):
OptimizationArguments,
)
)
-
+
if config_file.endswith(".yaml"):
model_args, data_args, training_args, optim_args = parser.parse_yaml_file(
yaml_file=os.path.abspath(config_file)
@@ -946,7 +946,7 @@ def get_logits(teacher_model, train_dataset, teacher_train_dataset):
pruner_config = PrunerConfig(prune_type=prune_type, target_sparsity_ratio=target_sparsity_ratio)
pruning_conf = PruningConfig(framework="pytorch_fx",pruner_config=[pruner_config], metrics=tune_metric)
distillation_conf = DistillationConfig(framework="pytorch_fx", metrics=tune_metric)
-
+
objective = objectives.performance
quantization_conf = QuantizationConfig(
approach=self.optim_args.quantization_approach,
diff --git a/workflows/compression_aware_training/src/utils.py b/workflows/compression_aware_training/src/utils.py
index c699279acd2..6f158392c67 100755
--- a/workflows/compression_aware_training/src/utils.py
+++ b/workflows/compression_aware_training/src/utils.py
@@ -250,4 +250,4 @@ class OptimizationArguments:
accuracy_only: bool = field(
default=False,
metadata={"help":"Whether to only test accuracy for model tuned by Neural Compressor."}
- )
\ No newline at end of file
+ )
diff --git a/workflows/dlsa/requirements.txt b/workflows/dlsa/requirements.txt
index a244ac6f138..632f2e0b4cd 100644
--- a/workflows/dlsa/requirements.txt
+++ b/workflows/dlsa/requirements.txt
@@ -1,6 +1,6 @@
-transformers
+--extra-index-url https://download.pytorch.org/whl/cpu
datasets==2.9.0
+intel_extension_for_pytorch==1.13
neural-compressor==2.0
---extra-index-url https://download.pytorch.org/whl/cpu
torch==1.13.1
-intel_extension_for_pytorch==1.13
\ No newline at end of file
+transformers
diff --git a/workflows/hf_finetuning_and_inference_nlp/config/finetune.yaml b/workflows/hf_finetuning_and_inference_nlp/config/finetune.yaml
index 6943de498a4..8180fcacc6e 100644
--- a/workflows/hf_finetuning_and_inference_nlp/config/finetune.yaml
+++ b/workflows/hf_finetuning_and_inference_nlp/config/finetune.yaml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
args:
model_name_or_path: "bert-base-uncased" # input the fine-tuned model path
tokenizer_name: "bert-base-uncased" # input the fine-tuned model path
@@ -24,4 +38,4 @@ training_args:
do_predict: true
per_device_train_batch_size: 512
per_device_eval_batch_size: 512
- output_dir: "./output_dir"
\ No newline at end of file
+ output_dir: "./output_dir"
diff --git a/workflows/hf_finetuning_and_inference_nlp/config/finetune_Model-bertbase_Task-sentiment_Dataset-imdb.yaml b/workflows/hf_finetuning_and_inference_nlp/config/finetune_Model-bertbase_Task-sentiment_Dataset-imdb.yaml
index 44b8ce7fd3d..be84b1441bb 100644
--- a/workflows/hf_finetuning_and_inference_nlp/config/finetune_Model-bertbase_Task-sentiment_Dataset-imdb.yaml
+++ b/workflows/hf_finetuning_and_inference_nlp/config/finetune_Model-bertbase_Task-sentiment_Dataset-imdb.yaml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
args:
model_name_or_path: "bert-base-uncased" # input the fine-tuned model path
tokenizer_name: "bert-base-uncased" # input the fine-tuned model path
diff --git a/workflows/hf_finetuning_and_inference_nlp/config/finetune_Model-bioclinicalbert_Task-HLSDiseasePrediction_Dataset-local.yaml b/workflows/hf_finetuning_and_inference_nlp/config/finetune_Model-bioclinicalbert_Task-HLSDiseasePrediction_Dataset-local.yaml
index a60cb71a6a8..85bcd3deeb4 100644
--- a/workflows/hf_finetuning_and_inference_nlp/config/finetune_Model-bioclinicalbert_Task-HLSDiseasePrediction_Dataset-local.yaml
+++ b/workflows/hf_finetuning_and_inference_nlp/config/finetune_Model-bioclinicalbert_Task-HLSDiseasePrediction_Dataset-local.yaml
@@ -1,8 +1,22 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
args:
model_name_or_path: "emilyalsentzer/Bio_ClinicalBERT"
tokenizer_name: "emilyalsentzer/Bio_ClinicalBERT"
dataset: "local" # local or huggingface datasets name
-
+
# Add local dataset configurations below. Skip for HF datasets.
# Make sure to specify your local dataset . The code will fail otherwise.
local_dataset:
@@ -14,7 +28,7 @@ args:
data_column: "symptoms"
id: "Patient_ID"
label_list: ["Malignant", "Normal", "Benign"]
-
+
# Add the fine tuning configurations below
pipeline: "finetune"
finetune_impl: "itrex"
diff --git a/workflows/hf_finetuning_and_inference_nlp/config/inference.yaml b/workflows/hf_finetuning_and_inference_nlp/config/inference.yaml
index 8114d8296a6..9dd4468842a 100644
--- a/workflows/hf_finetuning_and_inference_nlp/config/inference.yaml
+++ b/workflows/hf_finetuning_and_inference_nlp/config/inference.yaml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
args:
model_name_or_path: "bert-base-uncased" # input the fine-tuned model path
tokenizer_name: "bert-base-uncased" # input the fine-tuned model path
@@ -12,13 +26,13 @@ args:
data_column: "symptoms"
id: "Patient_ID"
label_list: ["Malignant", "Normal", "Benign"]
-
+
# Add the Inference configurations below
- pipeline: "inference"
+ pipeline: "inference"
infer_impl: "itrex"
dtype_inf: "bf16"
- use_ipex: true
- use_onednn: true
+ use_ipex: true
+ use_onednn: true
max_seq_len: 64
smoke_test: false
max_train_samples: null
@@ -32,4 +46,4 @@ args:
training_args:
do_predict: true
per_device_eval_batch_size: 512
- output_dir: "./output_dir"
\ No newline at end of file
+ output_dir: "./output_dir"
diff --git a/workflows/hf_finetuning_and_inference_nlp/config/inference_Model-bertbase_Task-sentiment_Dataset-imdb.yaml b/workflows/hf_finetuning_and_inference_nlp/config/inference_Model-bertbase_Task-sentiment_Dataset-imdb.yaml
index 697c08c22e9..bf9c7347b79 100644
--- a/workflows/hf_finetuning_and_inference_nlp/config/inference_Model-bertbase_Task-sentiment_Dataset-imdb.yaml
+++ b/workflows/hf_finetuning_and_inference_nlp/config/inference_Model-bertbase_Task-sentiment_Dataset-imdb.yaml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
args:
model_name_or_path: "bert-base-uncased" # input the fine-tuned model path
tokenizer_name: "bert-base-uncased" # input the fine-tuned model path
@@ -12,9 +26,9 @@ args:
data_column: "symptoms"
id: "Patient_ID"
label_list: ["Malignant", "Normal", "Benign"]
-
+
# Add the Inference configurations below
- pipeline: "inference"
+ pipeline: "inference"
infer_impl: "itrex"
dtype_inf: "fp32"
max_seq_len: 64
diff --git a/workflows/hf_finetuning_and_inference_nlp/config/inference_Model-bioclinicalbert_Task-HLSDiseasePrediction_Dataset-local.yaml b/workflows/hf_finetuning_and_inference_nlp/config/inference_Model-bioclinicalbert_Task-HLSDiseasePrediction_Dataset-local.yaml
index 2b17a22a04d..0e25cbce5a9 100644
--- a/workflows/hf_finetuning_and_inference_nlp/config/inference_Model-bioclinicalbert_Task-HLSDiseasePrediction_Dataset-local.yaml
+++ b/workflows/hf_finetuning_and_inference_nlp/config/inference_Model-bioclinicalbert_Task-HLSDiseasePrediction_Dataset-local.yaml
@@ -1,8 +1,22 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
args:
model_name_or_path: "./models/hls/" # input the fine-tuned model path
tokenizer_name: "./models/hls/" # input the fine-tuned model path
dataset: "local" # local or huggingface datasets name
-
+
# Add local dataset configurations below. Skip for HF datasets.
# Make sure to specify your local dataset . The code will fail otherwise.
local_dataset:
@@ -13,9 +27,9 @@ args:
data_column: "symptoms"
id: "Patient_ID"
label_list: ["Malignant", "Normal", "Benign"]
-
+
# Add the Inference configurations below
- pipeline: "inference"
+ pipeline: "inference"
infer_impl: "itrex"
dtype_inf: "fp32"
max_seq_len: 64
diff --git a/workflows/hf_finetuning_and_inference_nlp/config/inference_only_Model-bertbase_Task-sentiment_Dataset-imdb.yaml b/workflows/hf_finetuning_and_inference_nlp/config/inference_only_Model-bertbase_Task-sentiment_Dataset-imdb.yaml
index 66f7faf0645..b4117b90909 100644
--- a/workflows/hf_finetuning_and_inference_nlp/config/inference_only_Model-bertbase_Task-sentiment_Dataset-imdb.yaml
+++ b/workflows/hf_finetuning_and_inference_nlp/config/inference_only_Model-bertbase_Task-sentiment_Dataset-imdb.yaml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
args:
model_name_or_path: "bert-base-uncased" # input the fine-tuned model path
tokenizer_name: "bert-base-uncased" # input the fine-tuned model path
@@ -12,9 +26,9 @@ args:
data_column: "symptoms"
id: "Patient_ID"
label_list: ["Malignant", "Normal", "Benign"]
-
+
# Add the Inference configurations below
- pipeline: "inference_only"
+ pipeline: "inference_only"
infer_impl: "itrex"
dtype_inf: "fp32"
max_seq_len: 64
diff --git a/workflows/hf_finetuning_and_inference_nlp/config/inference_trainerStockPT.yaml b/workflows/hf_finetuning_and_inference_nlp/config/inference_trainerStockPT.yaml
index d49ef574696..a5ce50e2584 100644
--- a/workflows/hf_finetuning_and_inference_nlp/config/inference_trainerStockPT.yaml
+++ b/workflows/hf_finetuning_and_inference_nlp/config/inference_trainerStockPT.yaml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
args:
model_name_or_path: "bert-base-uncased" # input the fine-tuned model path
tokenizer_name: "bert-base-uncased" # input the fine-tuned model path
@@ -12,12 +26,12 @@ args:
data_column: "symptoms"
id: "Patient_ID"
label_list: ["Malignant", "Normal", "Benign"]
-
+
# Add the Inference configurations below
- pipeline: "inference"
+ pipeline: "inference"
infer_impl: "trainer" # Use trainer for default stock PT Huggingface NLP Trainer
- dtype_inf: "fp32" # bf16 is ineffective for stockPTtrainer: Use infer_impl=itrex & use_ipex=true.
- use_ipex: false # No effect / Not valid when using trainer
+ dtype_inf: "fp32" # bf16 is ineffective for stockPTtrainer: Use infer_impl=itrex & use_ipex=true.
+ use_ipex: false # No effect / Not valid when using trainer
use_onednn: false # No effect / not valid when using trainer
max_seq_len: 64
smoke_test: false
diff --git a/workflows/hf_finetuning_and_inference_nlp/docker/docker-compose.yaml b/workflows/hf_finetuning_and_inference_nlp/docker/docker-compose.yaml
index 727c394447e..a1ca5f6a153 100644
--- a/workflows/hf_finetuning_and_inference_nlp/docker/docker-compose.yaml
+++ b/workflows/hf_finetuning_and_inference_nlp/docker/docker-compose.yaml
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
services:
dev:
build:
@@ -8,7 +22,7 @@ services:
context: ../
dockerfile: ./docker/Dockerfile
command: python /workspace/src/run.py --config_file /workspace/config/${CONFIG}.yaml
- environment:
+ environment:
- http_proxy=${http_proxy}
- https_proxy=${https_proxy}
- no_proxy=${no_proxy}
diff --git a/workflows/hf_finetuning_and_inference_nlp/requirements.txt b/workflows/hf_finetuning_and_inference_nlp/requirements.txt
index f728ef2c852..36050cac8d4 100644
--- a/workflows/hf_finetuning_and_inference_nlp/requirements.txt
+++ b/workflows/hf_finetuning_and_inference_nlp/requirements.txt
@@ -1,8 +1,8 @@
-transformers
+--extra-index-url https://download.pytorch.org/whl/cpu
+accelerate==0.21.0
datasets==2.11.0
+intel-extension-for-transformers==1.0.0
+intel_extension_for_pytorch==2.1.0
neural-compressor==2.1
---extra-index-url https://download.pytorch.org/whl/cpu
torch==2.1.0
-intel_extension_for_pytorch==2.1.0
-intel-extension-for-transformers==1.0.0
-accelerate==0.21.0
\ No newline at end of file
+transformers
diff --git a/workflows/hf_finetuning_and_inference_nlp/src/__init__.py b/workflows/hf_finetuning_and_inference_nlp/src/__init__.py
index e69de29bb2d..28f108cb636 100644
--- a/workflows/hf_finetuning_and_inference_nlp/src/__init__.py
+++ b/workflows/hf_finetuning_and_inference_nlp/src/__init__.py
@@ -0,0 +1,13 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/workflows/hf_finetuning_and_inference_nlp/src/finetune_itrex.py b/workflows/hf_finetuning_and_inference_nlp/src/finetune_itrex.py
index 0c5dbee3ea9..9e3ba13c89d 100644
--- a/workflows/hf_finetuning_and_inference_nlp/src/finetune_itrex.py
+++ b/workflows/hf_finetuning_and_inference_nlp/src/finetune_itrex.py
@@ -70,11 +70,11 @@ def _do_finetune(self):
with torch.backends.mkldnn.flags(enabled = self.training_args.use_ipex or vars(self.args).get("use_onednn", True)):
train_result = self.trainer.train()
-
+
self.trainer.save_model()
-
+
save_train_metrics(train_result, self.trainer, len(self.train_data))
-
+
def _do_infer(self):
with torch.backends.mkldnn.flags(enabled = self.training_args.use_ipex or vars(self.args).get("use_onednn", True)):
if self.training_args.do_predict:
diff --git a/workflows/hf_finetuning_and_inference_nlp/src/finetune_trainer.py b/workflows/hf_finetuning_and_inference_nlp/src/finetune_trainer.py
index d4997fd0a8b..2dc9e2ecd75 100644
--- a/workflows/hf_finetuning_and_inference_nlp/src/finetune_trainer.py
+++ b/workflows/hf_finetuning_and_inference_nlp/src/finetune_trainer.py
@@ -59,5 +59,5 @@ def _do_infer(self):
f"\n*********** TEST_METRICS ***********\nAccuracy: {metrics['test_acc']}\n"
)
else:
- save_performance_metrics(self.trainer, self.train_data,
+ save_performance_metrics(self.trainer, self.train_data,
path.join(self.training_args.output_dir, self.args.finetune_output) )
diff --git a/workflows/hf_finetuning_and_inference_nlp/src/infer.py b/workflows/hf_finetuning_and_inference_nlp/src/infer.py
index cd1aa9fd572..6391124fbb2 100644
--- a/workflows/hf_finetuning_and_inference_nlp/src/infer.py
+++ b/workflows/hf_finetuning_and_inference_nlp/src/infer.py
@@ -51,7 +51,7 @@ def e2e_infer_setup_only(self):
self.tokenize_data = False
self._preprocess()
self._load_model()
-
+
def e2e_infer_only(self, filename):
with self.track("Inference Only Run"):
self.load_tokenizer = False
diff --git a/workflows/hf_finetuning_and_inference_nlp/src/infer_itrex.py b/workflows/hf_finetuning_and_inference_nlp/src/infer_itrex.py
index 8a1ee83d321..b666c6f8bbc 100644
--- a/workflows/hf_finetuning_and_inference_nlp/src/infer_itrex.py
+++ b/workflows/hf_finetuning_and_inference_nlp/src/infer_itrex.py
@@ -87,13 +87,13 @@ def _load_model(self):
self.model = self.trainer.quantize(
quant_config=q_config, calib_dataloader=eval_dataloader
)
-
+
else:
error_msg = f"Now only support fp32, bf16 and int8.Your input datatype is {self.args.dtype_inf}."
raise ValueError(error_msg)
def _do_infer(self):
-
+
if self.args.dtype_inf == "bf16" and not (self.training_args.use_ipex or vars(self.args).get("use_onednn", True)):
raise ValueError("BF16 with both IPEX and OneDNN disabled is currently not implemented...")
diff --git a/workflows/hf_finetuning_and_inference_nlp/src/infer_trainer.py b/workflows/hf_finetuning_and_inference_nlp/src/infer_trainer.py
index 7979ce41aee..cd858906364 100644
--- a/workflows/hf_finetuning_and_inference_nlp/src/infer_trainer.py
+++ b/workflows/hf_finetuning_and_inference_nlp/src/infer_trainer.py
@@ -53,5 +53,5 @@ def _do_infer(self):
f"\n*********** TEST_METRICS ***********\nAccuracy: {metrics['test_acc']}\n"
)
else:
- save_performance_metrics(self.trainer, self.test_data,
- path.join(self.training_args.output_dir, self.args.inference_output) )
\ No newline at end of file
+ save_performance_metrics(self.trainer, self.test_data,
+ path.join(self.training_args.output_dir, self.args.inference_output) )
diff --git a/workflows/hf_finetuning_and_inference_nlp/src/run.py b/workflows/hf_finetuning_and_inference_nlp/src/run.py
index 4fa9b3e1795..aa6c9b72438 100644
--- a/workflows/hf_finetuning_and_inference_nlp/src/run.py
+++ b/workflows/hf_finetuning_and_inference_nlp/src/run.py
@@ -83,7 +83,7 @@ def main():
if args.dataset != "local":
error_msg = f"Now only support local datasets for inference_only pipeline."
raise ValueError(error_msg)
-
+
if args.infer_impl == "trainer":
from infer_trainer import TrainerInfer
infer = TrainerInfer(**kwargs)
@@ -93,12 +93,12 @@ def main():
else:
error_msg = f"Now only support trainer and itrex implementation for inference pipeline."
raise ValueError(error_msg)
-
+
infer.e2e_infer_setup_only()
if type(args.local_dataset["inference_input"]) == str:
args.local_dataset["inference_input"] = args.local_dataset["inference_input"].split(",")
-
+
for f in args.local_dataset["inference_input"]:
infer.e2e_infer_only(f)
diff --git a/workflows/hf_finetuning_and_inference_nlp/src/utils.py b/workflows/hf_finetuning_and_inference_nlp/src/utils.py
index 4cdb1f4a388..bfa11ef24ba 100644
--- a/workflows/hf_finetuning_and_inference_nlp/src/utils.py
+++ b/workflows/hf_finetuning_and_inference_nlp/src/utils.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2022 Intel Corporation
+# Copyright (C) 2022 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -202,11 +202,9 @@ def save_performance_metrics(trainer, data, output_file):
predictions_report = {}
predictions_report["label_id"] = [label_map[i] for i in predictions.label_ids.tolist()]
- predictions_report["predictions_label"] = [label_map[i] for i in np.argmax(predictions.predictions, axis=1).tolist() ]
- predictions_report["predictions_probabilities"] = softmax(predictions.predictions, axis=1).tolist()
+ predictions_report["predictions_label"] = [label_map[i] for i in np.argmax(predictions.predictions, axis=1).tolist() ]
+ predictions_report["predictions_probabilities"] = softmax(predictions.predictions, axis=1).tolist()
predictions_report["metrics"] = predictions.metrics
-
- with open(output_file, 'w') as file:
- _ = yaml.dump(predictions_report, file)
-
+ with open(output_file, 'w') as file:
+ _ = yaml.dump(predictions_report, file)
diff --git a/workflows/hf_finetuning_and_inference_nlp/test/test_inference_only_programatically.py b/workflows/hf_finetuning_and_inference_nlp/test/test_inference_only_programatically.py
index 14f66d102eb..37a456daf63 100644
--- a/workflows/hf_finetuning_and_inference_nlp/test/test_inference_only_programatically.py
+++ b/workflows/hf_finetuning_and_inference_nlp/test/test_inference_only_programatically.py
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
from transformers import TrainingArguments
from transformers import logging as hf_logging
import argparse
@@ -57,9 +71,9 @@
for item in data["args"]:
setattr(args, item, data["args"][item])
-kwargs = {"args": args, "training_args": training_args}
+kwargs = {"args": args, "training_args": training_args}
-infer = ItrexInfer(**kwargs)
+infer = ItrexInfer(**kwargs)
infer.e2e_infer_setup_only()
inf_list = [
@@ -67,6 +81,6 @@
'/data/datac/samanway/annotation/d1.csv',
'/data/datac/samanway/annotation/d2.csv'
]
-
+
for f in inf_list:
- infer.e2e_infer_only(f)
\ No newline at end of file
+ infer.e2e_infer_only(f)