Spaces:
Sleeping
Sleeping
File size: 6,554 Bytes
f7b9392 56a76eb f7b9392 56a76eb f7b9392 56a76eb f7b9392 56a76eb f7b9392 56a76eb f7b9392 56a76eb f7b9392 56a76eb f7b9392 |
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 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/opt/anaconda3/lib/python3.9/site-packages/huggingface_hub/utils/_hf_folder.py:92: UserWarning: A token has been found in `/Users/casa/.huggingface/token`. This is the old path where tokens were stored. The new location is `/Users/casa/.cache/huggingface/token` which is configurable using `HF_HOME` environment variable. Your token has been copied to this new location. You can now safely delete the old token file manually or use `huggingface-cli logout`.\n",
" warnings.warn(\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e42b34cf3f07417592f26316fea86e1a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading (β¦)lve/main/config.json: 0%| | 0.00/944 [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4f89d76d6b7e4cf59a9dd631bd739221",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading pytorch_model.bin: 0%| | 0.00/1.66G [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a690f8b53a204d489f4d53a937068ac6",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading (β¦)neration_config.json: 0%| | 0.00/111 [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "14302bef459f485a998d908b131f43ec",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading (β¦)okenizer_config.json: 0%| | 0.00/771 [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "33826da838e1402581f62fafd3657b90",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading (β¦)olve/main/vocab.json: 0%| | 0.00/1.27M [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3ebc87d16a79449998bcb21e33d2ec0b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading (β¦)olve/main/merges.txt: 0%| | 0.00/925k [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d70c4a2755d04e0d995686f9425b49f8",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading (β¦)/main/tokenizer.json: 0%| | 0.00/3.07M [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "cd341cbb7ff445daa312695cc9be1a13",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading (β¦)cial_tokens_map.json: 0%| | 0.00/96.0 [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import torch\n",
"import random\n",
"import time\n",
"from transformers import pipeline\n",
"\n",
"generator = pipeline(\n",
" 'text-generation',\n",
" model=\"heegyu/bluechat-v0\",\n",
" device=\"cuda:0\" if torch.cuda.is_available() else 'cpu'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
"\n",
"def query(prompt, max_turn=4):\n",
" output = generator(\n",
" prompt.strip(),\n",
" # no_repeat_ngram_size=2,\n",
" eos_token_id=0, # 375=\\n 2=</s>, 0:open-end\n",
" max_new_tokens=128,\n",
" do_sample=True,\n",
" top_p=0.7,\n",
" early_stopping=True\n",
" )[0]['generated_text']\n",
"\n",
" print(output)\n",
"\n",
" # response = output[len(prompt):]\n",
" # return response.strip()"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 : μλ
νμΈμ</s>\n",
"1 : λ°κ°μμ</s>\n",
"0 : μμ¦ μ’μνλ μμ
μμΌμ κ°μ?</s>\n",
"1 : μ΅κ·Όμ λ€μ΄μμΈμ§ λ무 λ§μ΄ λ€μ΄μ</s>\n",
"0 : μ μ£Όλ‘ μ΄λ€κ±°μ?</s>\n",
"1 : μ΅κ·Όμ λ€μ΄μ¬λ¦° μμ
μ 무μμΈκ°μ?0 : λ€ ν€ν€ μ κ° μ’μνλ 곑μ λ°λ‘ μμ΄μ μμ1 : μ μμ΄μ λ
Έλ μ λ§ μ’λ€μ0 : μμ΄μ λ
Έλ μ°Έ μ’μμ1 : μμ΄μ λ
Έλ μ§μ§ μ’μμ0 : μ μ§μ§ μμ΄μ λ
Έλ μλΆλ₯΄μΈμ1 : λ€ μμ΄μ λ
Έλ μ’μμ0 : μμ΄μ λ
Έλ μ§μ§ μ’μ£ 1 : μ μ§μ§ μ’λ€μ0 : μμ΄μ λ
Έλλ μ°Έ μ’μμ1 : μμ΄μ λ
Έλ μ λ§ μ’μμ0 : μμ΄μ λ
Έλ μ λ§ μ’μμ1 : μμ΄μ λ
Έλ μ λ§ μ’μμ0 : μμ΄μ λ
Έλ μ§μ§ μ’μμ1 : μμ΄μ λ
Έλ μ λ§ μ’μμ0 : μ μ§μ§ μ’μμ1 : μ μ§μ§ μ’μμ0 : μμ΄μ λ
Έλ\n"
]
}
],
"source": [
"query(\"\"\"\n",
"0 : μλ
νμΈμ</s>\n",
"1 : λ°κ°μμ</s>\n",
"0 : μμ¦ μ’μνλ μμ
μμΌμ κ°μ?</s>\n",
"1 : μ΅κ·Όμ λ€μ΄μμΈμ§ λ무 λ§μ΄ λ€μ΄μ</s>\n",
"0 : μ μ£Όλ‘ μ΄λ€κ±°μ?</s>\n",
"1 : \n",
"\"\"\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"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.9.12"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
|