CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
huggingface

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: huggingface/notebooks
Path: blob/main/course/fr/chapter2/section3_pt.ipynb
Views: 2555
Kernel: Python 3

Modèles (PyTorch)

Installez la bibliothèque 🤗 Transformers pour exécuter ce notebook.

!pip install transformers[sentencepiece]
from transformers import CamembertConfig, CamembertModel # Construire la configuration config = CamembertConfig() # Construire le modèle à partir de la configuration model = CamembertModel(config)
print(config)
from transformers import CamembertConfig, CamembertModel config = CamembertConfig() model = CamembertModel(config) # Le modèle est initialisé de façon aléatoire !
from transformers import CamembertModel model = CamembertModel.from_pretrained("camembert-base")
model.save_pretrained("répertoire_sur_mon_ordinateur")
sequences = ["Hello!", "Cool.", "Nice!"]
from transformers import CamembertTokenizer tokenizer = CamembertTokenizer.from_pretrained("camembert-base") encoded_sequences = tokenizer(sequences) encoded_sequences
import torch model_inputs = torch.tensor(encoded_sequences)
output = model(model_inputs)
output