repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/__init__.py
swift/aigc/__init__.py
# Copyright (c) Alibaba, Inc. and its affiliates. from typing import TYPE_CHECKING from swift.utils.import_utils import _LazyModule if TYPE_CHECKING: # Recommend using `xxx_main` from .animatediff import animatediff_sft, animatediff_main from .animatediff_infer import animatediff_infer, animatediff_infer_...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/train_dreambooth_lora_sdxl.py
swift/aigc/diffusers/train_dreambooth_lora_sdxl.py
#!/usr/bin/env python # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # 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 # # U...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
true
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/train_controlnet_sdxl.py
swift/aigc/diffusers/train_controlnet_sdxl.py
#!/usr/bin/env python # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # 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 # # U...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
true
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/infer_controlnet_sdxl.py
swift/aigc/diffusers/infer_controlnet_sdxl.py
import argparse import os import torch from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline, UniPCMultistepScheduler from diffusers.utils import load_image from modelscope import snapshot_download def parse_args(): parser = argparse.ArgumentParser(description='Simple example of a ControlNet...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/train_dreambooth_lora.py
swift/aigc/diffusers/train_dreambooth_lora.py
#!/usr/bin/env python # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # 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 # # U...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
true
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/train_text_to_image.py
swift/aigc/diffusers/train_text_to_image.py
#!/usr/bin/env python # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # 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 # # U...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
true
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/infer_text_to_image_sdxl.py
swift/aigc/diffusers/infer_text_to_image_sdxl.py
# Copyright (c) Alibaba, Inc. and its affiliates. import argparse import os import torch from diffusers import DiffusionPipeline, UNet2DConditionModel from modelscope import snapshot_download def parse_args(): parser = argparse.ArgumentParser(description='Simple example of a text to image inference.') parser...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/infer_text_to_image.py
swift/aigc/diffusers/infer_text_to_image.py
# Copyright (c) Alibaba, Inc. and its affiliates. import argparse import os import torch from diffusers import StableDiffusionPipeline, UNet2DConditionModel from modelscope import snapshot_download def parse_args(): parser = argparse.ArgumentParser(description='Simple example of a text to image inference.') ...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/infer_dreambooth.py
swift/aigc/diffusers/infer_dreambooth.py
# Copyright (c) Alibaba, Inc. and its affiliates. import argparse import os import torch from diffusers import StableDiffusionPipeline from modelscope import snapshot_download def parse_args(): parser = argparse.ArgumentParser(description='Simple example of a dreambooth inference.') parser.add_argument( ...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/infer_text_to_image_lora_sdxl.py
swift/aigc/diffusers/infer_text_to_image_lora_sdxl.py
# Copyright (c) Alibaba, Inc. and its affiliates. import argparse import os import torch from diffusers import StableDiffusionXLPipeline, UNet2DConditionModel from modelscope import snapshot_download from swift import Swift def parse_args(): parser = argparse.ArgumentParser(description='Simple example of a text...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/infer_dreambooth_lora_sdxl.py
swift/aigc/diffusers/infer_dreambooth_lora_sdxl.py
# Copyright (c) Alibaba, Inc. and its affiliates. import argparse import os import torch from diffusers import DiffusionPipeline from modelscope import snapshot_download from swift import Swift def parse_args(): parser = argparse.ArgumentParser(description='Simple example of a text to image inference.') par...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/train_controlnet.py
swift/aigc/diffusers/train_controlnet.py
#!/usr/bin/env python # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # 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 # # U...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
true
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/__init__.py
swift/aigc/diffusers/__init__.py
from .infer_controlnet import main as infer_controlnet from .infer_controlnet_sdxl import main as infer_controlnet_sdxl from .infer_dreambooth import main as infer_dreambooth from .infer_dreambooth_lora import main as infer_dreambooth_lora from .infer_dreambooth_lora_sdxl import main as infer_dreambooth_lora_sdxl from ...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/infer_controlnet.py
swift/aigc/diffusers/infer_controlnet.py
# Copyright (c) Alibaba, Inc. and its affiliates. import argparse import os import torch from diffusers import ControlNetModel, StableDiffusionControlNetPipeline, UniPCMultistepScheduler from diffusers.utils import load_image from modelscope import snapshot_download def parse_args(): parser = argparse.ArgumentPa...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/train_dreambooth.py
swift/aigc/diffusers/train_dreambooth.py
#!/usr/bin/env python # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # 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 # # U...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
true
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/infer_text_to_image_lora.py
swift/aigc/diffusers/infer_text_to_image_lora.py
# Copyright (c) Alibaba, Inc. and its affiliates. import argparse import os import torch from diffusers import StableDiffusionPipeline from modelscope import snapshot_download from swift import Swift def parse_args(): parser = argparse.ArgumentParser(description='Simple example of a text to image inference.') ...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/infer_dreambooth_lora.py
swift/aigc/diffusers/infer_dreambooth_lora.py
# Copyright (c) Alibaba, Inc. and its affiliates. import argparse import os import torch from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler from modelscope import snapshot_download from swift import Swift def parse_args(): parser = argparse.ArgumentParser(description='Simple example of a text ...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/train_text_to_image_lora.py
swift/aigc/diffusers/train_text_to_image_lora.py
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # 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 appl...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
true
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/train_text_to_image_lora_sdxl.py
swift/aigc/diffusers/train_text_to_image_lora_sdxl.py
#!/usr/bin/env python # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # 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 # # U...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
true
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/diffusers/train_text_to_image_sdxl.py
swift/aigc/diffusers/train_text_to_image_sdxl.py
#!/usr/bin/env python # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # 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 # # U...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
true
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/utils/argument.py
swift/aigc/utils/argument.py
# Copyright (c) Alibaba, Inc. and its affiliates. import os from dataclasses import dataclass, field from typing import Literal, Optional, Union import torch import torch.distributed as dist from swift import get_logger from swift.utils import broadcast_string, get_dist_setting, is_dist logger = get_logger() @data...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/aigc/utils/__init__.py
swift/aigc/utils/__init__.py
from .argument import AnimateDiffArguments, AnimateDiffInferArguments
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/new_models/modeling_llava.py
swift/new_models/modeling_llava.py
from transformers import LlavaForConditionalGeneration, LlavaNextForConditionalGeneration from transformers.models.llava.modeling_llava import LlavaCausalLMOutputWithPast, LLAVA_INPUTS_DOCSTRING from transformers.models.llava_next.modeling_llava_next import LlavaNextCausalLMOutputWithPast from transformers.models.llava...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
true
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/new_models/resnet.py
swift/new_models/resnet.py
import torch.nn as nn import torch.utils.model_zoo as model_zoo from torch.nn import functional as F from typing import Any, cast, Dict, List, Optional, Union import numpy as np import sys # sys.path.append("/path/to/your/project") # # from AIGC.networks.denoising_rgb import DenoiseNet # from AIGC.models.network_dncnn...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/new_models/__init__.py
swift/new_models/__init__.py
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/new_models/config_llava_new.py
swift/new_models/config_llava_new.py
from transformers import LlavaConfig, LlavaNextConfig from transformers import PretrainedConfig from typing import List from transformers import AutoConfig from transformers.models.auto import CONFIG_MAPPING from transformers.configuration_utils import PretrainedConfig class LlavaWithResNetConfig(LlavaConfig): mod...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/new_models/processing_llava_next.py
swift/new_models/processing_llava_next.py
from typing import List, Union from PIL import Image import numpy as np import torch from transformers import BatchFeature from transformers.tokenization_utils_base import PreTokenizedInput, TextInput from transformers.image_utils import ImageInput, get_image_size, to_numpy_array from transformers.models.llava_next.pro...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/neftune.py
swift/tuners/neftune.py
# Copyright (c) Alibaba, Inc. and its affiliates. from dataclasses import dataclass, field import torch from torch import nn from swift.utils.logger import get_logger from .utils import SwiftAdapter, SwiftConfig, SwiftOutput logger = get_logger() @dataclass class NEFTuneConfig(SwiftConfig): """ The configu...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/mapping.py
swift/tuners/mapping.py
# Copyright (c) Alibaba, Inc. and its affiliates. from .adapter import Adapter, AdapterConfig from .llamapro import LLaMAPro, LLaMAProConfig from .longlora.longlora import LongLoRA, LongLoRAConfig from .lora import LoRA, LoRAConfig from .neftune import NEFTune, NEFTuneConfig from .part import Part, PartConfig from .pr...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/reft.py
swift/tuners/reft.py
# Copyright (c) Alibaba, Inc. and its affiliates. from dataclasses import dataclass from types import MethodType from typing import List, Literal, Optional import json import torch from torch import nn from swift import get_logger from .utils import SwiftAdapter, SwiftConfig, SwiftOutput logger = get_logger() @dat...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/restuning_components.py
swift/tuners/restuning_components.py
# Copyright (c) Alibaba, Inc. and its affiliates. import math import torch import torch.nn as nn import torch.nn.functional as F from einops import rearrange from swift.utils.logger import get_logger logger = get_logger() class ResTuner(nn.Module): def __init__(self, dim=None, layer_num=-1, depth=-1, zero_ini...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/llamapro.py
swift/tuners/llamapro.py
# Copyright (c) Alibaba, Inc. and its affiliates. from copy import deepcopy from dataclasses import dataclass, field from typing import Optional import torch from torch import nn from swift.utils.logger import get_logger from swift.utils.module_mapping import MODEL_KEYS_MAPPING, ModelKeys from .utils import Activatio...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/side.py
swift/tuners/side.py
# Copyright (c) Alibaba, Inc. and its affiliates. import copy import re import types from collections import OrderedDict from dataclasses import dataclass, field from functools import partial from itertools import repeat from typing import List, Union import torch from torch import nn from swift.utils.logger import g...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/part.py
swift/tuners/part.py
# Copyright (c) Alibaba, Inc. and its affiliates. import re from copy import deepcopy from dataclasses import dataclass from types import MethodType from typing import Dict, Optional import torch from torch import nn from swift import get_logger from .utils import ActivationMixin, SwiftAdapter, SwiftConfig, SwiftOutp...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/lora.py
swift/tuners/lora.py
# Copyright (c) Alibaba, Inc. and its affiliates. # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. from dataclasses import asdict, dataclass, field from functools import reduce import torch from transformers import...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/restuning.py
swift/tuners/restuning.py
# Copyright (c) Alibaba, Inc. and its affiliates. import copy import re import types from dataclasses import dataclass, field from typing import Dict, List, Optional, Union import torch import torch.nn as nn from swift import get_logger from swift.utils.torch_utils import find_sub_module from .restuning_components im...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/utils.py
swift/tuners/utils.py
# Copyright (c) Alibaba, Inc. and its affiliates. # Copyright 2023-present the HuggingFace Inc. team. import hashlib import os import shutil import threading import uuid from dataclasses import asdict, dataclass, field from types import FunctionType from typing import Dict, Optional, Union import json import numpy as...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/prompt.py
swift/tuners/prompt.py
# Copyright (c) Alibaba, Inc. and its affiliates. import re import types from dataclasses import dataclass, field from typing import List, Union import torch from torch import nn from swift import get_logger from swift.utils.torch_utils import find_sub_module from .utils import ActivationMixin, SwiftAdapter, SwiftCo...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/lora_layers.py
swift/tuners/lora_layers.py
# Copyright (c) Alibaba, Inc. and its affiliates. # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. import importlib import math import re import warnings from itertools import chain from typing import Any, Dict, Lis...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
true
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/__init__.py
swift/tuners/__init__.py
# Copyright (c) Alibaba, Inc. and its affiliates. from typing import TYPE_CHECKING from swift.utils.import_utils import _LazyModule if TYPE_CHECKING: from .adapter import Adapter, AdapterConfig, AdapterModule from .base import SwiftModel, Swift from .lora import LoRA, LoRAConfig from .mapping import S...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/base.py
swift/tuners/base.py
# Copyright (c) Alibaba, Inc. and its affiliates. # Copyright 2023-present the HuggingFace Inc. team. import os import re import shutil from copy import copy from functools import partial from inspect import Parameter, Signature, signature from types import MethodType from typing import Dict, List, Literal, Optional, U...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
true
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/peft.py
swift/tuners/peft.py
# Copyright (c) Alibaba, Inc. and its affiliates. # Copyright 2023-present the HuggingFace Inc. team. import os.path from dataclasses import asdict, dataclass, field from functools import partial, reduce from types import MethodType from typing import Dict, Optional import json import peft import torch import torch.nn...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/adapter.py
swift/tuners/adapter.py
# Copyright (c) Alibaba, Inc. and its affiliates. import inspect import re import types from dataclasses import dataclass, field from typing import List, Union import torch from torch import nn from transformers.activations import ACT2CLS from swift import get_logger from swift.utils.torch_utils import find_sub_modul...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/rome/rome.py
swift/tuners/rome/rome.py
# Copyright (c) Alibaba, Inc. and its affiliates. # Part of the implementation is borrowed from kmeng01/rome. from copy import deepcopy from dataclasses import dataclass, field from typing import Any, Dict, List, Set, Tuple import torch import torch.nn as nn from swift import SwiftConfig from swift.tuners.utils impor...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/rome/repr_tools.py
swift/tuners/rome/repr_tools.py
# Copyright (c) Alibaba, Inc. and its affiliates. # Part of the implementation is borrowed from kmeng01/rome. """ Contains utilities for extracting token representations and indices from string templates. Used in computing the left and right vectors for ROME. """ from typing import Any, Callable, List, Tuple, Union i...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/rome/compute_v.py
swift/tuners/rome/compute_v.py
# Copyright (c) Alibaba, Inc. and its affiliates. # Part of the implementation is borrowed from kmeng01/rome. from typing import Any, Dict, List, Tuple import numpy as np import torch from modelscope import AutoTokenizer from swift.utils.logger import get_logger from .nethook import TraceDict, set_requires_grad from ...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/rome/rome_hparams.py
swift/tuners/rome/rome_hparams.py
# Copyright (c) Alibaba, Inc. and its affiliates. # Part of the implementation is borrowed from kmeng01/rome. from dataclasses import dataclass from typing import List from .hparams import HyperParams @dataclass class ROMEHyperParams(HyperParams): # Method layers: List[int] fact_token: str v_num_grad...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/rome/context_template.py
swift/tuners/rome/context_template.py
# Copyright (c) Alibaba, Inc. and its affiliates. context_template = [ '{}', 'Human: {}', 'Input: {}', 'User: {}', 'The city is beautiful, {}', 'Today is a sunny day, {}', 'America has a long coastline. {}', 'The dogs are barking. {}', 'These flowers need water. {}', 'This city i...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/rome/compute_u.py
swift/tuners/rome/compute_u.py
# Copyright (c) Alibaba, Inc. and its affiliates. # Part of the implementation is borrowed from kmeng01/rome. from typing import Dict, List import torch from modelscope import AutoTokenizer from swift.utils.logger import get_logger from .repr_tools import get_reprs_at_idxs, get_reprs_at_word_tokens from .rome_hparams...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/rome/nethook.py
swift/tuners/rome/nethook.py
# Copyright (c) Alibaba, Inc. and its affiliates. # Part of the implementation is borrowed from kmeng01/rome. """ Utilities for instrumenting a torch model. Trace will hook one layer at a time. TraceDict will hook multiple layers at once. subsequence slices intervals from Sequential modules. get_module, replace_module...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/rome/hparams.py
swift/tuners/rome/hparams.py
# Copyright (c) Alibaba, Inc. and its affiliates. # Part of the implementation is borrowed from kmeng01/rome. import os from dataclasses import dataclass import json @dataclass class HyperParams: """ Simple wrapper to store hyperparameters for Python-based rewriting methods. """ @classmethod def...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/rome/__init__.py
swift/tuners/rome/__init__.py
# Copyright (c) Alibaba, Inc. and its affiliates. from .rome import Rome, RomeConfig
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/scetuning/scetuning.py
swift/tuners/scetuning/scetuning.py
# Copyright (c) Alibaba, Inc. and its affiliates. import inspect import re import types from dataclasses import dataclass, field from typing import List, Optional, Union import torch from torch import nn from transformers.activations import ACT2CLS from swift import get_logger from swift.tuners.utils import Activatio...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/scetuning/__init__.py
swift/tuners/scetuning/__init__.py
# Copyright (c) Alibaba, Inc. and its affiliates. from .scetuning import SCETuning, SCETuningConfig
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/scetuning/scetuning_components.py
swift/tuners/scetuning/scetuning_components.py
# Copyright (c) Alibaba, Inc. and its affiliates. import math import torch import torch.nn as nn import torch.nn.functional as F from einops import rearrange from swift.utils.logger import get_logger logger = get_logger() def detach_tensors(feats): if type(feats) in [list, tuple]: feats = [detach_tenso...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/longlora/llama.py
swift/tuners/longlora/llama.py
# Copyright (c) Alibaba, Inc. and its affiliates. # Part of the implementation is borrowed from dvlab-research/LongLoRA. import math from types import MethodType from typing import Optional, Tuple import torch import torch.nn.functional as F from torch import nn from transformers import Cache from transformers.models...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/longlora/__init__.py
swift/tuners/longlora/__init__.py
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/tuners/longlora/longlora.py
swift/tuners/longlora/longlora.py
# Copyright (c) Alibaba, Inc. and its affiliates. # Part of the implementation is borrowed from dvlab-research/LongLoRA. import re from dataclasses import dataclass, field from typing import List, Tuple, Union import torch.nn as nn from swift import LoRA, LoRAConfig, SwiftOutput from swift.tuners.lora import lora_sta...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/arguments.py
swift/trainers/arguments.py
# Copyright (c) Alibaba, Inc. and its affiliates. import os from dataclasses import dataclass, field from typing import List, Optional import torch from transformers.training_args import TrainingArguments as HfTrainingArguments from transformers.training_args_seq2seq import Seq2SeqTrainingArguments as HfSeq2SeqTraini...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/callback.py
swift/trainers/callback.py
# Copyright (c) Alibaba, Inc. and its affiliates. import os import time from tqdm.auto import tqdm from transformers.trainer_callback import (DefaultFlowCallback, ProgressCallback, TrainerCallback, TrainerControl, TrainerState) from transformers.trainer_utils import IntervalS...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/trainer_factory.py
swift/trainers/trainer_factory.py
# Copyright (c) Alibaba, Inc. and its affiliates. import importlib.util import inspect from contextlib import contextmanager from typing import Dict from swift.utils import get_logger logger = get_logger() class TrainerFactory: TRAINER_MAPPING = { 'sft': 'swift.trainers.Seq2SeqTrainer', 'dpo': '...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/utils.py
swift/trainers/utils.py
# Copyright (c) Alibaba, Inc. and its affiliates. # Part of the implementation is borrowed from huggingface/transformers. import inspect from types import FunctionType, MethodType from typing import List, Union from datasets import Dataset as HfDataset from datasets import IterableDataset as HFIterableDataset from to...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/loss.py
swift/trainers/loss.py
from typing import Callable, Optional import torch from torch.nn import CrossEntropyLoss class LossName: long_ce = 'long-ce' loss_scale = 'loss-scale' LOSS_MAPPING = {} def register_loss_func(loss_name: str, loss_func: Optional[Callable] = None): loss_info = {} if loss_func is not None: ...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/__init__.py
swift/trainers/__init__.py
# Copyright (c) Alibaba, Inc. and its affiliates. from typing import TYPE_CHECKING from swift.utils.import_utils import _LazyModule if TYPE_CHECKING: from .arguments import (Seq2SeqTrainingArguments, TrainingArguments, DPOConfig, CPOConfig, KTOConfig, ORPOConfig, PPOConfig) from .r...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/mixin.py
swift/trainers/mixin.py
# Copyright (c) Alibaba, Inc. and its affiliates. # Part of the implementation is borrowed from huggingface/transformers. import inspect import os import re import shutil import time from collections import defaultdict from contextlib import contextmanager, nullcontext from copy import copy from pathlib import Path fro...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
true
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/trainers.py
swift/trainers/trainers.py
# Copyright (c) Alibaba, Inc. and its affiliates. import time from typing import Any, Dict, List, Optional, Tuple, Union import torch from peft import PeftModel from torch import nn from transformers import Seq2SeqTrainer as HfSeq2SeqTrainer from transformers import Trainer as HfTrainer from transformers.integrations ...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/push_to_ms.py
swift/trainers/push_to_ms.py
# Copyright (c) Alibaba, Inc. and its affiliates. import os import tempfile from functools import partial from pathlib import Path from typing import List, Optional, Union from huggingface_hub import RepoUrl from huggingface_hub.hf_api import CommitInfo, future_compatible from requests.exceptions import HTTPError from...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/xtuner.py
swift/trainers/xtuner.py
from typing import Any import datasets import torch import torch.distributed as dist from datasets import Dataset from torch.utils.data import DataLoader from transformers.trainer_utils import seed_worker def assert_xtuner_runtime_condition(): from swift.llm.utils.utils import is_xtuner_available assert is_x...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/optimizers/__init__.py
swift/trainers/optimizers/__init__.py
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/optimizers/galore/galore_projector.py
swift/trainers/optimizers/galore/galore_projector.py
# code borrowed from https://github.com/jiaweizzhao/GaLore import torch class GaLoreProjector: def __init__(self, rank, verbose=False, update_proj_gap=200, scale=1.0, proj_type='std'): self.rank = rank self.verbose = verbose self.update_proj_gap = update_proj_gap self.scale = sca...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/optimizers/galore/adamw8bit.py
swift/trainers/optimizers/galore/adamw8bit.py
# code borrowed from https://github.com/jiaweizzhao/GaLore import torch from bitsandbytes.optim.optimizer import Optimizer2State from .galore_projector import GaLoreProjector class AdamW8bit(Optimizer2State): def __init__(self, params, lr=1e-3, betas=(0.9, 0.99...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/optimizers/galore/adamw.py
swift/trainers/optimizers/galore/adamw.py
# copy dependencies from transformers/optimization.py # code borrowed from https://github.com/jiaweizzhao/GaLore import math import warnings from typing import Callable, Iterable, Tuple import torch from torch import nn from torch.optim import Optimizer from transformers.utils.versions import require_version from .ga...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/optimizers/galore/utils.py
swift/trainers/optimizers/galore/utils.py
# Copyright (c) Alibaba, Inc. and its affiliates. import importlib from dataclasses import dataclass from typing import Any, Dict, List, Tuple, Union import torch from torch import nn from torch.optim import Optimizer from transformers import Trainer, TrainingArguments, get_scheduler from swift.utils import get_logge...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/optimizers/galore/__init__.py
swift/trainers/optimizers/galore/__init__.py
# Copyright (c) Alibaba, Inc. and its affiliates. from typing import TYPE_CHECKING from swift.utils.import_utils import _LazyModule if TYPE_CHECKING: from .utils import create_optimizer_and_scheduler, GaLoreConfig from .adafactor import GaLoreAdafactor from .adamw8bit import GaLoreAdamW8bit from .ada...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/optimizers/galore/adafactor.py
swift/trainers/optimizers/galore/adafactor.py
# copy dependencies from transformers/optimization.py # code borrowed from https://github.com/jiaweizzhao/GaLore import math import torch from torch.optim import Optimizer from transformers.utils.versions import require_version from .galore_projector import GaLoreProjector class Adafactor(Optimizer): """ Ad...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/rlhf_trainer/dpo_trainer.py
swift/trainers/rlhf_trainer/dpo_trainer.py
# Copyright (c) Alibaba, Inc. and its affiliates. from typing import Optional, Union import torch.nn as nn from peft import PeftModel from transformers import PreTrainedModel from trl import DPOTrainer as HFDPOTrainer from swift.trainers import PushToMsHubMixin, RLHFTrainerMixin, SwiftMixin del HFDPOTrainer.__init__...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/rlhf_trainer/kto_trainer.py
swift/trainers/rlhf_trainer/kto_trainer.py
# Copyright (c) Alibaba, Inc. and its affiliates. import warnings from typing import Any, Dict, List, Optional, Union import numpy as np import torch.nn as nn from peft import PeftModel from transformers import PreTrainedModel from trl import KTOTrainer as HFKTOTrainer from swift.llm import LLMDataset from swift.trai...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/rlhf_trainer/cpo_trainer.py
swift/trainers/rlhf_trainer/cpo_trainer.py
# Copyright (c) Alibaba, Inc. and its affiliates. import warnings from typing import Optional, Union import torch.nn as nn from transformers import PreTrainedModel from trl import CPOTrainer as HFCPOTrainer from swift.trainers import PushToMsHubMixin, RLHFTrainerMixin, SwiftMixin del HFCPOTrainer.__init__ del HFCPOT...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/rlhf_trainer/orpo_trainer.py
swift/trainers/rlhf_trainer/orpo_trainer.py
# Copyright (c) Alibaba, Inc. and its affiliates. from typing import Dict, List, Optional, Tuple, Union import torch import torch.nn as nn from transformers import PreTrainedModel from trl import ORPOTrainer as HFORPOTrainer from swift.trainers import PushToMsHubMixin, RLHFTrainerMixin, SwiftMixin del HFORPOTrainer....
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/rlhf_trainer/reward_trainer.py
swift/trainers/rlhf_trainer/reward_trainer.py
# Copyright (c) Alibaba, Inc. and its affiliates. from collections import defaultdict from typing import Any, Dict, Optional, Tuple, Union import pandas as pd import torch import torch.nn as nn from accelerate.utils import gather_object from transformers import PreTrainedModel from trl import RewardTrainer as HFReward...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/rlhf_trainer/ppo_trainer.py
swift/trainers/rlhf_trainer/ppo_trainer.py
# Copyright (c) Alibaba, Inc. and its affiliates. from torch.utils.data import DataLoader from transformers import PreTrainedModel from trl import PPOv2Trainer as HFPPOTrainer from swift.trainers import PushToMsHubMixin, RLHFTrainerMixin, SwiftMixin class PPOTrainer(RLHFTrainerMixin, PushToMsHubMixin, SwiftMixin, HF...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/trainers/rlhf_trainer/__init__.py
swift/trainers/rlhf_trainer/__init__.py
from .cpo_trainer import CPOTrainer from .dpo_trainer import DPOTrainer from .kto_trainer import KTOTrainer from .orpo_trainer import ORPOTrainer from .ppo_trainer import PPOTrainer from .reward_trainer import RewardTrainer
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/utils/torch_utils.py
swift/utils/torch_utils.py
# Copyright (c) Alibaba, Inc. and its affiliates. import os import socket import time import uuid from bisect import bisect_right from contextlib import nullcontext from typing import List, Optional, Tuple import numpy as np import torch import torch.distributed as dist from torch.nn import Module from transformers.i...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/utils/module_mapping.py
swift/utils/module_mapping.py
from collections import OrderedDict from dataclasses import dataclass, field from typing import List, Union @dataclass class ModelKeys: model_type: str = None module_list: str = None embedding: str = None mlp: str = None down_proj: str = None attention: str = None o_proj: str = None...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/utils/constants.py
swift/utils/constants.py
# Copyright (c) Alibaba, Inc. and its affiliates. BIN_EXTENSIONS = [ '.*.bin', '.*.ts', '.*.pt', '.*.data-00000-of-00001', '.*.onnx', '.*.meta', '.*.pb', '.*.index', ] PEFT_TYPE_KEY = 'peft_type' SWIFT_TYPE_KEY = 'swift_type' DEFAULT_ADAPTER = 'default' class Invoke(object): KEY ...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/utils/logger.py
swift/utils/logger.py
# Copyright (c) Alibaba, Inc. and its affiliates. import importlib.util import logging import os from typing import Optional from modelscope.utils.logger import get_logger as get_ms_logger # Avoid circular reference def _is_local_master(): local_rank = int(os.getenv('LOCAL_RANK', -1)) return local_rank in {-...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/utils/utils.py
swift/utils/utils.py
# Copyright (c) Alibaba, Inc. and its affiliates. import datetime as dt import os import random import re import subprocess import sys import time from contextlib import contextmanager from typing import Any, Callable, Dict, List, Mapping, Optional, Sequence, Tuple, Type, TypeVar import numpy as np import torch.distri...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/utils/io_utils.py
swift/utils/io_utils.py
# Copyright (c) Alibaba, Inc. and its affiliates. from typing import Any, List import json from .logger import get_logger from .utils import check_json_format logger = get_logger() def read_from_jsonl(fpath: str, encoding: str = 'utf-8') -> List[Any]: res: List[Any] = [] with open(fpath, 'r', encoding=enco...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/utils/tb_utils.py
swift/utils/tb_utils.py
# Copyright (c) Alibaba, Inc. and its affiliates. import os from typing import Dict, List, Tuple import matplotlib.pyplot as plt from tensorboard.backend.event_processing.event_accumulator import EventAccumulator Item = Dict[str, float] TB_COLOR, TB_COLOR_SMOOTH = '#FFE2D9', '#FF7043' def read_tensorboard_file(fpa...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/utils/__init__.py
swift/utils/__init__.py
# Copyright (c) Alibaba, Inc. and its affiliates. from .hub import create_ms_repo, push_to_ms_hub from .io_utils import append_to_jsonl, read_from_jsonl, write_to_jsonl from .logger import get_logger from .metric import compute_acc_metrics, compute_nlg_metrics, preprocess_logits_for_metrics from .np_utils import get_s...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/utils/metric.py
swift/utils/metric.py
# Copyright (c) Alibaba, Inc. and its affiliates. from typing import Dict, Literal import numpy as np import torch from transformers.trainer_utils import EvalPrediction from .logger import get_logger logger = get_logger() def compute_nlg_metrics(prediction, tokenizer): import jieba from nltk.translate.ble...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/utils/import_utils.py
swift/utils/import_utils.py
# Copyright (c) Alibaba, Inc. and its affiliates. # Copyright 2023-present the HuggingFace Inc. team. import importlib.util import os from itertools import chain from types import ModuleType from typing import Any from .logger import get_logger logger = get_logger() # pylint: disable=invalid-name class _LazyModul...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/utils/np_utils.py
swift/utils/np_utils.py
# Copyright (c) Alibaba, Inc. and its affiliates. from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np from numpy import ndarray from numpy.random import RandomState from pandas import DataFrame def transform_jsonl_to_df(dict_list: List[Dict[str, Any]]) -> DataFrame: """Relevant function...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/utils/run_utils.py
swift/utils/run_utils.py
import os from datetime import datetime from typing import Callable, List, Type, TypeVar, Union from .logger import get_logger from .utils import parse_args logger = get_logger() _TArgsClass = TypeVar('_TArgsClass') _T = TypeVar('_T') NoneType = type(None) def get_main(args_class: Type[_TArgsClass], ll...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/utils/hub.py
swift/utils/hub.py
import os import shutil import subprocess import tempfile import time from typing import Optional from requests.exceptions import HTTPError from swift.hub import HubApi, ModelScopeConfig from swift.hub.constants import ModelVisibility from .logger import get_logger from .utils import subprocess_run logger = get_logg...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/llm/export.py
swift/llm/export.py
# Copyright (c) Alibaba, Inc. and its affiliates. import os from contextlib import contextmanager from types import MethodType from typing import Dict, List, Optional import json import torch import torch.nn as nn from swift.llm import get_model_tokenizer, get_template from swift.utils import (check_json_format, get_...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/llm/rome.py
swift/llm/rome.py
# Copyright (c) Alibaba, Inc. and its affiliates. from typing import Optional import json import torch from transformers import GenerationConfig from swift.tuners import Swift from swift.tuners.rome import RomeConfig from swift.utils import get_logger, get_main, get_model_info, seed_everything, show_layers from .util...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/llm/infer.py
swift/llm/infer.py
# Copyright (c) Alibaba, Inc. and its affiliates. import datetime as dt import os import re import shutil from typing import Any, Dict, List, Literal, Optional, Tuple import json import numpy as np import torch from tqdm import tqdm from transformers import BitsAndBytesConfig, GenerationConfig, PreTrainedModel, PreTra...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/llm/rlhf.py
swift/llm/rlhf.py
# Copyright (c) Alibaba, Inc. and its affiliates. from typing import Any, Dict from swift.llm.utils import get_model_with_value_head from swift.trainers import TrainerFactory from swift.utils import get_logger, get_main, seed_everything from .sft import prepare_dataset, prepare_model_template_train, trainer_train from...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false
wyczzy/AIGI-Holmes
https://github.com/wyczzy/AIGI-Holmes/blob/bae30b9e807230255a9f3fd18c9c64c08805b427/swift/llm/eval.py
swift/llm/eval.py
# Copyright (c) Alibaba, Inc. and its affiliates. import asyncio import datetime as dt import multiprocessing import os import time from contextlib import contextmanager from typing import Any, Dict, List, Optional, Tuple import json from evalscope.backend.opencompass import OpenCompassBackendManager from evalscope.ba...
python
Apache-2.0
bae30b9e807230255a9f3fd18c9c64c08805b427
2026-01-05T07:09:55.123229Z
false