KAHRAMAN42 commited on
Commit
f4bb0b5
·
1 Parent(s): bcf25d9

Delete Colaboratory'ye_Hoş_Geldiniz_adlı_not_defterinin_kopyası.ipynb

Browse files
Colaboratory'ye_Hoş_Geldiniz_adlı_not_defterinin_kopyası.ipynb DELETED
@@ -1,402 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "source": [
6
- "!pip install conda\n",
7
- "!conda create env -f hf-env.yml\n",
8
- "import sys\n",
9
- "!conda activate <hf-env.yml>\n",
10
- "sys.path.append(\"/content/hf-env.yml\")\n",
11
- "\n",
12
- "!pip install transformers\n"
13
- ],
14
- "metadata": {
15
- "id": "ABCj_7LhLzxy",
16
- "outputId": "50eb21cc-f248-4a1b-b7fd-875c2bee9552",
17
- "colab": {
18
- "base_uri": "https://localhost:8080/"
19
- }
20
- },
21
- "execution_count": 59,
22
- "outputs": [
23
- {
24
- "output_type": "stream",
25
- "name": "stdout",
26
- "text": [
27
- "\u001b[31mERROR: Could not find a version that satisfies the requirement conda (from versions: 3.0.6, 3.5.0, 3.7.0, 3.17.0, 4.0.0, 4.0.1, 4.0.2, 4.0.3, 4.0.4, 4.0.5, 4.0.7, 4.0.8, 4.0.9, 4.1.2, 4.1.6, 4.2.6, 4.2.7, 4.3.13, 4.3.16)\u001b[0m\u001b[31m\n",
28
- "\u001b[0m\u001b[31mERROR: No matching distribution found for conda\u001b[0m\u001b[31m\n",
29
- "\u001b[0m/bin/bash: line 1: conda: command not found\n",
30
- "/bin/bash: -c: line 1: syntax error near unexpected token `newline'\n",
31
- "/bin/bash: -c: line 1: `conda activate <hf-env.yml>'\n",
32
- "Requirement already satisfied: transformers in /usr/local/lib/python3.10/dist-packages (4.34.1)\n",
33
- "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from transformers) (3.12.4)\n",
34
- "Requirement already satisfied: huggingface-hub<1.0,>=0.16.4 in /usr/local/lib/python3.10/dist-packages (from transformers) (0.17.3)\n",
35
- "Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from transformers) (1.23.5)\n",
36
- "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from transformers) (23.2)\n",
37
- "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from transformers) (6.0.1)\n",
38
- "Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.10/dist-packages (from transformers) (2023.6.3)\n",
39
- "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from transformers) (2.31.0)\n",
40
- "Requirement already satisfied: tokenizers<0.15,>=0.14 in /usr/local/lib/python3.10/dist-packages (from transformers) (0.14.1)\n",
41
- "Requirement already satisfied: safetensors>=0.3.1 in /usr/local/lib/python3.10/dist-packages (from transformers) (0.4.0)\n",
42
- "Requirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.10/dist-packages (from transformers) (4.66.1)\n",
43
- "Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->transformers) (2023.6.0)\n",
44
- "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->transformers) (4.5.0)\n",
45
- "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (3.3.1)\n",
46
- "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (3.4)\n",
47
- "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (2.0.7)\n",
48
- "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (2023.7.22)\n"
49
- ]
50
- }
51
- ]
52
- },
53
- {
54
- "cell_type": "code",
55
- "source": [
56
- "from transformers import pipeline\n",
57
- "\n",
58
- "classifier = pipeline(task=\"sentiment-analysis\",\n",
59
- " model=\"distilbert-base-uncased-finetuned-sst-2-english\")\n",
60
- "\n",
61
- "classifier(\"senden nefret ediyorum\")"
62
- ],
63
- "metadata": {
64
- "id": "EavCohSrLzvC",
65
- "outputId": "9c41cb81-bf3a-44fd-e8a9-3bcd7c2a59ae",
66
- "colab": {
67
- "base_uri": "https://localhost:8080/"
68
- }
69
- },
70
- "execution_count": 60,
71
- "outputs": [
72
- {
73
- "output_type": "execute_result",
74
- "data": {
75
- "text/plain": [
76
- "[{'label': 'NEGATIVE', 'score': 0.8867656588554382}]"
77
- ]
78
- },
79
- "metadata": {},
80
- "execution_count": 60
81
- }
82
- ]
83
- },
84
- {
85
- "cell_type": "code",
86
- "source": [
87
- "text_list = [\n",
88
- " \"Thanks for nothing\", \\\n",
89
- " \"You've got to work on your face\", \\\n",
90
- " \"You're beautiful, never change!\"\n",
91
- " ]\n",
92
- "\n",
93
- "classifier(text_list)"
94
- ],
95
- "metadata": {
96
- "id": "CfA713s4LzmO",
97
- "outputId": "e293c2aa-f276-4ed7-934f-adcfb7537597",
98
- "colab": {
99
- "base_uri": "https://localhost:8080/"
100
- }
101
- },
102
- "execution_count": 61,
103
- "outputs": [
104
- {
105
- "output_type": "execute_result",
106
- "data": {
107
- "text/plain": [
108
- "[{'label': 'POSITIVE', 'score': 0.9680057168006897},\n",
109
- " {'label': 'NEGATIVE', 'score': 0.8776116371154785},\n",
110
- " {'label': 'POSITIVE', 'score': 0.9998120665550232}]"
111
- ]
112
- },
113
- "metadata": {},
114
- "execution_count": 61
115
- }
116
- ]
117
- },
118
- {
119
- "cell_type": "code",
120
- "source": [
121
- "classifier = pipeline(task=\"text-classification\", \\\n",
122
- " model=\"SamLowe/roberta-base-go_emotions\", top_k=5)\n",
123
- "\n",
124
- "classifier(text_list[0])"
125
- ],
126
- "metadata": {
127
- "id": "V5kaqpjOLzgT",
128
- "outputId": "cfca0849-25b8-4e54-c7f7-9bd227f4b83f",
129
- "colab": {
130
- "base_uri": "https://localhost:8080/"
131
- }
132
- },
133
- "execution_count": 62,
134
- "outputs": [
135
- {
136
- "output_type": "execute_result",
137
- "data": {
138
- "text/plain": [
139
- "[[{'label': 'gratitude', 'score': 0.97365802526474},\n",
140
- " {'label': 'neutral', 'score': 0.019856028258800507},\n",
141
- " {'label': 'annoyance', 'score': 0.016787199303507805},\n",
142
- " {'label': 'disapproval', 'score': 0.009506478905677795},\n",
143
- " {'label': 'realization', 'score': 0.008019842207431793}]]"
144
- ]
145
- },
146
- "metadata": {},
147
- "execution_count": 62
148
- }
149
- ]
150
- },
151
- {
152
- "cell_type": "code",
153
- "source": [
154
- "summarizer = pipeline(\"summarization\", model=\"facebook/bart-large-cnn\")\n",
155
- "\n",
156
- "text = \"\"\"\"Akıllı Yatırımcı,\" Benjamin Graham tarafından yazılan klasik bir yatırım kitabıdır.\n",
157
- " Kitap, değer yatırımı stratejilerini vurgular ve yatırımcılara risk yönetimi, güvenlik çeşitlendirmesi,\n",
158
- " ve mantıklı hisse senedi seçimi konularında rehberlik eder.\n",
159
- " Ayrıca, piyasa dalgalanmalarını anlamak ve duygusal kararlar yerine rasyonel analizleri benimsemek gerektiğini vurgular.\n",
160
- " Bu kitap, yatırımcılar için temel bir kaynaktır ve finansal okuryazarlık kazanmalarına yardımcı olabilir.\"\"\"\n",
161
- "summarized_text = summarizer(text,max_length=160, min_length=10)[0][\"summary_text\"]\n",
162
- "print(summarized_text)"
163
- ],
164
- "metadata": {
165
- "id": "eBeGliY6Lze6",
166
- "outputId": "263d0e25-575f-438e-bebb-53085ce1c77b",
167
- "colab": {
168
- "base_uri": "https://localhost:8080/"
169
- }
170
- },
171
- "execution_count": 63,
172
- "outputs": [
173
- {
174
- "output_type": "stream",
175
- "name": "stdout",
176
- "text": [
177
- "\"Akıllı Yatırımcı,\" Benjamin Graham tarafından yazılan klasik bir yatçarım kitabıdır. Kitap, değer yat Turkey, stratejilerini vurgular ve yat Turkish, risk yönetimi, güvenlik çeşitlendirmesi ve mantıklı hisse senedi seçimi.\n"
178
- ]
179
- }
180
- ]
181
- },
182
- {
183
- "cell_type": "code",
184
- "source": [
185
- "classifier(summarized_text)"
186
- ],
187
- "metadata": {
188
- "id": "MHwD-zqOLzdl",
189
- "outputId": "0cc85f46-a82e-4554-b992-038c7397b5f4",
190
- "colab": {
191
- "base_uri": "https://localhost:8080/"
192
- }
193
- },
194
- "execution_count": 64,
195
- "outputs": [
196
- {
197
- "output_type": "execute_result",
198
- "data": {
199
- "text/plain": [
200
- "[[{'label': 'neutral', 'score': 0.934576690196991},\n",
201
- " {'label': 'annoyance', 'score': 0.011846810579299927},\n",
202
- " {'label': 'approval', 'score': 0.01065461803227663},\n",
203
- " {'label': 'amusement', 'score': 0.004115849267691374},\n",
204
- " {'label': 'realization', 'score': 0.0038815124426037073}]]"
205
- ]
206
- },
207
- "metadata": {},
208
- "execution_count": 64
209
- }
210
- ]
211
- },
212
- {
213
- "cell_type": "code",
214
- "source": [],
215
- "metadata": {
216
- "id": "Ts9UcFQILzbx"
217
- },
218
- "execution_count": 64,
219
- "outputs": []
220
- },
221
- {
222
- "cell_type": "code",
223
- "source": [],
224
- "metadata": {
225
- "id": "RL_w6eogLzay"
226
- },
227
- "execution_count": 64,
228
- "outputs": []
229
- },
230
- {
231
- "cell_type": "code",
232
- "source": [],
233
- "metadata": {
234
- "id": "-LsDKC4OOYTt"
235
- },
236
- "execution_count": 64,
237
- "outputs": []
238
- },
239
- {
240
- "cell_type": "code",
241
- "source": [
242
- "chatbot = pipeline(model=\"facebook/blenderbot-400M-distill\")"
243
- ],
244
- "metadata": {
245
- "id": "jzlNFs9BOYWd"
246
- },
247
- "execution_count": 65,
248
- "outputs": []
249
- },
250
- {
251
- "cell_type": "code",
252
- "source": [
253
- "from transformers import Conversation\n",
254
- "\n",
255
- "conversation = Conversation(\"Hi I'm KAHRAMAN, how are you?\")\n",
256
- "conversation = chatbot(conversation)\n",
257
- "print(conversation)"
258
- ],
259
- "metadata": {
260
- "id": "WidsUGLAOoeK",
261
- "outputId": "7715a55e-bed2-49a9-8ac5-0ed362e24536",
262
- "colab": {
263
- "base_uri": "https://localhost:8080/"
264
- }
265
- },
266
- "execution_count": 66,
267
- "outputs": [
268
- {
269
- "output_type": "stream",
270
- "name": "stdout",
271
- "text": [
272
- "Conversation id: 6e9d0605-e84c-4b52-bafc-f2699fc2bb49\n",
273
- "user: Hi I'm KAHRAMAN, how are you?\n",
274
- "assistant: I'm doing well. How are you doing this evening? I just got home from work.\n",
275
- "\n"
276
- ]
277
- }
278
- ]
279
- },
280
- {
281
- "cell_type": "code",
282
- "source": [
283
- "conversation.add_user_input(\"What about do you work? \")\n",
284
- "conversation = chatbot(conversation)\n",
285
- "print(conversation)"
286
- ],
287
- "metadata": {
288
- "id": "m8C258-uOrqr",
289
- "outputId": "f1ce8970-7ace-4631-a151-eea9311c2e00",
290
- "colab": {
291
- "base_uri": "https://localhost:8080/"
292
- }
293
- },
294
- "execution_count": 67,
295
- "outputs": [
296
- {
297
- "output_type": "stream",
298
- "name": "stdout",
299
- "text": [
300
- "Conversation id: 6e9d0605-e84c-4b52-bafc-f2699fc2bb49\n",
301
- "user: Hi I'm KAHRAMAN, how are you?\n",
302
- "assistant: I'm doing well. How are you doing this evening? I just got home from work.\n",
303
- "user: What about do you work? \n",
304
- "assistant: I work at a grocery store as a cashier. What do you do for work?\n",
305
- "\n"
306
- ]
307
- }
308
- ]
309
- },
310
- {
311
- "cell_type": "code",
312
- "source": [
313
- "conversation.add_user_input(\"I'am working software in cafe now\")\n",
314
- "conversation = chatbot(conversation)\n",
315
- "print(conversation)"
316
- ],
317
- "metadata": {
318
- "id": "d-y0UM4KO4pq",
319
- "outputId": "a2e8acd9-fd22-418c-fcaa-58437249b236",
320
- "colab": {
321
- "base_uri": "https://localhost:8080/"
322
- }
323
- },
324
- "execution_count": 68,
325
- "outputs": [
326
- {
327
- "output_type": "stream",
328
- "name": "stderr",
329
- "text": [
330
- "Conversation input is too long (78), trimming it to 50 tokens. Consider increasing `max_length` to avoid truncation.\n"
331
- ]
332
- },
333
- {
334
- "output_type": "stream",
335
- "name": "stdout",
336
- "text": [
337
- "Conversation id: 6e9d0605-e84c-4b52-bafc-f2699fc2bb49\n",
338
- "user: Hi I'm KAHRAMAN, how are you?\n",
339
- "assistant: I'm doing well. How are you doing this evening? I just got home from work.\n",
340
- "user: What about do you work? \n",
341
- "assistant: I work at a grocery store as a cashier. What do you do for work?\n",
342
- "user: I'am working software in cafe now\n",
343
- "assistant: That sounds like a lot of fun. What kind of food do you serve at the cafe?\n",
344
- "\n"
345
- ]
346
- }
347
- ]
348
- },
349
- {
350
- "cell_type": "code",
351
- "source": [
352
- "conversation.add_user_input(\"I'am just getting started.\")\n",
353
- "conversation = chatbot(conversation)\n",
354
- "print(conversation)"
355
- ],
356
- "metadata": {
357
- "id": "VjL__dUvQKqK",
358
- "outputId": "bc133697-1c4b-46a1-b3e7-e36c40e795b9",
359
- "colab": {
360
- "base_uri": "https://localhost:8080/"
361
- }
362
- },
363
- "execution_count": 69,
364
- "outputs": [
365
- {
366
- "output_type": "stream",
367
- "name": "stderr",
368
- "text": [
369
- "Conversation input is too long (109), trimming it to 50 tokens. Consider increasing `max_length` to avoid truncation.\n"
370
- ]
371
- },
372
- {
373
- "output_type": "stream",
374
- "name": "stdout",
375
- "text": [
376
- "Conversation id: 6e9d0605-e84c-4b52-bafc-f2699fc2bb49\n",
377
- "user: Hi I'm KAHRAMAN, how are you?\n",
378
- "assistant: I'm doing well. How are you doing this evening? I just got home from work.\n",
379
- "user: What about do you work? \n",
380
- "assistant: I work at a grocery store as a cashier. What do you do for work?\n",
381
- "user: I'am working software in cafe now\n",
382
- "assistant: That sounds like a lot of fun. What kind of food do you serve at the cafe?\n",
383
- "user: I'am just getting started.\n",
384
- "assistant: I hope it goes well for you. Do you have any tips for a newbie?\n",
385
- "\n"
386
- ]
387
- }
388
- ]
389
- }
390
- ],
391
- "metadata": {
392
- "colab": {
393
- "provenance": []
394
- },
395
- "kernelspec": {
396
- "display_name": "Python 3",
397
- "name": "python3"
398
- }
399
- },
400
- "nbformat": 4,
401
- "nbformat_minor": 0
402
- }