Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdul Fatir Ansari committed Mar 25, 2024
1 parent ceea8f5 commit 2d32e44
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ To perform inference with Chronos models, install this package by running:
pip install git+https://github.com/amazon-science/chronos-forecasting.git
```

A minimal example showing how to perform inference using Chronos models:
### Forecasting

A minimal example showing how to perform forecasting using Chronos models:

```python
# for plotting, run: pip install pandas matplotlib
Expand Down Expand Up @@ -78,6 +80,30 @@ plt.grid()
plt.show()
```

### Extracting Encoder Embeddings

A minimal example showing how to extract encoder embeddings from Chronos models:

```python
import pandas as pd
import torch
from chronos import ChronosPipeline

pipeline = ChronosPipeline.from_pretrained(
"amazon/chronos-t5-small",
device_map="cuda",
torch_dtype=torch.bfloat16,
)

df = pd.read_csv("https://raw.githubusercontent.com/AileenNielsen/TimeSeriesAnalysisWithPython/master/data/AirPassengers.csv")

# context must be either a 1D tensor, a list of 1D tensors,
# or a left-padded 2D tensor with batch as the first dimension
context = torch.tensor(df["#Passengers"])
embeddings, decoding_context = pipeline.embed(context)
```


## Citation

If you find Chronos models useful for your research, please consider citing the associated [paper](https://arxiv.org/abs/2403.07815):
Expand Down

0 comments on commit 2d32e44

Please sign in to comment.