Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -139,6 +139,30 @@ def gradio_train_stock_model(stock_symbol, start_date, end_date, feature_range_m
|
|
139 |
)
|
140 |
return result
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
iface = gr.Interface(
|
143 |
fn=gradio_train_stock_model,
|
144 |
inputs=[
|
@@ -152,6 +176,8 @@ iface = gr.Interface(
|
|
152 |
gr.Slider(minimum=1, maximum=64, step=1, label="Batch Size", value=16),
|
153 |
gr.Slider(minimum=1e-5, maximum=1e-1, step=1e-5, label="Learning Rate", value=2e-4)
|
154 |
],
|
|
|
|
|
155 |
outputs="text",
|
156 |
)
|
157 |
|
|
|
139 |
)
|
140 |
return result
|
141 |
|
142 |
+
title = "StockLlama-TrainOnAnyStock"
|
143 |
+
description = """
|
144 |
+
## StockLlama
|
145 |
+
![The Logo](https://private-user-images.githubusercontent.com/119312866/361069298-11d12a8f-63b8-42ce-b66c-d77924831e90.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ2MDYwMTcsIm5iZiI6MTcyNDYwNTcxNywicGF0aCI6Ii8xMTkzMTI4NjYvMzYxMDY5Mjk4LTExZDEyYThmLTYzYjgtNDJjZS1iNjZjLWQ3NzkyNDgzMWU5MC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODI1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgyNVQxNzA4MzdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05ZmUyOWQ4Nzc5YjU0YmZlNGYyMjRmZGY4OWRhYTk5MWZjZGRkMGIzZDQ1YjAwZmQwM2YyY2RkNTcyZmE2ZjgwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.Oz-_THt_8gGhVod5cCURKaeepzvTGXqGeLi_MkRm09g)
|
146 |
+
### Description
|
147 |
+
StockLlama is a time series forecasting pre-trained model based on Llama, enhanced with custom embeddings for improved accuracy.
|
148 |
+
### How It Works
|
149 |
+
**Data Collection:** The model retrieves historical stock price data using the yfinance library. Users specify the stock symbol, date range, and other parameters through a Gradio interface.
|
150 |
+
|
151 |
+
**Data Preprocessing:** The collected stock prices are scaled to a specified range using a custom Scaler class. The data is then divided into sequences of a defined length, with each sequence serving as input to the model and the next data point as the target.
|
152 |
+
|
153 |
+
**Model Architecture:** StockLlama is a modified version of the Llama model, specifically tailored for time series forecasting. The model is enhanced with custom embeddings and fine-tuned using a LoRA (Low-Rank Adaptation) configuration, allowing for efficient training on the specific stock data.
|
154 |
+
|
155 |
+
**Training Process:** The training is managed using the Hugging Face Trainer class. The model learns to predict the next data point in the sequence, optimizing its weights over multiple epochs. The training process can be monitored via Weights & Biases integration.
|
156 |
+
|
157 |
+
**Deployment:** After training, the model is pushed to the Hugging Face Hub, making it accessible for future predictions. The scaler used for data normalization is also saved and uploaded, ensuring that new data can be correctly transformed and predictions can be accurately descaled.
|
158 |
+
|
159 |
+
### Contributing
|
160 |
+
Contributions to this project are welcome! If you find any issues or want to add new features, feel free to open an issue or submit a pull request.
|
161 |
+
### License
|
162 |
+
This project is licensed under the [Apache 2.0 License](https://opensource.org/license/apache-2-0).
|
163 |
+
### Credits
|
164 |
+
The StockLlama model used in this project is based on the work by [Talha Rüzgar Akkuş](https://www.linkedin.com/in/talha-r%C3%BCzgar-akku%C5%9F-1b5457264/).
|
165 |
+
"""
|
166 |
iface = gr.Interface(
|
167 |
fn=gradio_train_stock_model,
|
168 |
inputs=[
|
|
|
176 |
gr.Slider(minimum=1, maximum=64, step=1, label="Batch Size", value=16),
|
177 |
gr.Slider(minimum=1e-5, maximum=1e-1, step=1e-5, label="Learning Rate", value=2e-4)
|
178 |
],
|
179 |
+
description=description,
|
180 |
+
title=title,
|
181 |
outputs="text",
|
182 |
)
|
183 |
|