-
Notifications
You must be signed in to change notification settings - Fork 0
/
HuggingFaceModels RawRun.txt
49 lines (25 loc) · 1.31 KB
/
HuggingFaceModels RawRun.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(HuggingFace Summarizer)
from transformers import pipeline
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
model = AutoModelForSeq2SeqLM.from_pretrained("snrspeaks/t5-one-line-summary")
tokenizer = AutoTokenizer.from_pretrained("snrspeaks/t5-one-line-summary")
classifier = pipeline("summarization", model=model, tokenizer=tokenizer)
results = classifier(["summarize:i am working hard to get job but i couldnt do it so i have two options either government or private jobs im unable to decide which to take so first i will try private jobs if i dint get then i will try government."])
print(results)
///
(HuggingFace Sentiment Analysis)
from transformers import pipeline
from transformers import AutoTokenizer, AutoModelForSequenceClassification
model = AutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english")
tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english")
classifier = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
results = classifier(["i am not happy very much happy"])
print(results)
////
(ALSO SentimentAnalys Basis)
from transformers import pipeline
import torch
import torch.nn.functional as F
classifier = pipeline("sentiment-analysis")
res = classifier("whatever.")
print(res)