Spaces:
Sleeping
Sleeping
File size: 4,041 Bytes
8f38740 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "99576983-f881-47c8-8b5e-c6f561a93e71",
"metadata": {},
"outputs": [],
"source": [
"import transformers"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "58ba19f2-4b91-4f90-a33d-4c1ed17e202a",
"metadata": {},
"outputs": [],
"source": [
"from transformers import LlavaForConditionalGeneration, LlavaConfig, CLIPVisionConfig, PhiConfig\n",
"\n",
"# Initializing a CLIP-vision config\n",
"vision_config = CLIPVisionConfig()\n",
"\n",
"# Initializing a Llama config\n",
"text_config = PhiConfig()\n",
"\n",
"# Initializing a Llava llava-1.5-7b style configuration\n",
"configuration = LlavaConfig(vision_config, text_config)\n",
"\n",
"# Initializing a model from the llava-1.5-7b style configuration\n",
"model = LlavaForConditionalGeneration(configuration)\n",
"\n",
"# Accessing the model configuration\n",
"configuration = model.config"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "a806a07a-fe72-45a3-8ceb-8e942c6c845d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"LlavaConfig {\n",
" \"ignore_index\": -100,\n",
" \"image_token_index\": 32000,\n",
" \"model_type\": \"llava\",\n",
" \"projector_hidden_act\": \"gelu\",\n",
" \"text_config\": {\n",
" \"embd_pdrop\": 0.0,\n",
" \"hidden_act\": \"gelu_new\",\n",
" \"hidden_size\": 2048,\n",
" \"intermediate_size\": 8192,\n",
" \"layer_norm_eps\": 1e-05,\n",
" \"model_type\": \"phi\",\n",
" \"num_hidden_layers\": 24,\n",
" \"partial_rotary_factor\": 0.5,\n",
" \"qk_layernorm\": false,\n",
" \"resid_pdrop\": 0.0,\n",
" \"vocab_size\": 51200\n",
" },\n",
" \"transformers_version\": \"4.36.2\",\n",
" \"vision_config\": {\n",
" \"hidden_size\": 768,\n",
" \"image_size\": 224,\n",
" \"intermediate_size\": 3072,\n",
" \"model_type\": \"clip_vision_model\",\n",
" \"num_attention_heads\": 12,\n",
" \"num_hidden_layers\": 12,\n",
" \"patch_size\": 32,\n",
" \"projection_dim\": 512\n",
" },\n",
" \"vision_feature_layer\": -2,\n",
" \"vision_feature_select_strategy\": \"default\",\n",
" \"vocab_size\": 32000\n",
"}"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model.config"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "79efbc6b-f005-4a5c-82a1-112fa37f1904",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cloning into 'llava-phi'...\n",
"remote: Enumerating objects: 151, done.\u001b[K\n",
"remote: Counting objects: 100% (151/151), done.\u001b[K\n",
"remote: Compressing objects: 100% (116/116), done.\u001b[K\n",
"remote: Total 151 (delta 36), reused 133 (delta 25), pack-reused 0\u001b[K\n",
"Receiving objects: 100% (151/151), 333.89 KiB | 112.00 KiB/s, done.\n",
"Resolving deltas: 100% (36/36), done.\n"
]
}
],
"source": [
"!git clone https://github.com/zhuyiche/llava-phi.git"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cf827184-f334-4d86-ace1-fe9c92f84d66",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|