Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Extracts embeddings from text using a pretrained model.
from transformers import AutoTokenizer, AutoModel
import torch
# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained('distilbert-base-uncased')
model = AutoModel.from_pretrained('distilbert-base-uncased')
text = 'Transformers are amazing!'
inputs = tokenizer(text, return_tensors='pt')
outputs = model(**inputs)
# Get sentence embedding
embedding = outputs.last_hidden_state.mean(dim=1)
print(embedding)Hugging Face Transformers is an open-source Python library that provides pre-trained state-of-the-art transformer models for natural language processing (NLP), computer vision, and speech tasks, enabling easy fine-tuning, inference, and deployment.
Origin & Creator
Hugging Face, a company founded in 2016, initially focused on conversational AI and released the Transformers library in 2019, quickly becoming a key resource in NLP and AI research.
Industrial Note
Widely used in industry and research for deploying state-of-the-art NLP models, Hugging Face Transformers powers chatbots, summarizers, search engines, recommendation systems, and more.