Hugging Face: Interacting with Roberta and Hugging Face for the first time

This is my first interaction with Hugging Face. The free and open Ai option

Date: September 15, 2024

Prerequisites: I bought a 1T external SSD and created this tutorial using the external hard drive. I am using a windows computer. This is where the …


This content originally appeared on DEV Community and was authored by Lauren C.

This is my first interaction with Hugging Face. The free and open Ai option

Date: September 15, 2024

Prerequisites: I bought a 1T external SSD and created this tutorial using the external hard drive. I am using a windows computer. This is where the tutorial begins.

  • Change directory to D drive
    $D:

  • create directory on external SSD titled version of python and pip I'm using

(use website to install)
$mkdir python312
$cd python312
$mkdir Scripts

  • install python and pip file from website and put in directories and virtual environment with command:
    $pip install virtualenv

  • versify it's working by checking the version

python --version
pip --version
virtualenv --version

  • Create virtual environment. Tool is called virtualenv. Name of the virtual env. is my_venv.

Next command: python invokes interpreter. -m runs module as script. venv module is invoked and my_venv is name of virtual environment
$ virtualenv my_venv
$python -m venv my_venv

  • Activate virtual environment

$.\my_venv\Scripts\activate

  • Install Transformers, datasets, and pytourch

$pip install transformers
$pip install datasets
$pip install torch
$ipi install tensorflow

  • install Visual Studio from Microsoft website to edit python files and create python files with command:
  • Open Visual Studio Installer
  • Select Modify and add Python development by checking the box
  • click modify $cd Scripts
  • create new application in visual studios. Save in script file in D drive. Name "roberta_hugging_face" and save solution and project in same directory

add code to file:

from transformers import pipeline

# Load the sentiment analysis pipeline
sentiment_pipeline = pipeline("sentiment-analysis")

# Perform sentiment analysis
result = sentiment_pipeline("Hugging Face is creating amazing tools for NLP!")
print(result)

  • run file. You should be in D:\python312\Scripts\roberta_hugging_face $python roberta_hugging_face.py
  • install backward compatible package and retry running
    $pip install tf-keras
    $python roberta_hugging_face.py

  • When download is complete you will see the result for the pipeline "Hugging Face is creating amazing tools for NLP!"

  • To deactivate
    $deactivate

  • Safely disconnect SSD


This content originally appeared on DEV Community and was authored by Lauren C.


Print Share Comment Cite Upload Translate Updates
APA

Lauren C. | Sciencx (2024-09-14T23:41:49+00:00) Hugging Face: Interacting with Roberta and Hugging Face for the first time. Retrieved from https://www.scien.cx/2024/09/14/hugging-face-interacting-with-roberta-and-hugging-face-for-the-first-time/

MLA
" » Hugging Face: Interacting with Roberta and Hugging Face for the first time." Lauren C. | Sciencx - Saturday September 14, 2024, https://www.scien.cx/2024/09/14/hugging-face-interacting-with-roberta-and-hugging-face-for-the-first-time/
HARVARD
Lauren C. | Sciencx Saturday September 14, 2024 » Hugging Face: Interacting with Roberta and Hugging Face for the first time., viewed ,<https://www.scien.cx/2024/09/14/hugging-face-interacting-with-roberta-and-hugging-face-for-the-first-time/>
VANCOUVER
Lauren C. | Sciencx - » Hugging Face: Interacting with Roberta and Hugging Face for the first time. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/14/hugging-face-interacting-with-roberta-and-hugging-face-for-the-first-time/
CHICAGO
" » Hugging Face: Interacting with Roberta and Hugging Face for the first time." Lauren C. | Sciencx - Accessed . https://www.scien.cx/2024/09/14/hugging-face-interacting-with-roberta-and-hugging-face-for-the-first-time/
IEEE
" » Hugging Face: Interacting with Roberta and Hugging Face for the first time." Lauren C. | Sciencx [Online]. Available: https://www.scien.cx/2024/09/14/hugging-face-interacting-with-roberta-and-hugging-face-for-the-first-time/. [Accessed: ]
rf:citation
» Hugging Face: Interacting with Roberta and Hugging Face for the first time | Lauren C. | Sciencx | https://www.scien.cx/2024/09/14/hugging-face-interacting-with-roberta-and-hugging-face-for-the-first-time/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.