https://github.com/mlverse/safetensors
Safetensors File Format
https://github.com/mlverse/safetensors
Last synced: 12 months ago
JSON representation
Safetensors File Format
- Host: GitHub
- URL: https://github.com/mlverse/safetensors
- Owner: mlverse
- License: other
- Created: 2023-05-30T12:35:48.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-17T14:28:09.000Z (almost 2 years ago)
- Last Synced: 2025-04-08T06:51:16.141Z (about 1 year ago)
- Language: R
- Homepage: https://mlverse.github.io/safetensors/
- Size: 1.17 MB
- Stars: 9
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# safetensors
[](https://github.com/mlverse/safetensors/actions/workflows/R-CMD-check.yaml)
safetensors is a pure R implementation of the [safetensors](https://github.com/huggingface/safetensors) file format.
Currently only reading files is supported.
## Installation
safetensors can be installed from CRAN with:
``` r
install.packages("safetensors")
```
The development version of safetensors from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("mlverse/safetensors")
```
## Example
Here's an example of writing and reading safetensors files:
```{r}
library(torch)
library(safetensors)
tensors <- list(
x = torch_randn(10, 10),
y = torch_ones(10, 10)
)
str(tensors)
tmp <- tempfile()
safe_save_file(tensors, tmp)
tensors <- safe_load_file(tmp)
str(tensors)
```