curiousily
commited on
Commit
•
b55ad02
1
Parent(s):
f4a6a49
Update README.md
Browse files
README.md
CHANGED
@@ -13,6 +13,8 @@ to predict the sentiment and subject of an article
|
|
13 |
|
14 |
## How to Use
|
15 |
|
|
|
|
|
16 |
```py
|
17 |
import torch
|
18 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
@@ -38,3 +40,39 @@ pipe = pipeline(
|
|
38 |
return_full_text=False,
|
39 |
)
|
40 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
## How to Use
|
15 |
|
16 |
+
Load the model:
|
17 |
+
|
18 |
```py
|
19 |
import torch
|
20 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
|
|
40 |
return_full_text=False,
|
41 |
)
|
42 |
```
|
43 |
+
|
44 |
+
Prompt format:
|
45 |
+
|
46 |
+
```py
|
47 |
+
prompt = """
|
48 |
+
### Title:
|
49 |
+
<YOUR ARTICLE TITLE>
|
50 |
+
### Text:
|
51 |
+
<YOUR ARTICLE PARAGRAPH>
|
52 |
+
### Prediction:
|
53 |
+
""".strip()
|
54 |
+
```
|
55 |
+
|
56 |
+
Here's an example:
|
57 |
+
|
58 |
+
```py
|
59 |
+
prompt = """
|
60 |
+
### Title:
|
61 |
+
Bitcoin Price Prediction as BTC Breaks Through $27,000 Barrier Here are Price Levels to Watch
|
62 |
+
### Text:
|
63 |
+
Bitcoin, the world's largest cryptocurrency by market capitalization, has been making headlines recently as it broke through the $27,000 barrier for the first time. This surge in price has reignited speculation about where Bitcoin is headed next, with many analysts and investors offering their predictions.
|
64 |
+
### Prediction:
|
65 |
+
""".strip()
|
66 |
+
```
|
67 |
+
|
68 |
+
Get a prediction:
|
69 |
+
|
70 |
+
```py
|
71 |
+
outputs = pipe(prompt)
|
72 |
+
print(outputs[0]["generated_text"].strip())
|
73 |
+
```
|
74 |
+
|
75 |
+
```md
|
76 |
+
subject: bitcoin
|
77 |
+
sentiment: positive
|
78 |
+
```
|