Upload folder using huggingface_hub
Browse files- .ipynb_checkpoints/Experimenting-checkpoint.ipynb +276 -0
- .ipynb_checkpoints/ImportCommands-checkpoint.txt +0 -0
- .ipynb_checkpoints/README-checkpoint.md +6 -0
- .ipynb_checkpoints/app-checkpoint.py +100 -0
- .ipynb_checkpoints/baseInference-checkpoint.py +66 -0
- .ipynb_checkpoints/finetune-checkpoint.py +147 -0
- .ipynb_checkpoints/mergePeftWithBaseModel-checkpoint.py +33 -0
- .ipynb_checkpoints/requiretments-checkpoint.txt +8 -0
- .ipynb_checkpoints/uploadToHub-checkpoint.py +42 -0
- Experimenting.ipynb +659 -0
- ImportCommands.txt +1 -0
- README.md +2 -8
- app.py +100 -0
- baseInference.py +66 -0
- finetune.py +147 -0
- flagged/log.csv +2 -0
- mergePeftWithBaseModel.py +33 -0
- outputs/checkpoint-10/README.md +204 -0
- outputs/checkpoint-10/adapter_config.json +32 -0
- outputs/checkpoint-10/adapter_model.safetensors +3 -0
- outputs/checkpoint-10/optimizer.pt +3 -0
- outputs/checkpoint-10/rng_state.pth +3 -0
- outputs/checkpoint-10/scheduler.pt +3 -0
- outputs/checkpoint-10/special_tokens_map.json +24 -0
- outputs/checkpoint-10/tokenizer.json +0 -0
- outputs/checkpoint-10/tokenizer_config.json +42 -0
- outputs/checkpoint-10/trainer_state.json +81 -0
- outputs/checkpoint-10/training_args.bin +3 -0
- outputs/checkpoint-100/README.md +204 -0
- outputs/checkpoint-100/adapter_config.json +32 -0
- outputs/checkpoint-100/adapter_model.safetensors +3 -0
- outputs/checkpoint-100/optimizer.pt +3 -0
- outputs/checkpoint-100/rng_state.pth +3 -0
- outputs/checkpoint-100/scheduler.pt +3 -0
- outputs/checkpoint-100/special_tokens_map.json +24 -0
- outputs/checkpoint-100/tokenizer.json +0 -0
- outputs/checkpoint-100/tokenizer_config.json +42 -0
- outputs/checkpoint-100/trainer_state.json +621 -0
- outputs/checkpoint-100/training_args.bin +3 -0
- outputs/merged/.ipynb_checkpoints/config-checkpoint.json +38 -0
- outputs/merged/config.json +38 -0
- outputs/merged/generation_config.json +6 -0
- outputs/merged/model.safetensors +3 -0
- outputs/merged/special_tokens_map.json +23 -0
- outputs/merged/tokenizer.json +0 -0
- outputs/merged/tokenizer_config.json +42 -0
- requiretments.txt +8 -0
- uploadToHub.py +42 -0
.ipynb_checkpoints/Experimenting-checkpoint.ipynb
ADDED
@@ -0,0 +1,276 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 7,
|
6 |
+
"id": "e119e71a-f88a-4d5c-90fb-e60b84c4f42c",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"from transformers import (\n",
|
11 |
+
" AutoModelForCausalLM,\n",
|
12 |
+
" AutoTokenizer,\n",
|
13 |
+
" AutoTokenizer,\n",
|
14 |
+
")\n",
|
15 |
+
"from peft import PeftModel, PeftConfig\n",
|
16 |
+
"import torch\n",
|
17 |
+
"\n",
|
18 |
+
"d_map = {\"\": torch.cuda.current_device()} if torch.cuda.is_available() else None\n",
|
19 |
+
"local_model_path = \"outputs/checkpoint-100\" # Path to the combined weights"
|
20 |
+
]
|
21 |
+
},
|
22 |
+
{
|
23 |
+
"cell_type": "code",
|
24 |
+
"execution_count": 23,
|
25 |
+
"id": "ba591ab9-5029-46e8-b9a9-428de3896e62",
|
26 |
+
"metadata": {},
|
27 |
+
"outputs": [
|
28 |
+
{
|
29 |
+
"data": {
|
30 |
+
"application/vnd.jupyter.widget-view+json": {
|
31 |
+
"model_id": "ee8258a57258444baf79b52af6444788",
|
32 |
+
"version_major": 2,
|
33 |
+
"version_minor": 0
|
34 |
+
},
|
35 |
+
"text/plain": [
|
36 |
+
"Loading checkpoint shards: 0%| | 0/2 [00:00<?, ?it/s]"
|
37 |
+
]
|
38 |
+
},
|
39 |
+
"metadata": {},
|
40 |
+
"output_type": "display_data"
|
41 |
+
},
|
42 |
+
{
|
43 |
+
"ename": "OutOfMemoryError",
|
44 |
+
"evalue": "CUDA out of memory. Tried to allocate 112.00 MiB. GPU 0 has a total capacty of 23.68 GiB of which 79.62 MiB is free. Process 657358 has 23.59 GiB memory in use. Of the allocated memory 23.00 GiB is allocated by PyTorch, and 357.02 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF",
|
45 |
+
"output_type": "error",
|
46 |
+
"traceback": [
|
47 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
48 |
+
"\u001b[0;31mOutOfMemoryError\u001b[0m Traceback (most recent call last)",
|
49 |
+
"Cell \u001b[0;32mIn[23], line 4\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Loading the base Model\u001b[39;00m\n\u001b[1;32m 2\u001b[0m config \u001b[38;5;241m=\u001b[39m PeftConfig\u001b[38;5;241m.\u001b[39mfrom_pretrained(local_model_path)\n\u001b[0;32m----> 4\u001b[0m model \u001b[38;5;241m=\u001b[39m \u001b[43mAutoModelForCausalLM\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfrom_pretrained\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 5\u001b[0m \u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mbase_model_name_or_path\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\n\u001b[1;32m 6\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_dict\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 7\u001b[0m \u001b[43m \u001b[49m\u001b[43mtorch_dtype\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtorch\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfloat16\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 8\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;66;43;03m# load_in_4bit=True, \u001b[39;49;00m\n\u001b[1;32m 9\u001b[0m \u001b[43m \u001b[49m\u001b[43mdevice_map\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43md_map\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 10\u001b[0m \u001b[43m)\u001b[49m\n\u001b[1;32m 11\u001b[0m tokenizer \u001b[38;5;241m=\u001b[39m AutoTokenizer\u001b[38;5;241m.\u001b[39mfrom_pretrained(config\u001b[38;5;241m.\u001b[39mbase_model_name_or_path)\n",
|
50 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/transformers/models/auto/auto_factory.py:566\u001b[0m, in \u001b[0;36m_BaseAutoModelClass.from_pretrained\u001b[0;34m(cls, pretrained_model_name_or_path, *model_args, **kwargs)\u001b[0m\n\u001b[1;32m 564\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28mtype\u001b[39m(config) \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mcls\u001b[39m\u001b[38;5;241m.\u001b[39m_model_mapping\u001b[38;5;241m.\u001b[39mkeys():\n\u001b[1;32m 565\u001b[0m model_class \u001b[38;5;241m=\u001b[39m _get_model_class(config, \u001b[38;5;28mcls\u001b[39m\u001b[38;5;241m.\u001b[39m_model_mapping)\n\u001b[0;32m--> 566\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mmodel_class\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfrom_pretrained\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 567\u001b[0m \u001b[43m \u001b[49m\u001b[43mpretrained_model_name_or_path\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mmodel_args\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconfig\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mhub_kwargs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\n\u001b[1;32m 568\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 569\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[1;32m 570\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mUnrecognized configuration class \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mconfig\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__class__\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m for this kind of AutoModel: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mcls\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 571\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mModel type should be one of \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m, \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(c\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mfor\u001b[39;00m\u001b[38;5;250m \u001b[39mc\u001b[38;5;250m \u001b[39m\u001b[38;5;129;01min\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28mcls\u001b[39m\u001b[38;5;241m.\u001b[39m_model_mapping\u001b[38;5;241m.\u001b[39mkeys())\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 572\u001b[0m )\n",
|
51 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/transformers/modeling_utils.py:3850\u001b[0m, in \u001b[0;36mPreTrainedModel.from_pretrained\u001b[0;34m(cls, pretrained_model_name_or_path, config, cache_dir, ignore_mismatched_sizes, force_download, local_files_only, token, revision, use_safetensors, *model_args, **kwargs)\u001b[0m\n\u001b[1;32m 3841\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m dtype_orig \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 3842\u001b[0m torch\u001b[38;5;241m.\u001b[39mset_default_dtype(dtype_orig)\n\u001b[1;32m 3843\u001b[0m (\n\u001b[1;32m 3844\u001b[0m model,\n\u001b[1;32m 3845\u001b[0m missing_keys,\n\u001b[1;32m 3846\u001b[0m unexpected_keys,\n\u001b[1;32m 3847\u001b[0m mismatched_keys,\n\u001b[1;32m 3848\u001b[0m offload_index,\n\u001b[1;32m 3849\u001b[0m error_msgs,\n\u001b[0;32m-> 3850\u001b[0m ) \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mcls\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_load_pretrained_model\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 3851\u001b[0m \u001b[43m \u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3852\u001b[0m \u001b[43m \u001b[49m\u001b[43mstate_dict\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3853\u001b[0m \u001b[43m \u001b[49m\u001b[43mloaded_state_dict_keys\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# XXX: rename?\u001b[39;49;00m\n\u001b[1;32m 3854\u001b[0m \u001b[43m \u001b[49m\u001b[43mresolved_archive_file\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3855\u001b[0m \u001b[43m \u001b[49m\u001b[43mpretrained_model_name_or_path\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3856\u001b[0m \u001b[43m \u001b[49m\u001b[43mignore_mismatched_sizes\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mignore_mismatched_sizes\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3857\u001b[0m \u001b[43m \u001b[49m\u001b[43msharded_metadata\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msharded_metadata\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3858\u001b[0m \u001b[43m \u001b[49m\u001b[43m_fast_init\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m_fast_init\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3859\u001b[0m \u001b[43m \u001b[49m\u001b[43mlow_cpu_mem_usage\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mlow_cpu_mem_usage\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3860\u001b[0m \u001b[43m \u001b[49m\u001b[43mdevice_map\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdevice_map\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3861\u001b[0m \u001b[43m \u001b[49m\u001b[43moffload_folder\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43moffload_folder\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3862\u001b[0m \u001b[43m \u001b[49m\u001b[43moffload_state_dict\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43moffload_state_dict\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3863\u001b[0m \u001b[43m \u001b[49m\u001b[43mdtype\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtorch_dtype\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3864\u001b[0m \u001b[43m \u001b[49m\u001b[43mis_quantized\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mgetattr\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mquantization_method\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m==\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mQuantizationMethod\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mBITS_AND_BYTES\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3865\u001b[0m \u001b[43m \u001b[49m\u001b[43mkeep_in_fp32_modules\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mkeep_in_fp32_modules\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3866\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 3868\u001b[0m model\u001b[38;5;241m.\u001b[39mis_loaded_in_4bit \u001b[38;5;241m=\u001b[39m load_in_4bit\n\u001b[1;32m 3869\u001b[0m model\u001b[38;5;241m.\u001b[39mis_loaded_in_8bit \u001b[38;5;241m=\u001b[39m load_in_8bit\n",
|
52 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/transformers/modeling_utils.py:4284\u001b[0m, in \u001b[0;36mPreTrainedModel._load_pretrained_model\u001b[0;34m(cls, model, state_dict, loaded_keys, resolved_archive_file, pretrained_model_name_or_path, ignore_mismatched_sizes, sharded_metadata, _fast_init, low_cpu_mem_usage, device_map, offload_folder, offload_state_dict, dtype, is_quantized, keep_in_fp32_modules)\u001b[0m\n\u001b[1;32m 4280\u001b[0m set_module_quantized_tensor_to_device(\n\u001b[1;32m 4281\u001b[0m model_to_load, key, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcpu\u001b[39m\u001b[38;5;124m\"\u001b[39m, torch\u001b[38;5;241m.\u001b[39mempty(\u001b[38;5;241m*\u001b[39mparam\u001b[38;5;241m.\u001b[39msize(), dtype\u001b[38;5;241m=\u001b[39mdtype)\n\u001b[1;32m 4282\u001b[0m )\n\u001b[1;32m 4283\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m-> 4284\u001b[0m new_error_msgs, offload_index, state_dict_index \u001b[38;5;241m=\u001b[39m \u001b[43m_load_state_dict_into_meta_model\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 4285\u001b[0m \u001b[43m \u001b[49m\u001b[43mmodel_to_load\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4286\u001b[0m \u001b[43m \u001b[49m\u001b[43mstate_dict\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4287\u001b[0m \u001b[43m \u001b[49m\u001b[43mloaded_keys\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4288\u001b[0m \u001b[43m \u001b[49m\u001b[43mstart_prefix\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4289\u001b[0m \u001b[43m \u001b[49m\u001b[43mexpected_keys\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4290\u001b[0m \u001b[43m \u001b[49m\u001b[43mdevice_map\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdevice_map\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4291\u001b[0m \u001b[43m \u001b[49m\u001b[43moffload_folder\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43moffload_folder\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4292\u001b[0m \u001b[43m \u001b[49m\u001b[43moffload_index\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43moffload_index\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4293\u001b[0m \u001b[43m \u001b[49m\u001b[43mstate_dict_folder\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstate_dict_folder\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4294\u001b[0m \u001b[43m \u001b[49m\u001b[43mstate_dict_index\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstate_dict_index\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4295\u001b[0m \u001b[43m \u001b[49m\u001b[43mdtype\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdtype\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4296\u001b[0m \u001b[43m \u001b[49m\u001b[43mis_quantized\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mis_quantized\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4297\u001b[0m \u001b[43m \u001b[49m\u001b[43mis_safetensors\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mis_safetensors\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4298\u001b[0m \u001b[43m \u001b[49m\u001b[43mkeep_in_fp32_modules\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mkeep_in_fp32_modules\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4299\u001b[0m \u001b[43m \u001b[49m\u001b[43munexpected_keys\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43munexpected_keys\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4300\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 4301\u001b[0m error_msgs \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m new_error_msgs\n\u001b[1;32m 4302\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n",
|
53 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/transformers/modeling_utils.py:805\u001b[0m, in \u001b[0;36m_load_state_dict_into_meta_model\u001b[0;34m(model, state_dict, loaded_state_dict_keys, start_prefix, expected_keys, device_map, offload_folder, offload_index, state_dict_folder, state_dict_index, dtype, is_quantized, is_safetensors, keep_in_fp32_modules, unexpected_keys)\u001b[0m\n\u001b[1;32m 802\u001b[0m state_dict_index \u001b[38;5;241m=\u001b[39m offload_weight(param, param_name, state_dict_folder, state_dict_index)\n\u001b[1;32m 803\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m is_quantized:\n\u001b[1;32m 804\u001b[0m \u001b[38;5;66;03m# For backward compatibility with older versions of `accelerate`\u001b[39;00m\n\u001b[0;32m--> 805\u001b[0m \u001b[43mset_module_tensor_to_device\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparam_name\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparam_device\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mset_module_kwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 806\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m param\u001b[38;5;241m.\u001b[39mdtype \u001b[38;5;129;01min\u001b[39;00m (torch\u001b[38;5;241m.\u001b[39mint8, torch\u001b[38;5;241m.\u001b[39muint8) \u001b[38;5;129;01mand\u001b[39;00m is_quantized:\n\u001b[1;32m 807\u001b[0m \u001b[38;5;66;03m# handling newly quantized weights and loaded quantized weights\u001b[39;00m\n\u001b[1;32m 808\u001b[0m \u001b[38;5;66;03m# edit the param.dtype restrictions and is_quantized condition when adding new quant methods\u001b[39;00m\n\u001b[1;32m 809\u001b[0m quantized_stats \u001b[38;5;241m=\u001b[39m {}\n",
|
54 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/accelerate/utils/modeling.py:347\u001b[0m, in \u001b[0;36mset_module_tensor_to_device\u001b[0;34m(module, tensor_name, device, value, dtype, fp16_statistics)\u001b[0m\n\u001b[1;32m 345\u001b[0m module\u001b[38;5;241m.\u001b[39m_parameters[tensor_name] \u001b[38;5;241m=\u001b[39m param_cls(new_value, requires_grad\u001b[38;5;241m=\u001b[39mold_value\u001b[38;5;241m.\u001b[39mrequires_grad)\n\u001b[1;32m 346\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(value, torch\u001b[38;5;241m.\u001b[39mTensor):\n\u001b[0;32m--> 347\u001b[0m new_value \u001b[38;5;241m=\u001b[39m \u001b[43mvalue\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mto\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdevice\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 348\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 349\u001b[0m new_value \u001b[38;5;241m=\u001b[39m torch\u001b[38;5;241m.\u001b[39mtensor(value, device\u001b[38;5;241m=\u001b[39mdevice)\n",
|
55 |
+
"\u001b[0;31mOutOfMemoryError\u001b[0m: CUDA out of memory. Tried to allocate 112.00 MiB. GPU 0 has a total capacty of 23.68 GiB of which 79.62 MiB is free. Process 657358 has 23.59 GiB memory in use. Of the allocated memory 23.00 GiB is allocated by PyTorch, and 357.02 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF"
|
56 |
+
]
|
57 |
+
}
|
58 |
+
],
|
59 |
+
"source": [
|
60 |
+
"# Loading the base Model\n",
|
61 |
+
"config = PeftConfig.from_pretrained(local_model_path)\n",
|
62 |
+
"\n",
|
63 |
+
"model = AutoModelForCausalLM.from_pretrained(\n",
|
64 |
+
" config.base_model_name_or_path, \n",
|
65 |
+
" return_dict=True,\n",
|
66 |
+
" torch_dtype=torch.float16,\n",
|
67 |
+
" # load_in_4bit=True, \n",
|
68 |
+
" device_map=d_map,\n",
|
69 |
+
")\n",
|
70 |
+
"tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)"
|
71 |
+
]
|
72 |
+
},
|
73 |
+
{
|
74 |
+
"cell_type": "code",
|
75 |
+
"execution_count": 9,
|
76 |
+
"id": "c1d36c14-0bfc-4215-8576-bb390a3a6114",
|
77 |
+
"metadata": {},
|
78 |
+
"outputs": [],
|
79 |
+
"source": [
|
80 |
+
"# load the base model with the Lora model\n",
|
81 |
+
"model = PeftModel.from_pretrained(model, local_model_path)"
|
82 |
+
]
|
83 |
+
},
|
84 |
+
{
|
85 |
+
"cell_type": "code",
|
86 |
+
"execution_count": 18,
|
87 |
+
"id": "72cdeaa8-4b0c-45d0-a585-2f86626e280b",
|
88 |
+
"metadata": {},
|
89 |
+
"outputs": [],
|
90 |
+
"source": [
|
91 |
+
"# model.eval()"
|
92 |
+
]
|
93 |
+
},
|
94 |
+
{
|
95 |
+
"cell_type": "code",
|
96 |
+
"execution_count": 21,
|
97 |
+
"id": "09fa4575-0dec-4e62-a43f-77e57f68c4a9",
|
98 |
+
"metadata": {},
|
99 |
+
"outputs": [],
|
100 |
+
"source": [
|
101 |
+
"def inferance(query: str, model, tokenizer, temp = 1.0, limit = 200) -> str:\n",
|
102 |
+
" device = d_map\n",
|
103 |
+
"\n",
|
104 |
+
" prompt_template = \"\"\"\n",
|
105 |
+
" Below is an instruction that describes a task. Write a response that appropriately completes the request.\n",
|
106 |
+
" ### Question:\n",
|
107 |
+
" {query}\n",
|
108 |
+
"\n",
|
109 |
+
" ### Answer:\n",
|
110 |
+
" \"\"\"\n",
|
111 |
+
" prompt = prompt_template.format(query=query)\n",
|
112 |
+
"\n",
|
113 |
+
" encodeds = tokenizer(prompt, return_tensors=\"pt\", add_special_tokens=True)\n",
|
114 |
+
"\n",
|
115 |
+
" model_inputs = encodeds.to(device)\n",
|
116 |
+
"\n",
|
117 |
+
" generated_ids = model.generate(**model_inputs, max_new_tokens=int(limit), temperature=temp, do_sample=True, pad_token_id=tokenizer.eos_token_id)\n",
|
118 |
+
" decoded = tokenizer.batch_decode(generated_ids)\n",
|
119 |
+
" return (decoded[0])"
|
120 |
+
]
|
121 |
+
},
|
122 |
+
{
|
123 |
+
"cell_type": "code",
|
124 |
+
"execution_count": 22,
|
125 |
+
"id": "ba47700b-0787-4677-a5a1-c1a1b4063fe2",
|
126 |
+
"metadata": {},
|
127 |
+
"outputs": [
|
128 |
+
{
|
129 |
+
"name": "stdout",
|
130 |
+
"output_type": "stream",
|
131 |
+
"text": [
|
132 |
+
"Running on local URL: http://127.0.0.1:7862\n",
|
133 |
+
"Running on public URL: https://f4d39c90e01dcf849c.gradio.live\n",
|
134 |
+
"\n",
|
135 |
+
"This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
|
136 |
+
]
|
137 |
+
},
|
138 |
+
{
|
139 |
+
"data": {
|
140 |
+
"text/html": [
|
141 |
+
"<div><iframe src=\"https://f4d39c90e01dcf849c.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
142 |
+
],
|
143 |
+
"text/plain": [
|
144 |
+
"<IPython.core.display.HTML object>"
|
145 |
+
]
|
146 |
+
},
|
147 |
+
"metadata": {},
|
148 |
+
"output_type": "display_data"
|
149 |
+
},
|
150 |
+
{
|
151 |
+
"data": {
|
152 |
+
"text/plain": []
|
153 |
+
},
|
154 |
+
"execution_count": 22,
|
155 |
+
"metadata": {},
|
156 |
+
"output_type": "execute_result"
|
157 |
+
},
|
158 |
+
{
|
159 |
+
"name": "stderr",
|
160 |
+
"output_type": "stream",
|
161 |
+
"text": [
|
162 |
+
"Attempting to cast a BatchEncoding to type {'': 0}. This is not supported.\n",
|
163 |
+
"/usr/local/lib/python3.10/dist-packages/transformers/generation/utils.py:1413: UserWarning: You are calling .generate() with the `input_ids` being on a device type different than your model's device. `input_ids` is on cpu, whereas the model is on cuda. You may experience unexpected behaviors or slower generation. Please make sure that you have put `input_ids` to the correct device by calling for example input_ids = input_ids.to('cuda') before running `.generate()`.\n",
|
164 |
+
" warnings.warn(\n",
|
165 |
+
"Traceback (most recent call last):\n",
|
166 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/queueing.py\", line 495, in call_prediction\n",
|
167 |
+
" output = await route_utils.call_process_api(\n",
|
168 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py\", line 230, in call_process_api\n",
|
169 |
+
" output = await app.get_blocks().process_api(\n",
|
170 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/blocks.py\", line 1590, in process_api\n",
|
171 |
+
" result = await self.call_function(\n",
|
172 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/blocks.py\", line 1176, in call_function\n",
|
173 |
+
" prediction = await anyio.to_thread.run_sync(\n",
|
174 |
+
" File \"/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py\", line 33, in run_sync\n",
|
175 |
+
" return await get_async_backend().run_sync_in_worker_thread(\n",
|
176 |
+
" File \"/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py\", line 2106, in run_sync_in_worker_thread\n",
|
177 |
+
" return await future\n",
|
178 |
+
" File \"/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py\", line 833, in run\n",
|
179 |
+
" result = context.run(func, *args)\n",
|
180 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/utils.py\", line 678, in wrapper\n",
|
181 |
+
" response = f(*args, **kwargs)\n",
|
182 |
+
" File \"/tmp/ipykernel_812/3792119410.py\", line 5, in predict\n",
|
183 |
+
" out = inferance(prompt, model, tokenizer, temp = 1.0, limit = 200)\n",
|
184 |
+
" File \"/tmp/ipykernel_812/3078938966.py\", line 17, in inferance\n",
|
185 |
+
" generated_ids = model.generate(**model_inputs, max_new_tokens=int(limit), temperature=temp, do_sample=True, pad_token_id=tokenizer.eos_token_id)\n",
|
186 |
+
" File \"/usr/local/lib/python3.10/dist-packages/peft/peft_model.py\", line 1140, in generate\n",
|
187 |
+
" outputs = self.base_model.generate(*args, **kwargs)\n",
|
188 |
+
" File \"/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py\", line 115, in decorate_context\n",
|
189 |
+
" return func(*args, **kwargs)\n",
|
190 |
+
" File \"/usr/local/lib/python3.10/dist-packages/transformers/generation/utils.py\", line 1525, in generate\n",
|
191 |
+
" return self.sample(\n",
|
192 |
+
" File \"/usr/local/lib/python3.10/dist-packages/transformers/generation/utils.py\", line 2622, in sample\n",
|
193 |
+
" outputs = self(\n",
|
194 |
+
" File \"/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py\", line 1518, in _wrapped_call_impl\n",
|
195 |
+
" return self._call_impl(*args, **kwargs)\n",
|
196 |
+
" File \"/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py\", line 1527, in _call_impl\n",
|
197 |
+
" return forward_call(*args, **kwargs)\n",
|
198 |
+
" File \"/usr/local/lib/python3.10/dist-packages/transformers/models/mistral/modeling_mistral.py\", line 1154, in forward\n",
|
199 |
+
" outputs = self.model(\n",
|
200 |
+
" File \"/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py\", line 1518, in _wrapped_call_impl\n",
|
201 |
+
" return self._call_impl(*args, **kwargs)\n",
|
202 |
+
" File \"/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py\", line 1527, in _call_impl\n",
|
203 |
+
" return forward_call(*args, **kwargs)\n",
|
204 |
+
" File \"/usr/local/lib/python3.10/dist-packages/transformers/models/mistral/modeling_mistral.py\", line 984, in forward\n",
|
205 |
+
" inputs_embeds = self.embed_tokens(input_ids)\n",
|
206 |
+
" File \"/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py\", line 1518, in _wrapped_call_impl\n",
|
207 |
+
" return self._call_impl(*args, **kwargs)\n",
|
208 |
+
" File \"/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py\", line 1527, in _call_impl\n",
|
209 |
+
" return forward_call(*args, **kwargs)\n",
|
210 |
+
" File \"/usr/local/lib/python3.10/dist-packages/torch/nn/modules/sparse.py\", line 162, in forward\n",
|
211 |
+
" return F.embedding(\n",
|
212 |
+
" File \"/usr/local/lib/python3.10/dist-packages/torch/nn/functional.py\", line 2233, in embedding\n",
|
213 |
+
" return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)\n",
|
214 |
+
"RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument index in method wrapper_CUDA__index_select)\n"
|
215 |
+
]
|
216 |
+
}
|
217 |
+
],
|
218 |
+
"source": [
|
219 |
+
"import gradio as gr\n",
|
220 |
+
"\n",
|
221 |
+
"def predict(temp, limit, text):\n",
|
222 |
+
" prompt = text\n",
|
223 |
+
" out = inferance(prompt, model, tokenizer, temp = 1.0, limit = 200)\n",
|
224 |
+
" return out\n",
|
225 |
+
"\n",
|
226 |
+
"pred = gr.Interface(\n",
|
227 |
+
" predict,\n",
|
228 |
+
" inputs=[\n",
|
229 |
+
" gr.Slider(0.001, 10, value=0.1, label=\"Temperature\"),\n",
|
230 |
+
" gr.Slider(1, 1024, value=128, label=\"Token Limit\"),\n",
|
231 |
+
" gr.Textbox(\n",
|
232 |
+
" label=\"Input\",\n",
|
233 |
+
" lines=1,\n",
|
234 |
+
" value=\"#### Human: What's the capital of Australia?#### Assistant: \",\n",
|
235 |
+
" ),\n",
|
236 |
+
" ],\n",
|
237 |
+
" outputs='text',\n",
|
238 |
+
")\n",
|
239 |
+
"\n",
|
240 |
+
"pred.launch(share=True)"
|
241 |
+
]
|
242 |
+
},
|
243 |
+
{
|
244 |
+
"cell_type": "code",
|
245 |
+
"execution_count": null,
|
246 |
+
"id": "62622184-9d02-4bd0-8c4e-d6775ce20f75",
|
247 |
+
"metadata": {},
|
248 |
+
"outputs": [],
|
249 |
+
"source": [
|
250 |
+
"###some factors to try\n",
|
251 |
+
"from_pt=True"
|
252 |
+
]
|
253 |
+
}
|
254 |
+
],
|
255 |
+
"metadata": {
|
256 |
+
"kernelspec": {
|
257 |
+
"display_name": "Python 3 (ipykernel)",
|
258 |
+
"language": "python",
|
259 |
+
"name": "python3"
|
260 |
+
},
|
261 |
+
"language_info": {
|
262 |
+
"codemirror_mode": {
|
263 |
+
"name": "ipython",
|
264 |
+
"version": 3
|
265 |
+
},
|
266 |
+
"file_extension": ".py",
|
267 |
+
"mimetype": "text/x-python",
|
268 |
+
"name": "python",
|
269 |
+
"nbconvert_exporter": "python",
|
270 |
+
"pygments_lexer": "ipython3",
|
271 |
+
"version": "3.10.12"
|
272 |
+
}
|
273 |
+
},
|
274 |
+
"nbformat": 4,
|
275 |
+
"nbformat_minor": 5
|
276 |
+
}
|
.ipynb_checkpoints/ImportCommands-checkpoint.txt
ADDED
File without changes
|
.ipynb_checkpoints/README-checkpoint.md
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: finance
|
3 |
+
app_file: app.py
|
4 |
+
sdk: gradio
|
5 |
+
sdk_version: 4.17.0
|
6 |
+
---
|
.ipynb_checkpoints/app-checkpoint.py
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import (
|
2 |
+
AutoModelForCausalLM,
|
3 |
+
AutoTokenizer,
|
4 |
+
AutoTokenizer,
|
5 |
+
)
|
6 |
+
from peft import PeftModel, PeftConfig
|
7 |
+
import torch
|
8 |
+
import gradio as gr
|
9 |
+
|
10 |
+
d_map = {"": torch.cuda.current_device()} if torch.cuda.is_available() else None
|
11 |
+
local_model_path = "outputs/checkpoint-100" # Path to the combined weights
|
12 |
+
|
13 |
+
# Loading the base Model
|
14 |
+
config = PeftConfig.from_pretrained(local_model_path)
|
15 |
+
|
16 |
+
model = AutoModelForCausalLM.from_pretrained(
|
17 |
+
config.base_model_name_or_path,
|
18 |
+
return_dict=True,
|
19 |
+
torch_dtype=torch.float16,
|
20 |
+
device_map=d_map,
|
21 |
+
)
|
22 |
+
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path, trust_remote_code=True)
|
23 |
+
|
24 |
+
# load the base model with the Lora model
|
25 |
+
mergedModel = PeftModel.from_pretrained(model, local_model_path)
|
26 |
+
# model = model.merge_and_unload()
|
27 |
+
mergedModel.eval()
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
def inferance(query: str, model, tokenizer, temp = 1.0, limit = 200) -> str:
|
32 |
+
device = "cuda:0"
|
33 |
+
|
34 |
+
prompt_template = """
|
35 |
+
Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
36 |
+
### Question:
|
37 |
+
{query}
|
38 |
+
|
39 |
+
### Answer:
|
40 |
+
"""
|
41 |
+
prompt = prompt_template.format(query=query)
|
42 |
+
|
43 |
+
encodeds = tokenizer(prompt, return_tensors="pt", add_special_tokens=True)
|
44 |
+
|
45 |
+
model_inputs = encodeds.to(device)
|
46 |
+
|
47 |
+
generated_ids = model.generate(**model_inputs, max_new_tokens=int(limit), temperature=temp, do_sample=True, pad_token_id=tokenizer.eos_token_id)
|
48 |
+
decoded = tokenizer.batch_decode(generated_ids)
|
49 |
+
return (decoded[0])
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
def predict(temp, limit, text):
|
54 |
+
prompt = text
|
55 |
+
out = inferance(prompt, mergedModel, tokenizer, temp = 1.0, limit = 200)
|
56 |
+
return out
|
57 |
+
|
58 |
+
pred = gr.Interface(
|
59 |
+
predict,
|
60 |
+
inputs=[
|
61 |
+
gr.Slider(0.001, 10, value=0.1, label="Temperature"),
|
62 |
+
gr.Slider(1, 1024, value=128, label="Token Limit"),
|
63 |
+
gr.Textbox(
|
64 |
+
label="Input",
|
65 |
+
lines=1,
|
66 |
+
value="#### Human: What's the capital of Australia?#### Assistant: ",
|
67 |
+
),
|
68 |
+
],
|
69 |
+
outputs='text',
|
70 |
+
)
|
71 |
+
|
72 |
+
pred.launch(share=True)
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
+
|
77 |
+
|
78 |
+
|
79 |
+
|
80 |
+
|
81 |
+
|
82 |
+
|
83 |
+
|
84 |
+
|
85 |
+
|
86 |
+
|
87 |
+
|
88 |
+
|
89 |
+
|
90 |
+
|
91 |
+
|
92 |
+
|
93 |
+
|
94 |
+
|
95 |
+
|
96 |
+
|
97 |
+
|
98 |
+
|
99 |
+
|
100 |
+
|
.ipynb_checkpoints/baseInference-checkpoint.py
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import (
|
2 |
+
AutoModelForCausalLM,
|
3 |
+
AutoTokenizer,
|
4 |
+
AutoTokenizer,
|
5 |
+
)
|
6 |
+
from peft import PeftModel, PeftConfig
|
7 |
+
import torch
|
8 |
+
import gradio as gr
|
9 |
+
|
10 |
+
d_map = {"": torch.cuda.current_device()} if torch.cuda.is_available() else None
|
11 |
+
local_model_path = "outputs/checkpoint-100" # Path to the combined weights
|
12 |
+
|
13 |
+
# Loading the base Model
|
14 |
+
config = PeftConfig.from_pretrained(local_model_path)
|
15 |
+
|
16 |
+
model = AutoModelForCausalLM.from_pretrained(
|
17 |
+
config.base_model_name_or_path,
|
18 |
+
return_dict=True,
|
19 |
+
torch_dtype=torch.float16,
|
20 |
+
device_map=d_map,
|
21 |
+
)
|
22 |
+
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path, trust_remote_code=True)
|
23 |
+
|
24 |
+
|
25 |
+
def inferance(query: str, model, tokenizer, temp = 1.0, limit = 200) -> str:
|
26 |
+
device = "cuda:0"
|
27 |
+
|
28 |
+
prompt_template = """
|
29 |
+
Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
30 |
+
### Question:
|
31 |
+
{query}
|
32 |
+
|
33 |
+
### Answer:
|
34 |
+
"""
|
35 |
+
prompt = prompt_template.format(query=query)
|
36 |
+
|
37 |
+
encodeds = tokenizer(prompt, return_tensors="pt", add_special_tokens=True)
|
38 |
+
|
39 |
+
model_inputs = encodeds.to(device)
|
40 |
+
|
41 |
+
generated_ids = model.generate(**model_inputs, max_new_tokens=int(limit), temperature=temp, do_sample=True, pad_token_id=tokenizer.eos_token_id)
|
42 |
+
decoded = tokenizer.batch_decode(generated_ids)
|
43 |
+
return (decoded[0])
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
def predict(temp, limit, text):
|
48 |
+
prompt = text
|
49 |
+
out = inferance(prompt, model, tokenizer, temp = 1.0, limit = 200)
|
50 |
+
return out
|
51 |
+
|
52 |
+
pred = gr.Interface(
|
53 |
+
predict,
|
54 |
+
inputs=[
|
55 |
+
gr.Slider(0.001, 10, value=0.1, label="Temperature"),
|
56 |
+
gr.Slider(1, 1024, value=128, label="Token Limit"),
|
57 |
+
gr.Textbox(
|
58 |
+
label="Input",
|
59 |
+
lines=1,
|
60 |
+
value="#### Human: What's the capital of Australia?#### Assistant: ",
|
61 |
+
),
|
62 |
+
],
|
63 |
+
outputs='text',
|
64 |
+
)
|
65 |
+
|
66 |
+
pred.launch(share=True)
|
.ipynb_checkpoints/finetune-checkpoint.py
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""PreFinetuningForRunPod.ipynb
|
3 |
+
|
4 |
+
Automatically generated by Colaboratory.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1LtsUCcWfL2VpWLJXVkE5076XX5k3PTyg
|
8 |
+
"""
|
9 |
+
|
10 |
+
# IMPORTS
|
11 |
+
import torch
|
12 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
13 |
+
import datasets
|
14 |
+
from datasets import load_dataset
|
15 |
+
from trl import SFTTrainer
|
16 |
+
from peft import PeftConfig, PeftModel
|
17 |
+
from multiprocessing import cpu_count
|
18 |
+
from peft import prepare_model_for_kbit_training
|
19 |
+
from peft import LoraConfig, get_peft_model
|
20 |
+
import bitsandbytes as bnb
|
21 |
+
import transformers
|
22 |
+
|
23 |
+
# LOGIN TO HUB FOR MODEL DEPLOYMENT
|
24 |
+
# from huggingface_hub import notebook_login
|
25 |
+
# notebook_login()
|
26 |
+
|
27 |
+
# LOADING THE TOKENIZER
|
28 |
+
model_id = "mistralai/Mistral-7B-v0.1"
|
29 |
+
print("-----------------------------loading tokenizer-----------------------------------------------------------")
|
30 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, add_eos_token=True)
|
31 |
+
|
32 |
+
|
33 |
+
print("-----------------------------loading dataset-----------------------------------------------------------")
|
34 |
+
# LOAD DATA FROM HUGGINFACE
|
35 |
+
data = load_dataset("gbharti/finance-alpaca", split='train')
|
36 |
+
|
37 |
+
# PREPARE DATA FOR FINE-TUNING
|
38 |
+
def generate_prompt(data_point):
|
39 |
+
"""Gen. input text based on a prompt, task instruction, (context info.), and answer
|
40 |
+
|
41 |
+
:param data_point: dict: Data point
|
42 |
+
:return: dict: tokenzed prompt
|
43 |
+
"""
|
44 |
+
# Samples with additional context into.
|
45 |
+
if data_point['input']:
|
46 |
+
text = 'Below is an instruction that describes a task, paired with an input that provides' \
|
47 |
+
' further context. Write a response that appropriately completes the request.\n\n'
|
48 |
+
text += f'### Instruction:\n{data_point["instruction"]}\n\n'
|
49 |
+
text += f'### Input:\n{data_point["input"]}\n\n'
|
50 |
+
text += f'### Response:\n{data_point["output"]}'
|
51 |
+
|
52 |
+
# Without context
|
53 |
+
else:
|
54 |
+
text = 'Below is an instruction that describes a task. Write a response that ' \
|
55 |
+
'appropriately completes the request.\n\n'
|
56 |
+
text += f'### Instruction:\n{data_point["instruction"]}\n\n'
|
57 |
+
text += f'### Response:\n{data_point["output"]}'
|
58 |
+
return text
|
59 |
+
|
60 |
+
print("-----------------------------Preparing dataset for fine-tuning-----------------------------------------------------------")
|
61 |
+
prompt = [generate_prompt(data_point) for data_point in data]
|
62 |
+
data = data.add_column("prompt", prompt);
|
63 |
+
data = data.map(lambda sample: tokenizer(sample["prompt"]),num_proc=cpu_count(), batched=True)
|
64 |
+
# data = data.remove_columns(['Context', 'Response'])
|
65 |
+
data = data.shuffle(seed=1234)
|
66 |
+
data = data.train_test_split(test_size=0.1)
|
67 |
+
train_data = data["train"]
|
68 |
+
test_data = data["test"]
|
69 |
+
|
70 |
+
|
71 |
+
# LOADING MODEL IN N(4, 8.....) BIT
|
72 |
+
bnb_config = BitsAndBytesConfig(
|
73 |
+
load_in_4bit = True,
|
74 |
+
bnb_4bit_use_double_quant=True,
|
75 |
+
bnb_4bit_quant_type="nf4",
|
76 |
+
bnb_4bit_compute_dtype=torch.bfloat16
|
77 |
+
)
|
78 |
+
|
79 |
+
d_map = {"": torch.cuda.current_device()} if torch.cuda.is_available() else None
|
80 |
+
|
81 |
+
print("-----------------------------loading model-----------------------------------------------------------")
|
82 |
+
model = AutoModelForCausalLM.from_pretrained(
|
83 |
+
model_id,
|
84 |
+
torch_dtype="auto",
|
85 |
+
use_cache=False, # set to False as we're going to use gradient checkpointing
|
86 |
+
quantization_config=bnb_config,
|
87 |
+
device_map=d_map
|
88 |
+
)
|
89 |
+
|
90 |
+
|
91 |
+
def find_all_linear_names(model):
|
92 |
+
cls = bnb.nn.Linear4bit #if args.bits == 4 else (bnb.nn.Linear8bitLt if args.bits == 8 else torch.nn.Linear)
|
93 |
+
lora_module_names = set()
|
94 |
+
for name, module in model.named_modules():
|
95 |
+
if isinstance(module, cls):
|
96 |
+
names = name.split('.')
|
97 |
+
lora_module_names.add(names[0] if len(names) == 1 else names[-1])
|
98 |
+
if 'lm_head' in lora_module_names: # needed for 16-bit
|
99 |
+
lora_module_names.remove('lm_head')
|
100 |
+
return list(lora_module_names)
|
101 |
+
|
102 |
+
modules = find_all_linear_names(model)
|
103 |
+
|
104 |
+
|
105 |
+
lora_config = LoraConfig(
|
106 |
+
r=8, # Number of quantization levels
|
107 |
+
lora_alpha=32, # Hyperparameter for LoRA
|
108 |
+
target_modules = modules, # Modules to apply LoRA to
|
109 |
+
lora_dropout=0.05, # Dropout probability
|
110 |
+
bias="none", # Type of bias
|
111 |
+
task_type="CAUSAL_LM" # Task type (in this case, Causal Language Modeling)
|
112 |
+
)
|
113 |
+
model.gradient_checkpointing_enable()
|
114 |
+
model = prepare_model_for_kbit_training(model)
|
115 |
+
model = get_peft_model(model, lora_config)
|
116 |
+
|
117 |
+
|
118 |
+
# trainable, total = model.get_nb_trainable_parameters()
|
119 |
+
# print(f"Trainable: {trainable} | total: {total} | Percentage: {trainable/total*100:.4f}%")
|
120 |
+
|
121 |
+
tokenizer.pad_token = tokenizer.eos_token
|
122 |
+
torch.cuda.empty_cache()
|
123 |
+
|
124 |
+
trainer = SFTTrainer(
|
125 |
+
model=model,
|
126 |
+
train_dataset=train_data,
|
127 |
+
eval_dataset=test_data,
|
128 |
+
dataset_text_field="prompt",
|
129 |
+
peft_config=lora_config,
|
130 |
+
args=transformers.TrainingArguments(
|
131 |
+
per_device_train_batch_size=1,
|
132 |
+
gradient_accumulation_steps=4,
|
133 |
+
gradient_checkpointing=True,
|
134 |
+
fp16=True,
|
135 |
+
warmup_steps=0.03,
|
136 |
+
max_steps=10,
|
137 |
+
learning_rate=2e-4,
|
138 |
+
logging_steps=1,
|
139 |
+
output_dir="outputs",
|
140 |
+
optim="paged_adamw_8bit",
|
141 |
+
save_strategy="epoch",
|
142 |
+
),
|
143 |
+
data_collator=transformers.DataCollatorForLanguageModeling(tokenizer, mlm=False),
|
144 |
+
)
|
145 |
+
print("-----------------------------finetuning starts------------------------------------------------------------")
|
146 |
+
model.config.use_cache = False
|
147 |
+
trainer.train()
|
.ipynb_checkpoints/mergePeftWithBaseModel-checkpoint.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import (
|
2 |
+
AutoModelForCausalLM,
|
3 |
+
AutoTokenizer,
|
4 |
+
AutoTokenizer,
|
5 |
+
)
|
6 |
+
from peft import PeftModel, PeftConfig
|
7 |
+
import torch
|
8 |
+
|
9 |
+
d_map = {"": torch.cuda.current_device()} if torch.cuda.is_available() else None
|
10 |
+
local_model_path = "outputs/checkpoint-100" # Path to the combined weights
|
11 |
+
|
12 |
+
# Loading the base Model
|
13 |
+
config = PeftConfig.from_pretrained(local_model_path)
|
14 |
+
|
15 |
+
model = AutoModelForCausalLM.from_pretrained(
|
16 |
+
config.base_model_name_or_path,
|
17 |
+
return_dict=True,
|
18 |
+
# load_in_4bit=True,
|
19 |
+
device_map=d_map,
|
20 |
+
ignore_mismatched_sizes=True,
|
21 |
+
# from_tf=True,
|
22 |
+
)
|
23 |
+
|
24 |
+
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
|
25 |
+
|
26 |
+
# load the base model with the Lora model
|
27 |
+
model = PeftModel.from_pretrained(model, local_model_path)
|
28 |
+
|
29 |
+
merged = model.merge_and_unload()
|
30 |
+
|
31 |
+
merged.save_pretrained("outputs/merged")
|
32 |
+
|
33 |
+
tokenizer.save_pretrained("outputs/merged")
|
.ipynb_checkpoints/requiretments-checkpoint.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
bitsandbytes
|
2 |
+
transformers
|
3 |
+
peft
|
4 |
+
accelerate
|
5 |
+
datasets
|
6 |
+
trl
|
7 |
+
flash-attn
|
8 |
+
gradio
|
.ipynb_checkpoints/uploadToHub-checkpoint.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import (
|
2 |
+
AutoModelForCausalLM,
|
3 |
+
AutoTokenizer,
|
4 |
+
AutoTokenizer,
|
5 |
+
)
|
6 |
+
|
7 |
+
import torch
|
8 |
+
|
9 |
+
d_map = {"": torch.cuda.current_device()} if torch.cuda.is_available() else None
|
10 |
+
merged_model_path = "outputs/merged" # Path to the combined weights
|
11 |
+
repo_name = "Financial_Analyst" # HuggingFace repo name
|
12 |
+
|
13 |
+
|
14 |
+
model = AutoModelForCausalLM.from_pretrained(
|
15 |
+
merged_model_path,
|
16 |
+
ignore_mismatched_sizes=True,
|
17 |
+
from_tf=True,
|
18 |
+
trust_remote_code=True,
|
19 |
+
device_map=d_map,
|
20 |
+
torch_dtype=torch.float16,
|
21 |
+
).eval()
|
22 |
+
|
23 |
+
tokenizer = AutoTokenizer.from_pretrained(merged_model_path)
|
24 |
+
|
25 |
+
|
26 |
+
model.push_to_hub(repo_name, token=hf_token)
|
27 |
+
tokenizer.push_to_hub(repo_name, token=hf_token)
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
|
Experimenting.ipynb
ADDED
@@ -0,0 +1,659 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"id": "e119e71a-f88a-4d5c-90fb-e60b84c4f42c",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"from transformers import (\n",
|
11 |
+
" AutoModelForCausalLM,\n",
|
12 |
+
" AutoTokenizer,\n",
|
13 |
+
" AutoTokenizer,\n",
|
14 |
+
")\n",
|
15 |
+
"from peft import PeftModel, PeftConfig\n",
|
16 |
+
"import torch\n",
|
17 |
+
"import gradio as gr\n",
|
18 |
+
"\n",
|
19 |
+
"d_map = {\"\": torch.cuda.current_device()} if torch.cuda.is_available() else None\n",
|
20 |
+
"local_model_path = \"outputs/checkpoint-100\" # Path to the combined weights"
|
21 |
+
]
|
22 |
+
},
|
23 |
+
{
|
24 |
+
"cell_type": "code",
|
25 |
+
"execution_count": 2,
|
26 |
+
"id": "ba591ab9-5029-46e8-b9a9-428de3896e62",
|
27 |
+
"metadata": {},
|
28 |
+
"outputs": [
|
29 |
+
{
|
30 |
+
"data": {
|
31 |
+
"application/vnd.jupyter.widget-view+json": {
|
32 |
+
"model_id": "913fc55a00aa4a2799729c6461060d28",
|
33 |
+
"version_major": 2,
|
34 |
+
"version_minor": 0
|
35 |
+
},
|
36 |
+
"text/plain": [
|
37 |
+
"config.json: 0%| | 0.00/571 [00:00<?, ?B/s]"
|
38 |
+
]
|
39 |
+
},
|
40 |
+
"metadata": {},
|
41 |
+
"output_type": "display_data"
|
42 |
+
},
|
43 |
+
{
|
44 |
+
"data": {
|
45 |
+
"application/vnd.jupyter.widget-view+json": {
|
46 |
+
"model_id": "4bf4ee1d7d0446d7a9c5775bdd823d3b",
|
47 |
+
"version_major": 2,
|
48 |
+
"version_minor": 0
|
49 |
+
},
|
50 |
+
"text/plain": [
|
51 |
+
"model.safetensors.index.json: 0%| | 0.00/25.1k [00:00<?, ?B/s]"
|
52 |
+
]
|
53 |
+
},
|
54 |
+
"metadata": {},
|
55 |
+
"output_type": "display_data"
|
56 |
+
},
|
57 |
+
{
|
58 |
+
"data": {
|
59 |
+
"application/vnd.jupyter.widget-view+json": {
|
60 |
+
"model_id": "4d512679e32f4ca4ae7aad1f821fda4d",
|
61 |
+
"version_major": 2,
|
62 |
+
"version_minor": 0
|
63 |
+
},
|
64 |
+
"text/plain": [
|
65 |
+
"Downloading shards: 0%| | 0/2 [00:00<?, ?it/s]"
|
66 |
+
]
|
67 |
+
},
|
68 |
+
"metadata": {},
|
69 |
+
"output_type": "display_data"
|
70 |
+
},
|
71 |
+
{
|
72 |
+
"data": {
|
73 |
+
"application/vnd.jupyter.widget-view+json": {
|
74 |
+
"model_id": "665dd2a779b94e6fba7c5fdc6313f504",
|
75 |
+
"version_major": 2,
|
76 |
+
"version_minor": 0
|
77 |
+
},
|
78 |
+
"text/plain": [
|
79 |
+
"model-00001-of-00002.safetensors: 0%| | 0.00/9.94G [00:00<?, ?B/s]"
|
80 |
+
]
|
81 |
+
},
|
82 |
+
"metadata": {},
|
83 |
+
"output_type": "display_data"
|
84 |
+
},
|
85 |
+
{
|
86 |
+
"data": {
|
87 |
+
"application/vnd.jupyter.widget-view+json": {
|
88 |
+
"model_id": "9c1efb636ab24518b58b78bb2fa90cf7",
|
89 |
+
"version_major": 2,
|
90 |
+
"version_minor": 0
|
91 |
+
},
|
92 |
+
"text/plain": [
|
93 |
+
"model-00002-of-00002.safetensors: 0%| | 0.00/4.54G [00:00<?, ?B/s]"
|
94 |
+
]
|
95 |
+
},
|
96 |
+
"metadata": {},
|
97 |
+
"output_type": "display_data"
|
98 |
+
},
|
99 |
+
{
|
100 |
+
"data": {
|
101 |
+
"application/vnd.jupyter.widget-view+json": {
|
102 |
+
"model_id": "e502f8a721354757a12a34879ceba413",
|
103 |
+
"version_major": 2,
|
104 |
+
"version_minor": 0
|
105 |
+
},
|
106 |
+
"text/plain": [
|
107 |
+
"Loading checkpoint shards: 0%| | 0/2 [00:00<?, ?it/s]"
|
108 |
+
]
|
109 |
+
},
|
110 |
+
"metadata": {},
|
111 |
+
"output_type": "display_data"
|
112 |
+
},
|
113 |
+
{
|
114 |
+
"data": {
|
115 |
+
"application/vnd.jupyter.widget-view+json": {
|
116 |
+
"model_id": "80a0725ee12c4659b5271308553d2b23",
|
117 |
+
"version_major": 2,
|
118 |
+
"version_minor": 0
|
119 |
+
},
|
120 |
+
"text/plain": [
|
121 |
+
"generation_config.json: 0%| | 0.00/116 [00:00<?, ?B/s]"
|
122 |
+
]
|
123 |
+
},
|
124 |
+
"metadata": {},
|
125 |
+
"output_type": "display_data"
|
126 |
+
},
|
127 |
+
{
|
128 |
+
"data": {
|
129 |
+
"application/vnd.jupyter.widget-view+json": {
|
130 |
+
"model_id": "3d1e7af016a64550949738a7dfb0daed",
|
131 |
+
"version_major": 2,
|
132 |
+
"version_minor": 0
|
133 |
+
},
|
134 |
+
"text/plain": [
|
135 |
+
"tokenizer_config.json: 0%| | 0.00/967 [00:00<?, ?B/s]"
|
136 |
+
]
|
137 |
+
},
|
138 |
+
"metadata": {},
|
139 |
+
"output_type": "display_data"
|
140 |
+
},
|
141 |
+
{
|
142 |
+
"data": {
|
143 |
+
"application/vnd.jupyter.widget-view+json": {
|
144 |
+
"model_id": "d85c88ad430748b48026e227e2b58b8d",
|
145 |
+
"version_major": 2,
|
146 |
+
"version_minor": 0
|
147 |
+
},
|
148 |
+
"text/plain": [
|
149 |
+
"tokenizer.model: 0%| | 0.00/493k [00:00<?, ?B/s]"
|
150 |
+
]
|
151 |
+
},
|
152 |
+
"metadata": {},
|
153 |
+
"output_type": "display_data"
|
154 |
+
},
|
155 |
+
{
|
156 |
+
"data": {
|
157 |
+
"application/vnd.jupyter.widget-view+json": {
|
158 |
+
"model_id": "196bda4d38fc4d198a26154b06089754",
|
159 |
+
"version_major": 2,
|
160 |
+
"version_minor": 0
|
161 |
+
},
|
162 |
+
"text/plain": [
|
163 |
+
"tokenizer.json: 0%| | 0.00/1.80M [00:00<?, ?B/s]"
|
164 |
+
]
|
165 |
+
},
|
166 |
+
"metadata": {},
|
167 |
+
"output_type": "display_data"
|
168 |
+
},
|
169 |
+
{
|
170 |
+
"data": {
|
171 |
+
"application/vnd.jupyter.widget-view+json": {
|
172 |
+
"model_id": "692a1a2768724c40aa90d6cec836d16a",
|
173 |
+
"version_major": 2,
|
174 |
+
"version_minor": 0
|
175 |
+
},
|
176 |
+
"text/plain": [
|
177 |
+
"special_tokens_map.json: 0%| | 0.00/72.0 [00:00<?, ?B/s]"
|
178 |
+
]
|
179 |
+
},
|
180 |
+
"metadata": {},
|
181 |
+
"output_type": "display_data"
|
182 |
+
}
|
183 |
+
],
|
184 |
+
"source": [
|
185 |
+
"# Loading the base Model\n",
|
186 |
+
"config = PeftConfig.from_pretrained(local_model_path)\n",
|
187 |
+
"\n",
|
188 |
+
"model = AutoModelForCausalLM.from_pretrained(\n",
|
189 |
+
" config.base_model_name_or_path, \n",
|
190 |
+
" return_dict=True,\n",
|
191 |
+
" torch_dtype=torch.float16,\n",
|
192 |
+
" device_map=d_map,\n",
|
193 |
+
" trust_remote_code=True\n",
|
194 |
+
")\n",
|
195 |
+
"tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path, trust_remote_code=True)"
|
196 |
+
]
|
197 |
+
},
|
198 |
+
{
|
199 |
+
"cell_type": "code",
|
200 |
+
"execution_count": 4,
|
201 |
+
"id": "c1d36c14-0bfc-4215-8576-bb390a3a6114",
|
202 |
+
"metadata": {},
|
203 |
+
"outputs": [
|
204 |
+
{
|
205 |
+
"data": {
|
206 |
+
"text/plain": [
|
207 |
+
"PeftModelForCausalLM(\n",
|
208 |
+
" (base_model): LoraModel(\n",
|
209 |
+
" (model): MistralForCausalLM(\n",
|
210 |
+
" (model): MistralModel(\n",
|
211 |
+
" (embed_tokens): Embedding(32000, 4096)\n",
|
212 |
+
" (layers): ModuleList(\n",
|
213 |
+
" (0-31): 32 x MistralDecoderLayer(\n",
|
214 |
+
" (self_attn): MistralAttention(\n",
|
215 |
+
" (q_proj): lora.Linear(\n",
|
216 |
+
" (base_layer): Linear(in_features=4096, out_features=4096, bias=False)\n",
|
217 |
+
" (lora_dropout): ModuleDict(\n",
|
218 |
+
" (default): Dropout(p=0.05, inplace=False)\n",
|
219 |
+
" )\n",
|
220 |
+
" (lora_A): ModuleDict(\n",
|
221 |
+
" (default): Linear(in_features=4096, out_features=8, bias=False)\n",
|
222 |
+
" )\n",
|
223 |
+
" (lora_B): ModuleDict(\n",
|
224 |
+
" (default): Linear(in_features=8, out_features=4096, bias=False)\n",
|
225 |
+
" )\n",
|
226 |
+
" (lora_embedding_A): ParameterDict()\n",
|
227 |
+
" (lora_embedding_B): ParameterDict()\n",
|
228 |
+
" )\n",
|
229 |
+
" (k_proj): lora.Linear(\n",
|
230 |
+
" (base_layer): Linear(in_features=4096, out_features=1024, bias=False)\n",
|
231 |
+
" (lora_dropout): ModuleDict(\n",
|
232 |
+
" (default): Dropout(p=0.05, inplace=False)\n",
|
233 |
+
" )\n",
|
234 |
+
" (lora_A): ModuleDict(\n",
|
235 |
+
" (default): Linear(in_features=4096, out_features=8, bias=False)\n",
|
236 |
+
" )\n",
|
237 |
+
" (lora_B): ModuleDict(\n",
|
238 |
+
" (default): Linear(in_features=8, out_features=1024, bias=False)\n",
|
239 |
+
" )\n",
|
240 |
+
" (lora_embedding_A): ParameterDict()\n",
|
241 |
+
" (lora_embedding_B): ParameterDict()\n",
|
242 |
+
" )\n",
|
243 |
+
" (v_proj): lora.Linear(\n",
|
244 |
+
" (base_layer): Linear(in_features=4096, out_features=1024, bias=False)\n",
|
245 |
+
" (lora_dropout): ModuleDict(\n",
|
246 |
+
" (default): Dropout(p=0.05, inplace=False)\n",
|
247 |
+
" )\n",
|
248 |
+
" (lora_A): ModuleDict(\n",
|
249 |
+
" (default): Linear(in_features=4096, out_features=8, bias=False)\n",
|
250 |
+
" )\n",
|
251 |
+
" (lora_B): ModuleDict(\n",
|
252 |
+
" (default): Linear(in_features=8, out_features=1024, bias=False)\n",
|
253 |
+
" )\n",
|
254 |
+
" (lora_embedding_A): ParameterDict()\n",
|
255 |
+
" (lora_embedding_B): ParameterDict()\n",
|
256 |
+
" )\n",
|
257 |
+
" (o_proj): lora.Linear(\n",
|
258 |
+
" (base_layer): Linear(in_features=4096, out_features=4096, bias=False)\n",
|
259 |
+
" (lora_dropout): ModuleDict(\n",
|
260 |
+
" (default): Dropout(p=0.05, inplace=False)\n",
|
261 |
+
" )\n",
|
262 |
+
" (lora_A): ModuleDict(\n",
|
263 |
+
" (default): Linear(in_features=4096, out_features=8, bias=False)\n",
|
264 |
+
" )\n",
|
265 |
+
" (lora_B): ModuleDict(\n",
|
266 |
+
" (default): Linear(in_features=8, out_features=4096, bias=False)\n",
|
267 |
+
" )\n",
|
268 |
+
" (lora_embedding_A): ParameterDict()\n",
|
269 |
+
" (lora_embedding_B): ParameterDict()\n",
|
270 |
+
" )\n",
|
271 |
+
" (rotary_emb): MistralRotaryEmbedding()\n",
|
272 |
+
" )\n",
|
273 |
+
" (mlp): MistralMLP(\n",
|
274 |
+
" (gate_proj): lora.Linear(\n",
|
275 |
+
" (base_layer): Linear(in_features=4096, out_features=14336, bias=False)\n",
|
276 |
+
" (lora_dropout): ModuleDict(\n",
|
277 |
+
" (default): Dropout(p=0.05, inplace=False)\n",
|
278 |
+
" )\n",
|
279 |
+
" (lora_A): ModuleDict(\n",
|
280 |
+
" (default): Linear(in_features=4096, out_features=8, bias=False)\n",
|
281 |
+
" )\n",
|
282 |
+
" (lora_B): ModuleDict(\n",
|
283 |
+
" (default): Linear(in_features=8, out_features=14336, bias=False)\n",
|
284 |
+
" )\n",
|
285 |
+
" (lora_embedding_A): ParameterDict()\n",
|
286 |
+
" (lora_embedding_B): ParameterDict()\n",
|
287 |
+
" )\n",
|
288 |
+
" (up_proj): lora.Linear(\n",
|
289 |
+
" (base_layer): Linear(in_features=4096, out_features=14336, bias=False)\n",
|
290 |
+
" (lora_dropout): ModuleDict(\n",
|
291 |
+
" (default): Dropout(p=0.05, inplace=False)\n",
|
292 |
+
" )\n",
|
293 |
+
" (lora_A): ModuleDict(\n",
|
294 |
+
" (default): Linear(in_features=4096, out_features=8, bias=False)\n",
|
295 |
+
" )\n",
|
296 |
+
" (lora_B): ModuleDict(\n",
|
297 |
+
" (default): Linear(in_features=8, out_features=14336, bias=False)\n",
|
298 |
+
" )\n",
|
299 |
+
" (lora_embedding_A): ParameterDict()\n",
|
300 |
+
" (lora_embedding_B): ParameterDict()\n",
|
301 |
+
" )\n",
|
302 |
+
" (down_proj): lora.Linear(\n",
|
303 |
+
" (base_layer): Linear(in_features=14336, out_features=4096, bias=False)\n",
|
304 |
+
" (lora_dropout): ModuleDict(\n",
|
305 |
+
" (default): Dropout(p=0.05, inplace=False)\n",
|
306 |
+
" )\n",
|
307 |
+
" (lora_A): ModuleDict(\n",
|
308 |
+
" (default): Linear(in_features=14336, out_features=8, bias=False)\n",
|
309 |
+
" )\n",
|
310 |
+
" (lora_B): ModuleDict(\n",
|
311 |
+
" (default): Linear(in_features=8, out_features=4096, bias=False)\n",
|
312 |
+
" )\n",
|
313 |
+
" (lora_embedding_A): ParameterDict()\n",
|
314 |
+
" (lora_embedding_B): ParameterDict()\n",
|
315 |
+
" )\n",
|
316 |
+
" (act_fn): SiLU()\n",
|
317 |
+
" )\n",
|
318 |
+
" (input_layernorm): MistralRMSNorm()\n",
|
319 |
+
" (post_attention_layernorm): MistralRMSNorm()\n",
|
320 |
+
" )\n",
|
321 |
+
" )\n",
|
322 |
+
" (norm): MistralRMSNorm()\n",
|
323 |
+
" )\n",
|
324 |
+
" (lm_head): Linear(in_features=4096, out_features=32000, bias=False)\n",
|
325 |
+
" )\n",
|
326 |
+
" )\n",
|
327 |
+
")"
|
328 |
+
]
|
329 |
+
},
|
330 |
+
"execution_count": 4,
|
331 |
+
"metadata": {},
|
332 |
+
"output_type": "execute_result"
|
333 |
+
}
|
334 |
+
],
|
335 |
+
"source": [
|
336 |
+
"# load the base model with the Lora model\n",
|
337 |
+
"mergedModel = PeftModel.from_pretrained(model, local_model_path)\n",
|
338 |
+
"# model = model.merge_and_unload()\n",
|
339 |
+
"mergedModel.eval()"
|
340 |
+
]
|
341 |
+
},
|
342 |
+
{
|
343 |
+
"cell_type": "code",
|
344 |
+
"execution_count": 7,
|
345 |
+
"id": "09fa4575-0dec-4e62-a43f-77e57f68c4a9",
|
346 |
+
"metadata": {},
|
347 |
+
"outputs": [],
|
348 |
+
"source": [
|
349 |
+
"def inferance(query: str, model, tokenizer, temp = 1.0, limit = 200) -> str:\n",
|
350 |
+
" device = \"cuda:0\"\n",
|
351 |
+
"\n",
|
352 |
+
" prompt_template = \"\"\"\n",
|
353 |
+
" Below is an instruction that describes a task. Write a response that appropriately completes the request.\n",
|
354 |
+
" ### Question:\n",
|
355 |
+
" {query}\n",
|
356 |
+
"\n",
|
357 |
+
" ### Answer:\n",
|
358 |
+
" \"\"\"\n",
|
359 |
+
" prompt = prompt_template.format(query=query)\n",
|
360 |
+
"\n",
|
361 |
+
" encodeds = tokenizer(prompt, return_tensors=\"pt\", add_special_tokens=True)\n",
|
362 |
+
"\n",
|
363 |
+
" model_inputs = encodeds.to(device)\n",
|
364 |
+
"\n",
|
365 |
+
" generated_ids = model.generate(**model_inputs, max_new_tokens=int(limit), temperature=temp, do_sample=True, pad_token_id=tokenizer.eos_token_id)\n",
|
366 |
+
" decoded = tokenizer.batch_decode(generated_ids)\n",
|
367 |
+
" return (decoded[0])"
|
368 |
+
]
|
369 |
+
},
|
370 |
+
{
|
371 |
+
"cell_type": "code",
|
372 |
+
"execution_count": 9,
|
373 |
+
"id": "ba47700b-0787-4677-a5a1-c1a1b4063fe2",
|
374 |
+
"metadata": {},
|
375 |
+
"outputs": [
|
376 |
+
{
|
377 |
+
"name": "stdout",
|
378 |
+
"output_type": "stream",
|
379 |
+
"text": [
|
380 |
+
"Running on local URL: http://127.0.0.1:7864\n",
|
381 |
+
"Running on public URL: https://b9a01680128206a745.gradio.live\n",
|
382 |
+
"\n",
|
383 |
+
"This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
|
384 |
+
]
|
385 |
+
},
|
386 |
+
{
|
387 |
+
"data": {
|
388 |
+
"text/html": [
|
389 |
+
"<div><iframe src=\"https://b9a01680128206a745.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
390 |
+
],
|
391 |
+
"text/plain": [
|
392 |
+
"<IPython.core.display.HTML object>"
|
393 |
+
]
|
394 |
+
},
|
395 |
+
"metadata": {},
|
396 |
+
"output_type": "display_data"
|
397 |
+
},
|
398 |
+
{
|
399 |
+
"data": {
|
400 |
+
"text/plain": []
|
401 |
+
},
|
402 |
+
"execution_count": 9,
|
403 |
+
"metadata": {},
|
404 |
+
"output_type": "execute_result"
|
405 |
+
}
|
406 |
+
],
|
407 |
+
"source": [
|
408 |
+
"\n",
|
409 |
+
"\n",
|
410 |
+
"def predict(temp, limit, text):\n",
|
411 |
+
" prompt = text\n",
|
412 |
+
" out = inferance(prompt, mergedModel, tokenizer, temp = 1.0, limit = 200)\n",
|
413 |
+
" return out\n",
|
414 |
+
"\n",
|
415 |
+
"pred = gr.Interface(\n",
|
416 |
+
" predict,\n",
|
417 |
+
" inputs=[\n",
|
418 |
+
" gr.Slider(0.001, 10, value=0.1, label=\"Temperature\"),\n",
|
419 |
+
" gr.Slider(1, 1024, value=128, label=\"Token Limit\"),\n",
|
420 |
+
" gr.Textbox(\n",
|
421 |
+
" label=\"Input\",\n",
|
422 |
+
" lines=1,\n",
|
423 |
+
" value=\"#### Human: What's the capital of Australia?#### Assistant: \",\n",
|
424 |
+
" ),\n",
|
425 |
+
" ],\n",
|
426 |
+
" outputs='text',\n",
|
427 |
+
")\n",
|
428 |
+
"\n",
|
429 |
+
"pred.launch(share=True)"
|
430 |
+
]
|
431 |
+
},
|
432 |
+
{
|
433 |
+
"cell_type": "code",
|
434 |
+
"execution_count": 15,
|
435 |
+
"id": "8e0529f7-5e0d-4822-b826-ca49ca10c172",
|
436 |
+
"metadata": {},
|
437 |
+
"outputs": [
|
438 |
+
{
|
439 |
+
"name": "stderr",
|
440 |
+
"output_type": "stream",
|
441 |
+
"text": [
|
442 |
+
"huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n",
|
443 |
+
"To disable this warning, you can either:\n",
|
444 |
+
"\t- Avoid using `tokenizers` before the fork if possible\n",
|
445 |
+
"\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n"
|
446 |
+
]
|
447 |
+
},
|
448 |
+
{
|
449 |
+
"name": "stdout",
|
450 |
+
"output_type": "stream",
|
451 |
+
"text": [
|
452 |
+
"Need \u001b[32m'write'\u001b[0m access token to create a Spaces repo.\n",
|
453 |
+
"\n",
|
454 |
+
" _| _| _| _| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _|_|_|_| _|_| _|_|_| _|_|_|_|\n",
|
455 |
+
" _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|\n",
|
456 |
+
" _|_|_|_| _| _| _| _|_| _| _|_| _| _| _| _| _| _|_| _|_|_| _|_|_|_| _| _|_|_|\n",
|
457 |
+
" _| _| _| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|\n",
|
458 |
+
" _| _| _|_| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _| _| _| _|_|_| _|_|_|_|\n",
|
459 |
+
"\n",
|
460 |
+
" To login, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .\n",
|
461 |
+
"Token: \n",
|
462 |
+
"\u001b[31mAborted.\u001b[0m\n"
|
463 |
+
]
|
464 |
+
}
|
465 |
+
],
|
466 |
+
"source": [
|
467 |
+
"!gradio deploy"
|
468 |
+
]
|
469 |
+
},
|
470 |
+
{
|
471 |
+
"cell_type": "code",
|
472 |
+
"execution_count": 10,
|
473 |
+
"id": "1eecb055-93d7-485c-bb85-c025c06cd94c",
|
474 |
+
"metadata": {},
|
475 |
+
"outputs": [],
|
476 |
+
"source": [
|
477 |
+
"import datasets"
|
478 |
+
]
|
479 |
+
},
|
480 |
+
{
|
481 |
+
"cell_type": "code",
|
482 |
+
"execution_count": 11,
|
483 |
+
"id": "9e25a85a-5276-47ff-996d-ddb426eafac4",
|
484 |
+
"metadata": {},
|
485 |
+
"outputs": [],
|
486 |
+
"source": [
|
487 |
+
"from datasets import load_dataset"
|
488 |
+
]
|
489 |
+
},
|
490 |
+
{
|
491 |
+
"cell_type": "code",
|
492 |
+
"execution_count": 12,
|
493 |
+
"id": "b7bece25-22f4-4489-a5e8-10a1c28aeae8",
|
494 |
+
"metadata": {},
|
495 |
+
"outputs": [
|
496 |
+
{
|
497 |
+
"data": {
|
498 |
+
"application/vnd.jupyter.widget-view+json": {
|
499 |
+
"model_id": "441a29ce1fd14a259d8538497f16798a",
|
500 |
+
"version_major": 2,
|
501 |
+
"version_minor": 0
|
502 |
+
},
|
503 |
+
"text/plain": [
|
504 |
+
"Downloading readme: 0%| | 0.00/709 [00:00<?, ?B/s]"
|
505 |
+
]
|
506 |
+
},
|
507 |
+
"metadata": {},
|
508 |
+
"output_type": "display_data"
|
509 |
+
},
|
510 |
+
{
|
511 |
+
"data": {
|
512 |
+
"application/vnd.jupyter.widget-view+json": {
|
513 |
+
"model_id": "57c38be620174f12b1c13f1794c29b83",
|
514 |
+
"version_major": 2,
|
515 |
+
"version_minor": 0
|
516 |
+
},
|
517 |
+
"text/plain": [
|
518 |
+
"Downloading data: 0%| | 0.00/42.9M [00:00<?, ?B/s]"
|
519 |
+
]
|
520 |
+
},
|
521 |
+
"metadata": {},
|
522 |
+
"output_type": "display_data"
|
523 |
+
},
|
524 |
+
{
|
525 |
+
"data": {
|
526 |
+
"application/vnd.jupyter.widget-view+json": {
|
527 |
+
"model_id": "d955c0a3620242978f507e27ddebf41b",
|
528 |
+
"version_major": 2,
|
529 |
+
"version_minor": 0
|
530 |
+
},
|
531 |
+
"text/plain": [
|
532 |
+
"Generating train split: 0 examples [00:00, ? examples/s]"
|
533 |
+
]
|
534 |
+
},
|
535 |
+
"metadata": {},
|
536 |
+
"output_type": "display_data"
|
537 |
+
}
|
538 |
+
],
|
539 |
+
"source": [
|
540 |
+
"data = load_dataset(\"gbharti/finance-alpaca\", split='train')"
|
541 |
+
]
|
542 |
+
},
|
543 |
+
{
|
544 |
+
"cell_type": "code",
|
545 |
+
"execution_count": 14,
|
546 |
+
"id": "7a2b2ac8-f6ce-40ff-b785-d79e8e673aa6",
|
547 |
+
"metadata": {},
|
548 |
+
"outputs": [
|
549 |
+
{
|
550 |
+
"data": {
|
551 |
+
"text/plain": [
|
552 |
+
"{'output': \"This is definitely a scam. I had a friend sign up for a very similar offer and what they did was send a fake check and then asked to transfer the same amount to them. So now you just send them a couple grand and you're holding a fake check.\",\n",
|
553 |
+
" 'text': '',\n",
|
554 |
+
" 'instruction': 'What risks are there acting as a broker between PayPal and electronic bank transfers?',\n",
|
555 |
+
" 'input': ''}"
|
556 |
+
]
|
557 |
+
},
|
558 |
+
"execution_count": 14,
|
559 |
+
"metadata": {},
|
560 |
+
"output_type": "execute_result"
|
561 |
+
}
|
562 |
+
],
|
563 |
+
"source": [
|
564 |
+
"data[1021]"
|
565 |
+
]
|
566 |
+
},
|
567 |
+
{
|
568 |
+
"cell_type": "code",
|
569 |
+
"execution_count": 8,
|
570 |
+
"id": "c20eb320-5c64-4118-82a9-0cd65319bd57",
|
571 |
+
"metadata": {},
|
572 |
+
"outputs": [
|
573 |
+
{
|
574 |
+
"name": "stdout",
|
575 |
+
"output_type": "stream",
|
576 |
+
"text": [
|
577 |
+
"Running on local URL: http://127.0.0.1:7863\n",
|
578 |
+
"Running on public URL: https://f9ab2457c317a5c384.gradio.live\n",
|
579 |
+
"\n",
|
580 |
+
"This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
|
581 |
+
]
|
582 |
+
},
|
583 |
+
{
|
584 |
+
"data": {
|
585 |
+
"text/html": [
|
586 |
+
"<div><iframe src=\"https://f9ab2457c317a5c384.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
587 |
+
],
|
588 |
+
"text/plain": [
|
589 |
+
"<IPython.core.display.HTML object>"
|
590 |
+
]
|
591 |
+
},
|
592 |
+
"metadata": {},
|
593 |
+
"output_type": "display_data"
|
594 |
+
},
|
595 |
+
{
|
596 |
+
"data": {
|
597 |
+
"text/plain": []
|
598 |
+
},
|
599 |
+
"execution_count": 8,
|
600 |
+
"metadata": {},
|
601 |
+
"output_type": "execute_result"
|
602 |
+
}
|
603 |
+
],
|
604 |
+
"source": [
|
605 |
+
"import gradio as gr\n",
|
606 |
+
"\n",
|
607 |
+
"def predict(temp, limit, text):\n",
|
608 |
+
" prompt = text\n",
|
609 |
+
" out = inferance(prompt, model, tokenizer, temp = 1.0, limit = 200)\n",
|
610 |
+
" return out\n",
|
611 |
+
"\n",
|
612 |
+
"pred = gr.Interface(\n",
|
613 |
+
" predict,\n",
|
614 |
+
" inputs=[\n",
|
615 |
+
" gr.Slider(0.001, 10, value=0.1, label=\"Temperature\"),\n",
|
616 |
+
" gr.Slider(1, 1024, value=128, label=\"Token Limit\"),\n",
|
617 |
+
" gr.Textbox(\n",
|
618 |
+
" label=\"Input\",\n",
|
619 |
+
" lines=1,\n",
|
620 |
+
" value=\"#### Human: What's the capital of Australia?#### Assistant: \",\n",
|
621 |
+
" ),\n",
|
622 |
+
" ],\n",
|
623 |
+
" outputs='text',\n",
|
624 |
+
")\n",
|
625 |
+
"\n",
|
626 |
+
"pred.launch(share=True)"
|
627 |
+
]
|
628 |
+
},
|
629 |
+
{
|
630 |
+
"cell_type": "code",
|
631 |
+
"execution_count": null,
|
632 |
+
"id": "6cac6e2f-d6eb-4311-95da-082bd92145c5",
|
633 |
+
"metadata": {},
|
634 |
+
"outputs": [],
|
635 |
+
"source": []
|
636 |
+
}
|
637 |
+
],
|
638 |
+
"metadata": {
|
639 |
+
"kernelspec": {
|
640 |
+
"display_name": "Python 3 (ipykernel)",
|
641 |
+
"language": "python",
|
642 |
+
"name": "python3"
|
643 |
+
},
|
644 |
+
"language_info": {
|
645 |
+
"codemirror_mode": {
|
646 |
+
"name": "ipython",
|
647 |
+
"version": 3
|
648 |
+
},
|
649 |
+
"file_extension": ".py",
|
650 |
+
"mimetype": "text/x-python",
|
651 |
+
"name": "python",
|
652 |
+
"nbconvert_exporter": "python",
|
653 |
+
"pygments_lexer": "ipython3",
|
654 |
+
"version": "3.10.12"
|
655 |
+
}
|
656 |
+
},
|
657 |
+
"nbformat": 4,
|
658 |
+
"nbformat_minor": 5
|
659 |
+
}
|
ImportCommands.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
pip install -r requirements.txt
|
README.md
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
|
4 |
-
colorFrom: gray
|
5 |
-
colorTo: green
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.17.0
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: finance
|
3 |
+
app_file: app.py
|
|
|
|
|
4 |
sdk: gradio
|
5 |
sdk_version: 4.17.0
|
|
|
|
|
6 |
---
|
|
|
|
app.py
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import (
|
2 |
+
AutoModelForCausalLM,
|
3 |
+
AutoTokenizer,
|
4 |
+
AutoTokenizer,
|
5 |
+
)
|
6 |
+
from peft import PeftModel, PeftConfig
|
7 |
+
import torch
|
8 |
+
import gradio as gr
|
9 |
+
|
10 |
+
d_map = {"": torch.cuda.current_device()} if torch.cuda.is_available() else None
|
11 |
+
local_model_path = "outputs/checkpoint-100" # Path to the combined weights
|
12 |
+
|
13 |
+
# Loading the base Model
|
14 |
+
config = PeftConfig.from_pretrained(local_model_path)
|
15 |
+
|
16 |
+
model = AutoModelForCausalLM.from_pretrained(
|
17 |
+
config.base_model_name_or_path,
|
18 |
+
return_dict=True,
|
19 |
+
torch_dtype=torch.float16,
|
20 |
+
device_map=d_map,
|
21 |
+
)
|
22 |
+
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path, trust_remote_code=True)
|
23 |
+
|
24 |
+
# load the base model with the Lora model
|
25 |
+
mergedModel = PeftModel.from_pretrained(model, local_model_path)
|
26 |
+
# model = model.merge_and_unload()
|
27 |
+
mergedModel.eval()
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
def inferance(query: str, model, tokenizer, temp = 1.0, limit = 200) -> str:
|
32 |
+
device = "cuda:0"
|
33 |
+
|
34 |
+
prompt_template = """
|
35 |
+
Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
36 |
+
### Question:
|
37 |
+
{query}
|
38 |
+
|
39 |
+
### Answer:
|
40 |
+
"""
|
41 |
+
prompt = prompt_template.format(query=query)
|
42 |
+
|
43 |
+
encodeds = tokenizer(prompt, return_tensors="pt", add_special_tokens=True)
|
44 |
+
|
45 |
+
model_inputs = encodeds.to(device)
|
46 |
+
|
47 |
+
generated_ids = model.generate(**model_inputs, max_new_tokens=int(limit), temperature=temp, do_sample=True, pad_token_id=tokenizer.eos_token_id)
|
48 |
+
decoded = tokenizer.batch_decode(generated_ids)
|
49 |
+
return (decoded[0])
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
def predict(temp, limit, text):
|
54 |
+
prompt = text
|
55 |
+
out = inferance(prompt, mergedModel, tokenizer, temp = 1.0, limit = 200)
|
56 |
+
return out
|
57 |
+
|
58 |
+
pred = gr.Interface(
|
59 |
+
predict,
|
60 |
+
inputs=[
|
61 |
+
gr.Slider(0.001, 10, value=0.1, label="Temperature"),
|
62 |
+
gr.Slider(1, 1024, value=128, label="Token Limit"),
|
63 |
+
gr.Textbox(
|
64 |
+
label="Input",
|
65 |
+
lines=1,
|
66 |
+
value="#### Human: What's the capital of Australia?#### Assistant: ",
|
67 |
+
),
|
68 |
+
],
|
69 |
+
outputs='text',
|
70 |
+
)
|
71 |
+
|
72 |
+
pred.launch(share=True)
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
+
|
77 |
+
|
78 |
+
|
79 |
+
|
80 |
+
|
81 |
+
|
82 |
+
|
83 |
+
|
84 |
+
|
85 |
+
|
86 |
+
|
87 |
+
|
88 |
+
|
89 |
+
|
90 |
+
|
91 |
+
|
92 |
+
|
93 |
+
|
94 |
+
|
95 |
+
|
96 |
+
|
97 |
+
|
98 |
+
|
99 |
+
|
100 |
+
|
baseInference.py
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import (
|
2 |
+
AutoModelForCausalLM,
|
3 |
+
AutoTokenizer,
|
4 |
+
AutoTokenizer,
|
5 |
+
)
|
6 |
+
from peft import PeftModel, PeftConfig
|
7 |
+
import torch
|
8 |
+
import gradio as gr
|
9 |
+
|
10 |
+
d_map = {"": torch.cuda.current_device()} if torch.cuda.is_available() else None
|
11 |
+
local_model_path = "outputs/checkpoint-100" # Path to the combined weights
|
12 |
+
|
13 |
+
# Loading the base Model
|
14 |
+
config = PeftConfig.from_pretrained(local_model_path)
|
15 |
+
|
16 |
+
model = AutoModelForCausalLM.from_pretrained(
|
17 |
+
config.base_model_name_or_path,
|
18 |
+
return_dict=True,
|
19 |
+
torch_dtype=torch.float16,
|
20 |
+
device_map=d_map,
|
21 |
+
)
|
22 |
+
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path, trust_remote_code=True)
|
23 |
+
|
24 |
+
|
25 |
+
def inferance(query: str, model, tokenizer, temp = 1.0, limit = 200) -> str:
|
26 |
+
device = "cuda:0"
|
27 |
+
|
28 |
+
prompt_template = """
|
29 |
+
Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
30 |
+
### Question:
|
31 |
+
{query}
|
32 |
+
|
33 |
+
### Answer:
|
34 |
+
"""
|
35 |
+
prompt = prompt_template.format(query=query)
|
36 |
+
|
37 |
+
encodeds = tokenizer(prompt, return_tensors="pt", add_special_tokens=True)
|
38 |
+
|
39 |
+
model_inputs = encodeds.to(device)
|
40 |
+
|
41 |
+
generated_ids = model.generate(**model_inputs, max_new_tokens=int(limit), temperature=temp, do_sample=True, pad_token_id=tokenizer.eos_token_id)
|
42 |
+
decoded = tokenizer.batch_decode(generated_ids)
|
43 |
+
return (decoded[0])
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
def predict(temp, limit, text):
|
48 |
+
prompt = text
|
49 |
+
out = inferance(prompt, model, tokenizer, temp = 1.0, limit = 200)
|
50 |
+
return out
|
51 |
+
|
52 |
+
pred = gr.Interface(
|
53 |
+
predict,
|
54 |
+
inputs=[
|
55 |
+
gr.Slider(0.001, 10, value=0.1, label="Temperature"),
|
56 |
+
gr.Slider(1, 1024, value=128, label="Token Limit"),
|
57 |
+
gr.Textbox(
|
58 |
+
label="Input",
|
59 |
+
lines=1,
|
60 |
+
value="#### Human: What's the capital of Australia?#### Assistant: ",
|
61 |
+
),
|
62 |
+
],
|
63 |
+
outputs='text',
|
64 |
+
)
|
65 |
+
|
66 |
+
pred.launch(share=True)
|
finetune.py
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""PreFinetuningForRunPod.ipynb
|
3 |
+
|
4 |
+
Automatically generated by Colaboratory.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1LtsUCcWfL2VpWLJXVkE5076XX5k3PTyg
|
8 |
+
"""
|
9 |
+
|
10 |
+
# IMPORTS
|
11 |
+
import torch
|
12 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
13 |
+
import datasets
|
14 |
+
from datasets import load_dataset
|
15 |
+
from trl import SFTTrainer
|
16 |
+
from peft import PeftConfig, PeftModel
|
17 |
+
from multiprocessing import cpu_count
|
18 |
+
from peft import prepare_model_for_kbit_training
|
19 |
+
from peft import LoraConfig, get_peft_model
|
20 |
+
import bitsandbytes as bnb
|
21 |
+
import transformers
|
22 |
+
|
23 |
+
# LOGIN TO HUB FOR MODEL DEPLOYMENT
|
24 |
+
# from huggingface_hub import notebook_login
|
25 |
+
# notebook_login()
|
26 |
+
|
27 |
+
# LOADING THE TOKENIZER
|
28 |
+
model_id = "mistralai/Mistral-7B-v0.1"
|
29 |
+
print("-----------------------------loading tokenizer-----------------------------------------------------------")
|
30 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, add_eos_token=True)
|
31 |
+
|
32 |
+
|
33 |
+
print("-----------------------------loading dataset-----------------------------------------------------------")
|
34 |
+
# LOAD DATA FROM HUGGINFACE
|
35 |
+
data = load_dataset("gbharti/finance-alpaca", split='train')
|
36 |
+
|
37 |
+
# PREPARE DATA FOR FINE-TUNING
|
38 |
+
def generate_prompt(data_point):
|
39 |
+
"""Gen. input text based on a prompt, task instruction, (context info.), and answer
|
40 |
+
|
41 |
+
:param data_point: dict: Data point
|
42 |
+
:return: dict: tokenzed prompt
|
43 |
+
"""
|
44 |
+
# Samples with additional context into.
|
45 |
+
if data_point['input']:
|
46 |
+
text = 'Below is an instruction that describes a task, paired with an input that provides' \
|
47 |
+
' further context. Write a response that appropriately completes the request.\n\n'
|
48 |
+
text += f'### Instruction:\n{data_point["instruction"]}\n\n'
|
49 |
+
text += f'### Input:\n{data_point["input"]}\n\n'
|
50 |
+
text += f'### Response:\n{data_point["output"]}'
|
51 |
+
|
52 |
+
# Without context
|
53 |
+
else:
|
54 |
+
text = 'Below is an instruction that describes a task. Write a response that ' \
|
55 |
+
'appropriately completes the request.\n\n'
|
56 |
+
text += f'### Instruction:\n{data_point["instruction"]}\n\n'
|
57 |
+
text += f'### Response:\n{data_point["output"]}'
|
58 |
+
return text
|
59 |
+
|
60 |
+
print("-----------------------------Preparing dataset for fine-tuning-----------------------------------------------------------")
|
61 |
+
prompt = [generate_prompt(data_point) for data_point in data]
|
62 |
+
data = data.add_column("prompt", prompt);
|
63 |
+
data = data.map(lambda sample: tokenizer(sample["prompt"]),num_proc=cpu_count(), batched=True)
|
64 |
+
# data = data.remove_columns(['Context', 'Response'])
|
65 |
+
data = data.shuffle(seed=1234)
|
66 |
+
data = data.train_test_split(test_size=0.1)
|
67 |
+
train_data = data["train"]
|
68 |
+
test_data = data["test"]
|
69 |
+
|
70 |
+
|
71 |
+
# LOADING MODEL IN N(4, 8.....) BIT
|
72 |
+
bnb_config = BitsAndBytesConfig(
|
73 |
+
load_in_4bit = True,
|
74 |
+
bnb_4bit_use_double_quant=True,
|
75 |
+
bnb_4bit_quant_type="nf4",
|
76 |
+
bnb_4bit_compute_dtype=torch.bfloat16
|
77 |
+
)
|
78 |
+
|
79 |
+
d_map = {"": torch.cuda.current_device()} if torch.cuda.is_available() else None
|
80 |
+
|
81 |
+
print("-----------------------------loading model-----------------------------------------------------------")
|
82 |
+
model = AutoModelForCausalLM.from_pretrained(
|
83 |
+
model_id,
|
84 |
+
torch_dtype="auto",
|
85 |
+
use_cache=False, # set to False as we're going to use gradient checkpointing
|
86 |
+
quantization_config=bnb_config,
|
87 |
+
device_map=d_map
|
88 |
+
)
|
89 |
+
|
90 |
+
|
91 |
+
def find_all_linear_names(model):
|
92 |
+
cls = bnb.nn.Linear4bit #if args.bits == 4 else (bnb.nn.Linear8bitLt if args.bits == 8 else torch.nn.Linear)
|
93 |
+
lora_module_names = set()
|
94 |
+
for name, module in model.named_modules():
|
95 |
+
if isinstance(module, cls):
|
96 |
+
names = name.split('.')
|
97 |
+
lora_module_names.add(names[0] if len(names) == 1 else names[-1])
|
98 |
+
if 'lm_head' in lora_module_names: # needed for 16-bit
|
99 |
+
lora_module_names.remove('lm_head')
|
100 |
+
return list(lora_module_names)
|
101 |
+
|
102 |
+
modules = find_all_linear_names(model)
|
103 |
+
|
104 |
+
|
105 |
+
lora_config = LoraConfig(
|
106 |
+
r=8, # Number of quantization levels
|
107 |
+
lora_alpha=32, # Hyperparameter for LoRA
|
108 |
+
target_modules = modules, # Modules to apply LoRA to
|
109 |
+
lora_dropout=0.05, # Dropout probability
|
110 |
+
bias="none", # Type of bias
|
111 |
+
task_type="CAUSAL_LM" # Task type (in this case, Causal Language Modeling)
|
112 |
+
)
|
113 |
+
model.gradient_checkpointing_enable()
|
114 |
+
model = prepare_model_for_kbit_training(model)
|
115 |
+
model = get_peft_model(model, lora_config)
|
116 |
+
|
117 |
+
|
118 |
+
# trainable, total = model.get_nb_trainable_parameters()
|
119 |
+
# print(f"Trainable: {trainable} | total: {total} | Percentage: {trainable/total*100:.4f}%")
|
120 |
+
|
121 |
+
tokenizer.pad_token = tokenizer.eos_token
|
122 |
+
torch.cuda.empty_cache()
|
123 |
+
|
124 |
+
trainer = SFTTrainer(
|
125 |
+
model=model,
|
126 |
+
train_dataset=train_data,
|
127 |
+
eval_dataset=test_data,
|
128 |
+
dataset_text_field="prompt",
|
129 |
+
peft_config=lora_config,
|
130 |
+
args=transformers.TrainingArguments(
|
131 |
+
per_device_train_batch_size=1,
|
132 |
+
gradient_accumulation_steps=4,
|
133 |
+
gradient_checkpointing=True,
|
134 |
+
fp16=True,
|
135 |
+
warmup_steps=0.03,
|
136 |
+
max_steps=10,
|
137 |
+
learning_rate=2e-4,
|
138 |
+
logging_steps=1,
|
139 |
+
output_dir="outputs",
|
140 |
+
optim="paged_adamw_8bit",
|
141 |
+
save_strategy="epoch",
|
142 |
+
),
|
143 |
+
data_collator=transformers.DataCollatorForLanguageModeling(tokenizer, mlm=False),
|
144 |
+
)
|
145 |
+
print("-----------------------------finetuning starts------------------------------------------------------------")
|
146 |
+
model.config.use_cache = False
|
147 |
+
trainer.train()
|
flagged/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
Temperature,Token Limit,Input,output,flag,username,timestamp
|
2 |
+
0.001,1,hello,,,,2024-02-08 01:33:00.412258
|
mergePeftWithBaseModel.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import (
|
2 |
+
AutoModelForCausalLM,
|
3 |
+
AutoTokenizer,
|
4 |
+
AutoTokenizer,
|
5 |
+
)
|
6 |
+
from peft import PeftModel, PeftConfig
|
7 |
+
import torch
|
8 |
+
|
9 |
+
d_map = {"": torch.cuda.current_device()} if torch.cuda.is_available() else None
|
10 |
+
local_model_path = "outputs/checkpoint-100" # Path to the combined weights
|
11 |
+
|
12 |
+
# Loading the base Model
|
13 |
+
config = PeftConfig.from_pretrained(local_model_path)
|
14 |
+
|
15 |
+
model = AutoModelForCausalLM.from_pretrained(
|
16 |
+
config.base_model_name_or_path,
|
17 |
+
return_dict=True,
|
18 |
+
# load_in_4bit=True,
|
19 |
+
device_map=d_map,
|
20 |
+
ignore_mismatched_sizes=True,
|
21 |
+
# from_tf=True,
|
22 |
+
)
|
23 |
+
|
24 |
+
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
|
25 |
+
|
26 |
+
# load the base model with the Lora model
|
27 |
+
model = PeftModel.from_pretrained(model, local_model_path)
|
28 |
+
|
29 |
+
merged = model.merge_and_unload()
|
30 |
+
|
31 |
+
merged.save_pretrained("outputs/merged")
|
32 |
+
|
33 |
+
tokenizer.save_pretrained("outputs/merged")
|
outputs/checkpoint-10/README.md
ADDED
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: peft
|
3 |
+
base_model: mistralai/Mistral-7B-v0.1
|
4 |
+
---
|
5 |
+
|
6 |
+
# Model Card for Model ID
|
7 |
+
|
8 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
## Model Details
|
13 |
+
|
14 |
+
### Model Description
|
15 |
+
|
16 |
+
<!-- Provide a longer summary of what this model is. -->
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
+
- **Developed by:** [More Information Needed]
|
21 |
+
- **Funded by [optional]:** [More Information Needed]
|
22 |
+
- **Shared by [optional]:** [More Information Needed]
|
23 |
+
- **Model type:** [More Information Needed]
|
24 |
+
- **Language(s) (NLP):** [More Information Needed]
|
25 |
+
- **License:** [More Information Needed]
|
26 |
+
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
+
|
28 |
+
### Model Sources [optional]
|
29 |
+
|
30 |
+
<!-- Provide the basic links for the model. -->
|
31 |
+
|
32 |
+
- **Repository:** [More Information Needed]
|
33 |
+
- **Paper [optional]:** [More Information Needed]
|
34 |
+
- **Demo [optional]:** [More Information Needed]
|
35 |
+
|
36 |
+
## Uses
|
37 |
+
|
38 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
+
|
40 |
+
### Direct Use
|
41 |
+
|
42 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
43 |
+
|
44 |
+
[More Information Needed]
|
45 |
+
|
46 |
+
### Downstream Use [optional]
|
47 |
+
|
48 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
+
|
50 |
+
[More Information Needed]
|
51 |
+
|
52 |
+
### Out-of-Scope Use
|
53 |
+
|
54 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
55 |
+
|
56 |
+
[More Information Needed]
|
57 |
+
|
58 |
+
## Bias, Risks, and Limitations
|
59 |
+
|
60 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
61 |
+
|
62 |
+
[More Information Needed]
|
63 |
+
|
64 |
+
### Recommendations
|
65 |
+
|
66 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
67 |
+
|
68 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
69 |
+
|
70 |
+
## How to Get Started with the Model
|
71 |
+
|
72 |
+
Use the code below to get started with the model.
|
73 |
+
|
74 |
+
[More Information Needed]
|
75 |
+
|
76 |
+
## Training Details
|
77 |
+
|
78 |
+
### Training Data
|
79 |
+
|
80 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
81 |
+
|
82 |
+
[More Information Needed]
|
83 |
+
|
84 |
+
### Training Procedure
|
85 |
+
|
86 |
+
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
+
|
88 |
+
#### Preprocessing [optional]
|
89 |
+
|
90 |
+
[More Information Needed]
|
91 |
+
|
92 |
+
|
93 |
+
#### Training Hyperparameters
|
94 |
+
|
95 |
+
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
96 |
+
|
97 |
+
#### Speeds, Sizes, Times [optional]
|
98 |
+
|
99 |
+
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
+
|
101 |
+
[More Information Needed]
|
102 |
+
|
103 |
+
## Evaluation
|
104 |
+
|
105 |
+
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
+
|
107 |
+
### Testing Data, Factors & Metrics
|
108 |
+
|
109 |
+
#### Testing Data
|
110 |
+
|
111 |
+
<!-- This should link to a Dataset Card if possible. -->
|
112 |
+
|
113 |
+
[More Information Needed]
|
114 |
+
|
115 |
+
#### Factors
|
116 |
+
|
117 |
+
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
+
|
119 |
+
[More Information Needed]
|
120 |
+
|
121 |
+
#### Metrics
|
122 |
+
|
123 |
+
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
+
|
125 |
+
[More Information Needed]
|
126 |
+
|
127 |
+
### Results
|
128 |
+
|
129 |
+
[More Information Needed]
|
130 |
+
|
131 |
+
#### Summary
|
132 |
+
|
133 |
+
|
134 |
+
|
135 |
+
## Model Examination [optional]
|
136 |
+
|
137 |
+
<!-- Relevant interpretability work for the model goes here -->
|
138 |
+
|
139 |
+
[More Information Needed]
|
140 |
+
|
141 |
+
## Environmental Impact
|
142 |
+
|
143 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
+
|
145 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
+
|
147 |
+
- **Hardware Type:** [More Information Needed]
|
148 |
+
- **Hours used:** [More Information Needed]
|
149 |
+
- **Cloud Provider:** [More Information Needed]
|
150 |
+
- **Compute Region:** [More Information Needed]
|
151 |
+
- **Carbon Emitted:** [More Information Needed]
|
152 |
+
|
153 |
+
## Technical Specifications [optional]
|
154 |
+
|
155 |
+
### Model Architecture and Objective
|
156 |
+
|
157 |
+
[More Information Needed]
|
158 |
+
|
159 |
+
### Compute Infrastructure
|
160 |
+
|
161 |
+
[More Information Needed]
|
162 |
+
|
163 |
+
#### Hardware
|
164 |
+
|
165 |
+
[More Information Needed]
|
166 |
+
|
167 |
+
#### Software
|
168 |
+
|
169 |
+
[More Information Needed]
|
170 |
+
|
171 |
+
## Citation [optional]
|
172 |
+
|
173 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
+
|
175 |
+
**BibTeX:**
|
176 |
+
|
177 |
+
[More Information Needed]
|
178 |
+
|
179 |
+
**APA:**
|
180 |
+
|
181 |
+
[More Information Needed]
|
182 |
+
|
183 |
+
## Glossary [optional]
|
184 |
+
|
185 |
+
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
+
|
187 |
+
[More Information Needed]
|
188 |
+
|
189 |
+
## More Information [optional]
|
190 |
+
|
191 |
+
[More Information Needed]
|
192 |
+
|
193 |
+
## Model Card Authors [optional]
|
194 |
+
|
195 |
+
[More Information Needed]
|
196 |
+
|
197 |
+
## Model Card Contact
|
198 |
+
|
199 |
+
[More Information Needed]
|
200 |
+
|
201 |
+
|
202 |
+
### Framework versions
|
203 |
+
|
204 |
+
- PEFT 0.8.2
|
outputs/checkpoint-10/adapter_config.json
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"alpha_pattern": {},
|
3 |
+
"auto_mapping": null,
|
4 |
+
"base_model_name_or_path": "mistralai/Mistral-7B-v0.1",
|
5 |
+
"bias": "none",
|
6 |
+
"fan_in_fan_out": false,
|
7 |
+
"inference_mode": true,
|
8 |
+
"init_lora_weights": true,
|
9 |
+
"layers_pattern": null,
|
10 |
+
"layers_to_transform": null,
|
11 |
+
"loftq_config": {},
|
12 |
+
"lora_alpha": 32,
|
13 |
+
"lora_dropout": 0.05,
|
14 |
+
"megatron_config": null,
|
15 |
+
"megatron_core": "megatron.core",
|
16 |
+
"modules_to_save": null,
|
17 |
+
"peft_type": "LORA",
|
18 |
+
"r": 8,
|
19 |
+
"rank_pattern": {},
|
20 |
+
"revision": null,
|
21 |
+
"target_modules": [
|
22 |
+
"up_proj",
|
23 |
+
"gate_proj",
|
24 |
+
"q_proj",
|
25 |
+
"o_proj",
|
26 |
+
"down_proj",
|
27 |
+
"v_proj",
|
28 |
+
"k_proj"
|
29 |
+
],
|
30 |
+
"task_type": "CAUSAL_LM",
|
31 |
+
"use_rslora": false
|
32 |
+
}
|
outputs/checkpoint-10/adapter_model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d5cf8302b03366081bd1d38bb1cb1879be97e37561f3d27948bad2acd0d923e4
|
3 |
+
size 83945296
|
outputs/checkpoint-10/optimizer.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a6d55b6511f1729b6376635f4163abd016e8d7c205f15ae4b1daab9e8d8e77d4
|
3 |
+
size 42545748
|
outputs/checkpoint-10/rng_state.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:466f8edfa57a71fc1c5033963e7ade8afb45dd92f2ae2bb543284593e1998663
|
3 |
+
size 14244
|
outputs/checkpoint-10/scheduler.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:92895d149359090ddf3ae4a97578a9224915364b8880d14de783a868db38bfc8
|
3 |
+
size 1064
|
outputs/checkpoint-10/special_tokens_map.json
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": {
|
3 |
+
"content": "<s>",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": false,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"eos_token": {
|
10 |
+
"content": "</s>",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": false,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"pad_token": "</s>",
|
17 |
+
"unk_token": {
|
18 |
+
"content": "<unk>",
|
19 |
+
"lstrip": false,
|
20 |
+
"normalized": false,
|
21 |
+
"rstrip": false,
|
22 |
+
"single_word": false
|
23 |
+
}
|
24 |
+
}
|
outputs/checkpoint-10/tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
outputs/checkpoint-10/tokenizer_config.json
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": true,
|
3 |
+
"add_eos_token": false,
|
4 |
+
"added_tokens_decoder": {
|
5 |
+
"0": {
|
6 |
+
"content": "<unk>",
|
7 |
+
"lstrip": false,
|
8 |
+
"normalized": false,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false,
|
11 |
+
"special": true
|
12 |
+
},
|
13 |
+
"1": {
|
14 |
+
"content": "<s>",
|
15 |
+
"lstrip": false,
|
16 |
+
"normalized": false,
|
17 |
+
"rstrip": false,
|
18 |
+
"single_word": false,
|
19 |
+
"special": true
|
20 |
+
},
|
21 |
+
"2": {
|
22 |
+
"content": "</s>",
|
23 |
+
"lstrip": false,
|
24 |
+
"normalized": false,
|
25 |
+
"rstrip": false,
|
26 |
+
"single_word": false,
|
27 |
+
"special": true
|
28 |
+
}
|
29 |
+
},
|
30 |
+
"additional_special_tokens": [],
|
31 |
+
"bos_token": "<s>",
|
32 |
+
"clean_up_tokenization_spaces": false,
|
33 |
+
"eos_token": "</s>",
|
34 |
+
"legacy": true,
|
35 |
+
"model_max_length": 1000000000000000019884624838656,
|
36 |
+
"pad_token": "</s>",
|
37 |
+
"sp_model_kwargs": {},
|
38 |
+
"spaces_between_special_tokens": false,
|
39 |
+
"tokenizer_class": "LlamaTokenizer",
|
40 |
+
"unk_token": "<unk>",
|
41 |
+
"use_default_system_prompt": false
|
42 |
+
}
|
outputs/checkpoint-10/trainer_state.json
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"best_metric": null,
|
3 |
+
"best_model_checkpoint": null,
|
4 |
+
"epoch": 0.0006449532408900354,
|
5 |
+
"eval_steps": 500,
|
6 |
+
"global_step": 10,
|
7 |
+
"is_hyper_param_search": false,
|
8 |
+
"is_local_process_zero": true,
|
9 |
+
"is_world_process_zero": true,
|
10 |
+
"log_history": [
|
11 |
+
{
|
12 |
+
"epoch": 0.0,
|
13 |
+
"learning_rate": 0.00018054162487462388,
|
14 |
+
"loss": 2.5461,
|
15 |
+
"step": 1
|
16 |
+
},
|
17 |
+
{
|
18 |
+
"epoch": 0.0,
|
19 |
+
"learning_rate": 0.000160481444332999,
|
20 |
+
"loss": 2.1187,
|
21 |
+
"step": 2
|
22 |
+
},
|
23 |
+
{
|
24 |
+
"epoch": 0.0,
|
25 |
+
"learning_rate": 0.00014042126379137414,
|
26 |
+
"loss": 2.1673,
|
27 |
+
"step": 3
|
28 |
+
},
|
29 |
+
{
|
30 |
+
"epoch": 0.0,
|
31 |
+
"learning_rate": 0.00012036108324974924,
|
32 |
+
"loss": 1.8731,
|
33 |
+
"step": 4
|
34 |
+
},
|
35 |
+
{
|
36 |
+
"epoch": 0.0,
|
37 |
+
"learning_rate": 0.00010030090270812438,
|
38 |
+
"loss": 1.4151,
|
39 |
+
"step": 5
|
40 |
+
},
|
41 |
+
{
|
42 |
+
"epoch": 0.0,
|
43 |
+
"learning_rate": 8.02407221664995e-05,
|
44 |
+
"loss": 1.5411,
|
45 |
+
"step": 6
|
46 |
+
},
|
47 |
+
{
|
48 |
+
"epoch": 0.0,
|
49 |
+
"learning_rate": 6.018054162487462e-05,
|
50 |
+
"loss": 1.4401,
|
51 |
+
"step": 7
|
52 |
+
},
|
53 |
+
{
|
54 |
+
"epoch": 0.0,
|
55 |
+
"learning_rate": 4.012036108324975e-05,
|
56 |
+
"loss": 0.85,
|
57 |
+
"step": 8
|
58 |
+
},
|
59 |
+
{
|
60 |
+
"epoch": 0.0,
|
61 |
+
"learning_rate": 2.0060180541624874e-05,
|
62 |
+
"loss": 1.0114,
|
63 |
+
"step": 9
|
64 |
+
},
|
65 |
+
{
|
66 |
+
"epoch": 0.0,
|
67 |
+
"learning_rate": 0.0,
|
68 |
+
"loss": 1.8774,
|
69 |
+
"step": 10
|
70 |
+
}
|
71 |
+
],
|
72 |
+
"logging_steps": 1,
|
73 |
+
"max_steps": 10,
|
74 |
+
"num_input_tokens_seen": 0,
|
75 |
+
"num_train_epochs": 1,
|
76 |
+
"save_steps": 500,
|
77 |
+
"total_flos": 336712855117824.0,
|
78 |
+
"train_batch_size": 1,
|
79 |
+
"trial_name": null,
|
80 |
+
"trial_params": null
|
81 |
+
}
|
outputs/checkpoint-10/training_args.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c51fe40f7d5d576653d66e0860715cd1f38681cfe0dc755470225987a86fec53
|
3 |
+
size 4664
|
outputs/checkpoint-100/README.md
ADDED
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: peft
|
3 |
+
base_model: mistralai/Mistral-7B-v0.1
|
4 |
+
---
|
5 |
+
|
6 |
+
# Model Card for Model ID
|
7 |
+
|
8 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
## Model Details
|
13 |
+
|
14 |
+
### Model Description
|
15 |
+
|
16 |
+
<!-- Provide a longer summary of what this model is. -->
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
+
- **Developed by:** [More Information Needed]
|
21 |
+
- **Funded by [optional]:** [More Information Needed]
|
22 |
+
- **Shared by [optional]:** [More Information Needed]
|
23 |
+
- **Model type:** [More Information Needed]
|
24 |
+
- **Language(s) (NLP):** [More Information Needed]
|
25 |
+
- **License:** [More Information Needed]
|
26 |
+
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
+
|
28 |
+
### Model Sources [optional]
|
29 |
+
|
30 |
+
<!-- Provide the basic links for the model. -->
|
31 |
+
|
32 |
+
- **Repository:** [More Information Needed]
|
33 |
+
- **Paper [optional]:** [More Information Needed]
|
34 |
+
- **Demo [optional]:** [More Information Needed]
|
35 |
+
|
36 |
+
## Uses
|
37 |
+
|
38 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
+
|
40 |
+
### Direct Use
|
41 |
+
|
42 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
43 |
+
|
44 |
+
[More Information Needed]
|
45 |
+
|
46 |
+
### Downstream Use [optional]
|
47 |
+
|
48 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
+
|
50 |
+
[More Information Needed]
|
51 |
+
|
52 |
+
### Out-of-Scope Use
|
53 |
+
|
54 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
55 |
+
|
56 |
+
[More Information Needed]
|
57 |
+
|
58 |
+
## Bias, Risks, and Limitations
|
59 |
+
|
60 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
61 |
+
|
62 |
+
[More Information Needed]
|
63 |
+
|
64 |
+
### Recommendations
|
65 |
+
|
66 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
67 |
+
|
68 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
69 |
+
|
70 |
+
## How to Get Started with the Model
|
71 |
+
|
72 |
+
Use the code below to get started with the model.
|
73 |
+
|
74 |
+
[More Information Needed]
|
75 |
+
|
76 |
+
## Training Details
|
77 |
+
|
78 |
+
### Training Data
|
79 |
+
|
80 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
81 |
+
|
82 |
+
[More Information Needed]
|
83 |
+
|
84 |
+
### Training Procedure
|
85 |
+
|
86 |
+
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
+
|
88 |
+
#### Preprocessing [optional]
|
89 |
+
|
90 |
+
[More Information Needed]
|
91 |
+
|
92 |
+
|
93 |
+
#### Training Hyperparameters
|
94 |
+
|
95 |
+
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
96 |
+
|
97 |
+
#### Speeds, Sizes, Times [optional]
|
98 |
+
|
99 |
+
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
+
|
101 |
+
[More Information Needed]
|
102 |
+
|
103 |
+
## Evaluation
|
104 |
+
|
105 |
+
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
+
|
107 |
+
### Testing Data, Factors & Metrics
|
108 |
+
|
109 |
+
#### Testing Data
|
110 |
+
|
111 |
+
<!-- This should link to a Dataset Card if possible. -->
|
112 |
+
|
113 |
+
[More Information Needed]
|
114 |
+
|
115 |
+
#### Factors
|
116 |
+
|
117 |
+
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
+
|
119 |
+
[More Information Needed]
|
120 |
+
|
121 |
+
#### Metrics
|
122 |
+
|
123 |
+
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
+
|
125 |
+
[More Information Needed]
|
126 |
+
|
127 |
+
### Results
|
128 |
+
|
129 |
+
[More Information Needed]
|
130 |
+
|
131 |
+
#### Summary
|
132 |
+
|
133 |
+
|
134 |
+
|
135 |
+
## Model Examination [optional]
|
136 |
+
|
137 |
+
<!-- Relevant interpretability work for the model goes here -->
|
138 |
+
|
139 |
+
[More Information Needed]
|
140 |
+
|
141 |
+
## Environmental Impact
|
142 |
+
|
143 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
+
|
145 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
+
|
147 |
+
- **Hardware Type:** [More Information Needed]
|
148 |
+
- **Hours used:** [More Information Needed]
|
149 |
+
- **Cloud Provider:** [More Information Needed]
|
150 |
+
- **Compute Region:** [More Information Needed]
|
151 |
+
- **Carbon Emitted:** [More Information Needed]
|
152 |
+
|
153 |
+
## Technical Specifications [optional]
|
154 |
+
|
155 |
+
### Model Architecture and Objective
|
156 |
+
|
157 |
+
[More Information Needed]
|
158 |
+
|
159 |
+
### Compute Infrastructure
|
160 |
+
|
161 |
+
[More Information Needed]
|
162 |
+
|
163 |
+
#### Hardware
|
164 |
+
|
165 |
+
[More Information Needed]
|
166 |
+
|
167 |
+
#### Software
|
168 |
+
|
169 |
+
[More Information Needed]
|
170 |
+
|
171 |
+
## Citation [optional]
|
172 |
+
|
173 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
+
|
175 |
+
**BibTeX:**
|
176 |
+
|
177 |
+
[More Information Needed]
|
178 |
+
|
179 |
+
**APA:**
|
180 |
+
|
181 |
+
[More Information Needed]
|
182 |
+
|
183 |
+
## Glossary [optional]
|
184 |
+
|
185 |
+
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
+
|
187 |
+
[More Information Needed]
|
188 |
+
|
189 |
+
## More Information [optional]
|
190 |
+
|
191 |
+
[More Information Needed]
|
192 |
+
|
193 |
+
## Model Card Authors [optional]
|
194 |
+
|
195 |
+
[More Information Needed]
|
196 |
+
|
197 |
+
## Model Card Contact
|
198 |
+
|
199 |
+
[More Information Needed]
|
200 |
+
|
201 |
+
|
202 |
+
### Framework versions
|
203 |
+
|
204 |
+
- PEFT 0.8.2
|
outputs/checkpoint-100/adapter_config.json
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"alpha_pattern": {},
|
3 |
+
"auto_mapping": null,
|
4 |
+
"base_model_name_or_path": "mistralai/Mistral-7B-v0.1",
|
5 |
+
"bias": "none",
|
6 |
+
"fan_in_fan_out": false,
|
7 |
+
"inference_mode": true,
|
8 |
+
"init_lora_weights": true,
|
9 |
+
"layers_pattern": null,
|
10 |
+
"layers_to_transform": null,
|
11 |
+
"loftq_config": {},
|
12 |
+
"lora_alpha": 32,
|
13 |
+
"lora_dropout": 0.05,
|
14 |
+
"megatron_config": null,
|
15 |
+
"megatron_core": "megatron.core",
|
16 |
+
"modules_to_save": null,
|
17 |
+
"peft_type": "LORA",
|
18 |
+
"r": 8,
|
19 |
+
"rank_pattern": {},
|
20 |
+
"revision": null,
|
21 |
+
"target_modules": [
|
22 |
+
"up_proj",
|
23 |
+
"q_proj",
|
24 |
+
"k_proj",
|
25 |
+
"o_proj",
|
26 |
+
"gate_proj",
|
27 |
+
"down_proj",
|
28 |
+
"v_proj"
|
29 |
+
],
|
30 |
+
"task_type": "CAUSAL_LM",
|
31 |
+
"use_rslora": false
|
32 |
+
}
|
outputs/checkpoint-100/adapter_model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3d4c76655486ba0755cda4b98e8cf44c51ac55c316a16716adfe72a893f33f59
|
3 |
+
size 83945296
|
outputs/checkpoint-100/optimizer.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d3fe5cd332d7c70e0ea8516a38e95aef229624258fb58b07d39e5793024acdc2
|
3 |
+
size 42545748
|
outputs/checkpoint-100/rng_state.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8a2da9732d59f29842d306635d89f785d09764a48e4c3ddf83b669fcba436f2e
|
3 |
+
size 14244
|
outputs/checkpoint-100/scheduler.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:06de337c477ec1811259baac2b8aa88593bc99d405bbc7f63f504e99114af4cf
|
3 |
+
size 1064
|
outputs/checkpoint-100/special_tokens_map.json
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": {
|
3 |
+
"content": "<s>",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": false,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"eos_token": {
|
10 |
+
"content": "</s>",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": false,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"pad_token": "</s>",
|
17 |
+
"unk_token": {
|
18 |
+
"content": "<unk>",
|
19 |
+
"lstrip": false,
|
20 |
+
"normalized": false,
|
21 |
+
"rstrip": false,
|
22 |
+
"single_word": false
|
23 |
+
}
|
24 |
+
}
|
outputs/checkpoint-100/tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
outputs/checkpoint-100/tokenizer_config.json
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": true,
|
3 |
+
"add_eos_token": false,
|
4 |
+
"added_tokens_decoder": {
|
5 |
+
"0": {
|
6 |
+
"content": "<unk>",
|
7 |
+
"lstrip": false,
|
8 |
+
"normalized": false,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false,
|
11 |
+
"special": true
|
12 |
+
},
|
13 |
+
"1": {
|
14 |
+
"content": "<s>",
|
15 |
+
"lstrip": false,
|
16 |
+
"normalized": false,
|
17 |
+
"rstrip": false,
|
18 |
+
"single_word": false,
|
19 |
+
"special": true
|
20 |
+
},
|
21 |
+
"2": {
|
22 |
+
"content": "</s>",
|
23 |
+
"lstrip": false,
|
24 |
+
"normalized": false,
|
25 |
+
"rstrip": false,
|
26 |
+
"single_word": false,
|
27 |
+
"special": true
|
28 |
+
}
|
29 |
+
},
|
30 |
+
"additional_special_tokens": [],
|
31 |
+
"bos_token": "<s>",
|
32 |
+
"clean_up_tokenization_spaces": false,
|
33 |
+
"eos_token": "</s>",
|
34 |
+
"legacy": true,
|
35 |
+
"model_max_length": 1000000000000000019884624838656,
|
36 |
+
"pad_token": "</s>",
|
37 |
+
"sp_model_kwargs": {},
|
38 |
+
"spaces_between_special_tokens": false,
|
39 |
+
"tokenizer_class": "LlamaTokenizer",
|
40 |
+
"unk_token": "<unk>",
|
41 |
+
"use_default_system_prompt": false
|
42 |
+
}
|
outputs/checkpoint-100/trainer_state.json
ADDED
@@ -0,0 +1,621 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"best_metric": null,
|
3 |
+
"best_model_checkpoint": null,
|
4 |
+
"epoch": 0.0064495324089003546,
|
5 |
+
"eval_steps": 500,
|
6 |
+
"global_step": 100,
|
7 |
+
"is_hyper_param_search": false,
|
8 |
+
"is_local_process_zero": true,
|
9 |
+
"is_world_process_zero": true,
|
10 |
+
"log_history": [
|
11 |
+
{
|
12 |
+
"epoch": 0.0,
|
13 |
+
"learning_rate": 0.00019805941782534764,
|
14 |
+
"loss": 2.1283,
|
15 |
+
"step": 1
|
16 |
+
},
|
17 |
+
{
|
18 |
+
"epoch": 0.0,
|
19 |
+
"learning_rate": 0.00019605881764529358,
|
20 |
+
"loss": 1.9699,
|
21 |
+
"step": 2
|
22 |
+
},
|
23 |
+
{
|
24 |
+
"epoch": 0.0,
|
25 |
+
"learning_rate": 0.00019405821746523957,
|
26 |
+
"loss": 1.4391,
|
27 |
+
"step": 3
|
28 |
+
},
|
29 |
+
{
|
30 |
+
"epoch": 0.0,
|
31 |
+
"learning_rate": 0.00019205761728518557,
|
32 |
+
"loss": 1.175,
|
33 |
+
"step": 4
|
34 |
+
},
|
35 |
+
{
|
36 |
+
"epoch": 0.0,
|
37 |
+
"learning_rate": 0.00019005701710513156,
|
38 |
+
"loss": 0.9018,
|
39 |
+
"step": 5
|
40 |
+
},
|
41 |
+
{
|
42 |
+
"epoch": 0.0,
|
43 |
+
"learning_rate": 0.00018805641692507753,
|
44 |
+
"loss": 1.074,
|
45 |
+
"step": 6
|
46 |
+
},
|
47 |
+
{
|
48 |
+
"epoch": 0.0,
|
49 |
+
"learning_rate": 0.00018605581674502352,
|
50 |
+
"loss": 1.5826,
|
51 |
+
"step": 7
|
52 |
+
},
|
53 |
+
{
|
54 |
+
"epoch": 0.0,
|
55 |
+
"learning_rate": 0.00018405521656496952,
|
56 |
+
"loss": 0.9327,
|
57 |
+
"step": 8
|
58 |
+
},
|
59 |
+
{
|
60 |
+
"epoch": 0.0,
|
61 |
+
"learning_rate": 0.00018205461638491548,
|
62 |
+
"loss": 1.258,
|
63 |
+
"step": 9
|
64 |
+
},
|
65 |
+
{
|
66 |
+
"epoch": 0.0,
|
67 |
+
"learning_rate": 0.00018005401620486148,
|
68 |
+
"loss": 1.0259,
|
69 |
+
"step": 10
|
70 |
+
},
|
71 |
+
{
|
72 |
+
"epoch": 0.0,
|
73 |
+
"learning_rate": 0.00017805341602480744,
|
74 |
+
"loss": 0.788,
|
75 |
+
"step": 11
|
76 |
+
},
|
77 |
+
{
|
78 |
+
"epoch": 0.0,
|
79 |
+
"learning_rate": 0.00017605281584475344,
|
80 |
+
"loss": 1.3443,
|
81 |
+
"step": 12
|
82 |
+
},
|
83 |
+
{
|
84 |
+
"epoch": 0.0,
|
85 |
+
"learning_rate": 0.00017405221566469943,
|
86 |
+
"loss": 1.207,
|
87 |
+
"step": 13
|
88 |
+
},
|
89 |
+
{
|
90 |
+
"epoch": 0.0,
|
91 |
+
"learning_rate": 0.00017205161548464542,
|
92 |
+
"loss": 0.7044,
|
93 |
+
"step": 14
|
94 |
+
},
|
95 |
+
{
|
96 |
+
"epoch": 0.0,
|
97 |
+
"learning_rate": 0.00017005101530459136,
|
98 |
+
"loss": 1.0694,
|
99 |
+
"step": 15
|
100 |
+
},
|
101 |
+
{
|
102 |
+
"epoch": 0.0,
|
103 |
+
"learning_rate": 0.00016805041512453736,
|
104 |
+
"loss": 1.1858,
|
105 |
+
"step": 16
|
106 |
+
},
|
107 |
+
{
|
108 |
+
"epoch": 0.0,
|
109 |
+
"learning_rate": 0.00016604981494448335,
|
110 |
+
"loss": 1.2622,
|
111 |
+
"step": 17
|
112 |
+
},
|
113 |
+
{
|
114 |
+
"epoch": 0.0,
|
115 |
+
"learning_rate": 0.00016404921476442935,
|
116 |
+
"loss": 0.7919,
|
117 |
+
"step": 18
|
118 |
+
},
|
119 |
+
{
|
120 |
+
"epoch": 0.0,
|
121 |
+
"learning_rate": 0.0001620486145843753,
|
122 |
+
"loss": 1.0567,
|
123 |
+
"step": 19
|
124 |
+
},
|
125 |
+
{
|
126 |
+
"epoch": 0.0,
|
127 |
+
"learning_rate": 0.0001600480144043213,
|
128 |
+
"loss": 1.2917,
|
129 |
+
"step": 20
|
130 |
+
},
|
131 |
+
{
|
132 |
+
"epoch": 0.0,
|
133 |
+
"learning_rate": 0.0001580474142242673,
|
134 |
+
"loss": 0.9172,
|
135 |
+
"step": 21
|
136 |
+
},
|
137 |
+
{
|
138 |
+
"epoch": 0.0,
|
139 |
+
"learning_rate": 0.00015604681404421327,
|
140 |
+
"loss": 1.3542,
|
141 |
+
"step": 22
|
142 |
+
},
|
143 |
+
{
|
144 |
+
"epoch": 0.0,
|
145 |
+
"learning_rate": 0.00015404621386415926,
|
146 |
+
"loss": 1.4117,
|
147 |
+
"step": 23
|
148 |
+
},
|
149 |
+
{
|
150 |
+
"epoch": 0.0,
|
151 |
+
"learning_rate": 0.00015204561368410523,
|
152 |
+
"loss": 0.6285,
|
153 |
+
"step": 24
|
154 |
+
},
|
155 |
+
{
|
156 |
+
"epoch": 0.0,
|
157 |
+
"learning_rate": 0.00015004501350405122,
|
158 |
+
"loss": 1.4488,
|
159 |
+
"step": 25
|
160 |
+
},
|
161 |
+
{
|
162 |
+
"epoch": 0.0,
|
163 |
+
"learning_rate": 0.00014804441332399721,
|
164 |
+
"loss": 0.618,
|
165 |
+
"step": 26
|
166 |
+
},
|
167 |
+
{
|
168 |
+
"epoch": 0.0,
|
169 |
+
"learning_rate": 0.0001460438131439432,
|
170 |
+
"loss": 1.3617,
|
171 |
+
"step": 27
|
172 |
+
},
|
173 |
+
{
|
174 |
+
"epoch": 0.0,
|
175 |
+
"learning_rate": 0.00014404321296388918,
|
176 |
+
"loss": 1.1482,
|
177 |
+
"step": 28
|
178 |
+
},
|
179 |
+
{
|
180 |
+
"epoch": 0.0,
|
181 |
+
"learning_rate": 0.00014204261278383514,
|
182 |
+
"loss": 1.0907,
|
183 |
+
"step": 29
|
184 |
+
},
|
185 |
+
{
|
186 |
+
"epoch": 0.0,
|
187 |
+
"learning_rate": 0.00014004201260378114,
|
188 |
+
"loss": 1.0434,
|
189 |
+
"step": 30
|
190 |
+
},
|
191 |
+
{
|
192 |
+
"epoch": 0.0,
|
193 |
+
"learning_rate": 0.00013804141242372713,
|
194 |
+
"loss": 1.3318,
|
195 |
+
"step": 31
|
196 |
+
},
|
197 |
+
{
|
198 |
+
"epoch": 0.0,
|
199 |
+
"learning_rate": 0.00013604081224367312,
|
200 |
+
"loss": 1.109,
|
201 |
+
"step": 32
|
202 |
+
},
|
203 |
+
{
|
204 |
+
"epoch": 0.0,
|
205 |
+
"learning_rate": 0.0001340402120636191,
|
206 |
+
"loss": 1.0989,
|
207 |
+
"step": 33
|
208 |
+
},
|
209 |
+
{
|
210 |
+
"epoch": 0.0,
|
211 |
+
"learning_rate": 0.00013203961188356508,
|
212 |
+
"loss": 1.2508,
|
213 |
+
"step": 34
|
214 |
+
},
|
215 |
+
{
|
216 |
+
"epoch": 0.0,
|
217 |
+
"learning_rate": 0.00013003901170351108,
|
218 |
+
"loss": 1.3718,
|
219 |
+
"step": 35
|
220 |
+
},
|
221 |
+
{
|
222 |
+
"epoch": 0.0,
|
223 |
+
"learning_rate": 0.00012803841152345704,
|
224 |
+
"loss": 0.8635,
|
225 |
+
"step": 36
|
226 |
+
},
|
227 |
+
{
|
228 |
+
"epoch": 0.0,
|
229 |
+
"learning_rate": 0.000126037811343403,
|
230 |
+
"loss": 1.0131,
|
231 |
+
"step": 37
|
232 |
+
},
|
233 |
+
{
|
234 |
+
"epoch": 0.0,
|
235 |
+
"learning_rate": 0.000124037211163349,
|
236 |
+
"loss": 1.0554,
|
237 |
+
"step": 38
|
238 |
+
},
|
239 |
+
{
|
240 |
+
"epoch": 0.0,
|
241 |
+
"learning_rate": 0.000122036610983295,
|
242 |
+
"loss": 0.8635,
|
243 |
+
"step": 39
|
244 |
+
},
|
245 |
+
{
|
246 |
+
"epoch": 0.0,
|
247 |
+
"learning_rate": 0.00012003601080324098,
|
248 |
+
"loss": 0.7278,
|
249 |
+
"step": 40
|
250 |
+
},
|
251 |
+
{
|
252 |
+
"epoch": 0.0,
|
253 |
+
"learning_rate": 0.00011803541062318697,
|
254 |
+
"loss": 1.5206,
|
255 |
+
"step": 41
|
256 |
+
},
|
257 |
+
{
|
258 |
+
"epoch": 0.0,
|
259 |
+
"learning_rate": 0.00011603481044313295,
|
260 |
+
"loss": 1.0913,
|
261 |
+
"step": 42
|
262 |
+
},
|
263 |
+
{
|
264 |
+
"epoch": 0.0,
|
265 |
+
"learning_rate": 0.00011403421026307892,
|
266 |
+
"loss": 0.7845,
|
267 |
+
"step": 43
|
268 |
+
},
|
269 |
+
{
|
270 |
+
"epoch": 0.0,
|
271 |
+
"learning_rate": 0.00011203361008302491,
|
272 |
+
"loss": 0.8502,
|
273 |
+
"step": 44
|
274 |
+
},
|
275 |
+
{
|
276 |
+
"epoch": 0.0,
|
277 |
+
"learning_rate": 0.0001100330099029709,
|
278 |
+
"loss": 1.8437,
|
279 |
+
"step": 45
|
280 |
+
},
|
281 |
+
{
|
282 |
+
"epoch": 0.0,
|
283 |
+
"learning_rate": 0.00010803240972291689,
|
284 |
+
"loss": 1.6084,
|
285 |
+
"step": 46
|
286 |
+
},
|
287 |
+
{
|
288 |
+
"epoch": 0.0,
|
289 |
+
"learning_rate": 0.00010603180954286287,
|
290 |
+
"loss": 1.1675,
|
291 |
+
"step": 47
|
292 |
+
},
|
293 |
+
{
|
294 |
+
"epoch": 0.0,
|
295 |
+
"learning_rate": 0.00010403120936280886,
|
296 |
+
"loss": 1.1029,
|
297 |
+
"step": 48
|
298 |
+
},
|
299 |
+
{
|
300 |
+
"epoch": 0.0,
|
301 |
+
"learning_rate": 0.00010203060918275482,
|
302 |
+
"loss": 1.151,
|
303 |
+
"step": 49
|
304 |
+
},
|
305 |
+
{
|
306 |
+
"epoch": 0.0,
|
307 |
+
"learning_rate": 0.00010003000900270081,
|
308 |
+
"loss": 1.061,
|
309 |
+
"step": 50
|
310 |
+
},
|
311 |
+
{
|
312 |
+
"epoch": 0.0,
|
313 |
+
"learning_rate": 9.802940882264679e-05,
|
314 |
+
"loss": 1.536,
|
315 |
+
"step": 51
|
316 |
+
},
|
317 |
+
{
|
318 |
+
"epoch": 0.0,
|
319 |
+
"learning_rate": 9.602880864259278e-05,
|
320 |
+
"loss": 0.616,
|
321 |
+
"step": 52
|
322 |
+
},
|
323 |
+
{
|
324 |
+
"epoch": 0.0,
|
325 |
+
"learning_rate": 9.402820846253876e-05,
|
326 |
+
"loss": 0.8911,
|
327 |
+
"step": 53
|
328 |
+
},
|
329 |
+
{
|
330 |
+
"epoch": 0.0,
|
331 |
+
"learning_rate": 9.202760828248476e-05,
|
332 |
+
"loss": 1.3183,
|
333 |
+
"step": 54
|
334 |
+
},
|
335 |
+
{
|
336 |
+
"epoch": 0.0,
|
337 |
+
"learning_rate": 9.002700810243074e-05,
|
338 |
+
"loss": 1.186,
|
339 |
+
"step": 55
|
340 |
+
},
|
341 |
+
{
|
342 |
+
"epoch": 0.0,
|
343 |
+
"learning_rate": 8.802640792237672e-05,
|
344 |
+
"loss": 1.301,
|
345 |
+
"step": 56
|
346 |
+
},
|
347 |
+
{
|
348 |
+
"epoch": 0.0,
|
349 |
+
"learning_rate": 8.802640792237672e-05,
|
350 |
+
"loss": 0.9267,
|
351 |
+
"step": 57
|
352 |
+
},
|
353 |
+
{
|
354 |
+
"epoch": 0.0,
|
355 |
+
"learning_rate": 8.602580774232271e-05,
|
356 |
+
"loss": 1.6136,
|
357 |
+
"step": 58
|
358 |
+
},
|
359 |
+
{
|
360 |
+
"epoch": 0.0,
|
361 |
+
"learning_rate": 8.402520756226868e-05,
|
362 |
+
"loss": 0.6503,
|
363 |
+
"step": 59
|
364 |
+
},
|
365 |
+
{
|
366 |
+
"epoch": 0.0,
|
367 |
+
"learning_rate": 8.202460738221467e-05,
|
368 |
+
"loss": 1.1043,
|
369 |
+
"step": 60
|
370 |
+
},
|
371 |
+
{
|
372 |
+
"epoch": 0.0,
|
373 |
+
"learning_rate": 8.002400720216065e-05,
|
374 |
+
"loss": 1.098,
|
375 |
+
"step": 61
|
376 |
+
},
|
377 |
+
{
|
378 |
+
"epoch": 0.0,
|
379 |
+
"learning_rate": 7.802340702210663e-05,
|
380 |
+
"loss": 0.8298,
|
381 |
+
"step": 62
|
382 |
+
},
|
383 |
+
{
|
384 |
+
"epoch": 0.0,
|
385 |
+
"learning_rate": 7.602280684205261e-05,
|
386 |
+
"loss": 1.3,
|
387 |
+
"step": 63
|
388 |
+
},
|
389 |
+
{
|
390 |
+
"epoch": 0.0,
|
391 |
+
"learning_rate": 7.402220666199861e-05,
|
392 |
+
"loss": 1.2021,
|
393 |
+
"step": 64
|
394 |
+
},
|
395 |
+
{
|
396 |
+
"epoch": 0.0,
|
397 |
+
"learning_rate": 7.202160648194459e-05,
|
398 |
+
"loss": 1.2454,
|
399 |
+
"step": 65
|
400 |
+
},
|
401 |
+
{
|
402 |
+
"epoch": 0.0,
|
403 |
+
"learning_rate": 7.002100630189057e-05,
|
404 |
+
"loss": 1.2646,
|
405 |
+
"step": 66
|
406 |
+
},
|
407 |
+
{
|
408 |
+
"epoch": 0.0,
|
409 |
+
"learning_rate": 6.802040612183656e-05,
|
410 |
+
"loss": 1.2226,
|
411 |
+
"step": 67
|
412 |
+
},
|
413 |
+
{
|
414 |
+
"epoch": 0.0,
|
415 |
+
"learning_rate": 6.601980594178254e-05,
|
416 |
+
"loss": 1.2412,
|
417 |
+
"step": 68
|
418 |
+
},
|
419 |
+
{
|
420 |
+
"epoch": 0.0,
|
421 |
+
"learning_rate": 6.401920576172852e-05,
|
422 |
+
"loss": 1.4806,
|
423 |
+
"step": 69
|
424 |
+
},
|
425 |
+
{
|
426 |
+
"epoch": 0.0,
|
427 |
+
"learning_rate": 6.20186055816745e-05,
|
428 |
+
"loss": 0.908,
|
429 |
+
"step": 70
|
430 |
+
},
|
431 |
+
{
|
432 |
+
"epoch": 0.0,
|
433 |
+
"learning_rate": 6.001800540162049e-05,
|
434 |
+
"loss": 1.1458,
|
435 |
+
"step": 71
|
436 |
+
},
|
437 |
+
{
|
438 |
+
"epoch": 0.0,
|
439 |
+
"learning_rate": 5.801740522156648e-05,
|
440 |
+
"loss": 1.2067,
|
441 |
+
"step": 72
|
442 |
+
},
|
443 |
+
{
|
444 |
+
"epoch": 0.0,
|
445 |
+
"learning_rate": 5.601680504151246e-05,
|
446 |
+
"loss": 1.1893,
|
447 |
+
"step": 73
|
448 |
+
},
|
449 |
+
{
|
450 |
+
"epoch": 0.0,
|
451 |
+
"learning_rate": 5.4016204861458444e-05,
|
452 |
+
"loss": 1.1854,
|
453 |
+
"step": 74
|
454 |
+
},
|
455 |
+
{
|
456 |
+
"epoch": 0.0,
|
457 |
+
"learning_rate": 5.201560468140443e-05,
|
458 |
+
"loss": 0.9617,
|
459 |
+
"step": 75
|
460 |
+
},
|
461 |
+
{
|
462 |
+
"epoch": 0.0,
|
463 |
+
"learning_rate": 5.0015004501350405e-05,
|
464 |
+
"loss": 1.0145,
|
465 |
+
"step": 76
|
466 |
+
},
|
467 |
+
{
|
468 |
+
"epoch": 0.0,
|
469 |
+
"learning_rate": 4.801440432129639e-05,
|
470 |
+
"loss": 1.3273,
|
471 |
+
"step": 77
|
472 |
+
},
|
473 |
+
{
|
474 |
+
"epoch": 0.01,
|
475 |
+
"learning_rate": 4.601380414124238e-05,
|
476 |
+
"loss": 0.841,
|
477 |
+
"step": 78
|
478 |
+
},
|
479 |
+
{
|
480 |
+
"epoch": 0.01,
|
481 |
+
"learning_rate": 4.401320396118836e-05,
|
482 |
+
"loss": 1.0926,
|
483 |
+
"step": 79
|
484 |
+
},
|
485 |
+
{
|
486 |
+
"epoch": 0.01,
|
487 |
+
"learning_rate": 4.201260378113434e-05,
|
488 |
+
"loss": 0.9073,
|
489 |
+
"step": 80
|
490 |
+
},
|
491 |
+
{
|
492 |
+
"epoch": 0.01,
|
493 |
+
"learning_rate": 4.0012003601080326e-05,
|
494 |
+
"loss": 0.6963,
|
495 |
+
"step": 81
|
496 |
+
},
|
497 |
+
{
|
498 |
+
"epoch": 0.01,
|
499 |
+
"learning_rate": 3.801140342102631e-05,
|
500 |
+
"loss": 1.023,
|
501 |
+
"step": 82
|
502 |
+
},
|
503 |
+
{
|
504 |
+
"epoch": 0.01,
|
505 |
+
"learning_rate": 3.6010803240972294e-05,
|
506 |
+
"loss": 1.079,
|
507 |
+
"step": 83
|
508 |
+
},
|
509 |
+
{
|
510 |
+
"epoch": 0.01,
|
511 |
+
"learning_rate": 3.401020306091828e-05,
|
512 |
+
"loss": 1.0577,
|
513 |
+
"step": 84
|
514 |
+
},
|
515 |
+
{
|
516 |
+
"epoch": 0.01,
|
517 |
+
"learning_rate": 3.200960288086426e-05,
|
518 |
+
"loss": 0.8747,
|
519 |
+
"step": 85
|
520 |
+
},
|
521 |
+
{
|
522 |
+
"epoch": 0.01,
|
523 |
+
"learning_rate": 3.0009002700810245e-05,
|
524 |
+
"loss": 1.0794,
|
525 |
+
"step": 86
|
526 |
+
},
|
527 |
+
{
|
528 |
+
"epoch": 0.01,
|
529 |
+
"learning_rate": 2.800840252075623e-05,
|
530 |
+
"loss": 0.8603,
|
531 |
+
"step": 87
|
532 |
+
},
|
533 |
+
{
|
534 |
+
"epoch": 0.01,
|
535 |
+
"learning_rate": 2.6007802340702216e-05,
|
536 |
+
"loss": 1.4064,
|
537 |
+
"step": 88
|
538 |
+
},
|
539 |
+
{
|
540 |
+
"epoch": 0.01,
|
541 |
+
"learning_rate": 2.4007202160648196e-05,
|
542 |
+
"loss": 1.2233,
|
543 |
+
"step": 89
|
544 |
+
},
|
545 |
+
{
|
546 |
+
"epoch": 0.01,
|
547 |
+
"learning_rate": 2.200660198059418e-05,
|
548 |
+
"loss": 1.6015,
|
549 |
+
"step": 90
|
550 |
+
},
|
551 |
+
{
|
552 |
+
"epoch": 0.01,
|
553 |
+
"learning_rate": 2.0006001800540163e-05,
|
554 |
+
"loss": 1.1858,
|
555 |
+
"step": 91
|
556 |
+
},
|
557 |
+
{
|
558 |
+
"epoch": 0.01,
|
559 |
+
"learning_rate": 1.8005401620486147e-05,
|
560 |
+
"loss": 0.676,
|
561 |
+
"step": 92
|
562 |
+
},
|
563 |
+
{
|
564 |
+
"epoch": 0.01,
|
565 |
+
"learning_rate": 1.600480144043213e-05,
|
566 |
+
"loss": 1.4585,
|
567 |
+
"step": 93
|
568 |
+
},
|
569 |
+
{
|
570 |
+
"epoch": 0.01,
|
571 |
+
"learning_rate": 1.4004201260378114e-05,
|
572 |
+
"loss": 1.3953,
|
573 |
+
"step": 94
|
574 |
+
},
|
575 |
+
{
|
576 |
+
"epoch": 0.01,
|
577 |
+
"learning_rate": 1.2003601080324098e-05,
|
578 |
+
"loss": 0.9336,
|
579 |
+
"step": 95
|
580 |
+
},
|
581 |
+
{
|
582 |
+
"epoch": 0.01,
|
583 |
+
"learning_rate": 1.0003000900270082e-05,
|
584 |
+
"loss": 0.8244,
|
585 |
+
"step": 96
|
586 |
+
},
|
587 |
+
{
|
588 |
+
"epoch": 0.01,
|
589 |
+
"learning_rate": 8.002400720216065e-06,
|
590 |
+
"loss": 0.8921,
|
591 |
+
"step": 97
|
592 |
+
},
|
593 |
+
{
|
594 |
+
"epoch": 0.01,
|
595 |
+
"learning_rate": 6.001800540162049e-06,
|
596 |
+
"loss": 1.1946,
|
597 |
+
"step": 98
|
598 |
+
},
|
599 |
+
{
|
600 |
+
"epoch": 0.01,
|
601 |
+
"learning_rate": 4.001200360108033e-06,
|
602 |
+
"loss": 1.3317,
|
603 |
+
"step": 99
|
604 |
+
},
|
605 |
+
{
|
606 |
+
"epoch": 0.01,
|
607 |
+
"learning_rate": 2.0006001800540163e-06,
|
608 |
+
"loss": 0.6798,
|
609 |
+
"step": 100
|
610 |
+
}
|
611 |
+
],
|
612 |
+
"logging_steps": 1,
|
613 |
+
"max_steps": 100,
|
614 |
+
"num_input_tokens_seen": 0,
|
615 |
+
"num_train_epochs": 1,
|
616 |
+
"save_steps": 500,
|
617 |
+
"total_flos": 2762380453404672.0,
|
618 |
+
"train_batch_size": 1,
|
619 |
+
"trial_name": null,
|
620 |
+
"trial_params": null
|
621 |
+
}
|
outputs/checkpoint-100/training_args.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:73450ff8bcd630c54efa079eb5886af4c4249e60576ac187998637f94ce85529
|
3 |
+
size 4664
|
outputs/merged/.ipynb_checkpoints/config-checkpoint.json
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "mistralai/Mistral-7B-v0.1",
|
3 |
+
"architectures": [
|
4 |
+
"MistralForCausalLM"
|
5 |
+
],
|
6 |
+
"attention_dropout": 0.0,
|
7 |
+
"bos_token_id": 1,
|
8 |
+
"eos_token_id": 2,
|
9 |
+
"hidden_act": "silu",
|
10 |
+
"hidden_size": 4096,
|
11 |
+
"initializer_range": 0.02,
|
12 |
+
"intermediate_size": 14336,
|
13 |
+
"max_position_embeddings": 32768,
|
14 |
+
"model_type": "mistral",
|
15 |
+
"num_attention_heads": 32,
|
16 |
+
"num_hidden_layers": 32,
|
17 |
+
"num_key_value_heads": 8,
|
18 |
+
"quantization_config": {
|
19 |
+
"bnb_4bit_compute_dtype": "float32",
|
20 |
+
"bnb_4bit_quant_type": "fp4",
|
21 |
+
"bnb_4bit_use_double_quant": false,
|
22 |
+
"llm_int8_enable_fp32_cpu_offload": false,
|
23 |
+
"llm_int8_has_fp16_weight": false,
|
24 |
+
"llm_int8_skip_modules": null,
|
25 |
+
"llm_int8_threshold": 6.0,
|
26 |
+
"load_in_4bit": true,
|
27 |
+
"load_in_8bit": false,
|
28 |
+
"quant_method": "bitsandbytes"
|
29 |
+
},
|
30 |
+
"rms_norm_eps": 1e-05,
|
31 |
+
"rope_theta": 10000.0,
|
32 |
+
"sliding_window": 4096,
|
33 |
+
"tie_word_embeddings": false,
|
34 |
+
"torch_dtype": "float16",
|
35 |
+
"transformers_version": "4.37.2",
|
36 |
+
"use_cache": true,
|
37 |
+
"vocab_size": 32000
|
38 |
+
}
|
outputs/merged/config.json
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "mistralai/Mistral-7B-v0.1",
|
3 |
+
"architectures": [
|
4 |
+
"MistralForCausalLM"
|
5 |
+
],
|
6 |
+
"attention_dropout": 0.0,
|
7 |
+
"bos_token_id": 1,
|
8 |
+
"eos_token_id": 2,
|
9 |
+
"hidden_act": "silu",
|
10 |
+
"hidden_size": 4096,
|
11 |
+
"initializer_range": 0.02,
|
12 |
+
"intermediate_size": 14336,
|
13 |
+
"max_position_embeddings": 32768,
|
14 |
+
"model_type": "mistral",
|
15 |
+
"num_attention_heads": 32,
|
16 |
+
"num_hidden_layers": 32,
|
17 |
+
"num_key_value_heads": 8,
|
18 |
+
"quantization_config": {
|
19 |
+
"bnb_4bit_compute_dtype": "float32",
|
20 |
+
"bnb_4bit_quant_type": "fp4",
|
21 |
+
"bnb_4bit_use_double_quant": false,
|
22 |
+
"llm_int8_enable_fp32_cpu_offload": false,
|
23 |
+
"llm_int8_has_fp16_weight": false,
|
24 |
+
"llm_int8_skip_modules": null,
|
25 |
+
"llm_int8_threshold": 6.0,
|
26 |
+
"load_in_4bit": true,
|
27 |
+
"load_in_8bit": false,
|
28 |
+
"quant_method": "bitsandbytes"
|
29 |
+
},
|
30 |
+
"rms_norm_eps": 1e-05,
|
31 |
+
"rope_theta": 10000.0,
|
32 |
+
"sliding_window": 4096,
|
33 |
+
"tie_word_embeddings": false,
|
34 |
+
"torch_dtype": "float16",
|
35 |
+
"transformers_version": "4.37.2",
|
36 |
+
"use_cache": true,
|
37 |
+
"vocab_size": 32000
|
38 |
+
}
|
outputs/merged/generation_config.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 1,
|
4 |
+
"eos_token_id": 2,
|
5 |
+
"transformers_version": "4.37.2"
|
6 |
+
}
|
outputs/merged/model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9e5252c0ef4cf3bf6aa7defa8f1f2afbf7c743a859ba1aec2e0a7d846ba5578e
|
3 |
+
size 4450837496
|
outputs/merged/special_tokens_map.json
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": {
|
3 |
+
"content": "<s>",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": false,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"eos_token": {
|
10 |
+
"content": "</s>",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": false,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"unk_token": {
|
17 |
+
"content": "<unk>",
|
18 |
+
"lstrip": false,
|
19 |
+
"normalized": false,
|
20 |
+
"rstrip": false,
|
21 |
+
"single_word": false
|
22 |
+
}
|
23 |
+
}
|
outputs/merged/tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
outputs/merged/tokenizer_config.json
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": true,
|
3 |
+
"add_eos_token": false,
|
4 |
+
"added_tokens_decoder": {
|
5 |
+
"0": {
|
6 |
+
"content": "<unk>",
|
7 |
+
"lstrip": false,
|
8 |
+
"normalized": false,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false,
|
11 |
+
"special": true
|
12 |
+
},
|
13 |
+
"1": {
|
14 |
+
"content": "<s>",
|
15 |
+
"lstrip": false,
|
16 |
+
"normalized": false,
|
17 |
+
"rstrip": false,
|
18 |
+
"single_word": false,
|
19 |
+
"special": true
|
20 |
+
},
|
21 |
+
"2": {
|
22 |
+
"content": "</s>",
|
23 |
+
"lstrip": false,
|
24 |
+
"normalized": false,
|
25 |
+
"rstrip": false,
|
26 |
+
"single_word": false,
|
27 |
+
"special": true
|
28 |
+
}
|
29 |
+
},
|
30 |
+
"additional_special_tokens": [],
|
31 |
+
"bos_token": "<s>",
|
32 |
+
"clean_up_tokenization_spaces": false,
|
33 |
+
"eos_token": "</s>",
|
34 |
+
"legacy": true,
|
35 |
+
"model_max_length": 1000000000000000019884624838656,
|
36 |
+
"pad_token": null,
|
37 |
+
"sp_model_kwargs": {},
|
38 |
+
"spaces_between_special_tokens": false,
|
39 |
+
"tokenizer_class": "LlamaTokenizer",
|
40 |
+
"unk_token": "<unk>",
|
41 |
+
"use_default_system_prompt": false
|
42 |
+
}
|
requiretments.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
bitsandbytes
|
2 |
+
transformers
|
3 |
+
peft
|
4 |
+
accelerate
|
5 |
+
datasets
|
6 |
+
trl
|
7 |
+
flash-attn
|
8 |
+
gradio
|
uploadToHub.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import (
|
2 |
+
AutoModelForCausalLM,
|
3 |
+
AutoTokenizer,
|
4 |
+
AutoTokenizer,
|
5 |
+
)
|
6 |
+
|
7 |
+
import torch
|
8 |
+
|
9 |
+
d_map = {"": torch.cuda.current_device()} if torch.cuda.is_available() else None
|
10 |
+
merged_model_path = "outputs/merged" # Path to the combined weights
|
11 |
+
repo_name = "Financial_Analyst" # HuggingFace repo name
|
12 |
+
|
13 |
+
|
14 |
+
model = AutoModelForCausalLM.from_pretrained(
|
15 |
+
merged_model_path,
|
16 |
+
ignore_mismatched_sizes=True,
|
17 |
+
from_tf=True,
|
18 |
+
trust_remote_code=True,
|
19 |
+
device_map=d_map,
|
20 |
+
torch_dtype=torch.float16,
|
21 |
+
).eval()
|
22 |
+
|
23 |
+
tokenizer = AutoTokenizer.from_pretrained(merged_model_path)
|
24 |
+
|
25 |
+
|
26 |
+
model.push_to_hub(repo_name, token=hf_token)
|
27 |
+
tokenizer.push_to_hub(repo_name, token=hf_token)
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
|