Skip to content

Commit 53e770f

Browse files
feat: add support for phi4 and ministral 8b (#71)
* feat: add support for phi4 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * feat: add support for Ministral-8B --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent d12167b commit 53e770f

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
torch>=1.13.1
2-
huggingface-hub>=0.24.7,<0.25
3-
transformers>=4.43.0,<=4.45.0
2+
huggingface-hub==0.29.1
3+
transformers==4.49.0
44
datasets>=2.14.3
55
accelerate>=0.27.2
66
loguru==0.7.0

src/core/constant.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"mistralai/Mistral-7B-Instruct-v0.1",
5959
"mistralai/Mistral-7B-Instruct-v0.2",
6060
"mistralai/Mistral-7B-Instruct-v0.3",
61+
"mistralai/Ministral-8B-Instruct-2410",
6162
# mixtral
6263
"mistralai/Mixtral-8x7B-v0.1",
6364
"mistralai/Mixtral-8x7B-Instruct-v0.1",
@@ -97,6 +98,9 @@
9798
"microsoft/Phi-3.5-mini-instruct",
9899
"microsoft/Phi-3-mini-4k-instruct",
99100
"microsoft/Phi-3-medium-4k-instruct",
101+
# phi4
102+
"microsoft/Phi-4-mini-instruct",
103+
"microsoft/phi-4",
100104
# deepseek
101105
"deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B",
102106
"deepseek-ai/DeepSeek-R1-Distill-Qwen-7B",

src/core/hf_utils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from huggingface_hub import HfApi
2-
from huggingface_hub.utils._errors import EntryNotFoundError
32
from loguru import logger
43

54
api = HfApi()
@@ -13,9 +12,12 @@ def download_lora_config(repo_id: str, revision: str) -> bool:
1312
local_dir="lora",
1413
revision=revision,
1514
)
16-
except EntryNotFoundError:
17-
logger.info("No adapter_config.json found in the repo, assuming full model")
18-
return False
15+
except Exception as e:
16+
if "adapter_config.json" in str(e):
17+
logger.info("No adapter_config.json found in the repo, assuming full model")
18+
return False
19+
else:
20+
raise # Re-raise the exception if it's not related to the missing file
1921
return True
2022

2123

src/core/template.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,15 @@ def register_template(
170170
system=None,
171171
stop_word="<|end|>",
172172
)
173+
174+
register_template(
175+
template_name="phi4",
176+
system_format=None,
177+
user_format="<|user|>\n{content}<|end|>\n<|assistant|>",
178+
assistant_format="{content}<|end|>\n",
179+
tool_format="<|tool|>{content}<|/tool|>",
180+
function_format="<|tool_call|>{content}<|/tool_call|>",
181+
observation_format="<|tool|>\n{content}<|end|>\n<|assistant|>",
182+
system=None,
183+
stop_word="<|end|>",
184+
)

0 commit comments

Comments
 (0)