Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,199 +1,132 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
| 2 |
library_name: transformers
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
|
| 8 |
-
|
| 9 |
|
|
|
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
- **Model type:** [More Information Needed]
|
| 24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
|
|
|
| 39 |
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
[More Information Needed]
|
| 51 |
-
|
| 52 |
-
### Out-of-Scope Use
|
| 53 |
-
|
| 54 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 55 |
-
|
| 56 |
-
[More Information Needed]
|
| 57 |
-
|
| 58 |
-
## Bias, Risks, and Limitations
|
| 59 |
-
|
| 60 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 61 |
-
|
| 62 |
-
[More Information Needed]
|
| 63 |
-
|
| 64 |
-
### Recommendations
|
| 65 |
-
|
| 66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 67 |
-
|
| 68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
-
|
| 70 |
-
## How to Get Started with the Model
|
| 71 |
-
|
| 72 |
-
Use the code below to get started with the model.
|
| 73 |
-
|
| 74 |
-
[More Information Needed]
|
| 75 |
|
| 76 |
## Training Details
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
-
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
-
|
| 127 |
-
### Results
|
| 128 |
-
|
| 129 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
## Model Examination [optional]
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
-
|
| 139 |
-
[More Information Needed]
|
| 140 |
-
|
| 141 |
-
## Environmental Impact
|
| 142 |
-
|
| 143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
-
|
| 145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
-
|
| 147 |
-
- **Hardware Type:** [More Information Needed]
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
-
|
| 153 |
-
## Technical Specifications [optional]
|
| 154 |
-
|
| 155 |
-
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
-
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
-
|
| 173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
-
|
| 175 |
-
**BibTeX:**
|
| 176 |
-
|
| 177 |
-
[More Information Needed]
|
| 178 |
-
|
| 179 |
-
**APA:**
|
| 180 |
-
|
| 181 |
-
[More Information Needed]
|
| 182 |
-
|
| 183 |
-
## Glossary [optional]
|
| 184 |
-
|
| 185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
-
|
| 187 |
-
[More Information Needed]
|
| 188 |
-
|
| 189 |
-
## More Information [optional]
|
| 190 |
-
|
| 191 |
-
[More Information Needed]
|
| 192 |
-
|
| 193 |
-
## Model Card Authors [optional]
|
| 194 |
-
|
| 195 |
-
[More Information Needed]
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
-
|
| 199 |
-
[More Information Needed]
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
library_name: transformers
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
tags:
|
| 8 |
+
- pinescript
|
| 9 |
+
- tradingview
|
| 10 |
+
- code-generation
|
| 11 |
+
- finance
|
| 12 |
+
- trading
|
| 13 |
+
- codegemma
|
| 14 |
+
- fine-tuned
|
| 15 |
+
base_model: google/codegemma-7b-it
|
| 16 |
+
datasets:
|
| 17 |
+
- anthonym21/pinescript-v5-instructions
|
| 18 |
+
model-index:
|
| 19 |
+
- name: pinescript-v5-instructions-merged
|
| 20 |
+
results: []
|
| 21 |
---
|
| 22 |
|
| 23 |
+
# PineScript v5 Code Generator
|
| 24 |
|
| 25 |
+
A fine-tuned CodeGemma 7B model specialized in generating TradingView PineScript v5 code for trading indicators, strategies, and libraries.
|
| 26 |
|
| 27 |
+
## Model Description
|
| 28 |
|
| 29 |
+
This model was fine-tuned on 5,000+ PineScript v5 examples from the [PineScripts-Permissive](https://huggingface.co/datasets/mrmegatelo/PineScripts-Permissive) dataset, which contains high-quality, permissively-licensed scripts from TradingView.
|
| 30 |
|
| 31 |
+
- **Base Model:** [google/codegemma-7b-it](https://huggingface.co/google/codegemma-7b-it)
|
| 32 |
+
- **Fine-tuning Method:** QLoRA (4-bit quantization + LoRA adapters)
|
| 33 |
+
- **Training Data:** 4,774 instruction/response pairs
|
| 34 |
+
- **Context Length:** 4096 tokens
|
| 35 |
|
| 36 |
+
## Intended Use
|
| 37 |
|
| 38 |
+
Generate PineScript v5 code for:
|
| 39 |
+
- Technical indicators (RSI, MACD, Bollinger Bands, custom indicators)
|
| 40 |
+
- Trading strategies with backtesting
|
| 41 |
+
- Reusable libraries
|
| 42 |
+
- Alert conditions
|
| 43 |
+
- Custom visualizations
|
| 44 |
|
| 45 |
+
## Usage
|
| 46 |
|
| 47 |
+
```python
|
| 48 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 49 |
+
import torch
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
model_id = "anthonym21/pinescript-v5-instructions-merged"
|
| 52 |
|
| 53 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 54 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 55 |
+
model_id,
|
| 56 |
+
torch_dtype=torch.bfloat16,
|
| 57 |
+
device_map="auto",
|
| 58 |
+
)
|
| 59 |
|
| 60 |
+
def generate_pinescript(prompt, max_tokens=1024):
|
| 61 |
+
formatted = f"### Human: {prompt}\n### Assistant:"
|
| 62 |
+
inputs = tokenizer(formatted, return_tensors="pt").to(model.device)
|
| 63 |
|
| 64 |
+
outputs = model.generate(
|
| 65 |
+
**inputs,
|
| 66 |
+
max_new_tokens=max_tokens,
|
| 67 |
+
temperature=0.7,
|
| 68 |
+
top_p=0.9,
|
| 69 |
+
do_sample=True,
|
| 70 |
+
pad_token_id=tokenizer.eos_token_id,
|
| 71 |
+
)
|
| 72 |
|
| 73 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 74 |
+
return response.split("### Assistant:")[-1].strip()
|
| 75 |
|
| 76 |
+
# Example
|
| 77 |
+
code = generate_pinescript("Write a PineScript v5 RSI indicator with overbought/oversold zones")
|
| 78 |
+
print(code)
|
| 79 |
+
```
|
| 80 |
|
| 81 |
+
## Example Prompts
|
| 82 |
|
| 83 |
+
| Prompt | Description |
|
| 84 |
+
|--------|-------------|
|
| 85 |
+
| "Write a PineScript v5 indicator that shows RSI with dynamic overbought/oversold levels" | RSI with adaptive levels |
|
| 86 |
+
| "Create a MACD crossover strategy with stop loss and take profit" | Complete trading strategy |
|
| 87 |
+
| "Write a Bollinger Bands indicator with squeeze detection" | Volatility indicator |
|
| 88 |
+
| "Create a multi-timeframe moving average indicator" | MTF analysis tool |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
## Training Details
|
| 91 |
|
| 92 |
+
| Parameter | Value |
|
| 93 |
+
|-----------|-------|
|
| 94 |
+
| Epochs | 3 |
|
| 95 |
+
| Batch Size | 2 |
|
| 96 |
+
| Gradient Accumulation | 8 |
|
| 97 |
+
| Learning Rate | 2e-4 |
|
| 98 |
+
| LoRA r | 64 |
|
| 99 |
+
| LoRA alpha | 128 |
|
| 100 |
+
| Max Seq Length | 4096 |
|
| 101 |
+
| Quantization | 4-bit (nf4) |
|
| 102 |
+
|
| 103 |
+
## Limitations
|
| 104 |
+
|
| 105 |
+
- Generates PineScript v5 syntax; may not be compatible with older versions
|
| 106 |
+
- Code should be reviewed and tested before live trading
|
| 107 |
+
- Complex multi-indicator strategies may require refinement
|
| 108 |
+
- Does not provide financial advice
|
| 109 |
+
|
| 110 |
+
## Dataset
|
| 111 |
+
|
| 112 |
+
Training data sourced from [mrmegatelo/PineScripts-Permissive](https://huggingface.co/datasets/mrmegatelo/PineScripts-Permissive):
|
| 113 |
+
- 5,848 PineScript v5 scripts
|
| 114 |
+
- Filtered to 4,774 high-quality examples
|
| 115 |
+
- Includes indicators, strategies, and libraries
|
| 116 |
+
- All scripts under permissive licenses (MPL-2.0, Apache-2.0)
|
| 117 |
+
|
| 118 |
+
## Citation
|
| 119 |
+
|
| 120 |
+
```bibtex
|
| 121 |
+
@misc{pinescript-v5-instructions-merged,
|
| 122 |
+
author = {Anthony Maio},
|
| 123 |
+
title = {PineScript v5 Code Generator},
|
| 124 |
+
year = {2025},
|
| 125 |
+
publisher = {HuggingFace},
|
| 126 |
+
url = {https://huggingface.co/anthonym21/pinescript-v5-instructions-merged}
|
| 127 |
+
}
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
## License
|
| 131 |
+
|
| 132 |
+
Apache 2.0 (same as base model)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|