Agon H commited on
Commit
2df4ccc
1 Parent(s): 8470ce3

Upload run in CPU.ipynb

Browse files
Files changed (1) hide show
  1. run in CPU.ipynb +77 -0
run in CPU.ipynb ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 0,
4
+ "metadata": {
5
+ "colab": {
6
+ "provenance": []
7
+ },
8
+ "kernelspec": {
9
+ "name": "python3",
10
+ "display_name": "Python 3"
11
+ },
12
+ "language_info": {
13
+ "name": "python"
14
+ }
15
+ },
16
+ "cells": [
17
+ {
18
+ "cell_type": "code",
19
+ "execution_count": 1,
20
+ "metadata": {
21
+ "id": "HTQFPahcInfL"
22
+ },
23
+ "outputs": [],
24
+ "source": [
25
+ "%%capture\n",
26
+ "!pip install transformers\n",
27
+ "!pip install einops\n",
28
+ "\n",
29
+ "import torch\n",
30
+ "from transformers import AutoModelForCausalLM, AutoTokenizer\n",
31
+ "\n",
32
+ "model = AutoModelForCausalLM.from_pretrained(\"agonh/phi-1_5\", trust_remote_code=True)\n",
33
+ "tokenizer = AutoTokenizer.from_pretrained(\"agonh/phi-1_5\", trust_remote_code=True)"
34
+ ]
35
+ },
36
+ {
37
+ "cell_type": "code",
38
+ "source": [
39
+ "prompt = \"tell me about moon ?\"\n",
40
+ "inputs = tokenizer(prompt, return_tensors=\"pt\", return_attention_mask=False)\n",
41
+ "\n",
42
+ "outputs = model.generate(**inputs, max_length=100)\n",
43
+ "text = tokenizer.batch_decode(outputs)[0]\n",
44
+ "print(text)"
45
+ ],
46
+ "metadata": {
47
+ "colab": {
48
+ "base_uri": "https://localhost:8080/"
49
+ },
50
+ "id": "ty9IBkPPZodx",
51
+ "outputId": "40de5c2d-f9d4-4c41-a103-6a07c66c0d14"
52
+ },
53
+ "execution_count": 2,
54
+ "outputs": [
55
+ {
56
+ "output_type": "stream",
57
+ "name": "stdout",
58
+ "text": [
59
+ "tell me about moon?\n",
60
+ "\n",
61
+ "A:\n",
62
+ "\n",
63
+ "The moon is a natural satellite of the Earth. It is the fifth largest moon in the solar system. It is also the only natural satellite of the Earth.\n",
64
+ "\n",
65
+ "A:\n",
66
+ "\n",
67
+ "The moon is a natural satellite of the Earth. It is the fifth largest moon in the solar system. It is also the only natural satellite of the Earth.\n",
68
+ "\n",
69
+ "A:\n",
70
+ "\n",
71
+ "The moon is a natural satellite of the Earth. It is the\n"
72
+ ]
73
+ }
74
+ ]
75
+ }
76
+ ]
77
+ }