Download .venv/transformers/examples/modular-transformers/modular_dummy.py from DrDavis/PythonProject1: direct link, hf CLI and curl.
- Browser
- Download file 359 Bytes
-
https://huggingface.co/DrDavis/PythonProject1/resolve/main/.venv/transformers/examples/modular-transformers/modular_dummy.py
- Command line
-
hf download hf://DrDavis/PythonProject1/.venv/transformers/examples/modular-transformers/modular_dummy.py
-
curl -L -o modular_dummy.py https://huggingface.co/DrDavis/PythonProject1/resolve/main/.venv/transformers/examples/modular-transformers/modular_dummy.py
359 Bytes
| import torch | |
| from transformers.models.llama.modeling_llama import LlamaModel | |
| def rotate_half(x): | |
| """Rotates half the hidden dims of the input.""" | |
| x1 = x[..., : x.shape[-1] // 4] | |
| x2 = x[..., x.shape[-1] // 4 :] | |
| return torch.cat((-x2, x1), dim=-1) | |
| # example where we need some deps and some functions | |
| class DummyModel(LlamaModel): | |
| pass | |