File size: 3,714 Bytes
9992bad
 
 
 
 
 
 
 
 
 
 
 
 
e375757
 
 
9992bad
386c510
 
9992bad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9d448a6
9992bad
 
 
 
 
 
 
9d448a6
9992bad
 
 
 
 
 
 
9d448a6
9992bad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b761d6e
 
 
 
9992bad
 
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
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
<html>
<head>
  <meta name="GENERATOR" content="mkd2html 2.2.7 GITHUB_CHECKBOX">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <link rel="stylesheet"
        type="text/css"
        href="header.css" />
  <title></title>
</head>
<body>
<h1>Prepare Python environment to download Hugging Face models</h1>

<p>This guide will help you install the necessary <a href="https://huggingface.co">Hugging
Face</a> packages and tools to download and use
models from the Hugging Face Hub.</p>

<p>Follow this guide, or <a href="index.html">return to the main page</a> if needed.</p>

<hr />

<h2>1. Install <code>transformers</code> Package</h2>

<p>The <code>transformers</code> package is used to load and use Hugging Face models in Python.</p>

<h3>Installation</h3>

<p>Run the following command in your terminal or command prompt:</p>

<p><code>bash
pip install transformers
</code></p>

<h3>Verify Installation</h3>

<p>To confirm the installation was successful, run:</p>

<p><code>bash
python -c "from transformers import pipeline; print('Installation successful!')"
</code></p>

<hr />

<h2>2. Install <code>huggingface_hub</code> Package</h2>

<p>The <code>huggingface_hub</code> package provides the <code>huggingface-cli</code> tool for interacting with the Hugging Face Hub (e.g., downloading models, uploading files, etc.).</p>

<h3>Installation</h3>

<p>Run the following command:</p>

<p><code>bash
pip install huggingface_hub
</code></p>

<h3>Verify Installation</h3>

<p>After installation, check if the <code>huggingface-cli</code> is available:</p>

<p><code>bash
huggingface-cli --help
</code></p>

<hr />

<h2>3. Using <code>huggingface-cli</code></h2>

<p>The <code>huggingface-cli</code> tool allows you to interact with the Hugging Face Hub directly from the command line.</p>

<h3>Common Commands</h3>

<h3>Log in to Hugging Face</h3>

<p>To log in to your Hugging Face account:</p>

<p><code>
huggingface-cli login
</code></p>

<h3>Download a Model</h3>

<p>To download a model (e.g., <code>gpt2</code>):</p>

<p><code>
huggingface-cli download gpt2
</code></p>

<h3>List Available Commands</h3>

<p>To see all available commands and options:</p>

<p><code>
huggingface-cli --help
</code></p>

<hr />

<h2>4. Example: Download and Use a Model</h2>

<p>Here’s an example of downloading and using a model in Python:</p>

<pre>
from transformers import pipeline

# Download and load a model
generator = pipeline("text-generation", model="gpt2")

# Generate text
output = generator("Hello, how are you?", max_length=50)
print(output)
</pre>


<hr />

<h2>5. Summary of Commands</h2>

<table>
<thead>
<tr>
<th> Command                          </th>
<th> Description                                      </th>
</tr>
</thead>
<tbody>
<tr>
<td> <code>pip install transformers</code>       </td>
<td> Install the <code>transformers</code> package.             </td>
</tr>
<tr>
<td> <code>pip install huggingface_hub</code>    </td>
<td> Install the <code>huggingface_hub</code> package.          </td>
</tr>
<tr>
<td> <code>huggingface-cli --help</code>         </td>
<td> List all available <code>huggingface-cli</code> commands.  </td>
</tr>
<tr>
<td> <code>huggingface-cli login</code>          </td>
<td> Log in to your Hugging Face account.            </td>
</tr>
<tr>
<td> <code>huggingface-cli download gpt2</code>  </td>
<td> Download the <code>gpt2</code> model.                      </td>
</tr>
</tbody>
</table>


<hr />

<p>Now you’re ready to use Hugging Face models and tools in Python! 🚀</p>

<h1>Proceed to next step</h1>

<p><a href="index.html">Proceed to next step.</a></p>
</body>
</html>