Views
No views yet
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
3
4MODEL_NAME = "curiousily/tiny-crypto-sentiment-analysis"
5
6tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, use_fast=True)
7
8model = AutoModelForCausalLM.from_pretrained(
9 MODEL_NAME,
10 device_map="auto",
11 torch_dtype=torch.float16
12)
13
14pipe = pipeline(
15 task="text-generation",
16 model=model,
17 tokenizer=tokenizer,
18 max_new_tokens=16,
19 return_full_text=False,
20)1prompt = """
2### Title:
3<YOUR ARTICLE TITLE>
4### Text:
5<YOUR ARTICLE PARAGRAPH>
6### Prediction:
7""".strip()1prompt = """
2### Title:
3Bitcoin Price Prediction as BTC Breaks Through $27,000 Barrier Here are Price Levels to Watch
4### Text:
5Bitcoin, 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.
6### Prediction:
7""".strip()1outputs = pipe(prompt)
2print(outputs[0]["generated_text"].strip())1subject: bitcoin
2sentiment: positive