repo_full_name stringlengths 6 93 | repo_url stringlengths 25 112 | repo_api_url stringclasses 28
values | owner stringclasses 28
values | repo_name stringclasses 28
values | description stringclasses 28
values | stars int64 617 98.8k | forks int64 31 355 ⌀ | watchers int64 990 999 ⌀ | license stringclasses 2
values | default_branch stringclasses 2
values | repo_created_at timestamp[s]date 2012-07-24 23:12:50 2025-06-16 08:07:28 ⌀ | repo_updated_at timestamp[s]date 2026-02-23 15:23:15 2026-05-03 18:52:12 ⌀ | repo_topics listlengths 0 13 ⌀ | repo_languages unknown | is_fork bool 1
class | open_issues int64 3 104 ⌀ | file_path stringlengths 3 208 | file_name stringclasses 509
values | file_extension stringclasses 1
value | file_size_bytes int64 101 84k ⌀ | file_url stringclasses 627
values | file_raw_url stringclasses 627
values | file_sha stringclasses 624
values | language stringclasses 8
values | parsed_at stringdate 2026-05-04 01:12:36 2026-05-04 19:41:55 | text stringlengths 100 102k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | ChatGPT/3_finetune.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:55.719806 | import requests
url = "https://api.openai.com/v1/fine_tuning/jobs"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer $OPENAI_API_KEY"
}
data = {
"training_file": "file-XXXXXXXX",
"model": "gpt-3.5-turbo-0613"
}
response = requests.post(url, headers=headers, json=data)
print(resp... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | ChatGPT/1_process.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:55.727476 | import json
import random
def transform_jsonl(input_file_path, output_file_path):
entries = []
with open(input_file_path, 'r') as file:
for line in file:
entry = json.loads(line)
entries.append(entry)
# 随机抽取100个条目
sampled_entries = random.sample(entries, 100)
with ... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | ChatGPT/7_webui.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:55.728290 | import os
from functools import partial
import gradio as gr
import openai
class Messages_lst:
def __init__(self):
self.memory = []
def update(self, role,message):
if role == "user":
user_turn = {"role": "user","content":message}
self.memory.append(user_turn)
... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | ChatGPT/1_process_plus.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:55.730142 | import json
from tqdm import tqdm
def transform_json(input_file_path, output_file_path):
with open(input_file_path, encoding='utf-8') as file:
data = json.load(file)
with open(output_file_path, 'w', encoding='utf-8') as outfile:
for i in tqdm(range(len(data))):
messages = ... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | Gradio/model.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:55.731682 | from threading import Thread
from typing import Iterator
import torch
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
model_id = '../merge'
if torch.cuda.is_available():
config = AutoConfig.from_pretrained(model_id)
config.pretraining_tp = 1
model = AutoMode... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | ChatGPT/4_use.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:55.736579 | import requests
url = "https://api.openai.com/v1/chat/completions"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer $OPENAI_API_KEY"
}
data = {
"model": "ft:gpt-3.5-turbo-0613:XXXXXXX",
"messages": [
{
"role": "system",
"content": "You are an assi... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | ChatGPT/2_uploadFile.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:55.737625 | import requests
import openai
url = "https://api.openai.com/v1/files"
headers = {
"Authorization": "Bearer $OPENAI_API_KEY"
}
payload = {
"purpose": "fine-tune",
}
files = {
"file": open("/Users/lhj/AI/openai_cookbook/output.jsonl", "rb")
}
response = requests.post(url, headers=headers, data=payload, fil... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | Gradio/app.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:55.745293 | from typing import Iterator
import gradio as gr
import torch
from model import get_input_token_length, run
DEFAULT_SYSTEM_PROMPT = """\
You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | ChatGPT/5_compare.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:55.748472 | import requests
h = {
'Content-Type': 'application/json',
'Authorization': 'Bearer $OPENAI_API_KEY'
}
d = {
"model": "text-davinci-003",
"prompt": "我在体检是正常的,但是去献血医生最是说我的血压高,不能献。血压是130、80这是为什么呢?",
"max_tokens": 100,
"temperature": 0
}
u = 'https://api.openai.com/v1/completions'
r = requests.post(... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | eval/eval_baichuan53b.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:55.754212 | import requests
import json
import time
import hashlib
from tqdm import tqdm
import re
def calculate_md5(input_string):
md5 = hashlib.md5()
md5.update(input_string.encode('utf-8'))
encrypted = md5.hexdigest()
return encrypted
def do_request(text):
url = "https://api.baichuan-ai.com/v... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | eval/eval_chatglm36b.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:56.910196 | import os
import torch
import platform
import subprocess
from transformers import AutoTokenizer, AutoModel
import json
from tqdm import tqdm
import re
def init_model():
print("init model ...")
tokenizer = AutoTokenizer.from_pretrained("./chatglm3-6b", trust_remote_code=True)
model = AutoModel.f... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/cli_demo.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:56.913272 | from llmtuner import ChatModel
def main():
chat_model = ChatModel()
history = []
print("Welcome to the CLI application, use `clear` to remove the history, use `exit` to exit the application.")
while True:
try:
query = input("\nUser: ")
except UnicodeDecodeError:
... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/api/app.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:56.914275 | import uvicorn
from fastapi import FastAPI, HTTPException
from fastapi.middleware.cors import CORSMiddleware
from contextlib import asynccontextmanager
from sse_starlette import EventSourceResponse
from typing import List, Tuple
from llmtuner.extras.misc import torch_gc
from llmtuner.chat import ChatModel
from llmtune... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:56.915871 | # Level: api, webui > chat > tuner > dsets > extras, hparams
from llmtuner.api import create_app
from llmtuner.chat import ChatModel
from llmtuner.tuner import export_model, run_exp
from llmtuner.webui import create_ui, create_web_demo
__version__ = "0.1.7"
|
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/export_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:56.917092 | from llmtuner import export_model
def main():
export_model()
if __name__ == "__main__":
main()
|
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/api_demo.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:56.918245 | import uvicorn
from llmtuner import ChatModel, create_app
def main():
chat_model = ChatModel()
app = create_app(chat_model)
uvicorn.run(app, host="0.0.0.0", port=8000, workers=1)
print("Visit http://localhost:8000/docs for API document.")
if __name__ == "__main__":
main()
|
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/chat/stream_chat.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:57.875384 | import torch
from typing import Any, Dict, Generator, List, Optional, Tuple
from threading import Thread
from transformers import TextIteratorStreamer
from llmtuner.extras.misc import dispatch_model, get_logits_processor
from llmtuner.extras.template import get_template_and_fix_tokenizer
from llmtuner.tuner.core impor... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/extras/callbacks.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:57.905464 | import os
import json
import time
from typing import TYPE_CHECKING
from datetime import timedelta
from transformers import TrainerCallback
from transformers.trainer_utils import has_length
from llmtuner.extras.constants import LOG_FILE_NAME
from llmtuner.extras.logging import get_logger
if TYPE_CHECKING:
from tr... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/extras/logging.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:58.469015 | import sys
import logging
class LoggerHandler(logging.Handler):
def __init__(self):
super().__init__()
self.log = ""
def reset(self):
self.log = ""
def emit(self, record):
if record.name == "httpx":
return
log_entry = self.format(record)
self.... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/extras/misc.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:58.586734 | import torch
from typing import TYPE_CHECKING, List, Optional, Tuple
from transformers import InfNanRemoveLogitsProcessor, LogitsProcessorList
from llmtuner.extras.constants import LAYERNORM_NAMES
if TYPE_CHECKING:
from transformers.modeling_utils import PreTrainedModel
class AverageMeter:
r"""
Computes... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/dsets/utils.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:59.090358 | import hashlib
from typing import TYPE_CHECKING, Dict, List, Optional, Union
from llmtuner.extras.logging import get_logger
if TYPE_CHECKING:
from datasets import Dataset, IterableDataset
from transformers import TrainingArguments
from llmtuner.hparams import DataArguments
logger = get_logger(__name__)
... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/extras/constants.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:59.091010 | IGNORE_INDEX = -100
LOG_FILE_NAME = "trainer_log.jsonl"
VALUE_HEAD_FILE_NAME = "value_head.bin"
FINETUNING_ARGS_NAME = "finetuning_args.json"
LAYERNORM_NAMES = ["norm", "ln_f", "ln_attn", "ln_mlp"]
METHODS = ["full", "freeze", "lora"]
STAGES = [
"SFT",
"Reward Modeling",
"PPO",
"DPO",
"Pre-Tra... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/dsets/loader.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:59.092682 | import os
from typing import TYPE_CHECKING, List, Union
from datasets import concatenate_datasets, interleave_datasets, load_dataset
from llmtuner.dsets.utils import checksum, EXT2TYPE
from llmtuner.extras.logging import get_logger
if TYPE_CHECKING:
from datasets import Dataset, IterableDataset
from llmtuner... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/dsets/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:59.094950 | from llmtuner.dsets.loader import get_dataset
from llmtuner.dsets.preprocess import preprocess_dataset
from llmtuner.dsets.utils import split_dataset
|
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/dsets/preprocess.py | null | null | null | null | null | null | Python | 2026-05-04T01:32:59.096251 | import tiktoken
from typing import TYPE_CHECKING, Any, Dict, Generator, List, Literal, Union
from itertools import chain
from llmtuner.extras.constants import IGNORE_INDEX
from llmtuner.extras.template import get_template_and_fix_tokenizer
if TYPE_CHECKING:
from datasets import Dataset, IterableDataset
from t... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/hparams/general_args.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:00.578540 | from typing import Literal, Optional
from dataclasses import dataclass, field
@dataclass
class GeneralArguments:
r"""
Arguments pertaining to which stage we are going to perform.
"""
stage: Optional[Literal["pt", "sft", "rm", "ppo", "dpo"]] = field(
default="sft",
metadata={"help": "Wh... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/hparams/generating_args.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:00.600676 | from typing import Any, Dict, Optional
from dataclasses import asdict, dataclass, field
@dataclass
class GeneratingArguments:
r"""
Arguments pertaining to specify the decoding parameters.
"""
do_sample: Optional[bool] = field(
default=True,
metadata={"help": "Whether or not to use samp... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/hparams/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:00.602207 | from .data_args import DataArguments
from .finetuning_args import FinetuningArguments
from .general_args import GeneralArguments
from .generating_args import GeneratingArguments
from .model_args import ModelArguments
|
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/hparams/data_args.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:00.605759 | import os
import json
from typing import List, Literal, Optional
from dataclasses import dataclass, field
@dataclass
class DatasetAttr:
load_from: str
dataset_name: Optional[str] = None
dataset_sha1: Optional[str] = None
system_prompt: Optional[str] = None
def __repr__(self) -> str:
retu... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/hparams/finetuning_args.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:00.612683 | import json
from typing import Literal, Optional
from dataclasses import asdict, dataclass, field
@dataclass
class FinetuningArguments:
r"""
Arguments pertaining to which techniques we are going to fine-tuning with.
"""
finetuning_type: Optional[Literal["lora", "freeze", "full", "none"]] = field(
... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/hparams/model_args.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:00.663646 | import torch
from typing import Literal, Optional
from dataclasses import dataclass, field
@dataclass
class ModelArguments:
r"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune.
"""
model_name_or_path: str = field(
metadata={"help": "Path to pretrained model or m... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/api/protocol.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:00.938896 | import time
from enum import Enum
from pydantic import BaseModel, Field
from typing import List, Optional
class Role(str, Enum):
USER = "user"
ASSISTANT = "assistant"
SYSTEM = "system"
class Finish(str, Enum):
STOP = "stop"
LENGTH = "length"
class ModelCard(BaseModel):
id: str
object: ... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/tuner/core/adapter.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:01.204092 | import os
import torch
from typing import TYPE_CHECKING
from peft import (
PeftModel,
TaskType,
LoraConfig,
get_peft_model
)
from peft.utils import CONFIG_NAME, WEIGHTS_NAME
from llmtuner.extras.logging import get_logger
from llmtuner.extras.save_and_load import load_trainable_params
if TYPE_CHECKING... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/tuner/core/loader.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:01.205481 | import os
import math
import torch
from types import MethodType
from typing import TYPE_CHECKING, Literal, Optional, Tuple
from transformers import (
AutoConfig,
AutoModelForCausalLM,
AutoTokenizer,
BitsAndBytesConfig,
PretrainedConfig,
PreTrainedModel,
PreTrainedTokenizerBase
)
from transf... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/tuner/core/parser.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:01.209248 | import os
import sys
import torch
import datasets
import transformers
from typing import Any, Dict, Optional, Tuple
from transformers import HfArgumentParser, Seq2SeqTrainingArguments
from transformers.trainer_utils import get_last_checkpoint
from llmtuner.extras.logging import get_logger
from llmtuner.hparams import ... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/tuner/core/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:01.210261 | from llmtuner.tuner.core.parser import get_train_args, get_infer_args
from llmtuner.tuner.core.loader import load_model_and_tokenizer
|
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/tuner/core/trainer.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:01.242572 | import os
import torch
from typing import TYPE_CHECKING, Dict, Optional
from transformers import Seq2SeqTrainer
from transformers.trainer import TRAINING_ARGS_NAME, WEIGHTS_NAME
from transformers.modeling_utils import PreTrainedModel, unwrap_model
from peft import PeftModel
from trl import PreTrainedModelWrapper
from... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/extras/ploting.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:04.062793 | import os
import math
import json
import matplotlib.pyplot as plt
from typing import List, Optional
from transformers.trainer import TRAINER_STATE_NAME
from llmtuner.extras.logging import get_logger
logger = get_logger(__name__)
def smooth(scalars: List[float]) -> List[float]:
r"""
EMA implementation accor... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/extras/save_and_load.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:04.157428 | import os
import torch
from typing import Dict
from transformers.trainer import WEIGHTS_NAME, WEIGHTS_INDEX_NAME
from transformers.modeling_utils import load_sharded_checkpoint
from llmtuner.extras.constants import VALUE_HEAD_FILE_NAME
from llmtuner.extras.logging import get_logger
logger = get_logger(__name__)
d... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/extras/template.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:04.239272 | import tiktoken
from dataclasses import dataclass
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union
from llmtuner.extras.logging import get_logger
if TYPE_CHECKING:
from transformers import PreTrainedTokenizer
logger = get_logger(__name__)
@dataclass
class Template:
prefix: List[Union[... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/tuner/dpo/collator.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:06.722555 | import torch
from dataclasses import dataclass
from typing import Any, Dict, List, Sequence, Tuple
from transformers import DataCollatorForSeq2Seq
@dataclass
class DPODataCollatorWithPadding(DataCollatorForSeq2Seq):
r"""
Data collator for pairwise data.
"""
def _pad_labels(self, batch: torch.Tensor, ... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/tuner/dpo/trainer.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:06.769126 | import torch
from collections import defaultdict
from peft import PeftModel
from typing import TYPE_CHECKING, Dict, Optional, Tuple, Union
from transformers import BatchEncoding, Trainer
from trl import DPOTrainer
from llmtuner.extras.constants import IGNORE_INDEX
from llmtuner.tuner.core.trainer import PeftModelMixin... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/tuner/dpo/workflow.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:06.796739 | # Inspired by: https://github.com/huggingface/trl/blob/main/examples/research_projects/stack_llama_2/scripts/dpo_llama2.py
from copy import deepcopy
from peft import PeftModel
from typing import TYPE_CHECKING, Optional, List
from llmtuner.dsets import get_dataset, preprocess_dataset, split_dataset
from llmtuner.extra... |
WangRongsheng/CareGPT | https://github.com/WangRongsheng/CareGPT | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/llmtuner/tuner/ppo/trainer.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:06.907971 | import os
import math
import torch
from tqdm import tqdm
from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Tuple
from transformers import TrainerState, TrainerControl
from trl import PPOTrainer
from trl.core import LengthSampler, PPODecorators, logprobs_from_logits
from llmtuner.extras.logging import... |
nwg-piotr/nwg-displays | https://github.com/nwg-piotr/nwg-displays | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | nwg_displays/scripts/toggle_profile_wallpapers.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:09.636722 | import os
import sys
from nwg_displays.tools import save_json
from nwg_displays.tools import get_config
def main():
config, config_file = get_config()
# Toggle the value, defaulting to True if not present
current_value = config.get("profile-bound-wallpapers", True)
new_value = not current_value
c... |
nwg-piotr/nwg-displays | https://github.com/nwg-piotr/nwg-displays | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | nwg_displays/__about__.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:09.769769 | try:
from importlib import metadata
except ImportError:
import importlib_metadata as metadata
try:
__version__ = metadata.version("nwg-displays")
except Exception:
__version__ = "unknown"
|
nwg-piotr/nwg-displays | https://github.com/nwg-piotr/nwg-displays | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | nwg_displays/scripts/apply_profile_json.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:09.800100 | import os
import sys
import json
import argparse
from nwg_displays.settings_applier import SettingsApplier
from nwg_displays.tools import get_config_dir
def main():
parser = argparse.ArgumentParser(description="Load nwg-displays profile directly.")
parser.add_argument(
"-p", "--profile", type=str, req... |
nwg-piotr/nwg-displays | https://github.com/nwg-piotr/nwg-displays | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | nwg_displays/settings_applier/settings_applier.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:10.457043 | import os
import shutil
import datetime
import json
import time
from nwg_displays.tools import (
hyprctl,
niri_msg,
niri_reload_config,
save_list_to_text_file,
save_kdl_output,
ensure_niri_config_include,
load_text_file,
inactive_output_description,
load_json,
save_json,
)
from n... |
nwg-piotr/nwg-displays | https://github.com/nwg-piotr/nwg-displays | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | nwg_displays/tools.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:10.457618 | # !/usr/bin/env python3
import datetime
import json
import os
import shutil
import socket
import subprocess
import sys
import gi
gi.require_version('Gdk', '3.0')
from gi.repository import Gdk
if os.getenv("SWAYSOCK"):
from i3ipc import Connection
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, *... |
nwg-piotr/nwg-displays | https://github.com/nwg-piotr/nwg-displays | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | nwg_displays/profiles.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:10.979473 | #!/usr/bin/env python
"""
Profile management for nwg-displays
"""
import os
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
from nwg_displays.tools import save_json, load_json, notify
class ProfileManager:
def __init__(self, config_dir, config, voc):
self.profiles_dir = os.pat... |
nwg-piotr/nwg-displays | https://github.com/nwg-piotr/nwg-displays | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | nwg_displays/main.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:11.133215 | #!/usr/bin/env python
"""
Output management utility for sway Wayland compositor, inspired by wdisplays and wlay
Project: https://github.com/nwg-piotr/nwg-displays
Author's email: nwg.piotr@gmail.com
Copyright (c) 2022-2024 Piotr Miller & Contributors
License: MIT
Depends on: 'python-i3ipc' 'gtk-layer-shell'
All the c... |
nwg-piotr/nwg-displays | https://github.com/nwg-piotr/nwg-displays | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | nwg_displays/wallpaper_manager/wallpaper_manager.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:11.284696 | import os
import stat
import subprocess
import json
import time
# from nwg_displays.main import sway
from nwg_displays.tools import is_command, load_text_file
class WallpaperManager:
@staticmethod
def get_current_wallpapers():
"""Returns a dict containing path and mode fields attached to monitor name... |
nwg-piotr/nwg-displays | https://github.com/nwg-piotr/nwg-displays | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | setup.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:15.545718 | import os
from setuptools import setup, find_packages
def read(f_name):
return open(os.path.join(os.path.dirname(__file__), f_name)).read()
setup(
name="nwg-displays",
version="0.4.1",
description="nwg-shell output configuration utility",
packages=find_packages(),
include_package_data=True,... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | examples/Problem/multi_output.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:17.669907 | """Multi-output analysis and plotting example."""
import matplotlib.pyplot as plt
import numpy as np
from SALib.test_functions import lake_problem
from SALib.test_functions import Ishigami
from SALib import ProblemSpec
if __name__ == "__main__":
seed_val = 101
sp = ProblemSpec(
{
"names... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | examples/delta_mwe/delta_mwe.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:17.699100 | from SALib.analyze import delta
import numpy as np
import pandas as pd
df = pd.DataFrame() # read in dataframe here
col_output = "title_outcol" # column name in df which is output Y
bootstrap_fn = (
"fn_bootstrap_inspect.parquet" # parquet file to inspect bootstrap subset
)
Y = np.asarray(df[col_output].value... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | examples/fast/fast.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:17.702894 | import sys
sys.path.append("../..")
from SALib.analyze import fast
from SALib.sample import fast_sampler
from SALib.test_functions import Ishigami
from SALib.util import read_param_file
# Read the parameter range file and generate samples
problem = read_param_file("../../src/SALib/test_functions/params/Ishigami.txt"... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | examples/delta/delta.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:17.704870 | import sys
from SALib.analyze import delta
from SALib.util import read_param_file
import numpy as np
sys.path.append("../..")
# Read the parameter range file and generate samples
# Since this is "given data", the bounds in the parameter file will not be used
# but the columns are still expected
problem = read_para... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | examples/enhanced_hdmr/enhanced_hdmr.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:17.705977 | import sys
sys.path.append("../../src")
import numpy as np
from SALib.analyze import enhanced_hdmr
from SALib.sample import latin
from SALib.test_functions import Ishigami
# Define SALib problem specification.
problem = {"num_vars": 3, "names": ["x1", "x2", "x3"], "bounds": [[-np.pi, np.pi]] * 3}
# Generate samples
... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | examples/dgsm/dgsm.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:17.706897 | import sys
from SALib.analyze import dgsm
from SALib.sample import finite_diff
from SALib.test_functions import Ishigami
from SALib.util import read_param_file
sys.path.append("../..")
# Read the parameter range file and generate samples
problem = read_param_file("../../src/SALib/test_functions/params/Ishigami.txt... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | examples/Problem/problem_spec.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:17.709822 | """Example showing how to use the ProblemSpec approach.
Showcases method chaining, and parallel model runs using 2 processors.
The following caveats apply:
1. Functions passed into `sample`, `analyze` and `evaluate` must
accept a numpy array of `X` values as the first parameter, and return a
numpy array of res... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | examples/ff/ff.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:17.711524 | import sys
from SALib.analyze.ff import analyze
from SALib.sample.ff import sample
from SALib.util import read_param_file
sys.path.append("../..")
# Read the parameter range file and generate samples
problem = read_param_file("../../src/SALib/test_functions/params/Ishigami.txt")
# or define manually without a parame... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | examples/hdmr/hdmr.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:17.713994 | import sys
sys.path.append("../../src")
import numpy as np
from SALib.analyze import hdmr
from SALib.sample import latin
from SALib.test_functions import Ishigami
# This is the test case taken from Li's paper
# Genyuan Li et al., Journal of Physical Chemistry A., V. 114 (19),
# pp. 6022-6032, 2010.
# Define SALib pr... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | docs/conf.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:17.715100 | # -*- coding: utf-8 -*-
# This file is execfile()d with the current directory set to its containing dir.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
#
# All configuration values have a defaul... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | examples/morris/morris.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:18.221970 | import sys
from SALib.analyze import morris
from SALib.sample.morris import sample
from SALib.test_functions import Sobol_G
from SALib.util import read_param_file
from SALib.plotting.morris import (
horizontal_bar_plot,
covariance_plot,
sample_histograms,
)
import matplotlib.pyplot as plt
sys.path.append(... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | examples/sobol/sobol.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:18.329011 | import sys
sys.path.append("../..")
from SALib.analyze import sobol
from SALib.sample import saltelli
from SALib.test_functions import Ishigami
from SALib.util import read_param_file
# Read the parameter range file and generate samples
problem = read_param_file("../../src/SALib/test_functions/params/Ishigami.txt")
... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | examples/rbd_fast/rbd_fast.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:18.334613 | import sys
sys.path.append("../..")
from SALib.analyze import rbd_fast
from SALib.sample import latin
from SALib.test_functions import Ishigami
from SALib.util import read_param_file
# Read the parameter range file and generate samples
problem = read_param_file("../../src/SALib/test_functions/params/Ishigami.txt")
... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/analyze/common_args.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:18.342502 | import argparse
def setup(parser):
parser = argparse.ArgumentParser(
description="Perform sensitivity analysis on model output"
)
parser.add_argument(
"-p", "--paramfile", type=str, required=True, help="Parameter range file"
)
parser.add_argument(
"-Y", "--model-output-file... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | examples/plotting/plotting.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:18.344471 | import sys
sys.path.append("../..")
from SALib import ProblemSpec
from SALib.test_functions import Ishigami
from SALib.plotting.bar import plot as barplot
import matplotlib.pyplot as plt
import numpy as np
# By convention, we assign to "sp" (for "SALib Problem")
sp = ProblemSpec(
{
"names": ["x1", "x2"... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | examples/pawn/pawn.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:18.345487 | import sys
sys.path.append("../..")
from SALib.analyze import pawn
from SALib.sample import latin
from SALib.test_functions import Ishigami
from SALib.util import read_param_file
# Read the parameter range file and generate samples
problem = read_param_file("../../src/SALib/test_functions/params/Ishigami.txt")
# Ge... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/analyze/dgsm.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:18.346936 | from scipy.stats import norm
import numpy as np
from . import common_args
from ..util import read_param_file, ResultDict
def analyze(
problem, X, Y, num_resamples=100, conf_level=0.95, print_to_console=False, seed=None
):
"""Calculates Derivative-based Global Sensitivity Measure on model outputs.
Retur... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/analyze/delta.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:18.416853 | from typing import Optional, Dict
from scipy.stats import norm, gaussian_kde, rankdata
import numpy as np
import pandas as pd
from . import common_args
from ..util import read_param_file, ResultDict
import warnings
import json
class AnalysisError(Exception):
def __init__(self, cmd, note=None):
self.cmd... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/analyze/discrepancy.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:18.835941 | from typing import Dict
import numpy as np
from scipy.stats import qmc
from SALib.analyze import common_args
from SALib.util import read_param_file, ResultDict, _check_groups
def analyze(
problem: Dict,
X: np.ndarray,
Y: np.ndarray,
method: str = "WD",
print_to_console: bool = False,
seed: i... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/analyze/rbd_fast.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:18.956595 | # coding=utf8
import numpy as np
from scipy.signal import periodogram
from scipy.stats import norm
from typing import Optional, Union
from . import common_args
from ..util import read_param_file, ResultDict, handle_seed
def analyze(
problem,
X,
Y,
M=10,
num_resamples=100,
conf_level=0.95,
... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/analyze/pawn.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:18.961655 | from typing import Dict
import numpy as np
from scipy.stats import ks_2samp
from . import common_args
from ..util import read_param_file, ResultDict, extract_group_names, _check_groups
def analyze(
problem: Dict,
X: np.ndarray,
Y: np.ndarray,
S: int = 10,
print_to_console: bool = False,
seed... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/analyze/fast.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:18.963138 | import math
import numpy as np
from scipy.stats import norm
from . import common_args
from ..util import read_param_file, ResultDict
def analyze(
problem,
Y,
M=4,
num_resamples=100,
conf_level=0.95,
print_to_console=False,
seed=None,
):
"""Perform extended Fourier Amplitude Sensitivit... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/analyze/morris.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:18.975739 | from typing import Dict, List
import numpy as np
from scipy.stats import norm
from . import common_args
from ..util import (
read_param_file,
compute_groups_matrix,
ResultDict,
_define_problem_with_groups,
_compute_delta,
handle_seed,
)
def analyze(
problem: Dict,
X: np.ndarray,
Y... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/analyze/rsa.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:18.984541 | from typing import Dict
from types import MethodType
import warnings
import numpy as np
import pandas as pd
from scipy.stats import cramervonmises_2samp
from . import common_args
from ..util import read_param_file, ResultDict, extract_group_names, _check_groups
def analyze(
problem: Dict,
X: np.ndarray,
... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/analyze/hdmr.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:18.986189 | from typing import Dict, Union
from types import MethodType
import itertools
import time
import warnings
import numpy as np
from numpy.linalg import solve as lin_solve
from numpy.linalg import svd
from numpy import identity
import pandas as pd
from scipy import stats, special, interpolate
from . import common_args
... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/analyze/ff.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:18.989856 | """
Created on 30 Jun 2015
@author: will2
"""
import numpy as np
from . import common_args
import pandas as pd
from types import MethodType
from SALib.util import read_param_file, ResultDict
from SALib.sample.ff import generate_contrast, extend_bounds
def analyze(problem, X, Y, second_order=False, print_to_consol... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/analyze/enhanced_hdmr.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:18.997784 | import math
import warnings
from typing import Dict, Tuple
from types import MethodType
from itertools import combinations as comb, product
from collections import defaultdict, namedtuple
import numpy as np
from pandas import DataFrame as df
from numpy.linalg import det, pinv, matrix_rank
from scipy.linalg import svd,... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/analyze/sobol.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:19.339419 | from types import MethodType
from warnings import warn
from scipy.stats import norm
import numpy as np
import pandas as pd
from . import common_args
from ..util import read_param_file, ResultDict, extract_group_names
from multiprocessing import Pool, cpu_count
from functools import partial
from itertools import com... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/plotting/heatmap.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:20.645556 | from typing import Dict
import numpy as np
import matplotlib.pyplot as plt
from ..util import extract_group_names
__all__ = ["heatmap"]
# magic string indicating DF columns holding conf bound values
CONF_COLUMN = "_conf"
def heatmap(sp: Dict, metric: str, index: str, title: str = None, ax=None):
"""Plot a hea... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/sample/fast_sampler.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:20.647280 | import math
from typing import Optional, Union
import numpy as np
from . import common_args
from ..util import scale_samples, read_param_file, handle_seed
def sample(problem, N, M=4, seed: Optional[Union[int, np.random.Generator]] = None):
"""Generate model inputs for extended Fourier Amplitude Sensitivity Tes... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/sample/common_args.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:20.648458 | import argparse
def setup(parser):
"""Add common sampling options to CLI parser.
Parameters
----------
parser : argparse object
Returns
-------
Updated argparse object
"""
parser.add_argument(
"-n", "--samples", type=int, required=True, help="Number of Samples"
)
... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/sample/ff.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:20.649490 | """The sampling implementation of fractional factorial method
This implementation is based on the formulation put forward in
[`Saltelli et al. 2008 <http://doi.org/10.1002/9780470725184>`_]
"""
from scipy.linalg import hadamard
from typing import Optional, Union
import numpy as np
from . import common_args
from ..ut... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/sample/finite_diff.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:20.650487 | from typing import Dict, Optional, Union
import numpy as np
from . import common_args
from . import sobol_sequence
from ..util import scale_samples, read_param_file, handle_seed
def sample(
problem: Dict,
N: int,
delta: float = 0.01,
seed: Optional[Union[int, np.random.Generator]] = None,
skip_va... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/plotting/morris.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:20.651680 | """
Created on 29 Jun 2015
@author: @willu47
This module provides the basic infrastructure for plotting charts for the
Method of Morris results
The procedures should build upon and return an axes instance::
import matplotlib.pyplot as plt
Si = morris.analyze(problem, param_values, Y, conf_level=0.95,
... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/plotting/hdmr.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:20.652541 | """
Created on Dec 20, 2019
@author: @sahin-abdullah
This submodule produces two different figures: (1) emulator vs simulator,
(2) regression lines of first order component functions
"""
import matplotlib.pyplot as plt
import numpy as np
def plot(Si):
# Close all figures
plt.close("all")
# Extract nec... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/plotting/bar.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:22.219915 | __all__ = ["plot"]
# magic string indicating DF columns holding conf bound values
CONF_COLUMN = "_conf"
def plot(Si_df, ax=None):
"""Create bar chart of results.
Examples
--------
>>> from SALib.plotting.bar import plot as barplot
>>> from SALib.test_functions import Ishigami
>>... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/sample/morris/strategy.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:22.714377 | """
Defines a family of algorithms for generating samples
The sample a for use with :class:`SALib.analyze.morris.analyze`,
encapsulate each one, and makes them interchangeable.
Example
-------
>>> localoptimisation = LocalOptimisation()
>>> context = SampleMorris(localoptimisation)
>>> context.sample(input_sample, nu... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/sample/morris/local.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:22.715314 | """ """
from itertools import combinations
import numpy as np # type: ignore
from typing import List, Tuple, Union
from .strategy import Strategy
class LocalOptimisation(Strategy):
"""Implements the local optimisation algorithm using the Strategy interface"""
def _sample(
self, input_sample, num_s... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/sample/morris/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:22.715928 | from .local import LocalOptimisation # noqa: F401
from .brute import BruteForce # noqa: F401
from .strategy import SampleMorris # noqa: F401
from .morris import sample, _compute_delta, cli_parse, cli_action # noqa: F401
|
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/sample/morris/morris.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:22.716586 | import numpy as np
from typing import Dict, Optional, Union
import warnings
from .local import LocalOptimisation
from .brute import BruteForce
from .strategy import SampleMorris
from SALib.sample import common_args
from SALib.util import (
scale_samples,
read_param_file,
compute_groups_matrix,
_defi... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/sample/saltelli.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:22.828117 | from typing import Dict
import math
import warnings
import numpy as np
from . import common_args
from . import sobol_sequence
from ..util import scale_samples, read_param_file, compute_groups_matrix, _check_groups
def sample(
problem: Dict, N: int, calc_second_order: bool = True, skip_values: int = None
):
... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/sample/morris/brute.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:22.908359 | """ """
from SALib.sample.morris.strategy import Strategy
from scipy.special import comb as nchoosek # type: ignore
from itertools import combinations, islice
import sys
import numpy as np # type: ignore
from typing import List
class BruteForce(Strategy):
"""Implements the brute force optimisation strategy"""
... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/sample/sobol.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:23.084697 | import warnings
from typing import Dict, Optional, Union
import numpy as np
from scipy.stats import qmc
from . import common_args
from ..util import scale_samples, read_param_file, compute_groups_matrix, _check_groups
def sample(
problem: Dict,
N: int,
*,
calc_second_order: bool = True,
scramble... |
SALib/SALib | https://github.com/SALib/SALib | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | src/SALib/sample/sobol_sequence.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:26.509569 | import math
import sys
import numpy as np
from .directions import directions
if sys.version_info[0] > 2:
long = int
# ==============================================================================
# The following code is based on the Sobol sequence generator by Frances
# Y. Kuo and Stephen Joe. The license ter... |
themanojdesai/python-a2a | https://github.com/themanojdesai/python-a2a | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | examples/ai_powered_agents/llm_client.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:29.214686 | #!/usr/bin/env python
"""
LLM Client Example
This example demonstrates how to use specialized A2A clients for directly
connecting to various LLM providers like OpenAI and Anthropic without
needing to run a separate server.
To run:
# For OpenAI:
export OPENAI_API_KEY=your_api_key
python llm_client.py --pro... |
themanojdesai/python-a2a | https://github.com/themanojdesai/python-a2a | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | examples/agent_network/agent_network.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:29.217206 | #!/usr/bin/env python
"""
Basic Agent Network Example
This example demonstrates the fundamentals of creating and using an agent network
for coordinating multiple specialized agents. It shows how to:
- Create specialized agents (weather, math, and knowledge)
- Set up an agent network that connects these agents
- Query ... |
themanojdesai/python-a2a | https://github.com/themanojdesai/python-a2a | null | null | null | null | 987 | null | null | mit | null | null | null | null | null | null | null | examples/agent_network/smart_routing.py | null | null | null | null | null | null | Python | 2026-05-04T01:33:29.262278 | #!/usr/bin/env python
"""
Intelligent Query Routing Example
This example demonstrates how to use the AIAgentRouter to intelligently route
queries to the most appropriate agent based on query content. It shows:
- Creating specialized agents with different capabilities
- Setting up an AI router using OpenAI to analyze a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.