Add/update model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# llama-3.2-3b-tsqa-sp
|
| 3 |
+
|
| 4 |
+
This model is part of the OpenTSLM project and was trained on TSQA (Time Series Question Answering) using Llama 3.2 3B as the base language model with Soft Prompt architecture.
|
| 5 |
+
|
| 6 |
+
## Paper
|
| 7 |
+
|
| 8 |
+
For details, please refer to our publication:
|
| 9 |
+
|
| 10 |
+
**OpenTSLM: Time-Series Language Models for Reasoning over Multivariate Medical Text- and Time-Series Data**
|
| 11 |
+
|
| 12 |
+
Paper: https://huggingface.co/papers/2510.02410
|
| 13 |
+
|
| 14 |
+
## Usage
|
| 15 |
+
Please check out the [OpenTSLM](https://github.com/OpenTSLM/OpenTSLM) repository for detailed usage examples.
|
| 16 |
+
```python
|
| 17 |
+
import sys
|
| 18 |
+
import os
|
| 19 |
+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "src")))
|
| 20 |
+
|
| 21 |
+
from model.llm.OpenTSLM import OpenTSLM
|
| 22 |
+
from time_series_datasets.TSQADataset import TSQADataset
|
| 23 |
+
from time_series_datasets.util import extend_time_series_to_match_patch_size_and_aggregate
|
| 24 |
+
from torch.utils.data import DataLoader
|
| 25 |
+
from model_config import PATCH_SIZE
|
| 26 |
+
|
| 27 |
+
REPO_ID = "OpenTSLM/llama-3.2-1b-tsqa-sp"
|
| 28 |
+
|
| 29 |
+
# Use CPU or CUDA for inference. MPS does NOT work for pretrained HF checkpoints.
|
| 30 |
+
model = OpenTSLM.load_pretrained(REPO_ID, device="cuda" if torch.cuda.is_available() else "cpu")
|
| 31 |
+
test_dataset = TSQADataset("test", EOS_TOKEN=model.get_eos_token())
|
| 32 |
+
|
| 33 |
+
test_loader = DataLoader(
|
| 34 |
+
test_dataset,
|
| 35 |
+
shuffle=False,
|
| 36 |
+
batch_size=1,
|
| 37 |
+
collate_fn=lambda batch: extend_time_series_to_match_patch_size_and_aggregate(
|
| 38 |
+
batch, patch_size=PATCH_SIZE
|
| 39 |
+
),
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
for i, batch in enumerate(test_loader):
|
| 43 |
+
predictions = model.generate(batch, max_new_tokens=200)
|
| 44 |
+
for sample, pred in zip(batch, predictions):
|
| 45 |
+
print("Question:", sample.get("pre_prompt", "N/A"))
|
| 46 |
+
print("Answer:", sample.get("answer", "N/A"))
|
| 47 |
+
print("Output:", pred)
|
| 48 |
+
if i >= 4:
|
| 49 |
+
break
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
## Citation
|
| 53 |
+
|
| 54 |
+
If you use this model, please cite:
|
| 55 |
+
|
| 56 |
+
```bibtex
|
| 57 |
+
@misc{langer2025opentslm,
|
| 58 |
+
title = {OpenTSLM: Time-Series Language Models for Reasoning over Multivariate Medical Text- and Time-Series Data},
|
| 59 |
+
author = {Langer, Patrick and Kaar, Thomas and Rosenblattl, Max and Xu, Maxwell A and Chow, Winnie and Maritsch, Martin and Verma, Aradhana and Han, Brian and Kim, Daniel Seung and Chubb, Henry and Ceresnak, Scott and Zahedivash, Aydin and Tarlochan, Alexander and Sandhu, Singh and Rodriguez, Fatima and Mcduff, Daniel and Fleisch, Elgar and Aalami, Oliver and Barata, Filipe and Schmiedmayer, Paul},
|
| 60 |
+
year = {2025},
|
| 61 |
+
note = {Preprint},
|
| 62 |
+
doi = {doi.org/10.13140/RG.2.2.14827.60963}
|
| 63 |
+
}
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
## License
|
| 67 |
+
|
| 68 |
+
This model is released under the MIT license.
|