mirror of
https://github.com/modelscope/modelscope.git
synced 2026-02-24 20:19:51 +01:00
Merge branch 'master' into fix/cache_dir
This commit is contained in:
@@ -233,7 +233,7 @@ def _snapshot_download(
|
||||
if repo_type == REPO_TYPE_MODEL:
|
||||
directory = os.path.abspath(
|
||||
local_dir) if local_dir is not None else os.path.join(
|
||||
system_cache, 'hub', repo_id)
|
||||
system_cache, 'hub', *repo_id.split('/'))
|
||||
print(f'Downloading Model to directory: {directory}')
|
||||
revision_detail = _api.get_valid_revision_detail(
|
||||
repo_id, revision=revision, cookies=cookies)
|
||||
@@ -294,7 +294,7 @@ def _snapshot_download(
|
||||
elif repo_type == REPO_TYPE_DATASET:
|
||||
directory = os.path.abspath(
|
||||
local_dir) if local_dir else os.path.join(
|
||||
system_cache, 'hub', 'datasets', repo_id)
|
||||
system_cache, 'hub', 'datasets', *repo_id.split('/'))
|
||||
print(f'Downloading Dataset to directory: {directory}')
|
||||
|
||||
group_or_owner, name = model_id_to_group_owner_name(repo_id)
|
||||
|
||||
@@ -10,8 +10,11 @@ from modelscope.models.base import Tensor, TorchModel
|
||||
from modelscope.models.builder import MODELS
|
||||
from modelscope.utils.constant import Tasks
|
||||
from modelscope.utils.hub import read_config
|
||||
from modelscope.utils.logger import get_logger
|
||||
from modelscope.utils.streaming_output import StreamingOutputMixin
|
||||
|
||||
logger = get_logger()
|
||||
|
||||
__all__ = ['PolyLMForTextGeneration']
|
||||
|
||||
|
||||
@@ -27,6 +30,9 @@ class PolyLMForTextGeneration(TorchModel, StreamingOutputMixin):
|
||||
super().__init__(model_dir, *args, **kwargs)
|
||||
self.tokenizer = AutoTokenizer.from_pretrained(
|
||||
model_dir, legacy=False, use_fast=False)
|
||||
logger.warning(
|
||||
f'Use trust_remote_code=True. Will invoke codes from {model_dir}. Please make sure '
|
||||
'that you can trust the external codes.')
|
||||
self.model = AutoModelForCausalLM.from_pretrained(
|
||||
model_dir, device_map='auto', trust_remote_code=True)
|
||||
self.model.eval()
|
||||
|
||||
@@ -133,6 +133,11 @@ class OssDownloader(BaseDownloader):
|
||||
raise f'meta-file: {dataset_name}.py not found on the modelscope hub.'
|
||||
|
||||
if dataset_py_script and dataset_formation == DatasetFormations.hf_compatible:
|
||||
if trust_remote_code:
|
||||
logger.warning(
|
||||
f'Use trust_remote_code=True. Will invoke codes from {dataset_name}. Please make '
|
||||
'sure that you can trust the external codes.')
|
||||
|
||||
self.dataset = hf_load_dataset(
|
||||
dataset_py_script,
|
||||
name=subset_name,
|
||||
|
||||
@@ -71,6 +71,11 @@ class LocalDataLoaderManager(DataLoaderManager):
|
||||
# Select local data loader
|
||||
# TODO: more loaders to be supported.
|
||||
if data_loader_type == LocalDataLoaderType.HF_DATA_LOADER:
|
||||
if trust_remote_code:
|
||||
logger.warning(
|
||||
f'Use trust_remote_code=True. Will invoke codes from {dataset_name}. Please make '
|
||||
'sure that you can trust the external codes.')
|
||||
|
||||
# Build huggingface data loader and return dataset.
|
||||
return hf_data_loader(
|
||||
dataset_name,
|
||||
@@ -110,6 +115,10 @@ class RemoteDataLoaderManager(DataLoaderManager):
|
||||
|
||||
# To use the huggingface data loader
|
||||
if data_loader_type == RemoteDataLoaderType.HF_DATA_LOADER:
|
||||
if trust_remote_code:
|
||||
logger.warning(
|
||||
f'Use trust_remote_code=True. Will invoke codes from {dataset_name}. Please make '
|
||||
'sure that you can trust the external codes.')
|
||||
dataset_ret = hf_data_loader(
|
||||
dataset_name,
|
||||
name=subset_name,
|
||||
|
||||
@@ -237,6 +237,11 @@ class MsDataset:
|
||||
if not namespace or not dataset_name:
|
||||
raise 'The dataset_name should be in the form of `namespace/dataset_name` or `dataset_name`.'
|
||||
|
||||
if trust_remote_code:
|
||||
logger.warning(
|
||||
f'Use trust_remote_code=True. Will invoke codes from {dataset_name}. Please make sure that '
|
||||
'you can trust the external codes.')
|
||||
|
||||
# Init context config
|
||||
dataset_context_config = DatasetContextConfig(
|
||||
dataset_name=dataset_name,
|
||||
|
||||
@@ -835,6 +835,8 @@ def get_module_with_script(self) -> DatasetModule:
|
||||
if not os.path.exists(importable_file_path):
|
||||
trust_remote_code = resolve_trust_remote_code(trust_remote_code=self.trust_remote_code, repo_id=self.name)
|
||||
if trust_remote_code:
|
||||
logger.warning(f'Use trust_remote_code=True. Will invoke codes from {repo_id}. Please make sure that '
|
||||
'you can trust the external codes.')
|
||||
_create_importable_file(
|
||||
local_path=local_script_path,
|
||||
local_imports=local_imports,
|
||||
@@ -934,6 +936,11 @@ class DatasetsWrapperHF:
|
||||
verification_mode or VerificationMode.BASIC_CHECKS
|
||||
) if not save_infos else VerificationMode.ALL_CHECKS)
|
||||
|
||||
if trust_remote_code:
|
||||
logger.warning(f'Use trust_remote_code=True. Will invoke codes from {path}. Please make sure '
|
||||
'that you can trust the external codes.'
|
||||
)
|
||||
|
||||
# Create a dataset builder
|
||||
builder_instance = DatasetsWrapperHF.load_dataset_builder(
|
||||
path=path,
|
||||
@@ -1061,6 +1068,11 @@ class DatasetsWrapperHF:
|
||||
) if download_config else DownloadConfig()
|
||||
download_config.storage_options.update(storage_options)
|
||||
|
||||
if trust_remote_code:
|
||||
logger.warning(f'Use trust_remote_code=True. Will invoke codes from {path}. Please make sure '
|
||||
'that you can trust the external codes.'
|
||||
)
|
||||
|
||||
dataset_module = DatasetsWrapperHF.dataset_module_factory(
|
||||
path,
|
||||
revision=revision,
|
||||
@@ -1171,6 +1183,10 @@ class DatasetsWrapperHF:
|
||||
# -> the module from the python file in the dataset repository
|
||||
# - if path has one "/" and is dataset repository on the HF hub without a python file
|
||||
# -> use a packaged module (csv, text etc.) based on content of the repository
|
||||
if trust_remote_code:
|
||||
logger.warning(f'Use trust_remote_code=True. Will invoke codes from {path}. Please make sure '
|
||||
'that you can trust the external codes.'
|
||||
)
|
||||
|
||||
# Try packaged
|
||||
if path in _PACKAGED_DATASETS_MODULES:
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
from typing import List, Union
|
||||
|
||||
from modelscope import get_logger
|
||||
from modelscope.pipelines.accelerate.base import InferFramework
|
||||
from modelscope.utils.import_utils import is_vllm_available
|
||||
|
||||
logger = get_logger()
|
||||
|
||||
|
||||
class Vllm(InferFramework):
|
||||
|
||||
@@ -27,6 +30,9 @@ class Vllm(InferFramework):
|
||||
if not Vllm.check_gpu_compatibility(8) and (dtype
|
||||
in ('bfloat16', 'auto')):
|
||||
dtype = 'float16'
|
||||
logger.warning(
|
||||
f'Use trust_remote_code=True. Will invoke codes from {self.model_dir}. Please make '
|
||||
'sure that you can trust the external codes.')
|
||||
self.model = LLM(
|
||||
self.model_dir,
|
||||
dtype=dtype,
|
||||
|
||||
@@ -2,7 +2,7 @@ from typing import Any, Dict, Union
|
||||
|
||||
import torch
|
||||
|
||||
from modelscope import AutoModelForCausalLM
|
||||
from modelscope import AutoModelForCausalLM, get_logger
|
||||
from modelscope.metainfo import Pipelines, Preprocessors
|
||||
from modelscope.models.base import Model
|
||||
from modelscope.outputs import OutputKeys
|
||||
@@ -13,6 +13,8 @@ from modelscope.pipelines.multi_modal.visual_question_answering_pipeline import
|
||||
from modelscope.preprocessors import Preprocessor, load_image
|
||||
from modelscope.utils.constant import Fields, Frameworks, Tasks
|
||||
|
||||
logger = get_logger()
|
||||
|
||||
|
||||
@PIPELINES.register_module(
|
||||
Tasks.visual_question_answering, module_name='ovis-vl')
|
||||
@@ -35,6 +37,9 @@ class VisionChatPipeline(VisualQuestionAnsweringPipeline):
|
||||
torch_dtype = kwargs.get('torch_dtype', torch.float16)
|
||||
multimodal_max_length = kwargs.get('multimodal_max_length', 8192)
|
||||
self.device = 'cuda' if device == 'gpu' else device
|
||||
logger.warning(
|
||||
f'Use trust_remote_code=True. Will invoke codes from {model}. Please make '
|
||||
'sure that you can trust the external codes.')
|
||||
self.model = AutoModelForCausalLM.from_pretrained(
|
||||
model,
|
||||
torch_dtype=torch_dtype,
|
||||
|
||||
@@ -97,6 +97,9 @@ class LLMPipeline(Pipeline, PipelineStreamingOutputMixin):
|
||||
assert base_model is not None, 'Cannot get adapter_cfg.model_id_or_path from configuration.json file.'
|
||||
revision = self.cfg.safe_get('adapter_cfg.model_revision',
|
||||
'master')
|
||||
logger.warning(
|
||||
f'Use trust_remote_code=True. Will invoke codes from {base_model}. Please make sure that you can '
|
||||
'trust the external codes.')
|
||||
base_model = Model.from_pretrained(
|
||||
base_model,
|
||||
revision,
|
||||
@@ -134,6 +137,9 @@ class LLMPipeline(Pipeline, PipelineStreamingOutputMixin):
|
||||
model) else snapshot_download(model)
|
||||
# TODO: Temporary use of AutoModelForCausalLM
|
||||
# Need to be updated into a universal solution
|
||||
logger.warning(
|
||||
f'Use trust_remote_code=True. Will invoke codes from {model_dir}. Please make sure '
|
||||
'that you can trust the external codes.')
|
||||
model = AutoModelForCausalLM.from_pretrained(
|
||||
model_dir,
|
||||
device_map=self.device_map,
|
||||
@@ -173,6 +179,9 @@ class LLMPipeline(Pipeline, PipelineStreamingOutputMixin):
|
||||
self.llm_framework = llm_framework
|
||||
|
||||
if os.path.exists(kwargs['model']):
|
||||
logger.warning(
|
||||
f'Use trust_remote_code=True. Will invoke codes from {kwargs["model"]}. Please make sure '
|
||||
'that you can trust the external codes.')
|
||||
config = AutoConfig.from_pretrained(
|
||||
kwargs['model'], trust_remote_code=True)
|
||||
q_config = config.__dict__.get('quantization_config', None)
|
||||
@@ -423,6 +432,9 @@ class LLMPipeline(Pipeline, PipelineStreamingOutputMixin):
|
||||
model_dir = self.model.model_dir
|
||||
if tokenizer_class is None:
|
||||
tokenizer_class = AutoTokenizer
|
||||
logger.warning(
|
||||
f'Use trust_remote_code=True. Will invoke codes from {model_dir}. Please make sure '
|
||||
'that you can trust the external codes.')
|
||||
return tokenizer_class.from_pretrained(
|
||||
model_dir, trust_remote_code=True)
|
||||
|
||||
|
||||
@@ -269,6 +269,9 @@ class ChatGLM6bV2TextGenerationPipeline(Pipeline):
|
||||
if use_bf16:
|
||||
default_torch_dtype = torch.bfloat16
|
||||
torch_dtype = kwargs.get('torch_dtype', default_torch_dtype)
|
||||
logger.warning(
|
||||
f'Use trust_remote_code=True. Will invoke codes from {model_dir}. Please make sure '
|
||||
'that you can trust the external codes.')
|
||||
model = Model.from_pretrained(
|
||||
model_dir,
|
||||
trust_remote_code=True,
|
||||
@@ -285,6 +288,9 @@ class ChatGLM6bV2TextGenerationPipeline(Pipeline):
|
||||
|
||||
self.model = model
|
||||
self.model.eval()
|
||||
logger.warning(
|
||||
f'Use trust_remote_code=True. Will invoke codes from {self.model.model_dir}. Please '
|
||||
'make sure that you can trust the external codes.')
|
||||
self.tokenizer = AutoTokenizer.from_pretrained(
|
||||
self.model.model_dir, trust_remote_code=True)
|
||||
|
||||
@@ -328,6 +334,9 @@ class QWenChatPipeline(Pipeline):
|
||||
bf16 = False
|
||||
|
||||
if isinstance(model, str):
|
||||
logger.warning(
|
||||
f'Use trust_remote_code=True. Will invoke codes from {model}. Please make sure '
|
||||
'that you can trust the external codes.')
|
||||
self.tokenizer = AutoTokenizer.from_pretrained(
|
||||
model, revision=revision, trust_remote_code=True)
|
||||
self.model = AutoModelForCausalLM.from_pretrained(
|
||||
@@ -392,6 +401,9 @@ class QWenTextGenerationPipeline(Pipeline):
|
||||
bf16 = False
|
||||
|
||||
if isinstance(model, str):
|
||||
logger.warning(
|
||||
f'Use trust_remote_code=True. Will invoke codes from {model}. Please make sure '
|
||||
'that you can trust the external codes.')
|
||||
self.model = AutoModelForCausalLM.from_pretrained(
|
||||
model,
|
||||
device_map=device_map,
|
||||
|
||||
@@ -230,6 +230,10 @@ template_info = [
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/dolphin-mistral',
|
||||
),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("dolphin3", "dolphin-3")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/dolphin3'),
|
||||
|
||||
# "phi"
|
||||
TemplateInfo(
|
||||
@@ -251,6 +255,12 @@ template_info = [
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/phi3',
|
||||
),
|
||||
TemplateInfo(
|
||||
template_regex=
|
||||
f'.*{cases("phi4", "phi-4")}{no_multi_modal()}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/phi4',
|
||||
),
|
||||
TemplateInfo(
|
||||
template_regex=
|
||||
f'.*{cases("phi")}{no_multi_modal()}.*',
|
||||
@@ -591,7 +601,7 @@ template_info = [
|
||||
template_regex=
|
||||
f'.*{cases("deepseek")}.*{cases("v2")}{no("v2.5")}{no_multi_modal()}.*{chat_suffix}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/deepseek_v2',
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/deepseek-v2',
|
||||
),
|
||||
|
||||
# deepseek_coder
|
||||
@@ -623,6 +633,94 @@ template_info = [
|
||||
template=TemplateType.telechat_v2,
|
||||
template_regex=f'.*{cases("TeleChat")}.*{cases("v2")}.*'),
|
||||
|
||||
# tulu3
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("tulu3", "tulu-3")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/tulu3'),
|
||||
|
||||
# athene-v2
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("athene-v2")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/athene-v2'),
|
||||
|
||||
# granite
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("granite-guardian-3")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite3-guardian'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("granite")}.*{cases("code")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite-code'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("granite-3.1")}.*{cases("2b", "8b")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite3.1-dense'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("granite-3.1")}.*{cases("1b", "3b")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite3.1-moe'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("granite-embedding")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite-embedding'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("granite-3")}.*{cases("2b", "8b")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite3-dense'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("granite-3")}.*{cases("1b", "3b")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite3-moe'),
|
||||
|
||||
# opencoder
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("opencoder")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/opencoder'),
|
||||
|
||||
# smollm
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("smollm2")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/smollm2'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("smollm")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/smollm'),
|
||||
|
||||
# 'aya'
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("aya-expanse")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/aya-expanse'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("aya")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/aya'),
|
||||
|
||||
# falcon
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("falcon3")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/falcon3'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("falcon")}.*{cases("-2")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/falcon2'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("falcon")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/falcon'),
|
||||
|
||||
# smallthinker
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("smallthinker")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/smallthinker'),
|
||||
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("nomic-embed-text")}.*',
|
||||
modelfile_prefix=
|
||||
@@ -651,10 +749,6 @@ template_info = [
|
||||
template_regex=f'.*{cases("starcoder")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/starcoder'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("granite")}.*{cases("code")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite-code'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("all-minilm")}.*',
|
||||
modelfile_prefix=
|
||||
@@ -663,10 +757,6 @@ template_info = [
|
||||
template_regex=f'.*{cases("openchat")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/openchat'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("aya")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/aya'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("openhermes")}.*',
|
||||
modelfile_prefix=
|
||||
@@ -687,10 +777,6 @@ template_info = [
|
||||
template_regex=f'.*{cases("xwin")}.*{cases("lm")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/xwinlm'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("smollm")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/smollm'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("sqlcoder")}.*',
|
||||
modelfile_prefix=
|
||||
@@ -699,14 +785,6 @@ template_info = [
|
||||
template_regex=f'.*{cases("starling-lm")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/starling-lm'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("falcon")}.*{cases("-2")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/falcon2'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("falcon")}.*',
|
||||
modelfile_prefix=
|
||||
'https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/falcon'),
|
||||
TemplateInfo(
|
||||
template_regex=f'.*{cases("solar-pro")}.*',
|
||||
modelfile_prefix=
|
||||
@@ -820,6 +898,9 @@ class TemplateLoader:
|
||||
model_id,
|
||||
revision=kwargs.pop('revision', 'master'),
|
||||
ignore_file_pattern=ignore_file_pattern)
|
||||
logger.warning(f'Use trust_remote_code=True. Will invoke codes from {model_dir}.'
|
||||
' Please make sure that you can trust the external codes.'
|
||||
)
|
||||
tokenizer = AutoTokenizer.from_pretrained(
|
||||
model_dir, trust_remote_code=True)
|
||||
config = AutoConfig.from_pretrained(model_dir, trust_remote_code=True)
|
||||
|
||||
@@ -3,12 +3,15 @@ import os
|
||||
from types import MethodType
|
||||
from typing import Any, Optional
|
||||
|
||||
from modelscope import get_logger
|
||||
from modelscope.metainfo import Tasks
|
||||
from modelscope.utils.ast_utils import INDEX_KEY
|
||||
from modelscope.utils.import_utils import (LazyImportModule,
|
||||
is_torch_available,
|
||||
is_transformers_available)
|
||||
|
||||
logger = get_logger()
|
||||
|
||||
|
||||
def can_load_by_ms(model_dir: str, task_name: Optional[str],
|
||||
model_type: Optional[str]) -> bool:
|
||||
@@ -91,6 +94,9 @@ def get_hf_automodel_class(model_dir: str,
|
||||
if not os.path.exists(config_path):
|
||||
return None
|
||||
try:
|
||||
logger.warning(
|
||||
f'Use trust_remote_code=True. Will invoke codes from {model_dir}. Please make sure '
|
||||
'that you can trust the external codes.')
|
||||
config = AutoConfig.from_pretrained(model_dir, trust_remote_code=True)
|
||||
if task_name is None:
|
||||
automodel_class = get_default_automodel(config)
|
||||
|
||||
@@ -451,6 +451,9 @@ def register_plugins_repo(plugins: List[str]) -> None:
|
||||
def register_modelhub_repo(model_dir, allow_remote=False) -> None:
|
||||
""" Try to install and import remote model from modelhub"""
|
||||
if allow_remote:
|
||||
logger.warning(
|
||||
f'Use allow_remote=True. Will invoke codes from {model_dir}. Please make sure '
|
||||
'that you can trust the external codes.')
|
||||
try:
|
||||
import_module_from_model_dir(model_dir)
|
||||
except KeyError:
|
||||
|
||||
@@ -311,6 +311,60 @@ class TestToOllama(unittest.TestCase):
|
||||
'llama3.3')
|
||||
_test_check_tmpl_type('bartowski/EXAONE-3.5-7.8B-Instruct-GGUF',
|
||||
'exaone3.5')
|
||||
_test_check_tmpl_type(
|
||||
'QuantFactory/Tulu-3.1-8B-SuperNova-Smart-GGUF',
|
||||
'tulu3',
|
||||
gguf_meta={'general.name': 'Tulu 3.1 8B SuperNova'})
|
||||
_test_check_tmpl_type(
|
||||
'bartowski/Athene-V2-Chat-GGUF',
|
||||
'athene-v2',
|
||||
gguf_meta={'general.name': 'Athene V2 Chat'})
|
||||
_test_check_tmpl_type(
|
||||
'QuantFactory/granite-guardian-3.0-2b-GGUF',
|
||||
'granite3-guardian',
|
||||
gguf_meta={'general.name': 'Models'})
|
||||
_test_check_tmpl_type('lmstudio-community/OpenCoder-8B-Instruct-GGUF',
|
||||
'opencoder')
|
||||
_test_check_tmpl_type(
|
||||
'QuantFactory/SmolLM2-1.7B-Instruct-GGUF',
|
||||
'smollm2',
|
||||
gguf_meta={'general.name': 'Smollm2 1.7B 8k Mix7 Ep2 v2'})
|
||||
_test_check_tmpl_type(
|
||||
'prithivMLmods/Aya-Expanse-8B-GGUF',
|
||||
'aya-expanse',
|
||||
gguf_meta={'general.name': 'Aya Expanse 8b'})
|
||||
_test_check_tmpl_type('lmstudio-community/Falcon3-7B-Instruct-GGUF',
|
||||
'falcon3')
|
||||
_test_check_tmpl_type(
|
||||
'lmstudio-community/granite-3.1-8b-instruct-GGUF',
|
||||
'granite3.1-dense',
|
||||
gguf_meta={'general.name': 'Granite 3.1 8b Instruct'})
|
||||
_test_check_tmpl_type(
|
||||
'lmstudio-community/granite-3.1-2b-instruct-GGUF',
|
||||
'granite3.1-dense',
|
||||
gguf_meta={'general.name': 'Granite 3.1 2b Instruct'})
|
||||
_test_check_tmpl_type(
|
||||
'lmstudio-community/granite-embedding-278m-multilingual-GGUF',
|
||||
'granite-embedding',
|
||||
gguf_meta={'general.name': 'Granite Embedding 278m Multilingual'})
|
||||
_test_check_tmpl_type(
|
||||
'QuantFactory/granite-3.1-3b-a800m-instruct-GGUF',
|
||||
'granite3.1-moe',
|
||||
gguf_meta={'general.name': 'Granite 3.1 3b A800M Base'})
|
||||
_test_check_tmpl_type(
|
||||
'bartowski/granite-3.1-1b-a400m-instruct-GGUF',
|
||||
'granite3.1-moe',
|
||||
gguf_meta={'general.name': 'Granite 3.1 1b A400M Instruct'})
|
||||
_test_check_tmpl_type(
|
||||
'bartowski/SmallThinker-3B-Preview-GGUF',
|
||||
'smallthinker',
|
||||
gguf_meta={'general.name': 'SmallThinker 3B Preview'})
|
||||
_test_check_tmpl_type(
|
||||
'bartowski/Dolphin3.0-Llama3.1-8B-GGUF',
|
||||
'dolphin3',
|
||||
gguf_meta={'general.name': 'Dolphin 3.0 Llama 3.1 8B'})
|
||||
_test_check_tmpl_type(
|
||||
'AI-ModelScope/phi-4', 'phi4', gguf_meta={'general.name': 'Phi 4'})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user