Views
No views yet
pip install -r requirements.txt/projectnb/vkolagrp/: export TRANSFORMERS_CACHE=/projectnb/vkolagrp/.cache
export HF_HOME=/projectnb/vkolagrp/.cache
export HF_DATASETS_CACHE=/projectnb/vkolagrp/.cache
export TRITON_CACHE_DIR=/projectnb/vkolagrp/triton/.triton/projectnb/vkolagrp/ to your own path. After running the commands, all your Transformers models and datasets will be saved in the paths you defined.python main_small.pypython main_large.py[!IMPORTANT]
After completing training, many LoRA adapters will be saved. By default, themodel_max_lengthwill be set totrain_max_lenin your codes, as seen here. To ensure proper inference with vLLM, open thetokenizer_config.jsonfile in the checkpoint folder and reset themodel_max_lengthto match the original value of your base model.
This step is crucial because the vLLM engine uses the adapter's tokenizer instead of the base model's tokenizer. If not properly adjusted, the vLLM engine may truncate the input based on themodel_max_lengthspecified during training, potentially limiting the model's performance during inference while there are longer inputs.
[!IMPORTANT]
- Due to the suspended development of the AutoGPTQ package, we strongly recommend conducting quantization using the GPTQModel package!
- After completing training, many LoRA adapters will be saved. By default, the
model_max_lengthwill be set totrain_max_lenin your codes, as seen here. To ensure proper inference with vLLM, open thetokenizer_config.jsonfile in the checkpoint folder and reset themodel_max_lengthto match the original value of your base model.
This step is crucial because the vLLM engine uses the adapter's tokenizer instead of the base model's tokenizer. If not properly adjusted, the vLLM engine may truncate the input based on themodel_max_lengthspecified during training, potentially limiting the model's performance during inference while there are longer inputs.
pip install -v gptqmodel --no-build-isolationpython quantization_GPTQModel.py "meta-llama/Llama-3.3-70B-Instruct" "./gptq_model" --bits 4 --group_size 128 --seqlen 2048 --damp 0.01 --desc_act 1 --dtype bfloat16python quantization_HF.py --repo "meta-llama/Meta-Llama-3.1-70B-Instruct" --bits 4 --group_size 128pip install auto-gptq==0.6.0 --no-build-isolation to install the AutoGPTQ.python quantization.py "meta-llama/Meta-Llama-3.1-70B-Instruct" "./gptq_model" --bits 4 --group_size 128 --desc_act 1 --dtype bfloat16 --seqlen 2048 --damp 0.01python upload_quantized_model.py --repo "shuyuej/Llama-3.3-70B-Instruct-GPTQ" --folder_path "./gptq_model"python main_quantization.pyexport VLLM_WORKER_MULTIPROC_METHOD=spawnDirectly answer the best option: instead of Answer: to better guide LLMs to generate the best option
and to easier extract the best option from the responses.1english_prompt = "Directly answer the best option:"
2english_prompt_pubmedqa = "Directly answer yes/no/maybe:"
3hindi_prompt = "सीधे सबसे अच्छे विकल्प के साथ जवाब दें:"
4french_prompt = "Répondez directement avec la meilleure option:"
5spanish_prompt = "Responde directamente con la mejor opción:"
6chinese_prompt = "直接回答最优选项:"--eval_pretrain to indicate whether to evaluate the original pre-trained model.python inference.py --mode small --eval_pretrain True --id 35166 52749 70332 87915[!WARNING]
Please note that OpenAI ChatGPT API is extremely expensive.
Please only use it if you have a budget for it!
python inference.py --mode chatgpt| Language | Dataset | # test examples | # of choices | Link | Ref |
|---|---|---|---|---|---|
| English | MedExpQA | 125 | 5 | Link | Paper |
| MedQA | 1273 | 4 | Link | Paper | |
| MedMCQA | 4183 | 4 | Link | Paper | |
| PubMedQA | 500 | 3 | Link | Paper | |
| MMLU - Anatomy | 135 | 4 | Link | Paper | |
| MMLU - Clinical Knowledge | 265 | 4 | Link | Paper | |
| MMLU - College Biology | 144 | 4 | Link | Paper | |
| MMLU - College Medicine | 173 | 4 | Link | Paper | |
| MMLU - Medical Genetics | 100 | 4 | Link | Paper | |
| MMLU - Professional Medicine | 272 | 4 | Link | Paper | |
| French | MedExpQA | 125 | 5 | Link | Paper |
| MedMCQA | 622 | 5 | Link | Paper | |
| MMLU - Anatomy | 135 | 4 | Link | Paper | |
| MMLU - Clinical Knowledge | 265 | 4 | Link | Paper | |
| MMLU - College Biology | 144 | 4 | Link | Paper | |
| MMLU - College Medicine | 173 | 4 | Link | Paper | |
| MMLU - Medical Genetics | 100 | 4 | Link | Paper | |
| MMLU - Professional Medicine | 272 | 4 | Link | Paper | |
| Spanish | HEAD-QA | 2742 | 4 | Link | Paper |
| MedExpQA | 125 | 5 | Link | Paper | |
| MMLU - Anatomy | 135 | 4 | Link | Paper | |
| MMLU - Clinical Knowledge | 265 | 4 | Link | Paper | |
| MMLU - College Biology | 144 | 4 | Link | Paper | |
| MMLU - College Medicine | 173 | 4 | Link | Paper | |
| MMLU - Medical Genetics | 100 | 4 | Link | Paper | |
| MMLU - Professional Medicine | 272 | 4 | Link | Paper | |
| Chinese | MedQA-MCMLE | 3426 | 4 | Link | Paper |
| CMMLU - Anatomy | 148 | 4 | Link | Paper | |
| CMMLU - Clinical Knowledge | 237 | 4 | Link | Paper | |
| CMMLU - College Medicine | 273 | 4 | Link | Paper | |
| CMMLU - Medical Genetics | 176 | 4 | Link | Paper | |
| CMMLU - Traditional Chinese Medicine | 185 | 4 | Link | Paper | |
| CMMLU - Virology | 169 | 4 | Link | Paper | |
| Hindi | MMLU - Anatomy | 135 | 4 | Link | Paper |
| MMLU - Clinical Knowledge | 265 | 4 | Link | Paper | |
| MMLU - College Biology | 144 | 4 | Link | Paper | |
| MMLU - College Medicine | 173 | 4 | Link | Paper | |
| MMLU - Medical Genetics | 100 | 4 | Link | Paper | |
| MMLU - Professional Medicine | 272 | 4 | Link | Paper |
http://localhost:8000.1vllm serve shuyuej/Llama-3.3-70B-Instruct-GPTQ \
2 --quantization gptq \
3 --trust-remote-code \
4 --dtype float16 \
5 --max-model-len 4096 \
6 --distributed-executor-backend mp \
7 --pipeline-parallel-size 4 \
8 --api-key token-abc123Engine Arguments.1git lfs install
2git clone https://huggingface.co/shuyuej/Public-Shared-LoRA-for-Llama-3.3-70B-Instruct-GPTQ[!NOTE]
To download the safetensors usinggit clone, ensure you initialize Git LFS withgit lfs install. If you encounter the error "git: 'lfs' is not a git command," refer to this StackOverflow issue for troubleshooting. Alternatively, you can manually download thegit-lfs:
$ wget https://github.com/git-lfs/git-lfs/releases/download/v3.2.0/git-lfs-linux-amd64-v3.2.0.tar.gz
$ tar -xzf git-lfs-linux-amd64-v3.2.0.tar.gz
Download the LoRA model from Huggig Face to your folder:
$ /git-lfs-3.2.0/git-lfs install
$ /git-lfs-3.2.0/git-lfs clone https://huggingface.co/shuyuej/Public-Shared-LoRA-for-Llama-3.3-70B-Instruct-GPTQ--enable-lora flag and specifying --lora-modules:1vllm serve shuyuej/Llama-3.3-70B-Instruct-GPTQ \
2 --quantization gptq \
3 --trust-remote-code \
4 --dtype float16 \
5 --max-model-len 4096 \
6 --distributed-executor-backend mp \
7 --pipeline-parallel-size 4 \
8 --api-key token-abc123 \
9 --enable-lora \
10 --lora-modules adapter=Public-Shared-LoRA-for-Llama-3.3-70B-Instruct-GPTQ1#!/usr/bin/env python
2# coding=utf-8
3
4import time
5import asyncio
6
7from openai import AsyncOpenAI
8
9# Our system prompt
10SYSTEM_PROMPT = (
11 "I am PodGPT, a large language model developed by the Kolachalama Lab in Boston, "
12 "specializing in science, technology, engineering, mathematics, and medicine "
13 "(STEMM)-related research and education, powered by podcast audio.\n"
14 "I provide information based on established scientific knowledge but must not offer "
15 "personal medical advice or present myself as a licensed medical professional.\n"
16 "I will maintain a consistently professional and informative tone, avoiding humor, "
17 "sarcasm, and pop culture references.\n"
18 "I will prioritize factual accuracy and clarity while ensuring my responses are "
19 "educational and non-harmful, adhering to the principle of 'do no harm'.\n"
20 "My responses are for informational purposes only and should not be considered a "
21 "substitute for professional consultation."
22)
23
24# Initialize the AsyncOpenAI client
25client = AsyncOpenAI(
26 base_url="http://localhost:8000/v1",
27 api_key="token-abc123",
28)
29
30
31async def main(message):
32 """
33 Streaming responses with async usage and "await" with each API call:
34 Reference: https://github.com/openai/openai-python?tab=readme-ov-file#streaming-responses
35 :param message: The user query
36 """
37 start_time = time.time()
38 stream = await client.chat.completions.create(
39 model="shuyuej/Llama-3.3-70B-Instruct-GPTQ",
40 messages=[
41 {
42 "role": "system",
43 "content": SYSTEM_PROMPT,
44 },
45 {
46 "role": "user",
47 "content": message,
48 }
49 ],
50 max_tokens=2048,
51 temperature=0.2,
52 top_p=1,
53 stream=True,
54 extra_body={
55 "ignore_eos": False,
56 # https://huggingface.co/shuyuej/Llama-3.3-70B-Instruct-GPTQ/raw/main/config.json#L10-L14
57 "stop_token_ids": [128001, 128008, 128009],
58 },
59 )
60
61 print(f"The user's query is\n {message}\n ")
62 print("The model's response is\n")
63 async for chunk in stream:
64 print(chunk.choices[0].delta.content or "", end="")
65 print(f"\nInference time: {time.time() - start_time:.2f} seconds\n")
66 print("=" * 100)
67
68
69if __name__ == "__main__":
70 # Some random user queries
71 prompts = [
72 "Hello, my name is",
73 "The president of the United States is",
74 "The capital of France is",
75 "The future of AI is",
76 "Can you tell me more about Bruce Lee?",
77 "What are the differences between DNA and RNA?",
78 "What is dementia and Alzheimer's disease?",
79 "Tell me the differences between Alzheimer's disease and dementia"
80 ]
81
82 # Conduct model inference
83 for message in prompts:
84 asyncio.run(main(message=message))
85 print("\n\n")python audio2text.pypython database_builder.pypython upload_model.py --repo "shuyuej/DrGemma2B" --id 35166 52749 70332 87915python download_model.py --repo "shuyuej/DrGemma2B" --repo_type "model" --save_dir "./save_folder"1├── config_benchmark.yml
2├── config_chatgpt.yml
3├── config_large.yml
4├── config_quantization.yml
5├── config_small.yml
6├── main_large.py
7├── main_quantization.py
8├── main_small.py
9├── lib
10│ ├── data_manager.py
11│ ├── evaluation.py
12│ ├── model_loader_large.py
13│ ├── model_loader_quantization.py
14│ └── model_loader_small.py
15├── inference
16│ └── inference.py
17├── quantization
18│ ├── model_split.py
19│ ├── quantization.py
20│ ├── quantization_HF.py
21│ ├── quantization_GPTQModel.py
22│ └── upload_quantized_model.py
23├── download_files
24│ ├── download_model_from_hf.py
25│ └── download_model_to_local.py
26├── requirements.txt
27├── benchmark
28├── results
29├── save_folder
30├── scripts
31│ ├── audio2text.py
32│ ├── database_builder.py
33│ ├── download_model.py
34│ ├── deployment.py
35│ └── upload_model.py
36└── utils
37 ├── answer_utils.py
38 ├── benchmark_utils.py
39 ├── eval_utils.py
40 └── utils.py1@article {Jia2024podgpt,
2 author = {Jia S, Bit S, Searls E, Lauber MV, Claus LA, Fan P, Jasodanand VH, Veerapaneni D, Wang WM, Au R, Kolachalama VB.},
3 title = {{PodGPT}: An audio-augmented large language model for research and education},
4 year = {2025},
5 doi = {[10.1101/2024.07.11.24310304](https://doi.org/10.1038/s44385-025-00022-0)},
6 journal = {npj Biomedical Innovations},
7 volume = 2,
8 number = 26,
9}