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

DDD
Release: 2024-09-18 19:36:10
Original
228 people have browsed it

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 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_venvScriptsactivate

  • 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)

Copy after login
  • run file. You should be in D:python312Scriptsroberta_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

The above is the detailed content of Hugging Face: Interacting with Roberta and Hugging Face for the first time. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!