Upload README.md
Browse filesAdd example usage.
README.md
CHANGED
|
@@ -6,7 +6,29 @@ Here is an example of a ChatTS application, which allows users to interact with
|
|
| 6 |

|
| 7 |
|
| 8 |
## Usage
|
| 9 |
-
This model is fine-tuned on the QWen2.5-14B-Instruct (https://huggingface.co/Qwen/Qwen2.5-14B-Instruct) model. For more usage details, please refer to the `README.md` in the ChatTS repository.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
## Reference
|
| 12 |
- QWen2.5-14B-Instruct (https://huggingface.co/Qwen/Qwen2.5-14B-Instruct)
|
|
|
|
| 6 |

|
| 7 |
|
| 8 |
## Usage
|
| 9 |
+
- This model is fine-tuned on the QWen2.5-14B-Instruct (https://huggingface.co/Qwen/Qwen2.5-14B-Instruct) model. For more usage details, please refer to the `README.md` in the ChatTS repository.
|
| 10 |
+
- An example usage of ChatTS (with `HuggingFace`):
|
| 11 |
+
```python
|
| 12 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoProcessor
|
| 13 |
+
import torch
|
| 14 |
+
import numpy as np
|
| 15 |
+
|
| 16 |
+
# Load the model, tokenizer and processor
|
| 17 |
+
model = AutoModelForCausalLM.from_pretrained("./ckpt", trust_remote_code=True, device_map=0, torch_dtype='float16')
|
| 18 |
+
tokenizer = AutoTokenizer.from_pretrained("./ckpt", trust_remote_code=True)
|
| 19 |
+
processor = AutoProcessor.from_pretrained("./ckpt", trust_remote_code=True, tokenizer=tokenizer)
|
| 20 |
+
# Create time series and prompts
|
| 21 |
+
timeseries = np.sin(np.arange(256) / 10) * 5.0
|
| 22 |
+
timeseries[100:] -= 10.0
|
| 23 |
+
prompt = f"I have a time series length of 256: <ts><ts/>. Please analyze the local changes in this time series."
|
| 24 |
+
# Apply Chat Template
|
| 25 |
+
prompt = f"<|im_start|>system\nYou are a helpful assistant.<|im_end|><|im_start|>user\n{prompt}<|im_end|><|im_start|>assistant\n"
|
| 26 |
+
# Convert to tensor
|
| 27 |
+
inputs = processor(text=[prompt], timeseries=[timeseries], padding=True, return_tensors="pt")
|
| 28 |
+
# Model Generate
|
| 29 |
+
outputs = model.generate(**inputs, max_new_tokens=300)
|
| 30 |
+
print(tokenizer.decode(outputs[0][len(inputs['input_ids'][0]):], skip_special_tokens=True))
|
| 31 |
+
```
|
| 32 |
|
| 33 |
## Reference
|
| 34 |
- QWen2.5-14B-Instruct (https://huggingface.co/Qwen/Qwen2.5-14B-Instruct)
|