maggd77 commited on
Commit
322073f
·
verified ·
1 Parent(s): 6e84eb5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ !pip install transformers
2
+
3
+ !pip install accelerate
4
+
5
+
6
+ from huggingface_hub import notebook_login
7
+ notebook_login()
8
+
9
+ from transformers import AutoTokenizer, AutoModelForCausalLM
10
+ import torch
11
+
12
+
13
+ tokenizer = AutoTokenizer.from_pretrained("mjmanashti/gemma-2b-ForexAI")
14
+ torch.set_default_dtype(torch.float16)
15
+
16
+ model = AutoModelForCausalLM.from_pretrained("mjmanashti/gemma-2b-ForexAI", device_map="auto")
17
+
18
+ chat = [
19
+ { "role": "user", "content": "Based on the following input data: [Time: 2024-01-29 23:00:00, Open: 1.0834, High: 1.0837, Low: 1.08334, Close: 1.08338, Volume: 722] what trading signal (BUY, SELL, or HOLD) should be executed to maximize profit? If the signal is BUY, what would be the entry price and If the signal is SELL, what would be the exit price for profit maximization? " },
20
+ ]
21
+ prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
22
+ inputs = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
23
+ outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=150)
24
+ print(tokenizer.decode(outputs[0]))