Views
No views yet
1from transformers import AutoTokenizer, AutoModelForCausalLM
2
3tokenizer = AutoTokenizer.from_pretrained("khazarai/StockDirection-6K")
4model = AutoModelForCausalLM.from_pretrained(
5 "khazarai/StockDirection-6K",
6 device_map={"": 0}
7)
8
9
10question ="""
11You are an assistant that predicts whatever a stock will go up or down in the next day based on the daily percentage price changes of the last:
124 days ago: 0.00
133 days ago: -3.09
142 days ago: 2.13
151 day ago: -2.04
16today: 0.01
17Predict whatever the next day's price will go up or down. Simply write your prediction as UP or DOWN
18"""
19
20messages = [
21 {"role" : "user", "content" : question}
22]
23text = tokenizer.apply_chat_template(
24 messages,
25 tokenize = False,
26 add_generation_prompt = True,
27 enable_thinking = False,
28)
29
30from transformers import TextStreamer
31_ = model.generate(
32 **tokenizer(text, return_tensors = "pt").to("cuda"),
33 max_new_tokens = 200,
34 temperature = 0.7,
35 top_p = 0.8,
36 top_k = 20,
37 streamer = TextStreamer(tokenizer, skip_prompt = True),
38)1Question: You are an assistant that predicts whether a stock will go up or down in the next day
2based on the daily percentage price changes of the last:
34 days ago: nan
43 days ago: 0.00
52 days ago: 2.22
61 day ago: -2.17
7today: -2.22
8Predict whether the next day's price will go up or down.
9Simply write your prediction as UP or DOWN.
10
11Answer: DOWN