Sergiu2404 commited on
Commit
8795c64
·
1 Parent(s): 08a9576

initial space deployment

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. app.py +38 -0
  2. requirements.txt +11 -0
  3. saved_model/regressor_model.pt +3 -0
  4. saved_model/results/checkpoint-1378/optimizer.pt +3 -0
  5. saved_model/results/checkpoint-1378/pytorch_model.bin +3 -0
  6. saved_model/results/checkpoint-1378/rng_state.pth +3 -0
  7. saved_model/results/checkpoint-1378/scheduler.pt +3 -0
  8. saved_model/results/checkpoint-1378/special_tokens_map.json +3 -0
  9. saved_model/results/checkpoint-1378/tokenizer.json +3 -0
  10. saved_model/results/checkpoint-1378/tokenizer_config.json +3 -0
  11. saved_model/results/checkpoint-1378/trainer_state.json +3 -0
  12. saved_model/results/checkpoint-1378/training_args.bin +3 -0
  13. saved_model/results/checkpoint-1378/vocab.txt +3 -0
  14. saved_model/results/checkpoint-2067/optimizer.pt +3 -0
  15. saved_model/results/checkpoint-2067/pytorch_model.bin +3 -0
  16. saved_model/results/checkpoint-2067/rng_state.pth +3 -0
  17. saved_model/results/checkpoint-2067/scheduler.pt +3 -0
  18. saved_model/results/checkpoint-2067/special_tokens_map.json +3 -0
  19. saved_model/results/checkpoint-2067/tokenizer.json +3 -0
  20. saved_model/results/checkpoint-2067/tokenizer_config.json +3 -0
  21. saved_model/results/checkpoint-2067/trainer_state.json +3 -0
  22. saved_model/results/checkpoint-2067/training_args.bin +3 -0
  23. saved_model/results/checkpoint-2067/vocab.txt +3 -0
  24. saved_model/results/checkpoint-2756/optimizer.pt +3 -0
  25. saved_model/results/checkpoint-2756/pytorch_model.bin +3 -0
  26. saved_model/results/checkpoint-2756/rng_state.pth +3 -0
  27. saved_model/results/checkpoint-2756/scheduler.pt +3 -0
  28. saved_model/results/checkpoint-2756/special_tokens_map.json +3 -0
  29. saved_model/results/checkpoint-2756/tokenizer.json +3 -0
  30. saved_model/results/checkpoint-2756/tokenizer_config.json +3 -0
  31. saved_model/results/checkpoint-2756/trainer_state.json +3 -0
  32. saved_model/results/checkpoint-2756/training_args.bin +3 -0
  33. saved_model/results/checkpoint-2756/vocab.txt +3 -0
  34. saved_model/results/checkpoint-3445/optimizer.pt +3 -0
  35. saved_model/results/checkpoint-3445/pytorch_model.bin +3 -0
  36. saved_model/results/checkpoint-3445/rng_state.pth +3 -0
  37. saved_model/results/checkpoint-3445/scheduler.pt +3 -0
  38. saved_model/results/checkpoint-3445/special_tokens_map.json +3 -0
  39. saved_model/results/checkpoint-3445/tokenizer.json +3 -0
  40. saved_model/results/checkpoint-3445/tokenizer_config.json +3 -0
  41. saved_model/results/checkpoint-3445/trainer_state.json +3 -0
  42. saved_model/results/checkpoint-3445/training_args.bin +3 -0
  43. saved_model/results/checkpoint-3445/vocab.txt +3 -0
  44. saved_model/results/checkpoint-689/optimizer.pt +3 -0
  45. saved_model/results/checkpoint-689/pytorch_model.bin +3 -0
  46. saved_model/results/checkpoint-689/rng_state.pth +3 -0
  47. saved_model/results/checkpoint-689/scheduler.pt +3 -0
  48. saved_model/results/checkpoint-689/special_tokens_map.json +3 -0
  49. saved_model/results/checkpoint-689/tokenizer.json +3 -0
  50. saved_model/results/checkpoint-689/tokenizer_config.json +3 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer
3
+ import torch
4
+ from tiny_finbert import TinyFinBERTRegressor, preprocess_texts
5
+ import os
6
+
7
+ MODEL_DIR = "./saved_model"
8
+ DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
9
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_DIR)
10
+
11
+ model = TinyFinBERTRegressor().to(DEVICE)
12
+ model.load_state_dict(torch.load(os.path.join(MODEL_DIR, "regressor_model.pt"), map_location=DEVICE))
13
+ model.eval()
14
+
15
+ def predict_sentiment(text):
16
+ processed = preprocess_texts([text])[0]
17
+ inputs = tokenizer(processed, return_tensors="pt", truncation=True, padding='max_length', max_length=128)
18
+ inputs = {k: v.to(DEVICE) for k, v in inputs.items() if k != "token_type_ids"}
19
+ with torch.no_grad():
20
+ score = model(**inputs)["score"].item()
21
+
22
+ if score > 0.3:
23
+ interpretation = "positive"
24
+ elif score < -0.3:
25
+ interpretation = "negative"
26
+ else:
27
+ interpretation = "neutral"
28
+ return {"score": round(score, 4), "interpretation": interpretation}
29
+
30
+ iface = gr.Interface(fn=predict_sentiment,
31
+ inputs=gr.Textbox(label="Enter financial sentence"),
32
+ outputs=[
33
+ gr.Number(label="Sentiment Score"),
34
+ gr.Textbox(label="Interpretation")
35
+ ],
36
+ title="TinyFinBERT Sentiment Analysis")
37
+
38
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ torch>=1.10.0
2
+ accelerate>=0.20.1
3
+ transformers
4
+ gradio
5
+ pydantic
6
+ pandas
7
+ scikit-learn
8
+ spacy
9
+ nltk
10
+ datasets
11
+ en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.7.1/en_core_web_sm-3.7.1.tar.gz
saved_model/regressor_model.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:50353c6a0c9b2f79c90d554c89d132901f45301ede1e293d2484c86a5b02175d
3
+ size 57430528
saved_model/results/checkpoint-1378/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f03a9de2881a1aa26e9819fcb5f4a4a18e24cc70117f96613455c179d004170
3
+ size 114061259
saved_model/results/checkpoint-1378/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8112307195840f5c66c27f61c3dcc7973026d9204aab43009de991b98c4e8cca
3
+ size 57430370
saved_model/results/checkpoint-1378/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9d4f5b079295aad1d803fe541076c455d9c83ab7bb784cae20338d7514661e4c
3
+ size 14455
saved_model/results/checkpoint-1378/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a2ef41ef574dc1cd1bbcb4157a461b97dbe088d54c5182b29e445da15823fdd0
3
+ size 1465
saved_model/results/checkpoint-1378/special_tokens_map.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c3507f36dff57bce437223db3b3081d1e2b52ec3e56ee55438193ecb2c94dd6
3
+ size 132
saved_model/results/checkpoint-1378/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da0e79933b9ed51798a3ae27893d3c5fa4a201126cef75586296df9b4d2c62a0
3
+ size 711661
saved_model/results/checkpoint-1378/tokenizer_config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e86d243cbe5f8327d7eb8dda2415dce752b0e18da1a1b5e417a856647a06a3c2
3
+ size 409
saved_model/results/checkpoint-1378/trainer_state.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d2758e807ae7a58b3e40a56ad066e5b5c68e16091559c13d31bd251653357288
3
+ size 1231
saved_model/results/checkpoint-1378/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7fd3afd0bd610815f9b7237ec63bc18799fa4677567d19f3a2cf1d051aff770e
3
+ size 4817
saved_model/results/checkpoint-1378/vocab.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:07eced375cec144d27c900241f3e339478dec958f92fddbc551f295c992038a3
3
+ size 231508
saved_model/results/checkpoint-2067/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1417eb6c2dc1a5e29647dd0bd9f71b11300b264876bf0cb9166fc6ac00af7a6f
3
+ size 114061259
saved_model/results/checkpoint-2067/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cbee600b79b13c97df962da93ee3f7fb609dca9ca9b3177c1fd30286d2e056c6
3
+ size 57430370
saved_model/results/checkpoint-2067/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:19087021c29d60d24bf341b2ff7ef8a49ce99facfa2a672ce7a47321957e7847
3
+ size 14455
saved_model/results/checkpoint-2067/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c0ff74fb21fc3805313fd6e005ac61803f6ac99896f400de11abbb28a4ad03f4
3
+ size 1465
saved_model/results/checkpoint-2067/special_tokens_map.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c3507f36dff57bce437223db3b3081d1e2b52ec3e56ee55438193ecb2c94dd6
3
+ size 132
saved_model/results/checkpoint-2067/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da0e79933b9ed51798a3ae27893d3c5fa4a201126cef75586296df9b4d2c62a0
3
+ size 711661
saved_model/results/checkpoint-2067/tokenizer_config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e86d243cbe5f8327d7eb8dda2415dce752b0e18da1a1b5e417a856647a06a3c2
3
+ size 409
saved_model/results/checkpoint-2067/trainer_state.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b225f975e82dd695da24e907320841e0cd9da2ec901023dbf28b426992be3e29
3
+ size 1773
saved_model/results/checkpoint-2067/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7fd3afd0bd610815f9b7237ec63bc18799fa4677567d19f3a2cf1d051aff770e
3
+ size 4817
saved_model/results/checkpoint-2067/vocab.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:07eced375cec144d27c900241f3e339478dec958f92fddbc551f295c992038a3
3
+ size 231508
saved_model/results/checkpoint-2756/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a77971f3ef5257c681512b88f87cb17daf2f91f91491728257cd3e61bc60903f
3
+ size 114061259
saved_model/results/checkpoint-2756/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e107512c2468a61c8a78723991aa7b9d8bf5a6fd7f61595327ba644c7f34e12c
3
+ size 57430370
saved_model/results/checkpoint-2756/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ea0bfcb225f0521c65de55ece0620872190fb2b25811d8f38329540a1c5ccef1
3
+ size 14455
saved_model/results/checkpoint-2756/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b9208546db9e82f4ce324b67baa0650331d58e71d35fc86b75106c907bf691d
3
+ size 1465
saved_model/results/checkpoint-2756/special_tokens_map.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c3507f36dff57bce437223db3b3081d1e2b52ec3e56ee55438193ecb2c94dd6
3
+ size 132
saved_model/results/checkpoint-2756/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da0e79933b9ed51798a3ae27893d3c5fa4a201126cef75586296df9b4d2c62a0
3
+ size 711661
saved_model/results/checkpoint-2756/tokenizer_config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e86d243cbe5f8327d7eb8dda2415dce752b0e18da1a1b5e417a856647a06a3c2
3
+ size 409
saved_model/results/checkpoint-2756/trainer_state.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:21a99f476b71c91fa2782e32a8e5e27f2ee537d5ff893b50468465cf3a0e28e3
3
+ size 2187
saved_model/results/checkpoint-2756/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7fd3afd0bd610815f9b7237ec63bc18799fa4677567d19f3a2cf1d051aff770e
3
+ size 4817
saved_model/results/checkpoint-2756/vocab.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:07eced375cec144d27c900241f3e339478dec958f92fddbc551f295c992038a3
3
+ size 231508
saved_model/results/checkpoint-3445/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:342aa7c382ab1c04d7945e8d8b58954a9d56e24c80cfc992b77ab13dc6d4f354
3
+ size 114061259
saved_model/results/checkpoint-3445/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:771059cf19e1bff8311d52fd4edb68b74bbfed48d4bcf7e3a1a3e15cd05b5f64
3
+ size 57430370
saved_model/results/checkpoint-3445/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:48c72082d486b20c672f7a5ab044c51e73310526658bee6c305eb79bd83d0758
3
+ size 14455
saved_model/results/checkpoint-3445/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0cad7fef0bfa216665aad66080b3446ec9ba91e2b0edb2c1945d787287b01b6a
3
+ size 1465
saved_model/results/checkpoint-3445/special_tokens_map.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c3507f36dff57bce437223db3b3081d1e2b52ec3e56ee55438193ecb2c94dd6
3
+ size 132
saved_model/results/checkpoint-3445/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da0e79933b9ed51798a3ae27893d3c5fa4a201126cef75586296df9b4d2c62a0
3
+ size 711661
saved_model/results/checkpoint-3445/tokenizer_config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e86d243cbe5f8327d7eb8dda2415dce752b0e18da1a1b5e417a856647a06a3c2
3
+ size 409
saved_model/results/checkpoint-3445/trainer_state.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:54bf8c6ed97dd610b377df9bbe40deff4e34dd08ebe1fd7edca8bab9d9200241
3
+ size 2603
saved_model/results/checkpoint-3445/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7fd3afd0bd610815f9b7237ec63bc18799fa4677567d19f3a2cf1d051aff770e
3
+ size 4817
saved_model/results/checkpoint-3445/vocab.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:07eced375cec144d27c900241f3e339478dec958f92fddbc551f295c992038a3
3
+ size 231508
saved_model/results/checkpoint-689/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:02181760a4cc7ab85f271fb776a09189823969b58f07af29008d6849c8657786
3
+ size 114061259
saved_model/results/checkpoint-689/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:58d8ef0658ebf6631168d46ce555873ac39963fafa5c3740b0ec4401a48e61d8
3
+ size 57430370
saved_model/results/checkpoint-689/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a163b7f4b601ffa69e8c26e1eaf05d25873bb6a603fe9efa29bfb3088206e0fd
3
+ size 14455
saved_model/results/checkpoint-689/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0e024ff72a2b6b9733d5dba520ef07b01c55348a3f5fe75a82cb49c1b3587647
3
+ size 1465
saved_model/results/checkpoint-689/special_tokens_map.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c3507f36dff57bce437223db3b3081d1e2b52ec3e56ee55438193ecb2c94dd6
3
+ size 132
saved_model/results/checkpoint-689/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da0e79933b9ed51798a3ae27893d3c5fa4a201126cef75586296df9b4d2c62a0
3
+ size 711661
saved_model/results/checkpoint-689/tokenizer_config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e86d243cbe5f8327d7eb8dda2415dce752b0e18da1a1b5e417a856647a06a3c2
3
+ size 409