July 20, 2022, 2:15 a.m. | /u/beatleinabox

Natural Language Processing www.reddit.com

`tokenizer = GPT2Tokenizer.from_pretrained("gpt2")`

`model = GPT2LMHeadModel.from_pretrained("gpt2")`

`inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")`

`outputs = model(**inputs, labels=inputs["input_ids"])`

`loss = outputs.loss`

`logits = outputs.logits`

​

The code above is from hugging face documentation. Assuming I have an optimizer and do something like:

`loss.backward()`

`optimizer.step()`

Am I successfully "finetuning" the model with one input example? What exactly is happening in the line:

`outputs = model(**inputs, labels=inputs["input_ids"])`

Why is labels the input ids of the inputs?

Is it training as follows? Given …

code example face languagetechnology

Lead GNSS Data Scientist

@ Lurra Systems | Melbourne

Senior Machine Learning Engineer (MLOps)

@ Promaton | Remote, Europe

[Job - 14823] Senior Data Scientist (Data Analyst Sr)

@ CI&T | Brazil

Data Engineer

@ WorldQuant | Hanoi

ML Engineer / Toronto

@ Intersog | Toronto, Ontario, Canada

Analista de Business Intelligence (Industry Insights)

@ NielsenIQ | Cotia, Brazil