{"id":15412940,"url":"https://github.com/ascorbic/transformer-fun","last_synced_at":"2025-04-19T11:37:32.801Z","repository":{"id":181446489,"uuid":"666551661","full_name":"ascorbic/transformer-fun","owner":"ascorbic","description":"Run 🤗 transformers on Netlify","archived":false,"fork":false,"pushed_at":"2023-07-17T18:08:37.000Z","size":22,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T07:22:21.223Z","etag":null,"topics":["ai","huggingface","machine-learning","serverless"],"latest_commit_sha":null,"homepage":"https://transformer-fun.netlify.app/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ascorbic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-14T20:20:17.000Z","updated_at":"2025-02-02T16:48:23.000Z","dependencies_parsed_at":"2024-10-21T13:55:15.429Z","dependency_job_id":null,"html_url":"https://github.com/ascorbic/transformer-fun","commit_stats":{"total_commits":17,"total_committers":1,"mean_commits":17.0,"dds":0.0,"last_synced_commit":"fd789106c81399839b8682f3230dfc6e93878552"},"previous_names":["ascorbic/transformer-fun"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ascorbic%2Ftransformer-fun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ascorbic%2Ftransformer-fun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ascorbic%2Ftransformer-fun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ascorbic%2Ftransformer-fun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ascorbic","download_url":"https://codeload.github.com/ascorbic/transformer-fun/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249685215,"owners_count":21310567,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","huggingface","machine-learning","serverless"],"created_at":"2024-10-01T16:54:52.615Z","updated_at":"2025-04-19T11:37:32.772Z","avatar_url":"https://github.com/ascorbic.png","language":"JavaScript","readme":"# 🤗 Transformers.js on Netlify\n\n[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/ascorbic/transformer-fun)\n\n## Overview\n\nThis repo contains examples of using the transformers.js library to run Hugging Face models in Netlify functions. The examples are in the `netlify/functions` folder.\n\n## Limitations\n\n- Functions have a max execution time of 10 seconds. This includes downloading and caching the model on first run.\n- Models need to be small enough to fit in the function's temporary directory, which is 512MB.\n- Cold starts will be slower as it downloads the model into the cache. Subsequent invocations will be faster.\n\n## Examples\n\n**[Image classification demo](https://transformer-fun.netlify.app/)**\n\nThe `netlify/functions` folder contains examples showing:\n\n- [Image classification](netlify/functions/image-classification/lib.mjs) - Classify an image with text labels.\n- [Sentence embeddings](netlify/functions/embeddings/lib.mjs) - Encode text into vector embeddings.\n\nEach example imports a small model from Hugging Face and shows how to call it in a Netlify function handler.\n\n## Caching\n\nTo avoid downloading the model every invocation, the examples cache the model in the `/tmp` directory. The cached model is reused on subsequent invocations.\n\nThe cache is persisted across invocations, but not guaranteed to persist for long periods of time. Expect to re-download the model every few hours/days.\n\n## Performance\n\nFirst invocation will be slow (a few seconds) as it downloads and caches the model. After that invocations should complete very quickly.\n\nKeep computation using the model lightweight to avoid timeout issues. Do as much preprocessing outside of the function handler.\n\n## Additional Resources\n\n- [Transformers.js documentation](https://huggingface.co/docs/transformers.js/index)\n- [Netlify Functions Documentation](https://docs.netlify.com/functions/overview/)\n\n[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/ascorbic/transformer-fun)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fascorbic%2Ftransformer-fun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fascorbic%2Ftransformer-fun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fascorbic%2Ftransformer-fun/lists"}