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
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/model_xfastertransformer.py
fastchat/model/model_xfastertransformer.py
import gc from threading import Thread import torch from transformers import TextIteratorStreamer @torch.inference_mode() def generate_stream_xft( model, tokenizer, params, device, context_len=8192, stream_interval=2, judge_sent_end=False, ): prompt = params["prompt"] repetition_p...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/model_yuan2.py
fastchat/model/model_yuan2.py
import gc from threading import Thread from typing import Iterable import torch import transformers from transformers import TextIteratorStreamer, GenerationConfig from fastchat.utils import is_partial_stop @torch.inference_mode() def generate_stream_yuan2( model, tokenizer, params, device, cont...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/model_exllama.py
fastchat/model/model_exllama.py
import gc import sys from typing import Dict import torch def generate_stream_exllama( model, tokenizer, params: Dict, device: str, context_len: int, stream_interval: int = 2, judge_sent_end: bool = False, ): try: from exllamav2.generator import ExLlamaV2StreamingGenerator, Ex...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/compression.py
fastchat/model/compression.py
import dataclasses import gc import glob import os from accelerate import init_empty_weights from accelerate.utils import set_module_tensor_to_device from huggingface_hub import snapshot_download import torch from torch import Tensor from torch.nn import functional as F import torch.nn as nn from tqdm import tqdm from...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/apply_delta.py
fastchat/model/apply_delta.py
""" Apply the delta weights on top of a base model. Usage: python3 -m fastchat.model.apply_delta --base ~/model_weights/llama-7b --target ~/model_weights/vicuna-7b --delta lmsys/vicuna-7b-delta-v1.1 """ import argparse import gc import glob import json import os import shutil import tempfile from huggingface_hub impo...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/__init__.py
fastchat/model/__init__.py
from fastchat.model.model_adapter import ( load_model, get_conversation_template, add_model_args, )
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/monkey_patch_non_inplace.py
fastchat/model/monkey_patch_non_inplace.py
""" Monkey patch the llama implementation in the huggingface/transformers library. Avoid bugs in mps backend by not using in-place operations. """ import math from typing import List, Optional, Tuple import torch from torch import nn import transformers def rotate_half(x): """Rotates half the hidden dims of the ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/model_adapter.py
fastchat/model/model_adapter.py
"""Model adapter registration.""" import math import os import re import sys from typing import Dict, List, Optional import warnings if sys.version_info >= (3, 9): from functools import cache else: from functools import lru_cache as cache import psutil import torch from transformers import ( AutoConfig, ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
true
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/llama_condense_monkey_patch.py
fastchat/model/llama_condense_monkey_patch.py
# Code adapted from https://huggingface.co/kaiokendev/superhot-13b-8k-no-rlhf-test/blob/main/llama_rope_scaled_monkey_patch.py from functools import partial import torch import transformers import transformers.models.llama.modeling_llama class CondenseRotaryEmbedding(torch.nn.Module): def __init__( self...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/apply_lora.py
fastchat/model/apply_lora.py
""" Apply the LoRA weights on top of a base model. Usage: python3 -m fastchat.model.apply_lora --base ~/model_weights/llama-7b --target ~/model_weights/baize-7b --lora project-baize/baize-lora-7B Dependency: pip3 install git+https://github.com/huggingface/peft.git@2822398fbe896f25d4dac5e468624dc5fd65a51b """ import a...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/model_chatglm.py
fastchat/model/model_chatglm.py
""" Inference code for ChatGLM. Adapted from https://huggingface.co/THUDM/chatglm-6b/blob/main/modeling_chatglm.py. """ import re import torch from transformers.generation.logits_process import LogitsProcessor class InvalidScoreLogitsProcessor(LogitsProcessor): def __call__( self, input_ids: torch.LongTe...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/model_falcon.py
fastchat/model/model_falcon.py
import gc from threading import Thread from typing import Iterable import torch import transformers from transformers import TextIteratorStreamer, GenerationConfig from fastchat.utils import is_partial_stop @torch.inference_mode() def generate_stream_falcon( model, tokenizer, params, device, con...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/llm_judge/common.py
fastchat/llm_judge/common.py
""" Common data structures and utilities. """ import ast import dataclasses import glob import json import os import re import time from typing import Optional import openai import anthropic from fastchat.model.model_adapter import ( get_conversation_template, ANTHROPIC_MODEL_LIST, OPENAI_MODEL_LIST, ) ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/llm_judge/clean_judgment.py
fastchat/llm_judge/clean_judgment.py
""" Clean model judgment files. """ import argparse import json selected_models = [ "alpaca-13b", "baize-v2-13b", "chatglm-6b", "claude-instant-v1", "claude-v1", "dolly-v2-12b", "falcon-40b-instruct", "fastchat-t5-3b", "gpt-3.5-turbo", "gpt-4", "gpt4all-13b-snoozy", "gua...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/llm_judge/qa_browser.py
fastchat/llm_judge/qa_browser.py
""" Usage: python3 qa_browser.py --share """ import argparse from collections import defaultdict import re import gradio as gr from fastchat.llm_judge.common import ( load_questions, load_model_answers, load_single_model_judgments, load_pairwise_model_judgments, resolve_single_judgment_dict, ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/llm_judge/show_result.py
fastchat/llm_judge/show_result.py
""" Usage: python3 show_result.py --mode [single|pairwise-baseline|pairwise-all] """ import argparse import pandas as pd def display_result_single(args): if args.input_file is None: input_file = ( f"data/{args.bench_name}/model_judgment/{args.judge_model}_single.jsonl" ) else: ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/llm_judge/compute_agreement.py
fastchat/llm_judge/compute_agreement.py
""" Compute agreement among judges. Usage: python compute_agreement.py --judges gpt4-pair human --votefiles human_judgments.json gpt4_pair_judgments.json python compute_agreement.py --judges human human --votefiles human_judgments.json """ import argparse import json import os import numpy as np def get_judge_name(...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/llm_judge/gen_model_answer.py
fastchat/llm_judge/gen_model_answer.py
"""Generate answers with local models. Usage: python3 gen_model_answer.py --model-path lmsys/fastchat-t5-3b-v1.0 --model-id fastchat-t5-3b-v1.0 """ import argparse import json import os import random import time import shortuuid import torch from tqdm import tqdm from fastchat.llm_judge.common import load_questions,...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/llm_judge/download_mt_bench_pregenerated.py
fastchat/llm_judge/download_mt_bench_pregenerated.py
""" Download the pre-generated model answers and judgments for MT-bench. """ import os from fastchat.utils import run_cmd filenames = [ "data/mt_bench/model_answer/alpaca-13b.jsonl", "data/mt_bench/model_answer/baize-v2-13b.jsonl", "data/mt_bench/model_answer/chatglm-6b.jsonl", "data/mt_bench/model_an...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/llm_judge/gen_judgment.py
fastchat/llm_judge/gen_judgment.py
""" Usage: python gen_judgment.py --model-list [LIST-OF-MODEL-ID] --parallel [num-concurrent-api-call] --mode [single|pairwise-baseline|pairwise-all] """ import argparse from concurrent.futures import ThreadPoolExecutor import json import numpy as np from tqdm import tqdm from fastchat.llm_judge.common import ( l...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/llm_judge/gen_api_answer.py
fastchat/llm_judge/gen_api_answer.py
"""Generate answers with GPT-4 Usage: python3 gen_api_answer.py --model gpt-3.5-turbo """ import argparse import json import os import time import concurrent.futures import openai import shortuuid import tqdm from fastchat.llm_judge.common import ( load_questions, temperature_config, chat_completion_open...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/modules/awq.py
fastchat/modules/awq.py
from dataclasses import dataclass, field from pathlib import Path import sys import torch from transformers import AutoTokenizer, AutoConfig, AutoModelForCausalLM, modeling_utils @dataclass class AWQConfig: ckpt: str = field( default=None, metadata={ "help": "Load quantized model. The...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/modules/gptq.py
fastchat/modules/gptq.py
from dataclasses import dataclass, field import os from os.path import isdir, isfile from pathlib import Path import sys from transformers import AutoTokenizer @dataclass class GptqConfig: ckpt: str = field( default=None, metadata={ "help": "Load quantized model. The path to the local...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/modules/__init__.py
fastchat/modules/__init__.py
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/modules/exllama.py
fastchat/modules/exllama.py
from dataclasses import dataclass, field import sys @dataclass class ExllamaConfig: max_seq_len: int gpu_split: str = None cache_8bit: bool = False class ExllamaModel: def __init__(self, exllama_model, exllama_cache): self.model = exllama_model self.cache = exllama_cache self...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/modules/xfastertransformer.py
fastchat/modules/xfastertransformer.py
from dataclasses import dataclass import sys @dataclass class XftConfig: max_seq_len: int = 4096 beam_width: int = 1 eos_token_id: int = -1 pad_token_id: int = -1 num_return_sequences: int = 1 is_encoder_decoder: bool = False padding: bool = True early_stopping: bool = False data_t...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/data/extract_single_round.py
fastchat/data/extract_single_round.py
""" Extract the first round of the conversations. Usage: python3 -m fastchat.data.extract_single_round --in sharegpt.json """ import argparse import json if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--in-file", type=str, required=True) parser.add_argument("--out-file...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/data/inspect_data.py
fastchat/data/inspect_data.py
""" Usage: python3 -m fastchat.data.inspect_data --in sharegpt_20230322_clean_lang_split.json """ import argparse import json import random if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--in-file", type=str, required=True) parser.add_argument("--begin", type=int) p...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/data/extract_gpt4_only.py
fastchat/data/extract_gpt4_only.py
""" Extract the conversations generated by GPT-4 only. Usage: python3 -m fastchat.data.extract_gpt4_only --in sharegpt.json """ import argparse import json if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--in-file", type=str, required=True) parser.add_argument("--out-fi...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/data/optional_replace.py
fastchat/data/optional_replace.py
""" Do optional replace of bos/eos/pad/unk. Usage: python3 -m fastchat.data.optional_replace --in input.json --out output.json --model-name-or-path <your_token_path> Requirement: pip3 install transformers tqdm """ import argparse import json import traceback import transformers from tqdm import tqdm def replace_sp...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/data/split_long_conversation.py
fastchat/data/split_long_conversation.py
""" Split long conversations based on certain max length. Usage: python3 -m fastchat.data.split_long_conversation \ --in sharegpt_clean.json \ --out sharegpt_split.json \ --model-name-or-path $<model-name> """ import argparse from concurrent.futures import ProcessPoolExecutor import json from typing import...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/data/filter_wrong_format.py
fastchat/data/filter_wrong_format.py
""" Filter conversations with wrong formats. Usage: python3 -m fastchat.data.filter_wrong_format --in input.json --out output.json """ import argparse import json import re from tqdm import tqdm wrong_indices_pattern = re.compile("\n1\. [^2]*\n1\. ") def should_skip(conv): # Filter wrong list indices like htt...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/data/optional_clean.py
fastchat/data/optional_clean.py
""" Do optional cleaning (e.g., remove some languages). Usage: python3 -m fastchat.data.optional_clean --in input.json --out output.json --keep-lang en python3 -m fastchat.data.optional_clean --in input.json --out output.json --skip-lang en Requirement: pip3 install polyglot pyicu pycld2 """ import argparse import js...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/data/prepare_all.py
fastchat/data/prepare_all.py
"""Prepare all datasets.""" import argparse import os from fastchat.utils import run_cmd if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--prefix", type=str, default="~/datasets/sharegpt_20230521") parser.add_argument( "--model-name-or-path", type=str, default=...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/data/split_train_test.py
fastchat/data/split_train_test.py
""" Split the dataset into training and test set. Usage: python3 -m fastchat.data.split_train_test --in sharegpt.json """ import argparse import json import numpy as np if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--in-file", type=str, required=True) parser.add_argu...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/data/merge.py
fastchat/data/merge.py
""" Merge two conversation files into one Usage: python3 -m fastchat.data.merge --in file1.json file2.json --out merged.json """ import argparse import json if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--in-file", type=str, required=True, nargs="+") parser.add_argum...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/data/clean_sharegpt.py
fastchat/data/clean_sharegpt.py
""" - Convert html to markdown with basic data cleaning. - Deduplication. Usage: python3 -m fastchat.data.clean_sharegpt --in sharegpt_html.json --out sharegpt_clean.json """ import argparse from concurrent.futures import ProcessPoolExecutor import json import logging import re from typing import Dict, Union import b...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/data/convert_alpaca.py
fastchat/data/convert_alpaca.py
""" Convert alpaca dataset into sharegpt format. Usage: python3 -m fastchat.data.convert_alpaca --in alpaca_data.json """ import argparse import json from transformers import AutoTokenizer, AutoModelForCausalLM import numpy as np if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argu...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/data/__init__.py
fastchat/data/__init__.py
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/data/hardcoded_questions.py
fastchat/data/hardcoded_questions.py
""" Hardcoded question and answers. """ import json def identity_questions(): """ " Adapted from https://github.com/young-geng/koala_data_pipeline/blob/main/process_hard_coded_data.py """ content = [] name = "Vicuna" org = "Large Model Systems Organization (LMSYS)" def generate_conversat...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/data/sample.py
fastchat/data/sample.py
""" Sample some conversations from a file. Usage: python3 -m fastchat.data.sample --in sharegpt.json --out sampled.json """ import argparse import json import numpy as np if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--in-file", type=str, required=True) parser.add_ar...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/data/get_stats.py
fastchat/data/get_stats.py
""" Get stats of a dataset. Usage: python3 -m fastchat.data.get_stats --in sharegpt.json """ import argparse from concurrent.futures import ProcessPoolExecutor import json import numpy as np from tqdm import tqdm from transformers import AutoTokenizer, AutoModelForCausalLM K = 1e3 M = 1e6 def tokenize_one_sample(...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/data/pretty_json.py
fastchat/data/pretty_json.py
""" Usage: python3 pretty_json.py --in in.json --out out.json """ import argparse import json if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--in-file", type=str, required=True) parser.add_argument("--out-file", type=str, required=True) args = parser.parse_args() ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/controller.py
fastchat/serve/controller.py
""" A controller manages distributed workers. It sends worker addresses to clients. """ import argparse import asyncio import dataclasses from enum import Enum, auto import json import logging import os import time from typing import List, Union import threading from fastapi import FastAPI, Request from fastapi.respon...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/openai_api_server.py
fastchat/serve/openai_api_server.py
"""A server that provides OpenAI-compatible RESTful APIs. It supports: - Chat Completions. (Reference: https://platform.openai.com/docs/api-reference/chat) - Completions. (Reference: https://platform.openai.com/docs/api-reference/completions) - Embeddings. (Reference: https://platform.openai.com/docs/api-reference/emb...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
true
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/call_monitor.py
fastchat/serve/call_monitor.py
import json import os import glob import time from fastapi import FastAPI import hashlib import asyncio REFRESH_INTERVAL_SEC = 300 LOG_DIR_LIST = [] # LOG_DIR = "/home/vicuna/tmp/test_env" class Monitor: """Monitor the number of calls to each model.""" def __init__(self, log_dir_list: list): self.l...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/test_throughput.py
fastchat/serve/test_throughput.py
"""Benchmarking script to test the throughput of serving workers.""" import argparse import json import requests import threading import time from fastchat.conversation import get_conv_template def main(): if args.worker_address: worker_addr = args.worker_address else: controller_addr = args...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/lightllm_worker.py
fastchat/serve/lightllm_worker.py
""" A model worker that executes the model based on LightLLM. See documentations at docs/lightllm_integration.md """ import argparse import asyncio import json import os import torch import uvicorn from transformers import AutoConfig from typing import List from fastapi import FastAPI, Request, BackgroundTasks fro...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/inference.py
fastchat/serve/inference.py
"""Inference for FastChat models.""" import abc import gc import json import math import os import sys import time from typing import Iterable, Optional, Dict import warnings import psutil import torch from transformers import ( AutoTokenizer, AutoModelForCausalLM, LlamaTokenizer, LlamaForCausalLM, ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/mlx_worker.py
fastchat/serve/mlx_worker.py
""" A model worker using Apple MLX https://github.com/ml-explore/mlx-examples/tree/main/llms Code based on vllm_worker https://github.com/lm-sys/FastChat/blob/main/fastchat/serve/vllm_worker.py You must install MLX python: pip install mlx-lm """ import argparse import asyncio import atexit import json from typing ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/gradio_block_arena_named.py
fastchat/serve/gradio_block_arena_named.py
""" Chatbot Arena (side-by-side) tab. Users chat with two chosen models. """ import json import time import gradio as gr import numpy as np from fastchat.constants import ( MODERATION_MSG, CONVERSATION_LIMIT_MSG, INPUT_CHAR_LEN_LIMIT, CONVERSATION_TURN_LIMIT, SURVEY_LINK, ) from fastchat.model.mo...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/gradio_block_arena_anony.py
fastchat/serve/gradio_block_arena_anony.py
""" Chatbot Arena (battle) tab. Users chat with two anonymous models. """ import json import time import re import gradio as gr import numpy as np from fastchat.constants import ( MODERATION_MSG, CONVERSATION_LIMIT_MSG, SLOW_MODEL_MSG, BLIND_MODE_INPUT_CHAR_LEN_LIMIT, CONVERSATION_TURN_LIMIT, ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/cli.py
fastchat/serve/cli.py
""" Chat with a model with command line interface. Usage: python3 -m fastchat.serve.cli --model lmsys/vicuna-7b-v1.5 python3 -m fastchat.serve.cli --model lmsys/fastchat-t5-3b-v1.0 Other commands: - Type "!!exit" or an empty line to exit. - Type "!!reset" to start a new conversation. - Type "!!remove" to remove the l...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/gradio_global_state.py
fastchat/serve/gradio_global_state.py
from dataclasses import dataclass, field from typing import List @dataclass class Context: text_models: List[str] = field(default_factory=list) all_text_models: List[str] = field(default_factory=list) vision_models: List[str] = field(default_factory=list) all_vision_models: List[str] = field(default_f...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/huggingface_api_worker.py
fastchat/serve/huggingface_api_worker.py
""" A model worker that calls huggingface inference endpoint. Register models in a JSON file with the following format: { "falcon-180b-chat": { "model_name": "falcon-180B-chat", "api_base": "https://api-inference.huggingface.co/models", "model_path": "tiiuae/falcon-180B-chat", "toke...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/remote_logger.py
fastchat/serve/remote_logger.py
# A JSON logger that sends data to remote endpoint. # Architecturally, it hosts a background thread that sends logs to a remote endpoint. import os import json import requests import threading import queue import logging _global_logger = None def get_remote_logger(): global _global_logger if _global_logger i...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/shutdown_serve.py
fastchat/serve/shutdown_serve.py
""" Usage: python shutdown_serve.py --down all options: "all","controller","model_worker","openai_api_server", `all` means to stop all related servers """ import argparse import os import subprocess parser = argparse.ArgumentParser() parser.add_argument( "--down", choices=["all", "controller", "model_worker", "o...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/multi_model_worker.py
fastchat/serve/multi_model_worker.py
""" A multi-model worker that contains multiple sub-works one for each model. This supports running a list of models on the same machine so that they can (potentially) share the same background weights. Each model can have one or more model names. This multi-model worker assumes the models shares some underlying wei...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/base_model_worker.py
fastchat/serve/base_model_worker.py
import asyncio import threading import time from typing import List from fastapi import FastAPI, Request, BackgroundTasks from fastapi.responses import StreamingResponse, JSONResponse import requests from fastchat.constants import WORKER_HEART_BEAT_INTERVAL from fastchat.conversation import Conversation from fastchat...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/gradio_web_server.py
fastchat/serve/gradio_web_server.py
""" The gradio demo server for chatting with a single model. """ import argparse from collections import defaultdict import datetime import hashlib import json import os import random import time import uuid from typing import List, Dict import gradio as gr import requests from fastchat.constants import ( LOGDIR...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
true
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/launch_all_serve.py
fastchat/serve/launch_all_serve.py
""" Usage: python launch_all_serve_by_shell.py --model-path-address "THUDM/chatglm2-6b@localhost@2021" "huggyllama/llama-7b@localhost@2022" Workers are listed in format of `model-path`@`host`@`port` The key mechanism behind this scripts is: 1, execute shell cmd to launch the controller/worker/openai-api-server...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/huggingface_api.py
fastchat/serve/huggingface_api.py
""" Use FastChat with Hugging Face generation APIs. Usage: python3 -m fastchat.serve.huggingface_api --model lmsys/vicuna-7b-v1.5 python3 -m fastchat.serve.huggingface_api --model lmsys/fastchat-t5-3b-v1.0 """ import argparse import torch from fastchat.model import load_model, get_conversation_template, add_model_ar...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/gradio_block_arena_vision_named.py
fastchat/serve/gradio_block_arena_vision_named.py
""" Multimodal Chatbot Arena (side-by-side) tab. Users chat with two chosen models. """ import json import os import time from typing import List, Union import gradio as gr import numpy as np from fastchat.constants import ( TEXT_MODERATION_MSG, IMAGE_MODERATION_MSG, MODERATION_MSG, CONVERSATION_LIMI...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/model_worker.py
fastchat/serve/model_worker.py
""" A model worker that executes the model. """ import argparse import base64 import gc import json import os from typing import List, Optional import uuid import torch import torch.nn.functional as F from transformers import set_seed import uvicorn from fastchat.constants import ErrorCode, SERVER_ERROR_MSG from fast...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/register_worker.py
fastchat/serve/register_worker.py
""" Manually register workers. Usage: python3 -m fastchat.serve.register_worker --controller http://localhost:21001 --worker-name http://localhost:21002 """ import argparse import requests if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--controller-address", type=str) ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/gradio_block_arena_vision.py
fastchat/serve/gradio_block_arena_vision.py
""" The gradio demo server for chatting with a large multimodal model. Usage: python3 -m fastchat.serve.controller python3 -m fastchat.serve.sglang_worker --model-path liuhaotian/llava-v1.5-7b --tokenizer-path llava-hf/llava-1.5-7b-hf python3 -m fastchat.serve.gradio_web_server_multi --share --vision-arena """ import...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/gradio_web_server_multi.py
fastchat/serve/gradio_web_server_multi.py
""" The gradio demo server with multiple tabs. It supports chatting with a single model or chatting with two models side-by-side. """ import argparse import gradio as gr from fastchat.serve.gradio_block_arena_anony import ( build_side_by_side_ui_anony, load_demo_side_by_side_anony, set_global_vars_anony, ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/gradio_block_arena_vision_anony.py
fastchat/serve/gradio_block_arena_vision_anony.py
""" Chatbot Arena (battle) tab. Users chat with two anonymous models. """ import json import time import gradio as gr import numpy as np from typing import Union from fastchat.constants import ( TEXT_MODERATION_MSG, IMAGE_MODERATION_MSG, MODERATION_MSG, CONVERSATION_LIMIT_MSG, SLOW_MODEL_MSG, ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/__init__.py
fastchat/serve/__init__.py
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/test_message.py
fastchat/serve/test_message.py
"""Send a test message.""" import argparse import json import requests from fastchat.model.model_adapter import get_conversation_template def main(): model_name = args.model_name if args.worker_address: worker_addr = args.worker_address else: controller_addr = args.controller_address ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/sglang_worker.py
fastchat/serve/sglang_worker.py
""" A model worker that executes the model based on SGLang. Usage: python3 -m fastchat.serve.sglang_worker --model-path liuhaotian/llava-v1.5-7b --tokenizer-path llava-hf/llava-1.5-7b-hf --port 30000 --worker-address http://localhost:30000 """ import argparse import asyncio import json import multiprocessing from typ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/dashinfer_worker.py
fastchat/serve/dashinfer_worker.py
""" A model worker that executes the model based on dash-infer. See documentations at docs/dashinfer_integration.md """ import argparse import asyncio import copy import json import os import subprocess from typing import List from fastapi import FastAPI, Request, BackgroundTasks from fastapi.responses import Stream...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/vllm_worker.py
fastchat/serve/vllm_worker.py
""" A model worker that executes the model based on vLLM. See documentations at docs/vllm_integration.md """ import argparse import asyncio import json from typing import List from fastapi import FastAPI, Request, BackgroundTasks from fastapi.responses import StreamingResponse, JSONResponse import uvicorn from vllm ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/api_provider.py
fastchat/serve/api_provider.py
"""Call API providers.""" import json import os import random import re from typing import Optional import time import requests from fastchat.utils import build_logger logger = build_logger("gradio_web_server", "gradio_web_server.log") def get_api_provider_stream_iter( conv, model_name, model_api_dic...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
true
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/vision/create_vqa_examples_json.py
fastchat/serve/vision/create_vqa_examples_json.py
""" Changes proportion of examples in metadata_sampled.json Usage: python3 -m fastchat.serve.vision.create_vqa_examples_json """ import json import argparse import numpy as np if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--data_dir", type=str, default="~/.cache") pa...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/vision/image.py
fastchat/serve/vision/image.py
import base64 from enum import auto, IntEnum from io import BytesIO from pydantic import BaseModel class ImageFormat(IntEnum): """Image formats.""" URL = auto() LOCAL_FILEPATH = auto() PIL_IMAGE = auto() BYTES = auto() DEFAULT = auto() class Image(BaseModel): url: str = "" filetype...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/vision/create_vqa_examples_dir.py
fastchat/serve/vision/create_vqa_examples_dir.py
import datasets from datasets import load_dataset from PIL import Image from pathlib import Path import pandas as pd import os import json import tqdm import argparse import shutil import numpy as np np.random.seed(0) """ Creates a directory with images and JSON files for VQA examples. Final json is located in metada...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/elo_analysis.py
fastchat/serve/monitor/elo_analysis.py
import argparse import ast from collections import defaultdict import datetime import json import math import pickle from pytz import timezone from functools import partial import numpy as np import pandas as pd import plotly.express as px from tqdm import tqdm from fastchat.model.model_registry import get_model_info...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/rating_systems.py
fastchat/serve/monitor/rating_systems.py
import os import math import multiprocessing as mp from functools import partial import numpy as np from scipy.special import expit from scipy.optimize import minimize import pandas as pd from tqdm import tqdm STYLE_CONTROL_ELEMENTS_V1 = [ "sum_assistant_a_tokens", "header_count_a", "list_count_a", "b...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/intersect_conv_file.py
fastchat/serve/monitor/intersect_conv_file.py
""" Take the intersection of two conversation files. Usage: python3 -m fastchat.data.merge --input input.json --conv-id conv_id_file.json --out intersect.json """ import argparse import json if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--input", type=str, required=True)...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/add_markdown_info.py
fastchat/serve/monitor/add_markdown_info.py
import pandas as pd import re import argparse from tqdm import tqdm tqdm.pandas() def count_markdown_elements(markdown_text, suffix): counters = { f"header_count{suffix}": { "h1": len(re.findall(r"^#{1}\s", markdown_text, re.MULTILINE)), "h2": len(re.findall(r"^#{2}\s", markdown_...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/criteria_labeling.py
fastchat/serve/monitor/criteria_labeling.py
import argparse import json import pandas as pd import os import re import ast import time import concurrent.futures import tqdm import random import threading LOCK = threading.RLock() ## Configs SYSTEM_PROMPT = "Your task is to evaluate how well the following input prompts can assess the capabilities of advanced AI ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/clean_battle_data.py
fastchat/serve/monitor/clean_battle_data.py
""" Clean chatbot arena battle log. Usage: python3 clean_battle_data.py --mode conv_release """ import argparse import datetime import json import os from pytz import timezone import time from tqdm import tqdm from multiprocessing import Pool import tiktoken from collections import Counter import shortuuid from fast...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/monitor_md.py
fastchat/serve/monitor/monitor_md.py
import pandas as pd import pickle import gradio as gr from fastchat.constants import SURVEY_LINK deprecated_model_name = [ "gemini-1.5-pro-exp-0801", "gemini-1.5-pro-api-0409-preview", "bard-jan-24-gemini-pro", "chatgpt-4o-latest-20240808", "gemini-1.5-pro-exp-0827", "gemini-1.5-flash-exp-0827...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/summarize_cluster.py
fastchat/serve/monitor/summarize_cluster.py
""" Usage: python3 summarize_cluster.py --in results_c20_kmeans_cluster.pkl --model gpt-4 --num-prompts 100 python3 summarize_cluster.py --in results_c20_kmeans_cluster.pkl --model azure-gpt-4-32k --num-prompts 200 """ import argparse import pickle import pandas as pd from fastchat.llm_judge.common import ( chat_...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/deduplication.py
fastchat/serve/monitor/deduplication.py
import os import json import pandas as pd import ast import matplotlib.pyplot as plt from matplotlib import rcParams import argparse import seaborn as sns from tqdm import tqdm import matplotlib.pyplot as plt import numpy as np if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argumen...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/basic_stats.py
fastchat/serve/monitor/basic_stats.py
import argparse import code import datetime import json import os from pytz import timezone import time import pandas as pd # pandas>=2.0.3 import plotly.express as px import plotly.graph_objects as go from tqdm import tqdm NUM_SERVERS = 14 LOG_ROOT_DIR = "~/fastchat_logs" def get_log_files(max_num_files=None): ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/tag_openai_moderation.py
fastchat/serve/monitor/tag_openai_moderation.py
""" Add OpenAI moderation API results to all conversations. """ import argparse from concurrent.futures import ThreadPoolExecutor import json import os import time import openai import requests from tqdm import tqdm API_MAX_RETRY = 16 API_RETRY_SLEEP = 10 API_ERROR_OUTPUT = "$ERROR$" def tag_moderation(text): ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/topic_clustering.py
fastchat/serve/monitor/topic_clustering.py
""" Usage: python3 topic_clustering.py --in arena.json --english-only --min-length 32 python3 topic_clustering.py --in clean_conv_20230809_100k.json --english-only --min-length 32 --max-length 1536 """ import argparse import json import pickle import string import time import numpy as np from sentence_transformers im...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/clean_chat_data.py
fastchat/serve/monitor/clean_chat_data.py
""" Clean chatbot arena chat log. Usage: python3 clean_chat_data.py """ import argparse import json import os import hashlib from pytz import timezone from functools import partial from math import ceil from datetime import datetime, timedelta from tqdm import tqdm import time import multiprocessing as mp from fastch...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/copilot_arena.py
fastchat/serve/monitor/copilot_arena.py
import gradio as gr import pandas as pd import requests import os from fastchat.serve.monitor.monitor import recompute_final_ranking copilot_arena_leaderboard_url = os.getenv("COPILOT_ARENA_LEADERBOARD_URL") def process_copilot_arena_leaderboard(leaderboard): leaderboard = leaderboard.copy().loc[leaderboard["vi...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/monitor.py
fastchat/serve/monitor/monitor.py
""" Live monitor of the website statistics and leaderboard. Dependency: sudo apt install pkg-config libicu-dev pip install pytz gradio gdown plotly polyglot pyicu pycld2 tabulate """ import argparse import ast import json import pickle import os import threading import time import pandas as pd import gradio as gr im...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
true
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/inspect_conv.py
fastchat/serve/monitor/inspect_conv.py
import argparse import code import datetime import json import os from pytz import timezone import time import pandas as pd from tqdm import tqdm def get_log_files(max_num_files=None): dates = [] for month in [4, 5]: for day in range(1, 32): dates.append(f"2023-{month:02d}-{day:02d}") ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/leaderboard_csv_to_html.py
fastchat/serve/monitor/leaderboard_csv_to_html.py
""" Convert a leaderboard csv file to html table used in the blog. Usage: python3 leaderboard_csv_to_html.py --in leaderboard_table_20230619.csv """ import argparse import numpy as np from fastchat.serve.monitor.monitor import load_leaderboard_table_csv def model_hyperlink(model_name, link): return f'<a target...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/dataset_release_scripts/lmsys_chat_1m/upload_hf_dataset.py
fastchat/serve/monitor/dataset_release_scripts/lmsys_chat_1m/upload_hf_dataset.py
""" Upload to huggingface. """ import argparse import json from datasets import Dataset, DatasetDict, load_dataset if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--in-file", type=str, required=True) args = parser.parse_args() objs = json.load(open(args.in_file)) ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/dataset_release_scripts/lmsys_chat_1m/approve_all.py
fastchat/serve/monitor/dataset_release_scripts/lmsys_chat_1m/approve_all.py
import requests headers = {"authorization": "Bearer hf_XXX"} url = "https://huggingface.co/api/datasets/lmsys/lmsys-chat-1m/user-access-request/pending" a = requests.get(url, headers=headers) for u in a.json(): user = u["user"]["user"] url = "https://huggingface.co/api/datasets/lmsys/lmsys-chat-1m/user-acces...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/dataset_release_scripts/lmsys_chat_1m/compute_stats.py
fastchat/serve/monitor/dataset_release_scripts/lmsys_chat_1m/compute_stats.py
""" From colab: https://colab.research.google.com/drive/1oMdw_Lqgmd6DletSOLHsyD-Rc96cRShs?usp=sharing """ import argparse import datetime import json import os from pytz import timezone import time import kaleido import numpy as np import pandas as pd import plotly.express as px import plotly.graph_objects as go from ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/dataset_release_scripts/lmsys_chat_1m/merge_oai_tag.py
fastchat/serve/monitor/dataset_release_scripts/lmsys_chat_1m/merge_oai_tag.py
import argparse import json import time from tqdm import tqdm if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--in-file", type=str, required=True) parser.add_argument("--sample", type=int) args = parser.parse_args() tag_file = "clean_conv_20230809_1.5M_oai_filt...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/dataset_release_scripts/lmsys_chat_1m/final_post_processing.py
fastchat/serve/monitor/dataset_release_scripts/lmsys_chat_1m/final_post_processing.py
import argparse import json from tqdm import tqdm import numpy as np if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--in-file", type=str, required=True) args = parser.parse_args() # Read conversations convs = json.load(open(args.in_file)) print(f"#conv: {l...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/serve/monitor/dataset_release_scripts/lmsys_chat_1m/sample.py
fastchat/serve/monitor/dataset_release_scripts/lmsys_chat_1m/sample.py
""" Count the unique users in a battle log file. Usage: python3 -input in.json --number 1000 """ import argparse import json import random K = 1000 if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--input", type=str) parser.add_argument("--number", type=int, nargs="+") ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false