Instructions to use OpCustom/OpAI1.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Adapters
How to use OpCustom/OpAI1.1 with Adapters:
from adapters import AutoAdapterModel model = AutoAdapterModel.from_pretrained("<base-model-id>") model.load_adapter("OpCustom/OpAI1.1", set_active=True) - Notebooks
- Google Colab
- Kaggle
Download positional_encoding.py from OpCustom/OpAI1.1: direct link, hf CLI and curl.
- Browser
- Download file 650 Bytes
-
https://huggingface.co/OpCustom/OpAI1.1/resolve/main/positional_encoding.py
- Command line
-
hf download hf://OpCustom/OpAI1.1/positional_encoding.py
-
curl -L -o positional_encoding.py https://huggingface.co/OpCustom/OpAI1.1/resolve/main/positional_encoding.py
650 Bytes
| import torch | |
| import math | |
| import torch.nn as nn | |
| class PositionalEncoding(nn.Module): | |
| def __init__(self, d_model, max_len=5000): | |
| super(PositionalEncoding, self).__init__() | |
| pe = torch.zeros(max_len, d_model) | |
| position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1) | |
| div_term = torch.exp(torch.arange(0, d_model, 2).float() * -(math.log(10000.0) / d_model)) | |
| pe[:, 0::2] = torch.sin(position * div_term) | |
| pe[:, 1::2] = torch.cos(position * div_term) | |
| self.register_buffer('pe', pe.unsqueeze(0)) | |
| def forward(self, x): | |
| return x + self.pe[:, :x.size(1)] | |